[Swift-commit] r3668 - in trunk: libexec src/org/globus/swift/data src/org/globus/swift/data/policy tests/cdm

noreply at svn.ci.uchicago.edu noreply at svn.ci.uchicago.edu
Thu Oct 7 16:28:01 CDT 2010


Author: wozniak
Date: 2010-10-07 16:28:01 -0500 (Thu, 07 Oct 2010)
New Revision: 3668

Added:
   trunk/src/org/globus/swift/data/policy/External.java
   trunk/tests/cdm/210-external.check.sh
   trunk/tests/cdm/210-external.clean.sh
   trunk/tests/cdm/210-external.setup.sh
   trunk/tests/cdm/210-external.swift
Modified:
   trunk/libexec/_swiftwrap
   trunk/libexec/vdl-int.k
   trunk/libexec/vdl-lib.xml
   trunk/src/org/globus/swift/data/Action.java
   trunk/src/org/globus/swift/data/policy/Policy.java
   trunk/tests/cdm/fs.template.data
Log:
New CDM EXTERNAL method and test


Modified: trunk/libexec/_swiftwrap
===================================================================
--- trunk/libexec/_swiftwrap	2010-10-07 21:25:29 UTC (rev 3667)
+++ trunk/libexec/_swiftwrap	2010-10-07 21:28:01 UTC (rev 3668)
@@ -352,7 +352,8 @@
 	if [ ! -z $CDM_FILE ]; then
 		CDM_POLICY=$( cdm_lookup shared/cdm.pl $CDM_FILE $L )
 	fi
-	if [ $CDM_POLICY != "DEFAULT" ]; then
+	if [ $CDM_POLICY != "DEFAULT" &&
+         $CDM_POLICY != "EXTERNAL" ]; then
 		log "CDM_POLICY: $L -> $CDM_POLICY"
     	        eval cdm_action $DIR "INPUT" $L $CDM_POLICY
 		continue

Modified: trunk/libexec/vdl-int.k
===================================================================
--- trunk/libexec/vdl-int.k	2010-10-07 21:25:29 UTC (rev 3667)
+++ trunk/libexec/vdl-int.k	2010-10-07 21:28:01 UTC (rev 3668)
@@ -23,15 +23,15 @@
 			)
 			dir:remove(dir, host=host)
 		)
-		
+
 		element(createdirs, [path, dir, host]
 			dc := dircat(dir, path)
 			log(LOG:INFO, "START path={path} dir={dir} - Creating directory structure")
 
 			dir:make(dc, host=host)
 		)
-		
-		
+
+
 		element(checkJobStatus, [rhost, wfdir, jobid, tr, jobdir]
 			log(LOG:DEBUG, "START jobid={jobid}")
 			try(
@@ -40,9 +40,9 @@
 					 * This is a bit of optimization, but I'm not completely
 					 * sure of its correctness. The goal is to both detect
 					 * the presence of the success file and remove it, all
-					 * in one operation. It relies on file:remove() throwing 
-					 * an exception if the file is not there. 
-					 */ 
+					 * in one operation. It relies on file:remove() throwing
+					 * an exception if the file is not there.
+					 */
 					file:remove("{wfdir}/status/{jobdir}/{jobid}-success", host=rhost)
 					log(LOG:INFO, "SUCCESS jobid={jobid} - Success file found")
 				)
@@ -59,14 +59,14 @@
 						)
 						throw(error)
 					)
-					else (	
+					else (
 						log(LOG:INFO, "NO_STATUS_FILE jobid={jobid} - Both status files are missing")
-						throw("No status file was found. Check the shared filesystem on {rhost}")  
+						throw("No status file was found. Check the shared filesystem on {rhost}")
 					)
 				)
 			)
 		)
-		
+
 		element(initSharedDir, [rhost]
 			once(list(rhost, "shared")
 				vdl:setprogress("Initializing site shared directory")
@@ -97,7 +97,7 @@
 				log(LOG:INFO, "END host={rhost} - Done initializing shared directory")
 			)
 		)
-		
+
 		element(initDDir, []
 			ddir := "{VDL:SCRIPTNAME}-{VDL:RUNID}.d"
 			once(ddir
@@ -107,11 +107,11 @@
 			)
 			ddir
 		)
