[Swift-commit] r6511 - in branches/release-0.94: libexec src/org/griphyn/vdl/karajan/lib src/org/griphyn/vdl/mapping

hategan at ci.uchicago.edu hategan at ci.uchicago.edu
Sun May 19 19:35:11 CDT 2013


Author: hategan
Date: 2013-05-19 19:35:10 -0500 (Sun, 19 May 2013)
New Revision: 6511

Modified:
   branches/release-0.94/libexec/vdl-int-staging.k
   branches/release-0.94/src/org/griphyn/vdl/karajan/lib/AppStageins.java
   branches/release-0.94/src/org/griphyn/vdl/karajan/lib/AppStageouts.java
   branches/release-0.94/src/org/griphyn/vdl/mapping/AbsFile.java
Log:
take CWD into account when using provider staging

Modified: branches/release-0.94/libexec/vdl-int-staging.k
===================================================================
--- branches/release-0.94/libexec/vdl-int-staging.k	2013-05-20 00:34:18 UTC (rev 6510)
+++ branches/release-0.94/libexec/vdl-int-staging.k	2013-05-20 00:35:10 UTC (rev 6511)
@@ -151,7 +151,7 @@
 								stageIn("{loc}{swift.home}/libexec/cdm_lib.sh", "cdm_lib.sh")
 							))
 
-							appStageins(jobid, stagein, ".", stagingMethod)
+							appStageins(jobid, stagein, stagingMethod)
 
 							stageOut("wrapper.log", "{stagingMethod}://localhost/{ddir}/{jobid}.info", 
 								mode = WRAPPER_TRANSFER_MODE)
@@ -159,7 +159,7 @@
 							//stageOut("{stderr}", "{stagingMethod}://localhost/{ddir}/{stderr}")
 							stageOut("wrapper.error", "{stagingMethod}://localhost/{ddir}/{jobid}.error", 
 								mode = STAGING_MODE:IF_PRESENT)
-							appStageouts(jobid, stageout, ".", stagingMethod)
+							appStageouts(jobid, stageout, stagingMethod)
 
 							task:cleanUp(".") //the whole job directory
 						)

Modified: branches/release-0.94/src/org/griphyn/vdl/karajan/lib/AppStageins.java
===================================================================
--- branches/release-0.94/src/org/griphyn/vdl/karajan/lib/AppStageins.java	2013-05-20 00:34:18 UTC (rev 6510)
+++ branches/release-0.94/src/org/griphyn/vdl/karajan/lib/AppStageins.java	2013-05-20 00:35:10 UTC (rev 6511)
@@ -40,17 +40,17 @@
     
     public static final Arg JOBID = new Arg.Positional("jobid");
     public static final Arg FILES = new Arg.Positional("files");
-    public static final Arg DIR = new Arg.Positional("dir");
     public static final Arg STAGING_METHOD = new Arg.Positional("stagingMethod");
     public static final Arg.Channel STAGEIN = new Arg.Channel("stagein");
 
     static {
-        setArguments(AppStageins.class, new Arg[] { JOBID, FILES, DIR,
+        setArguments(AppStageins.class, new Arg[] { JOBID, FILES,
                 STAGING_METHOD });
     }
 
     protected void post(VariableStack stack) throws ExecutionException {
         List files = TypeUtil.toList(FILES.getValue(stack));
+        String cwd = stack.getExecutionContext().getCwd();
         for (Object f : files) {
             AbsFile file = new AbsFile(TypeUtil.toString(f));
             Policy policy = Director.lookup(file.toString());
@@ -63,20 +63,32 @@
             if (protocol.equals("file")) {
                 protocol = TypeUtil.toString(STAGING_METHOD.getValue(stack));
             }
-            String path = file.getDir().equals("") ? file.getName() : file
-                .getDir()
-                    + "/" + file.getName();
+            String path = file.getDir().equals("") ? 
+                    file.getName() : file.getDir() + "/" + file.getName();
             String relpath = path.startsWith("/") ? path.substring(1) : path;
             if (logger.isDebugEnabled()) {
                 logger.debug("will stage in: " + relpath + " via: " + protocol);
             }
             ArgUtil.getChannelReturn(stack, STAGEIN).append(
-                makeList(protocol + "://" + file.getHost() + "/" + path,
-                    TypeUtil.toString(DIR.getValue(stack)) + "/" + relpath));
+                makeList(localPath(cwd, protocol, path, file), relpath));
         }
         super.post(stack);
     }
 
+    protected static String localPath(String cwd, String protocol, String path, AbsFile file) {
+        StringBuilder sb = new StringBuilder();
+        sb.append(protocol);
+        sb.append("://");
+        sb.append(file.getHost());
+        sb.append('/');
+        if (!file.isAbsolute()) {
+            sb.append(cwd);
+            sb.append('/');
+        }
+        sb.append(path);
+        return sb.toString();
+    }
+
     private List<String> makeList(String s1, String s2) {
         List<String> l = new LinkedList<String>();
         l.add(s1);

Modified: branches/release-0.94/src/org/griphyn/vdl/karajan/lib/AppStageouts.java
===================================================================
--- branches/release-0.94/src/org/griphyn/vdl/karajan/lib/AppStageouts.java	2013-05-20 00:34:18 UTC (rev 6510)
+++ branches/release-0.94/src/org/griphyn/vdl/karajan/lib/AppStageouts.java	2013-05-20 00:35:10 UTC (rev 6511)
@@ -37,19 +37,18 @@
 
     public static final Arg JOBID = new Arg.Positional("jobid");
     public static final Arg FILES = new Arg.Positional("files");
-    public static final Arg DIR = new Arg.Positional("dir");
     public static final Arg STAGING_METHOD = new Arg.Positional("stagingMethod");
     public static final Arg VAR = new Arg.Optional("var", null);
     public static final Arg.Channel STAGEOUT = new Arg.Channel("stageout");
 
     static {
-        setArguments(AppStageouts.class, new Arg[] { JOBID, FILES, DIR,
-                STAGING_METHOD, VAR });
+        setArguments(AppStageouts.class, new Arg[] { JOBID, FILES, STAGING_METHOD, VAR });
     }
 
     protected void post(VariableStack stack) throws ExecutionException {
         try {
             List files = TypeUtil.toList(FILES.getValue(stack));
+            String cwd = stack.getExecutionContext().getCwd();
             for (Object f : files) { 
                 List pv = TypeUtil.toList(f);
                 Path p = (Path) pv.get(0);
@@ -64,8 +63,7 @@
                         + "/" + file.getName();
                 String relpath = path.startsWith("/") ? path.substring(1) : path;
                 ArgUtil.getChannelReturn(stack, STAGEOUT).append(
-                    makeList(TypeUtil.toString(DIR.getValue(stack)) + "/" + relpath,
-                        protocol + "://" + file.getHost() + "/" + path));
+                    makeList(relpath, AppStageins.localPath(cwd, protocol, path, file)));
             }
             super.post(stack);
         }

Modified: branches/release-0.94/src/org/griphyn/vdl/mapping/AbsFile.java
===================================================================
--- branches/release-0.94/src/org/griphyn/vdl/mapping/AbsFile.java	2013-05-20 00:34:18 UTC (rev 6510)
+++ branches/release-0.94/src/org/griphyn/vdl/mapping/AbsFile.java	2013-05-20 00:35:10 UTC (rev 6511)
@@ -170,6 +170,10 @@
 		return path;
 	}
 	
+	public boolean isAbsolute() {
+	    return !path.isEmpty() && path.startsWith("/");
+	}
+	
 	public String getType() {
 		return "file";
 	}




More information about the Swift-commit mailing list