Skip to content
Browse files

VMM reaper thread implementation

  • Loading branch information...
1 parent a8d41f6 commit d6e46e980a70550a13dffc5ecc69978b96e1f2ea @carlasouza carlasouza committed Jul 15, 2011
View
24 service/service/java/source/src/org/globus/workspace/service/impls/VMMReaper.java
@@ -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;
@@ -45,6 +48,7 @@
private static final Log logger =
LogFactory.getLog(VMMReaper.class.getName());
+ protected final RequestFactory reqFactory;
private final Gson gson = new Gson();
// -------------------------------------------------------------------------
@@ -78,6 +82,7 @@ public VMMReaper(ExecutorService executorService,
throw new IllegalArgumentException("lagerImpl may not be null");
}
this.lager = lagerImpl;
+ this.reqFactory = new RequestFactoryImpl(lager);
}
@@ -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();
@@ -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);
}

0 comments on commit d6e46e9

Please sign in to comment.
Something went wrong with that request. Please try again.