[Swift-commit] cog r3602

swift at ci.uchicago.edu swift at ci.uchicago.edu
Sat Feb 9 00:55:11 CST 2013


------------------------------------------------------------------------
r3602 | hategan | 2013-02-09 00:50:09 -0600 (Sat, 09 Feb 2013) | 1 line

added ability to override user home for remote coaster services
------------------------------------------------------------------------
Index: modules/provider-coaster/src/org/globus/cog/abstraction/impl/execution/coaster/ServiceManager.java
===================================================================
--- modules/provider-coaster/src/org/globus/cog/abstraction/impl/execution/coaster/ServiceManager.java	(revision 3601)
+++ modules/provider-coaster/src/org/globus/cog/abstraction/impl/execution/coaster/ServiceManager.java	(working copy)
@@ -54,7 +54,6 @@
 import org.globus.cog.karajan.workflow.service.channels.KarajanChannel;
 import org.globus.cog.karajan.workflow.service.commands.Command;
 import org.globus.cog.karajan.workflow.service.commands.Command.Callback;
-import org.globus.common.CoGProperties;
 import org.ietf.jgss.GSSCredential;
 
 public class ServiceManager implements StatusListener {
@@ -64,6 +63,7 @@
     public static final String BOOTSTRAP_JAR = "coaster-bootstrap.jar";
 
     public static final String TASK_ATTR_ID = "coaster:serviceid";
+    public static final String ATTR_USER_HOME_OVERRIDE = "userHomeOverride";
 
     private static ServiceManager defaultManager;
 
@@ -108,8 +108,12 @@
             return th;
         }
     }
+    
+    public String reserveService(Service service, String bootHandlerProvider) throws TaskSubmissionException {
+        return reserveService(service, bootHandlerProvider, null);
+    }
 
