Commit 7e32c79c authored by aninhacostaribeiro's avatar aninhacostaribeiro
Browse files

Changed the system for receiving also the macAddress of the host

parent 26c88c9f
......@@ -21,4 +21,4 @@ There are two main parts of the Fogbow Green Sitter: the Agent and the Server. T
The Server is a little bit more complex. There are three main parts of the Server system: The Cloud Information Plugin, already described; ; the Green Strategy, which is the heart of Green Sitter and where decisions are made (who is going to be turned up/down),.;and the Communication Component, that provides communication with Agents and with the Fogbow Manager. It receives the information sent by the agent and sends turn on/down signals to it when necessary by using both XMPP and wakeOnLan protocols. It also receives requests from the Fogbow Manager when there is no resources available in the private cloud, so it powers up a computer when possible.
The following image illustrates the architecture described:
<center>![General architecture](www.fogbowcloud.org/images/greenSitter.png)</center>
\ No newline at end of file
<center>![General architecture](http://www.fogbowcloud.org/images/greenSitter.png)</center>
\ No newline at end of file
......@@ -4,11 +4,13 @@ public class Agent {
private String hostName;
private String ip;
private String jid;
private String macAddress;
public Agent(String hostName, String jid, String ip) {
public Agent(String hostName, String jid, String ip, String macAddress) {
this.hostName = hostName;
this.jid = jid;
this.ip = ip;
this.macAddress = macAddress;
}
public String getHostName() {
......@@ -22,5 +24,9 @@ public class Agent {
public String getJid() {
return jid;
}
public String getMacAdress(){
return macAddress;
}
}
......@@ -19,8 +19,8 @@ public class GreenSitterCommunicationComponent extends XMPPComponent {
addHandlers();
}
public void setAgentAddress(String hostName, String jid, String ip) {
Agent agent = new Agent(hostName, jid, ip);
public void setAgentAddress(String hostName, String jid, String ip, String macAddress) {
Agent agent = new Agent(hostName, jid, ip, macAddress);
listAgent.add(agent);
}
......
......@@ -16,12 +16,13 @@ public class IAmAliveHandler extends AbstractQueryHandler {
@Override
public IQ handle(IQ query) {
//expected content format: IP plus host name (eg. "123.456.789 bobo")
//expected content format: IP plus MAC Address plus host name (eg. "123.456.789 a1:2b:3c:d4:45:67 bobo")
String ip = query.getElement().element("query").elementText("ip");
String hostName = query.getElement().element("query").elementText("hostName");
String jid = query.getFrom().toString();
String macAddress = query.getElement().element("query").elementText("macAddress");
gs.setAgentAddress(hostName, jid, ip);
gs.setAgentAddress(hostName, jid, ip, macAddress);
IQ resultIQ = IQ.createResultIQ(query);
......
......@@ -4,8 +4,8 @@ import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;
import org.fogbowcloud.green.server.communication.GreenSitterCommunicationComponent;
import org.fogbowcloud.green.server.core.greenStrategy.DefaultGreenStrategy;
import org.fogbowcloud.green.server.xmpp.GreenSitterCommunicationComponent;
public class Main {
......
......@@ -9,9 +9,9 @@ import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import org.fogbowcloud.green.server.communication.GreenSitterCommunicationComponent;
import org.fogbowcloud.green.server.core.plugins.CloudInfoPlugin;
import org.fogbowcloud.green.server.core.plugins.openstack.OpenStackInfoPlugin;
import org.fogbowcloud.green.server.xmpp.GreenSitterCommunicationComponent;
public class DefaultGreenStrategy implements GreenStrategy {
......@@ -94,8 +94,8 @@ public class DefaultGreenStrategy implements GreenStrategy {
this.gscc = gscc;
}
public void setAgentAddress(String hostName, String jid, String ip) {
gscc.setAgentAddress(hostName, jid, ip);
public void setAgentAddress(String hostName, String jid, String ip, String macAddress) {
gscc.setAgentAddress(hostName, jid, ip, macAddress);
}
public void wakeUpSleepingHost(int minCPU, int minRAM) {
......
package org.fogbowcloud.green.server.core.greenStrategy;
import org.fogbowcloud.green.server.xmpp.GreenSitterCommunicationComponent;
import org.fogbowcloud.green.server.communication.GreenSitterCommunicationComponent;
public interface GreenStrategy {
......@@ -8,7 +8,7 @@ public interface GreenStrategy {
public void wakeUpSleepingHost(int minCPU, int minRAM);
public void setAgentAddress(String Name, String JID, String IP);
public void setAgentAddress(String Name, String JID, String IP, String macAddress);
public void setCommunicationComponent(GreenSitterCommunicationComponent gscc);
......
......@@ -32,7 +32,7 @@ public class TestIamAliverHandler {
.addElement("content").setText(IP);
DefaultGreenStrategy gs = Mockito.mock(DefaultGreenStrategy.class);
Mockito.doNothing().when(gs).setAgentAddress("nothing",JID, IP);
Mockito.doNothing().when(gs).setAgentAddress("nothing",JID, IP, null);
IAmAliveHandler iah = new IAmAliveHandler(gs);
IQ result = iah.handle(iq);
......
......@@ -4,10 +4,10 @@ import java.util.Date;
import java.util.LinkedList;
import java.util.List;
import org.fogbowcloud.green.server.communication.GreenSitterCommunicationComponent;
import org.fogbowcloud.green.server.core.greenStrategy.DefaultGreenStrategy;
import org.fogbowcloud.green.server.core.greenStrategy.Host;
import org.fogbowcloud.green.server.core.plugins.openstack.OpenStackInfoPlugin;
import org.fogbowcloud.green.server.xmpp.GreenSitterCommunicationComponent;
import org.junit.Assert;
import org.junit.Test;
import org.mockito.Mockito;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment