Permalink
Browse files

Merge

  • Loading branch information...
2 parents d6e46e9 + 610aca1 commit 2265d35e9414d0d613b6a5b836556eb1b517acc1 @carlasouza carlasouza committed Jul 15, 2011
@@ -32,8 +32,7 @@
import edu.emory.mathcs.backport.java.util.concurrent.Callable;
import edu.emory.mathcs.backport.java.util.concurrent.FutureTask;
import edu.emory.mathcs.backport.java.util.concurrent.TimeUnit;
-import edu.emory.mathcs.backport.java.util.concurrent.Semaphore;
-import org.apache.xpath.operations.String;
+
public class WorkspaceUtil {
@@ -18,14 +18,11 @@
import com.google.gson.Gson;
import edu.emory.mathcs.backport.java.util.concurrent.ExecutorService;
-import edu.emory.mathcs.backport.java.util.concurrent.FutureTask;
-import edu.emory.mathcs.backport.java.util.concurrent.TimeUnit;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.globus.workspace.Lager;
import org.globus.workspace.scheduler.defaults.ResourcepoolEntry;
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;
@@ -118,6 +115,10 @@ protected void reaperVMM() throws ManageException {
for (ResourcepoolEntry r: vmms) {
String hostname = r.getHostname();
+// final WorkspaceRequestContext requestContext =
+// new WorkspaceRequestContext(id, resource.getName(),
+// this.locator, this.lager);
+
// These are the libvirt guest states
// 1 = running; 2 = idle; 3 = paused; 4 = shutdown; 5 = shut off; 6 = crashed; 7 = dying
WorkspaceRequest req = reqFactory.query();
@@ -16,6 +16,8 @@
package org.globus.workspace.service.impls.async;
+import org.globus.workspace.WorkspaceException;
+
// TODO: move to executor
public interface WorkspaceRequest {
@@ -25,7 +27,7 @@
* WorkspaceRequestQueue just knows how to dequeue work requests
* and call execute.
*/
- public void execute();
+ public String execute() throws WorkspaceException;
/**
* Information needed by request is supplied in context
@@ -68,27 +68,29 @@ protected Exception postExecute(Exception e, boolean fake) {
return e;
}
- public void execute() {
+ public String execute() throws WorkspaceException {
if (this.ctx == null) {
logger.fatal("request had null request ctx: " + this.name +
" [[ " + this.getClass().getName() + " ]]");
- return;
+ return null;
}
try {
this.init();
} catch (WorkspaceException e) {
this.done(e);
- return;
+ return null;
}
final boolean fake = this.ctx.getLocator().getGlobalPolicies().isFake();
Exception e = this.preExecute(fake);
+ String ret = null;
+
if (e == null) {
- e = this._execute(fake);
+ ret = this._execute(fake);
e = this.postExecute(e, fake);
}
@@ -100,7 +102,7 @@ public void execute() {
logger.trace(Lager.id(ctx.getId()) + ": " +
this.name + " async task started");
}
- return;
+ return null;
}
if (e == null) {
@@ -120,9 +122,10 @@ public void execute() {
}
this.done(e);
+ return ret;
}
- private Exception _execute(boolean fake) {
+ private String _execute(boolean fake) throws WorkspaceException {
final int id = this.ctx.getId();
final boolean traceLog = this.ctx.lager().traceLog;
@@ -224,22 +227,24 @@ private Exception _execute(boolean fake) {
err = "Do not run have rights to run " +
this.name + " with ctx ID = " + id;
}
- return new WorkspaceException(err);
+ throw new WorkspaceException(err);
}
// while developing it is sometimes helpful to set cmd to null
// before it is implemented (i.e., make just this one thing fake
// for the timebeing without using the fakeness infrastructure
// for other commands...).
+ //TODO: add json content here
+ String ret = null;
if (this.cmd != null) {
- WorkspaceUtil.runCommand(this.cmd, eventLog, traceLog, id);
+ ret = WorkspaceUtil.runCommand(this.cmd, eventLog, traceLog, id);
}
- return null;
+ return ret;
} catch (ReturnException e) {
- return XenUtil.translateReturnException(e);
+ throw XenUtil.translateReturnException(e);
} catch (WorkspaceException e) {
- return e;
+ throw e;
}
}
}
@@ -1,8 +1,6 @@
package org.globus.workspace.xen.xenlocal;
import org.globus.workspace.WorkspaceException;
-import org.globus.workspace.cmdutils.SSHUtil;
-import org.globus.workspace.service.binding.vm.VirtualMachine;
import org.globus.workspace.xen.XenTask;
import org.globus.workspace.xen.XenUtil;
@@ -19,7 +19,7 @@ protected void init() throws WorkspaceException {
this.doFakeLag = true;
final VirtualMachine vm = this.ctx.getVm();
- final ArrayList ssh = SSHUtil.constructSshCommand(vm.getVmm());
+ final ArrayList ssh = SSHUtil.constructSshCommand(vm.getNode());
final ArrayList exe = XenUtil.constructQueryCommand();
ssh.addAll(exe);
this.cmd = (String[]) ssh.toArray(new String[ssh.size()]);

0 comments on commit 2265d35

Please sign in to comment.