-    public String reserveService(Service service, String bootHandlerProvider) throws TaskSubmissionException {
+    public String reserveService(Service service, String bootHandlerProvider, String userHomeOverride) throws TaskSubmissionException {
         ServiceContact contact = service.getServiceContact();
         if (logger.isDebugEnabled()) {
             logger.debug("Reserving service " + contact);
@@ -121,7 +125,7 @@
             if (url == null) {
                 url =
                         startService(service, getBootHandler(bootHandlerProvider),
-                            bootHandlerProvider);
+                            bootHandlerProvider, userHomeOverride);
             }
             increaseUsageCount(contact);
             return url;
@@ -133,7 +137,12 @@
 
     public String reserveService(Task task, String bootHandlerProvider)
             throws TaskSubmissionException {
-        return reserveService(getService(task), bootHandlerProvider);
+        String userHomeOverride = null;
+        if (task.getType() == Task.JOB_SUBMISSION) {
+            JobSpecification spec = (JobSpecification) task.getSpecification();
+            userHomeOverride = (String) spec.getAttribute(ATTR_USER_HOME_OVERRIDE);
+        }
+        return reserveService(getService(task), bootHandlerProvider, userHomeOverride);
     }
     
     private Service getService(Task task) {
@@ -159,13 +168,13 @@
 
     // private static final String[] STRING_ARRAY = new String[0];
 
-    protected String startService(Service service, TaskHandler bootHandler, 
-            String bootHandlerProvider) throws Exception {
+    protected String startService(final Service service, TaskHandler bootHandler, 
+            String bootHandlerProvider, String userHomeOverride) throws Exception {
         ServiceContact contact = service.getServiceContact();
         SecurityContext sc = service.getSecurityContext();
         try {
             startLocalService();
-            final Task t = buildTask(service);
+            final Task t = buildTask(service, userHomeOverride);
             
             t.addStatusListener(this);
             if (logger.isDebugEnabled()) {
@@ -188,7 +197,8 @@
                 t.setAttribute(TASK_ATTR_ID, id);
                 new Thread(new Runnable() {
                     public void run() {
-                        CoasterService.main(new String[] { ls, id, "-local" });
+                        CoasterService.main(new String[] { ls, id, "-local", "-shared.dir", 
+                                (String) service.getAttribute(ATTR_USER_HOME_OVERRIDE) });
                     }
                 }).start();
             }
@@ -286,7 +296,7 @@
         return task.getService(0).getSecurityContext();
     }
 
-    private Task buildTask(Service service) throws TaskSubmissionException {
+    private Task buildTask(Service service, String userHomeOverride) throws TaskSubmissionException {
         try {
             Task t = new TaskImpl();
             t.setType(Task.JOB_SUBMISSION);
@@ -297,7 +307,8 @@
             t.setAttribute(TASK_ATTR_ID, id);
             js.addArgument(loadBootstrapScript(new String[] { getBootstrapServiceURL(),
                     getLocalServiceURL(), getMD5(BOOTSTRAP_JAR), getMD5(Bootstrap.BOOTSTRAP_LIST),
-                    id, service.getServiceContact().getHost() }));
+                    id, service.getServiceContact().getHost(), 
+                    userHomeOverride }));
             js.setDelegation(Delegation.FULL_DELEGATION);
             js.setStdOutputLocation(FileLocation.MEMORY);
             js.setStdErrorLocation(FileLocation.MEMORY);
Index: modules/provider-coaster/src/org/globus/cog/abstraction/impl/execution/coaster/bootstrap/Bootstrap.java
===================================================================
--- modules/provider-coaster/src/org/globus/cog/abstraction/impl/execution/coaster/bootstrap/Bootstrap.java	(revision 3601)
+++ modules/provider-coaster/src/org/globus/cog/abstraction/impl/execution/coaster/bootstrap/Bootstrap.java	(working copy)
@@ -187,6 +187,8 @@
         addDebuggingOptions(args);
         args.add("-Xmx256M");
         args.add("-Dtcp.channel.log.io.performance=true");
+        //pass user home override to service
+        args.add("-Duser.home=" + System.getProperty("user.home"));
         //args.add("-agentlib:hprof=file=c.hprof");
         addProperties(args);
         args.add("-cp");
Index: modules/provider-coaster/resources/bootstrap.sh
===================================================================
--- modules/provider-coaster/resources/bootstrap.sh	(revision 3601)
+++ modules/provider-coaster/resources/bootstrap.sh	(working copy)
@@ -3,9 +3,10 @@
 EMD5=$3
 ID=$5
 H=$6
-L=$7
+HO=$7
 B="coaster-bootstrap"
 
+
 error() {
 	echo $1
 	echo $1 >>$L
@@ -54,8 +55,12 @@
         eval "$@"
 }
 
+if [ "$HO" == "" ]; then
+	HO=$HOME
+fi
+
 if [ "$L" == "" ]; then
-	L=~/$B-$ID.log 
+	L=$HO/$B-$ID.log
 fi
 detectPaths
 DJ=`mktemp /tmp/bootstrap.XXXXXX`
@@ -88,9 +93,10 @@
 if [ "$AAMD5" != "$EMD5" ]; then
 	error "Bootstrap jar checksum failed: $EMD5 != $AAMD5"
 fi
+
 echo "JAVA=$JAVA" >>$L
 if [ -x $JAVA ]; then 
-	CMD="$WR $JAVA -Djava=\"$JAVA\" -DGLOBUS_TCP_PORT_RANGE=\"$GLOBUS_TCP_PORT_RANGE\" -DX509_USER_PROXY=\"$X509_USER_PROXY\" -DX509_CERT_DIR=\"$X509_CERT_DIR\" -DGLOBUS_HOSTNAME=\"$H\" -jar $DJ $BS $LS $ID"
+	CMD="$WR $JAVA -Djava=\"$JAVA\" -DGLOBUS_TCP_PORT_RANGE=\"$GLOBUS_TCP_PORT_RANGE\" -DX509_USER_PROXY=\"$X509_USER_PROXY\" -DX509_CERT_DIR=\"$X509_CERT_DIR\" -DGLOBUS_HOSTNAME=\"$H\" -Duser.home=\"$HO\" -jar $DJ $BS $LS $ID"
 	echo $CMD >>$L
 	eval $CMD >>$L
 	EC=$?



More information about the Swift-commit mailing list