Commit 2a7b6453 authored by marcosnobrega's avatar marcosnobrega
Browse files

Fixed sendHostToBed method to use jid, fixed some tests and added more

log
parent 36533d6d
......@@ -4,8 +4,8 @@ import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;
import org.apache.log4j.Logger;
import org.apache.log4j.ConsoleAppender;
import org.apache.log4j.Logger;
import org.fogbowcloud.green.server.communication.ServerCommunicationComponent;
import org.fogbowcloud.green.server.core.greenStrategy.DefaultGreenStrategy;
......@@ -36,8 +36,9 @@ public class Main {
prop, gs);
gs.setCommunicationComponent(scc);
gs.start();
LOGGER.info("Green Server started");
scc.connect();
scc.process(true);
LOGGER.info("Green Server started");
} catch (Exception e) {
LOGGER.fatal("You must provide as parameter the"
+ " path for the configuration file", e);
......
......@@ -113,7 +113,7 @@ public class DefaultGreenStrategy implements GreenStrategy {
public void receiveIamAliveInfo(String hostName, String jid, String ip,
String macAddress) {
LOGGER.info("Received IAmAlive from " + hostName);
LOGGER.info("Received IAmAlive from " + hostName + ", JID: " + jid + ", MAC: " + macAddress + ", IP: " +ip);
Host hostToUpdate = null;
for (Host host : this.hostsAwake) {
......@@ -151,7 +151,7 @@ public class DefaultGreenStrategy implements GreenStrategy {
* napping than put it in sleeping host list
*/
if (nowTime - host.getNappingSince() > this.graceTime) {
scc.sendIdleHostToBed(host.getMacAddress());
scc.sendIdleHostToBed(host.getJid());
LOGGER.info("Host " + host.getName() + " was sent to bed");
this.sleepingHosts.add(host);
}
......
......@@ -95,7 +95,7 @@ public class OpenStackInfoPlugin implements CloudInfoPlugin {
ZoneService zones = os().compute().zones();
HashMap<String, NovaHost> novaRunning = new HashMap<String, NovaHost>();
List<? extends AvailabilityZone> availabilityZoneList = zones
.list();
.list(true);
for (AvailabilityZone availabilityZone : availabilityZoneList) {
ZoneState zoneState = availabilityZone.getZoneState();
......
......@@ -38,7 +38,7 @@ public class TestOpenStackPlugin {
});
ZoneService zoneService = Mockito.mock(ZoneService.class);
Mockito.when(compute.zones()).thenReturn(zoneService);
Mockito.when(zoneService.list()).thenAnswer(new Answer<List<AvailabilityZone>>() {
Mockito.when(zoneService.list(true)).thenAnswer(new Answer<List<AvailabilityZone>>() {
@Override
public List<AvailabilityZone> answer(InvocationOnMock invocation)
throws Throwable {
......@@ -53,7 +53,7 @@ public class TestOpenStackPlugin {
OSClient osClient = createOSClientMock(new LinkedList<Hypervisor>(),
new LinkedList<AvailabilityZone>());
OpenStackInfoPlugin plugin = Mockito.spy(new OpenStackInfoPlugin(null, null, null, null));
Mockito.when(plugin.os()).thenReturn(osClient);
Mockito.doReturn(osClient).when(plugin).os();
return plugin;
}
......
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