Skip to content
This repository has been archived by the owner on Sep 23, 2020. It is now read-only.

Commit

Permalink
VMM reaper thread implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
carlasouza committed Jul 15, 2011
1 parent a8d41f6 commit d6e46e9
Showing 1 changed file with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
import org.globus.workspace.service.InstanceResource;
import org.globus.workspace.service.Sweepable;
import org.globus.workspace.service.WorkspaceHome;
import org.globus.workspace.service.impls.async.RequestFactory;
import org.globus.workspace.service.impls.async.RequestFactoryImpl;
import org.globus.workspace.service.impls.async.WorkspaceRequest;
import org.globus.workspace.xen.xenssh.Query;
import org.nimbustools.api.services.rm.ManageException;

Expand All @@ -45,6 +48,7 @@ public class VMMReaper implements Runnable {
private static final Log logger =
LogFactory.getLog(VMMReaper.class.getName());

protected final RequestFactory reqFactory;
private final Gson gson = new Gson();

// -------------------------------------------------------------------------
Expand Down Expand Up @@ -78,6 +82,7 @@ public VMMReaper(ExecutorService executorService,
throw new IllegalArgumentException("lagerImpl may not be null");
}
this.lager = lagerImpl;
this.reqFactory = new RequestFactoryImpl(lager);
}


Expand Down Expand Up @@ -115,7 +120,20 @@ protected void reaperVMM() throws ManageException {

// These are the libvirt guest states
// 1 = running; 2 = idle; 3 = paused; 4 = shutdown; 5 = shut off; 6 = crashed; 7 = dying
HashMap<String,Integer> result = gson.fromJson("query vmm", HashMap.class);//TODO get returned json
WorkspaceRequest req = reqFactory.query();
//set context
String state = null;
try{
// state = req.execute();
req.execute();
} catch (Exception e) {
//do something
}

if (state != null) {
HashMap<String,Integer> result = gson.fromJson(state, HashMap.class);
}

}

InstanceResource[] ires = this.home.findAll();
Expand All @@ -128,6 +146,10 @@ protected void reaperVMM() throws ManageException {
//TODO compare states with isInconsistent()
}

public int getCurrentState() {
return 0;
}

public static boolean isInconsistent(Integer state, Integer queriedState) {
return state != null && state.equals(queriedState);
}
Expand Down

0 comments on commit d6e46e9

Please sign in to comment.