Commit f452e152 authored by aninhacostaribeiro's avatar aninhacostaribeiro
Browse files

Implemented WakeUpRequestHandler

parent 348216f1
......@@ -34,7 +34,7 @@ public class GreenSitterCommunicationComponent extends XMPPComponent {
private void addHandlers() {
IAmAliveHandler alive = new IAmAliveHandler(gs);
WakeUpRequestHandler wakeup = new WakeUpRequestHandler();
WakeUpRequestHandler wakeup = new WakeUpRequestHandler(gs);
addGetHandler(alive);
addGetHandler(wakeup);
}
......
......@@ -16,7 +16,7 @@ public class IAmAliveHandler extends AbstractQueryHandler {
@Override
public IQ handle(IQ query) {
//expected content format: "123.456.789" IP
//expected content format: IP plus host name (eg. "123.456.789 bobo")
String ip = query.getElement().element("query").elementText("ip");
String hostName = query.getElement().element("query").elementText("hostName");
String jid = query.getFrom().toString();
......
package org.fogbowcloud.green.server.xmpp;
import org.fogbowcloud.green.server.core.greenStrategy.GreenStrategy;
import org.jamppa.component.handler.AbstractQueryHandler;
import org.xmpp.packet.IQ;
public class WakeUpRequestHandler extends AbstractQueryHandler {
private static final String NAMESPACE = "org.fogbowcloud.green.WakeUpRequest";
private final GreenStrategy gs;
public WakeUpRequestHandler() {
public WakeUpRequestHandler(GreenStrategy gs) {
super(NAMESPACE);
this.gs = gs;
}
@Override
public IQ handle(IQ arg0) {
return null;
public IQ handle(IQ query) {
//expected content format: the minimum CPU and the RAM (in GigaBytes) capacity required (eg. "1 8")
int minCPU = Integer.parseInt(query.getElement().element("query").elementText("cpu"));
int minRAM = Integer.parseInt(query.getElement().element("query").elementText("ram"));
gs.wakeUpSleepingHost(minCPU, minRAM);
IQ resultIQ = IQ.createResultIQ(query);
return resultIQ;
}
}
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