-				
+
 		element(inFiles, [stageins]
 			pathnames(stageins)
 		)
-				
+
 		element(fileDirs, [stageins, stageouts]
 			list(
 				unique(
@@ -120,7 +120,7 @@
 				)
 			)
 		)
-		
+
 		element(createDirSet, [jobid, destdir, host, dirs]
 			/*
 			 * Ideally this would be done by creating a tree of the directories
@@ -134,23 +134,23 @@
 			)
 			log(LOG:INFO, "END jobid={jobid} - Done initializing directory structure")
 		)
-		
+
 		element(cleanup, [dir, host]
 			log(LOG:INFO, "START dir={dir} host={host}")
 			cdmfile := cdm:file()
 			log(LOG:INFO, "cdmfile {cdmfile}")
 			if(cdmfile != "" then(
 				log(LOG:INFO, "submitting cdm_cleanup.sh to {dir}")
-				task:transfer(srcfile="cdm_cleanup.sh", 
+				task:transfer(srcfile="cdm_cleanup.sh",
 					      srcdir="{swift.home}/libexec",
 					      desthost=host, destdir=dir)
-				task:transfer(srcfile="cdm_lib.sh", 
+				task:transfer(srcfile="cdm_lib.sh",
 					      srcdir="{swift.home}/libexec",
 					      desthost=host, destdir=dir)
 			        log(LOG:INFO, "execute: cdm_cleanup.sh")
 				task:execute(
-					     executable="/bin/bash", 
-					     arguments=list("{dir}/cdm_cleanup.sh", 
+					     executable="/bin/bash",
+					     arguments=list("{dir}/cdm_cleanup.sh",
 					                     cdm:get("GATHER_DIR"), cdm:get("GATHER_TARGET")
 							     sys:uid() )
 					     host=host, batch=true, tcprofile(host))
@@ -158,7 +158,7 @@
 			)
 			if(vdl:configProperty("sitedir.keep") == "false"
 				task:execute(
-					vdl:siteprofile(host, "swift:cleanupCommand"), 
+					vdl:siteprofile(host, "swift:cleanupCommand"),
 					arguments=list(
 						vdl:siteprofile(host, "swift:cleanupCommandOptions"),
 						dir
@@ -167,7 +167,7 @@
 			)
 			log(LOG:INFO, "END dir={dir} host={host}")
 		)
-		
+
 		element(cleanups, [cleanup]
 			log(LOG:INFO, "START cleanups={cleanup}")
 			parallelFor(i, cleanup
@@ -182,7 +182,7 @@
 			)
 			log(LOG:INFO, "END cleanups={cleanup}")
 		)
-		
+
 		element(cleanupFiles, [files, host]
 			uParallelFor(r, files
 				log(LOG:INFO, "Purging ", r, " on ", host)
@@ -190,8 +190,8 @@
 				vdl:cacheFileRemoved(r, host)
 			)
 		)
-				
 
+
 		element(stageWrapperParams, [jobid, jobdir, wrapfile, dir, host]
 			log(LOG:INFO, "START jobid={jobid} - staging in wrapper params")
 			provider := provider(wrapfile)
@@ -216,14 +216,14 @@
 			libexec := "{swift.home}/libexec"
 
 			if (cdmfile != "" then(
-				doStageinFile(provider="file", srchost="localhost", srcfile=basename(cdmfile), 
-					    	srcdir=vdl:dirname(cdmfile), desthost=host, destdir=dir, 
+				doStageinFile(provider="file", srchost="localhost", srcfile=basename(cdmfile),
+					    	srcdir=vdl:dirname(cdmfile), desthost=host, destdir=dir,
 						size=file:size(cdmfile), policy="DEFAULT")
-				doStageinFile(provider="file", srchost="localhost", srcfile="cdm.pl", 
-					    	srcdir=libexec, desthost=host, destdir=dir, 
+				doStageinFile(provider="file", srchost="localhost", srcfile="cdm.pl",
+					    	srcdir=libexec, desthost=host, destdir=dir,
 						size=file:size("{libexec}/cdm.pl}"), policy="DEFAULT")
-				doStageinFile(provider="file", srchost="localhost", srcfile="cdm_lib.sh", 
-					    	srcdir=libexec, desthost=host, destdir=dir, 
+				doStageinFile(provider="file", srchost="localhost", srcfile="cdm_lib.sh",
+					    	srcdir=libexec, desthost=host, destdir=dir,
 						size=file:size("{libexec}/cdm_lib.sh}"), policy="DEFAULT")
 			))
 
@@ -238,9 +238,9 @@
 				policy := cdm:query(query=file)
 				log(LOG:DEBUG, "CDM: {file} : {policy}")
 
-				doStageinFile(provider=provider, srchost=srchost, srcfile=filename, 
+				doStageinFile(provider=provider, srchost=srchost, srcfile=filename,
 						srcdir=srcdir, desthost=host, destdir=destdir, size=size, policy=policy)
-			)			
+			)
 			log(LOG:INFO, "END jobid={jobid} - Staging in finished")
 		)
 
@@ -250,17 +250,21 @@
 
 			log(LOG:DEBUG, "FILE_STAGE_IN_START file={srcfile} ",
                                         "srchost={srchost} srcdir={srcdir} srcname={srcfile} ",
-					"desthost={desthost} destdir={destdir} provider={provider} ", 
+					"desthost={desthost} destdir={destdir} provider={provider} ",
                                         "policy={policy}")
-			if (policy == "DEFAULT" then( 
+			if (policy == "DEFAULT" then(
 				restartOnError(".*", 2
-					task:transfer(srcprovider=provider, srchost=srchost, srcfile=srcfile, 
-							srcdir=srcdir, desthost=desthost, destdir=destdir)))
+					task:transfer(srcprovider=provider, srchost=srchost, srcfile=srcfile,
+					              srcdir=srcdir, desthost=desthost, destdir=destdir)))
 			    policy == "BROADCAST" then(
 				log(LOG:DEBUG, "FILE_STAGE_IN_BROADCAST file={srcfile} policy={policy}")
 				cdm:broadcast(srcfile=srcfile, srcdir=srcdir))
+			    policy == "EXTERNAL" then(
+				log(LOG:DEBUG, "FILE_STAGE_IN_EXTERNAL file={srcfile} policy={policy}")
+				cdm:external(srcfile=srcfile, srcdir=srcdir,
+                                              desthost=desthost, destdir=destdir))
 			else(log(LOG:DEBUG, "FILE_STAGE_IN_SKIP file={srcfile} policy={policy}")))
-				log(LOG:DEBUG, "FILE_STAGE_IN_END file={srcfile} ",
+			log(LOG:DEBUG, "FILE_STAGE_IN_END file={srcfile} ",
 					"srchost={srchost} srcdir={srcdir} srcname={srcfile} ",
                                         "desthost={desthost} destdir={destdir} provider={provider}")
 			)
@@ -269,6 +273,7 @@
 
 		element(doStageout, [jobid, stageouts, dir, host]
 			log(LOG:INFO, "START jobid={jobid} - Staging out files")
+                        log(LOG:DEBUG, "stageouts: {stageouts}")
 			done := list(
 				uParallelFor(pv, stageouts
 					[path, var] := each(pv)
@@ -280,7 +285,7 @@
 					ldir := vdl:dirname(file)
 					fullLocal := dircat(ldir, bname)
 					fullRemote := dircat(rdir, bname)
-										
+
 					log(LOG:DEBUG, "FILE_STAGE_OUT_START srcname={bname} srcdir={rdir} srchost={host} ",
 							"destdir={ldir} desthost={dhost} provider={provider}")
 					//make sure we do have the directory on the client side
@@ -289,13 +294,13 @@
 					if (sys:or(policy == "DEFAULT", policy == "BROADCAST")
 						then(
 						restartOnError(".*", 2
-							task:transfer(srchost=host, srcfile=bname,srcdir=rdir, 
+							task:transfer(srchost=host, srcfile=bname,srcdir=rdir,
 								destdir=ldir, desthost=dhost, destprovider=provider)))
 					else(log(LOG:DEBUG, "FILE_STAGE_OUT_SKIP srcname={bname}"))
 					)
 					log(LOG:DEBUG, "FILE_STAGE_OUT_END srcname={bname} srcdir={rdir} srchost={host} ",
 						"destdir={ldir} desthost={dhost} provider={provider}")
-	
+
 					list(bname, rdir, host, file:size(fullLocal))
 				)
 			)
@@ -307,13 +312,13 @@
 			)
 			log(LOG:INFO, "END jobid={jobid} - Staging out finished")
 		)
-		
+
 		element(graphStuff, [tr, stagein, stageout, err, optional(args)]
 			if(
 				vdl:configProperty("pgraph") != "false" then(
 					errprops := if(err ",color=lightsalmon" ",color=lightsteelblue1")
 					tp := vdl:threadPrefix()
-					to(graph, 
+					to(graph,
 						concat(str:quote(tp), " [label=", str:quote(tr), "{errprops}]")
 					)
 					for(si, stagein
@@ -329,7 +334,7 @@
 						file := basename(file)
 						label := vdl:niceName(var, path = path)
 						to(graph
-							concat(str:quote(file), " [shape=parallelogram,label=", 
+							concat(str:quote(file), " [shape=parallelogram,label=",
 								str:quote(label), "]")
 							concat(str:quote(tp), " -> ", str:quote(file))
 						)
@@ -337,16 +342,16 @@
 				)
 			)
 		)
-		
+
 		element(fileSizes, [files]
 			math:sum(
 				for(f, files, file:size(file))
 			)
 		)
-		
+
 		element(transferStandardFiles, [rhost, tmpdir, jobid, stdout, stderr]
 			concat(
-				for(f, list(list("stderr.txt", stderr), list("stdout.txt", stdout))	
+				for(f, list(list("stderr.txt", stderr), list("stdout.txt", stdout))
 					[name, file] := each(f)
 					destfile := "{jobid}-{file}"
 					nl()
@@ -364,7 +369,7 @@
 				)
 			)
 		)
-		
+
 		element(transferKickstartRec, [rhost, wfdir, jobid, jobdir]
 			recfile := "{jobid}-kickstart.xml"
 			srcdir := dircat("{wfdir}/kickstart/", jobdir)
@@ -397,17 +402,17 @@
 			stagein := list(unique(each(stagein)))
 			stageout := list(unique(each(stageout)))
 			allocateHost(rhost, constraints=vdl:jobConstraints(tr, stagein=stagein)
-				
+
 				ddir := initDDir()
 				[wfdir, sharedDir] := try(
 					initSharedDir(rhost)
 					throw(exception("Could not initialize shared directory on {rhost}", exception))
 				)
-				
+
 				uid := uid()
 				jobdir := substring(uid, from=0, to=1)
 				jobid := "{tr}-{uid}"
-				
+
 				log(LOG:DEBUG, "THREAD_ASSOCIATION jobid={jobid} thread={#thread} host={rhost} replicationGroup={replicationGroup}")
 
 				statusMode := configProperty("status.mode",host=rhost)
@@ -419,7 +424,7 @@
 				stderr := try(stderr, "stderr.txt")
 				kickstart := vdl:kickstart(rhost)
 				fileDirs := fileDirs(stagein, stageout)
-				os := vdl:siteprofile(rhost, "SYSINFO:OS") 
+				os := vdl:siteprofile(rhost, "SYSINFO:OS")
 
 				if(wrapperMode == "files"
 					sequential(
@@ -443,12 +448,12 @@
 
 				vdl:setprogress("Stage in")
 				tmpdir := dircat("{wfdir}/jobs/{jobdir}", jobid)
-				
-				
-				
+
+
+
 				try(
 					sequential(
-						
+
 						createDirSet(jobid, sharedDir, rhost, fileDirs)
 						doStagein(jobid, stagein, sharedDir, rhost)
 						if(wrapperMode == "files"
@@ -457,7 +462,7 @@
 
 
 						log(LOG:DEBUG, "JOB_START jobid={jobid} tr={tr}", maybe(" arguments=", arguments), " tmpdir={tmpdir} host={rhost}")
-				
+
 						vdl:setprogress("Submitting")
 
 						if(wrapperMode == "files"
@@ -465,7 +470,7 @@
 								vdl:siteprofile(rhost, "swift:wrapperInterpreter"),
 								list(
 									vdl:siteprofile(rhost, "swift:wrapperInterpreterOptions"),
-									dircat("shared", vdl:siteprofile(rhost, "swift:wrapperScript"), os=os), 
+									dircat("shared", vdl:siteprofile(rhost, "swift:wrapperScript"), os=os),
 									jobid, "-p", jobdir
 								)
 								directory=wfdir
@@ -486,12 +491,12 @@
 								jobid,
 								"-jobdir", jobdir,
 								"-scratch", try(vdl:siteprofile(rhost, "scratch"), "")
-								"-e", vdl:executable(tr, rhost), 
-								"-out", stdout, 
-								"-err", stderr, 
+								"-e", vdl:executable(tr, rhost),
+								"-out", stdout,
+								"-err", stderr,
 								"-i", maybe(stdin),
 								"-d", flatten(each(fileDirs)),
-								"-if", flatten(infiles(stagein)), 
+								"-if", flatten(infiles(stagein)),
 								"-of", flatten(outfiles(stageout)),
 								"-k", kickstart,
 								"-cdmfile", cdm:file(),
@@ -519,11 +524,11 @@
 
 						log(LOG:DEBUG, "STAGING_OUT jobid={jobid}")
 
-									
+
 						/* need to stage the files to upper scratch area in case they are not transfered to another site
 						   before all the files get cleaned out */
-					
-						
+
+
 						vdl:setprogress("Stage out")
 						doStageout(jobid, stageout, sharedDir, rhost)
 						doRestartlog(restartout)
@@ -555,9 +560,9 @@
 						vdl:cacheUnlockFiles(stagein, sharedDir, rhost, force=false
 							cleanupFiles(cacheFilesToRemove, rhost)
 						)
-						
+
 						outs := transferStandardFiles(rhost, tmpdir, jobid, stdout, stderr)
-						
+
 						discard(maybe(transferWrapperLog(rhost, wfdir, jobid, jobdir)))
 
 						kickstartRec := if(
@@ -572,7 +577,7 @@
 								)
 							)
 						)
