[Swift-commit] r3438 - trunk/src/org/griphyn/vdl/karajan/lib

noreply at svn.ci.uchicago.edu noreply at svn.ci.uchicago.edu
Thu Jul 15 15:11:56 CDT 2010


Author: hategan
Date: 2010-07-15 15:11:55 -0500 (Thu, 15 Jul 2010)
New Revision: 3438

Added:
   trunk/src/org/griphyn/vdl/karajan/lib/AppStageins.java
   trunk/src/org/griphyn/vdl/karajan/lib/AppStageouts.java
Log:
added appStage(in|out) functions

Added: trunk/src/org/griphyn/vdl/karajan/lib/AppStageins.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/AppStageins.java	                        (rev 0)
+++ trunk/src/org/griphyn/vdl/karajan/lib/AppStageins.java	2010-07-15 20:11:55 UTC (rev 3438)
@@ -0,0 +1,54 @@
+/*
+ * Created on Jan 5, 2007
+ */
+package org.griphyn.vdl.karajan.lib;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import org.globus.cog.karajan.arguments.Arg;
+import org.globus.cog.karajan.arguments.ArgUtil;
+import org.globus.cog.karajan.stack.VariableStack;
+import org.globus.cog.karajan.util.TypeUtil;
+import org.globus.cog.karajan.workflow.ExecutionException;
+import org.globus.cog.karajan.workflow.nodes.AbstractSequentialWithArguments;
+import org.griphyn.vdl.mapping.AbsFile;
+
+public class AppStageins extends AbstractSequentialWithArguments {
+
+    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,
+                STAGING_METHOD });
+    }
+
+    protected void post(VariableStack stack) throws ExecutionException {
+        List files = TypeUtil.toList(FILES.getValue(stack));
+        for (Object f : files) {
+            AbsFile file = new AbsFile(TypeUtil.toString(f));
+            String protocol = file.getProtocol();
+            if (protocol.equals("file")) {
+                protocol = TypeUtil.toString(STAGING_METHOD.getValue(stack));
+            }
+            String path = file.getDir().equals("") ? file.getName() : file.getDir()
+                    + "/" + file.getName();
+            String relpath = path.startsWith("/") ? path.substring(1) : path;
+            ArgUtil.getChannelReturn(stack, STAGEIN).append(
+                makeList(protocol + "://" + file.getHost() + "/" + path, TypeUtil.toString(DIR.getValue(stack))
+                        + "/" + relpath));
+        }
+        super.post(stack);
+    }
+
+    private List<String> makeList(String s1, String s2) {
+        List<String> l = new LinkedList<String>();
+        l.add(s1);
+        l.add(s2);
+        return l;
+    }
+}

Added: trunk/src/org/griphyn/vdl/karajan/lib/AppStageouts.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/AppStageouts.java	                        (rev 0)
+++ trunk/src/org/griphyn/vdl/karajan/lib/AppStageouts.java	2010-07-15 20:11:55 UTC (rev 3438)
@@ -0,0 +1,66 @@
+/*
+ * Created on Jan 5, 2007
+ */
+package org.griphyn.vdl.karajan.lib;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import org.globus.cog.karajan.arguments.Arg;
+import org.globus.cog.karajan.arguments.ArgUtil;
+import org.globus.cog.karajan.stack.VariableStack;
+import org.globus.cog.karajan.util.TypeUtil;
+import org.globus.cog.karajan.workflow.ExecutionException;
+import org.globus.cog.karajan.workflow.nodes.AbstractSequentialWithArguments;
+import org.griphyn.vdl.mapping.AbsFile;
+import org.griphyn.vdl.mapping.DSHandle;
+import org.griphyn.vdl.mapping.Path;
+
+public class AppStageouts extends AbstractSequentialWithArguments {
+
+    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 });
+    }
+
+    protected void post(VariableStack stack) throws ExecutionException {
+        try {
+            List files = TypeUtil.toList(FILES.getValue(stack));
+            for (Object f : files) { 
+                List pv = TypeUtil.toList(f);
+                Path p = Path.parse(TypeUtil.toString(pv.get(0)));
+                DSHandle handle = (DSHandle) pv.get(1);
+                ArgUtil.getNamedArguments(stack).add("var", handle.getField(p));
+                AbsFile file = new AbsFile(VDLFunction.filename(stack)[0]);
+                String protocol = file.getProtocol();
+                if (protocol.equals("file")) {
+                    protocol = TypeUtil.toString(STAGING_METHOD.getValue(stack));
+                }
+                String path = file.getDir().equals("") ? file.getName() : file.getDir()
+                        + "/" + 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));
+            }
+            super.post(stack);
+        }
+        catch (Exception e) {
+            throw new ExecutionException(e);
+        }
+    }
+    
+    private List<String> makeList(String s1, String s2) {
+        List<String> l = new LinkedList<String>();
+        l.add(s1);
+        l.add(s2);
+        return l;
+    }
+}




More information about the Swift-commit mailing list