-						
+
 						throw(
 							exception(
 								concat(
@@ -591,7 +596,7 @@
 				)
 			)
 		)
-	
+
 		element(generateProvenanceGraph, [gdata]
 			pgraph := vdl:configProperty("pgraph")
 			gname := if(pgraph == "true" "{VDL:SCRIPTNAME}-{VDL:RUNID}.dot" pgraph)
@@ -599,7 +604,7 @@
 				"digraph SwiftProvenance {{", nl()
 				"	graph [", vdl:configProperty("pgraph.graph.options"), "];", nl()
 				"	node [", vdl:configProperty("pgraph.node.options"), "];", nl()
-						
+
 				for(i, gdata
 					"	", i, nl()
 				)

Modified: trunk/libexec/vdl-lib.xml
===================================================================
--- trunk/libexec/vdl-lib.xml	2010-10-07 21:25:29 UTC (rev 3667)
+++ trunk/libexec/vdl-lib.xml	2010-10-07 21:28:01 UTC (rev 3668)
@@ -126,6 +126,7 @@
 	<export name="get"><elementDef classname="org.globus.swift.data.Query"/></export>
   	<export name="file"><elementDef classname="org.globus.swift.data.Query"/></export>
   	<export name="broadcast"><elementDef classname="org.globus.swift.data.Action"/></export>
+  	<export name="external"><elementDef classname="org.globus.swift.data.Action"/></export>
   	<export name="wait"><elementDef classname="org.globus.swift.data.Action"/></export>
   </namespace>
 

Modified: trunk/src/org/globus/swift/data/Action.java
===================================================================
--- trunk/src/org/globus/swift/data/Action.java	2010-10-07 21:25:29 UTC (rev 3667)
+++ trunk/src/org/globus/swift/data/Action.java	2010-10-07 21:28:01 UTC (rev 3668)
@@ -6,22 +6,36 @@
 
 import org.globus.cog.karajan.arguments.Arg;
 import org.globus.cog.karajan.stack.VariableStack;
+import org.globus.cog.karajan.util.BoundContact;
 import org.globus.cog.karajan.workflow.ExecutionException;
 import org.globus.cog.karajan.workflow.nodes.functions.FunctionsCollection;
 import org.globus.swift.data.policy.Broadcast;
+import org.globus.swift.data.policy.External;
 import org.globus.swift.data.policy.Policy;
 
 /**
  * Karajan-accessible CDM functions that change something.
  * */
 public class Action extends FunctionsCollection {
-    private static final Logger logger = Logger.getLogger(Action.class);
+    private static final Logger logger = 
+        Logger.getLogger(Action.class);
     
-    public static final Arg PA_FILE = new Arg.Positional("srcfile");
-    public static final Arg PA_DIR  = new Arg.Positional("srcdir");
+    public static final Arg PA_SRCFILE  = 
+        new Arg.Positional("srcfile");
+    public static final Arg PA_SRCDIR   = 
+        new Arg.Positional("srcdir");
+    public static final Arg PA_DESTHOST = 
+        new Arg.Positional("desthost");
+    public static final Arg PA_DESTDIR  = 
+        new Arg.Positional("destdir");
 
     static {
-        setArguments("cdm_broadcast", new Arg[]{ PA_FILE, PA_DIR });
+        setArguments("cdm_broadcast", new Arg[]{ PA_SRCFILE, 
+                                                 PA_SRCDIR });
+        setArguments("cdm_external", new Arg[]{ PA_SRCFILE, 
+                                                PA_SRCDIR, 
+                                                PA_DESTHOST, 
+                                                PA_DESTDIR });
         setArguments("cdm_wait", new Arg[]{});
     }
 
@@ -29,9 +43,10 @@
        Register a file for broadcast by CDM.
        The actual broadcast is triggered by {@link cdm_wait}.
     */
-    public void cdm_broadcast(VariableStack stack) throws ExecutionException {
-        String srcfile = (String) PA_FILE.getValue(stack);
-        String srcdir  = (String) PA_DIR.getValue(stack);
+    public void cdm_broadcast(VariableStack stack) 
+    throws ExecutionException {
+        String srcfile = (String) PA_SRCFILE.getValue(stack);
+        String srcdir  = (String) PA_SRCDIR.getValue(stack);
 
         logger.debug("cdm_broadcast()");
         
@@ -39,8 +54,8 @@
         
         if (!(policy instanceof Broadcast)) {
             throw new RuntimeException
-                ("Attempting to BROADCAST the wrong file: directory: `" +
-                 srcdir + "' `" + srcfile + "' -> " + policy);
+                ("Attempting to BROADCAST the wrong file: " +
+                 srcdir + " " + srcfile + " -> " + policy);
         }
         
         if (srcdir == "") { 
@@ -50,10 +65,28 @@
         Director.addBroadcast(srcdir, srcfile);
     }
 
+    public void cdm_external(VariableStack stack) 
+    throws ExecutionException
+    {
+        String srcfile  = (String) PA_SRCFILE.getValue(stack);
+        String srcdir   = (String) PA_SRCDIR.getValue(stack);
+        BoundContact bc = (BoundContact) PA_DESTHOST.getValue(stack);
+        String destdir  = (String) PA_DESTDIR.getValue(stack);
+        
+        if (srcdir.length() == 0)
+            srcdir = ".";
+        String desthost = bc.getHost();
+        String workdir = (String) bc.getProperty("workdir");
+        
+        External.doExternal(srcfile, srcdir, 
+                            desthost, workdir+"/"+destdir);
+    }
+    
     /**
        Wait until CDM has ensured that all data has been propagated.
     */
-    public void cdm_wait(VariableStack stack) throws ExecutionException {
+    public void cdm_wait(VariableStack stack) 
+    throws ExecutionException {
         logger.debug("cdm_wait()");
         Director.doBroadcast();
     }

Added: trunk/src/org/globus/swift/data/policy/External.java
===================================================================
--- trunk/src/org/globus/swift/data/policy/External.java	                        (rev 0)
+++ trunk/src/org/globus/swift/data/policy/External.java	2010-10-07 21:28:01 UTC (rev 3668)
@@ -0,0 +1,68 @@
+package org.globus.swift.data.policy;
+
+import java.util.List;
+
+import org.apache.log4j.Logger;
+import org.globus.swift.data.Director;
+
+public class External 
+extends Policy {
+    
+    private static final Logger logger = 
+        Logger.getLogger(External.class);
+    
+    /** 
+       The name of the external program
+     */
+    String progname = null;
+    
+    public static void doExternal(String srcfile, String srcdir, 
+                                  String desthost, String destdir) {
+        logger.debug("doExternal: " + 
+                     "srcfile: " + srcfile + 
+                     "srcdir:  " + srcdir + 
+                     "desthost: " + desthost + 
+                     "destdir: " + destdir);
+        
+        Policy policy = Director.lookup(srcdir + "/" + srcfile);
+        
+        if (!(policy instanceof External))
+            throw new RuntimeException
+            ("doExternal called on non-EXTERNAL file!");
+            
+        External external = (External) policy;       
+        external.callProgram(srcdir, srcfile, desthost, destdir);
+    }
+    
+    void callProgram(String srcdir, String srcfile, 
+                     String desthost, String destdir)
+    {
+        String[] cmdline = new String[] { progname, srcdir, srcfile, 
+                                          desthost, destdir };
+        Process process = null;
+        try {
+            process = Runtime.getRuntime().exec(cmdline);
+            process.waitFor();
+        }
+        catch (Exception e) {
+            e.printStackTrace();
+            throw new RuntimeException
+            ("Could not launch external broadcast");
+        }
+    }
+    
+    @Override
+    public void settings(List<String> tokens) {
+        try {
+            progname = tokens.get(0);
+        } 
+        catch (Exception e) { 
+            throw new RuntimeException
+            ("Incorrect settings for EXTERNAL");
+        }
+    }
+    
+    public String toString() {
+        return "EXTERNAL";
+    }
+}

Modified: trunk/src/org/globus/swift/data/policy/Policy.java
===================================================================
--- trunk/src/org/globus/swift/data/policy/Policy.java	2010-10-07 21:25:29 UTC (rev 3667)
+++ trunk/src/org/globus/swift/data/policy/Policy.java	2010-10-07 21:28:01 UTC (rev 3668)
@@ -23,6 +23,8 @@
             return new Broadcast();
         else if (token.compareToIgnoreCase("gather") == 0)
             return new Gather();
+        else if (token.compareToIgnoreCase("external") == 0)
+            return new External();
         return null;
     }
 }

Added: trunk/tests/cdm/210-external.check.sh
===================================================================
--- trunk/tests/cdm/210-external.check.sh	                        (rev 0)
+++ trunk/tests/cdm/210-external.check.sh	2010-10-07 21:28:01 UTC (rev 3668)
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+set -x
+
+cat   external.out || exit 1
+rm -v external.out || exit 1
+
+grep $( uname -m ) 210-input.txt  || exit 1
+grep $( uname -m ) 210-output.txt || exit 1
+
+exit 0


Property changes on: trunk/tests/cdm/210-external.check.sh
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/tests/cdm/210-external.clean.sh
===================================================================
--- trunk/tests/cdm/210-external.clean.sh	                        (rev 0)
+++ trunk/tests/cdm/210-external.clean.sh	2010-10-07 21:28:01 UTC (rev 3668)
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+set -x
+
+rm -v 210-input.txt 210-output.txt
+
+exit 0


Property changes on: trunk/tests/cdm/210-external.clean.sh
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/tests/cdm/210-external.setup.sh
===================================================================
--- trunk/tests/cdm/210-external.setup.sh	                        (rev 0)
+++ trunk/tests/cdm/210-external.setup.sh	2010-10-07 21:28:01 UTC (rev 3668)
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+set -x
+
+{
+  uname -a
+  date
+} > 210-input.txt
+
+cp -v $GROUP/external.sh .
+
+exit 0


Property changes on: trunk/tests/cdm/210-external.setup.sh
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/tests/cdm/210-external.swift
===================================================================
--- trunk/tests/cdm/210-external.swift	                        (rev 0)
+++ trunk/tests/cdm/210-external.swift	2010-10-07 21:28:01 UTC (rev 3668)
@@ -0,0 +1,11 @@
+
+type file;
+
+app (file o) copy (file i)
+{
+  cp @i @o;
+}
+
+file f1<"210-input.txt">;
+file f2<"210-output.txt">;
+f2 = copy(f1);

Modified: trunk/tests/cdm/fs.template.data
===================================================================
--- trunk/tests/cdm/fs.template.data	2010-10-07 21:25:29 UTC (rev 3667)
+++ trunk/tests/cdm/fs.template.data	2010-10-07 21:28:01 UTC (rev 3668)
@@ -1 +1,2 @@
-rule .*output.txt DIRECT _PWD_/201
+rule .*201-output.txt DIRECT _PWD_/201
+rule .*210-input.txt EXTERNAL _PWD_/external.sh




More information about the Swift-commit mailing list