[Swift-commit] r2744 - in usertools: . cio cio/swift cio/swift/libexec

noreply at svn.ci.uchicago.edu noreply at svn.ci.uchicago.edu
Wed Mar 25 15:49:50 CDT 2009


Author: wilde
Date: 2009-03-25 15:49:49 -0500 (Wed, 25 Mar 2009)
New Revision: 2744

Added:
   usertools/cio/
   usertools/cio/README
   usertools/cio/swift/
   usertools/cio/swift/libexec/
   usertools/cio/swift/libexec/vdl-int.k
   usertools/cio/swift/libexec/wrapper.sh
   usertools/cio/swift/modswift.sh
Log:
Create initial dir struct and stubs for tracking all cio changes, data, code, etc.  This should contain everything for CIO other than changes the need to go into Falkon SVN.

Added: usertools/cio/README
===================================================================
--- usertools/cio/README	                        (rev 0)
+++ usertools/cio/README	2009-03-25 20:49:49 UTC (rev 2744)
@@ -0,0 +1,8 @@
+Tools for the cio project and paper.
+
+swift/*: subdirs containing mods to the swift release. one dir at this level for anything that goes into the swift src tree (mainly, eg swift/libexec)
+
+data/
+
+tools/
+

Added: usertools/cio/swift/libexec/vdl-int.k
===================================================================
--- usertools/cio/swift/libexec/vdl-int.k	                        (rev 0)
+++ usertools/cio/swift/libexec/vdl-int.k	2009-03-25 20:49:49 UTC (rev 2744)
@@ -0,0 +1,516 @@
+import("sys.k")
+import("task.k")
+import("vdl-lib.xml")
+/*
+ * Things that are not exposed to the translated file
+ */
+
+global(LOG:DEBUG, "debug")
+global(LOG:INFO, "info")
+global(LOG:WARN, "warn")
+global(LOG:ERROR, "error")
+global(LOG:FATAL, "fatal")
+
+namespace("vdl"
+	export(
+		element(rmdir, [dir, host]
+			parallelFor(entry, file:list(dir, host=host)
+				epath := concat(dir, "/", entry)
+				if(
+					file:isDirectory(epath, host=host) rmdir(epath, host)
+					file:remove(epath, host=host)
+				)
+			)
+			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(isDone, [stageout]
+			sys:and(
+				for(pv, stageout
+					[path, var] := each(pv)
+					vdl:isLogged(var, path)
+				)
+				sys:not(isEmpty(stageout))
+			)
+		)
+			
+		element(mark, [restarts, err, optional(mapping)]
+			if(
+				err for(pv, restarts
+					[path, var] := each(pv)
+					vdl:setFutureFault(var, path=path, mapping=mapping)
+				)
+			)
+		)
+		
+		element(flatten, [...]
+			if (
+				isEmpty(...) ""
+				
+				concat(
+					for(i, butLast(...), if(isList(i) flatten(i) i), "^") last(...)
+				)
+			)
+		)
+		
+		element(checkJobStatus, [rhost, wfdir, jobid, tr, jobdir]
+			log(LOG:DEBUG, "START jobid={jobid}")
+			try(
+				sequential(
+					/*
+					 * 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. 
+					 */
+					file:remove("{wfdir}/status/{jobdir}/{jobid}-success", host=rhost)
+					log(LOG:INFO, "SUCCESS jobid={jobid} - Success file found")
+				)
+				if(
+					file:exists("{wfdir}/status/{jobdir}/{jobid}-error", host=rhost) then(
+						log(LOG:INFO, "FAILURE jobid={jobid} - Failure file found")
+						task:transfer(srchost=rhost, srcdir="{wfdir}/status/{jobdir}", srcfile="{jobid}-error")
+						error := parallel(
+							file:remove("{wfdir}/status/{jobdir}/{jobid}-error", host=rhost)
+							sequential(
+								str:strip(file:read("{jobid}-error"))
+								file:remove("{jobid}-error")
+							)
+						)
+						throw(error)
+					)
+					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}")  
+					)
+				)
+			)
+		)
+		
+		element(initSharedDir, [rhost]
+			once(list(rhost, "shared")
+				vdl:setprogress("Initializing site shared directory")
+
+				log(LOG:INFO, "START host={rhost} - Initializing shared directory")
+
+				wfdir := "{VDL:SCRIPTNAME}-{VDL:RUNID}"
+				sharedDir := dircat(wfdir, "shared")
+				dir:make(sharedDir, host=rhost)
+				transfer(srcdir="{vds.home}/libexec/", srcfile="wrapper.sh", destdir=sharedDir, desthost=rhost)
+				transfer(srcdir="{vds.home}/libexec/", srcfile="seq.sh", destdir=sharedDir, desthost=rhost)
+				dir:make(dircat(wfdir, "kickstart"), host=rhost)
+
+				statusMode := configProperty("status.mode",host=rhost)
+				if(statusMode == "files"
+					dir:make(dircat(wfdir, "status"), host=rhost)
+				)
+
+				dir:make(dircat(wfdir, "info"), host=rhost)
+				wfdir, sharedDir
+				//we send the cleanup data to vdl:main()
+				to(cleanup, list(wfdir, rhost))
+				log(LOG:INFO, "END host={rhost} - Done initializing shared directory")
+			)
+		)
+		
+		element(inFileDirs, [stageins]
+			for(file, stageins
+		 		reldirname(file)
+			)
+		)
+		
+		element(outFileDirs, [stageouts] 
+			for(pv, stageouts
+				[path, var] := each(pv)
+			
+				file := vdl:filename(vdl:getfield(var, path = path))
+				
+				dirname(file)
+			)
+		)
+		
+		element(inFiles, [stageins]
+			pathnames(stageins)
+		)
+		
+		element(outFiles, [stageouts]
+			for(pv, stageouts
+				[path, var] := each(pv)
+			
+				file := vdl:filename(vdl:getfield(var, path = path))
+				
+				file
+			)
+		)
+		
+		element(fileDirs, [stageins, stageouts]
+			list(
+				unique(
+					inFileDirs(stageins)
+					outFileDirs(stageouts)
+				)
+			)
+		)
+		
+		element(createDirSet, [jobid, destdir, host, dirs]
+			/*
+			 * Ideally this would be done by creating a tree of the directories
+			 * to be created and (eventually) exploiting the concurrency in that.
+			 */
+			log(LOG:INFO, "START jobid={jobid} host={host} - Initializing directory structure")
+			for(u, dirs
+				cacheOn(list(u, destdir, host)
+					createdirs(u, destdir, host)
+				)
+			)
+			log(LOG:INFO, "END jobid={jobid} - Done initializing directory structure")
+		)
+		
+		element(cleanup, [dir, host]
+			log(LOG:INFO, "START dir={dir} host={host}")
+			if(vdl:configProperty("sitedir.keep") == "false"
+				task:execute("/bin/rm", arguments="-rf {dir}", host=host, batch=true)
+			)
+			log(LOG:INFO, "END dir={dir} host={host}")
+		)
+		
+		element(cleanups, [cleanup]
+			log(LOG:INFO, "START cleanups={cleanup}")
+			parallelFor(i, cleanup
+				[dir, host] := each(i)
+				try(
+					cleanup(dir, host)
+					catch(".*",
+						log(LOG:DEBUG, "EXCEPTION - Exception caught while cleaning up", exception)
+						to(warnings, exception("Cleanup on {host} failed", exception))
+					)
+				)
+			)
+		)
+		
+		element(cleanupFiles, [files, host]
+			uParallelFor(r, files
+				log(LOG:INFO, "Purging ", r, " on ", host)
+				file:remove(r, host=host)
+				vdl:cacheFileRemoved(r, host)
+			)
+		)
+				
+		element(doStagein, [jobid, files, dir, host]
+			log(LOG:INFO, "START jobid={jobid} - Staging in files")
+			uParallelFor(file, files
+				provider := provider(file)
+				srchost := hostname(file)
+				srcdir := dirname(file)
+				destdir := dircat(dir, reldirname(file))
+				filename := basename(file)
+				size := file:size("{srcdir}/{filename}", host=srchost, provider=provider)
+
+				vdl:cacheAddAndLockFile(filename, destdir, host, size
+					cleanupFiles(cacheFilesToRemove, host)
+					log(LOG:DEBUG, "FILE_STAGE_IN_START file={file} srchost={srchost} srcdir={srcdir} srcname={filename} ",
+						"desthost={host} destdir={destdir} provider={provider}")
+					restartOnError(".*", 2
+					    task:transfer(srcprovider=provider, srchost=srchost, srcfile=filename, 
+					    	srcdir=srcdir, desthost=host, destdir=destdir)
+					)
+					log(LOG:DEBUG, "FILE_STAGE_IN_END file={file} srchost={srchost} srcdir={srcdir} srcname={filename} ",
+						"desthost={host} destdir={destdir} provider={provider}")
+				)
+			)
+			log(LOG:INFO, "END jobid={jobid} - Staging in finished")
+		)
+		
+		element(doStageout, [jobid, stageouts, dir, host]
+			log(LOG:INFO, "START jobid={jobid} - Staging out files")
+			done := list(
+				uparallelFor(pv, stageouts
+					[path, var] := each(pv)
+					file := vdl:absfilename(vdl:getfield(var, path = path))
+					provider := vdl:provider(file)
+					dhost := vdl:hostname(file)
+					rdir := dircat(dir, reldirname(file))
+					bname := basename(file)
+					ldir := 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
+					dir:make(ldir, host=dhost, provider=provider)
+					restartOnError(".*", 2
+					    task:transfer(srchost=host, srcfile=bname,
+					        srcdir=rdir, destdir=ldir, desthost=dhost, destprovider=provider)
+					)
+					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))
+				)
+			)
+			uParallelFor(f, done
+				[bname, rdir, host, size] := each(f)
+				vdl:cacheAddFile(bname, rdir, host, size
+					cleanupFiles(cacheFilesToRemove, host)
+				)
+			)
+			log(LOG:INFO, "END jobid={jobid} - Staging out finished")
+		)
+
+		element(doRestartlog, [restartouts]
+			uParallelFor(f, restartouts,
+				[path, var] := each(f)
+				vdl:logvar(var, path)
+			)
+		)
+		
+		element(graphStuff, [tr, stagein, stageout, err, optional(args)]
+			if(
+				vdl:configProperty("pgraph") != "false" then(
+					errprops := if(err ",color=lightsalmon" "")
+					tp := vdl:threadPrefix()
+					to(graph, 
+						concat(str:quote(tp), " [label=", str:quote("{tr}{errprops}"), "]")
+					)
+					for(si, stagein
+						si := basename(si)
+						to(graph
+							concat(str:quote(si), " [shape=parallelogram{errprops}]")
+							concat(str:quote(si), " -> ", str:quote(tp))
+						)
+					)
+					for(pv, stageout
+						[path, var] := each(pv)
+						file := vdl:fileName(vdl:getfield(var, path=path))
+						file := basename(file)
+						label := vdl:niceName(var, path = path)
+						to(graph
+							concat(str:quote(file), " [shape=parallelogram,label=", 
+								str:quote("{label}{errprops}"), "]")
+							concat(str:quote(tp), " -> ", str:quote(file))
+						)
+					)
+				)
+			)
+		)
+		
+		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))	
+					[name, file] := each(f)
+					destfile := "{jobid}-{file}"
+					nl()
+					"{name}: "
+					try(
+						sequential(
+							task:transfer(srchost=rhost, srcdir=tmpdir, srcfile=file,
+								destfile=destfile)
+
+							file:read(destfile)
+						)
+						nl()
+					)
+					maybe(file:remove(destfile))
+				)
+			)
+		)
+		
+		element(transferKickstartRec, [rhost, wfdir, jobid, jobdir]
+			if(sys:not(file:exists("{VDL:SCRIPTNAME}-{VDL:RUNID}.d"))
+				task:dir:make("{VDL:SCRIPTNAME}-{VDL:RUNID}.d")
+			)
+			recfile := "{jobid}-kickstart.xml"
+			srcdir := dircat(concat(wfdir, "/kickstart/"), jobdir)
+			try(
+				task:transfer(srchost=rhost, srcdir=srcdir, srcfile=recfile, destdir="{VDL:SCRIPTNAME}-{VDL:RUNID}.d/")
+				(
+					maybe(file:remove(recfile))
+					log(LOG:WARN, "Failed to transfer kickstart records from {srcdir} on {rhost}", exception)
+				)
+			)
+			recfile
+		)
+
+		element(transferWrapperLog, [rhost, wfdir, jobid, jobdir]
+			if(sys:not(file:exists("{VDL:SCRIPTNAME}-{VDL:RUNID}.d"))
+				task:dir:make("{VDL:SCRIPTNAME}-{VDL:RUNID}.d")
+			)
+			recfile := "{jobid}-info"
+			srcdir := dircat(concat(wfdir, "/info/"), jobdir)
+			try(
+				task:transfer(srchost=rhost, srcdir=srcdir, srcfile=recfile, destdir="{VDL:SCRIPTNAME}-{VDL:RUNID}.d/")
+				(
+					maybe(file:remove(recfile))
+					log(LOG:WARN, "Failed to transfer wrapper log from {srcdir} on {rhost}")
+					log(LOG:DEBUG, "Exception for wrapper log failure from {srcdir} on {rhost}: ", exception)
+				)
+			)
+			recfile
+		)
+
+		element(execute2, [tr, optional(arguments, stdin, stdout, stderr), stagein, stageout,  restartout,
+			replicationGroup, replicationChannel]
+			stagein := list(unique(each(stagein)))
+			stageout := list(unique(each(stageout)))
+			allocateHost(rhost, constraints=vdl:jobConstraints(tr, stagein=stagein)
+				
+				[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 := concat(tr, "-", uid)
+				
+				log(LOG:DEBUG, "THREAD_ASSOCIATION jobid={jobid} thread={#thread} host={rhost} replicationGroup={replicationGroup}")
+
+				statusMode := configProperty("status.mode",host=rhost)
+
+				vdl:setprogress("Stage in")
+				tmpdir := dircat(concat(wfdir, "/jobs/", jobdir), jobid)
+				
+				stdout := try(stdout, "stdout.txt")
+				stderr := try(stderr, "stderr.txt")
+				
+				kickstart := vdl:kickstart(rhost)
+				
+				try(
+					sequential(
+						fileDirs := fileDirs(stagein, stageout)
+						
+						createDirSet(jobid, sharedDir, rhost, fileDirs)
+						doStagein(jobid, stagein, sharedDir, rhost)
+
+						log(LOG:DEBUG, "JOB_START jobid={jobid} tr={tr}", maybe(" arguments=", arguments), " tmpdir={tmpdir} host={rhost}")
+				
+						vdl:setprogress("Submitting")
+						vdl:execute("/bin/bash",
+							list("shared/wrapper.sh", jobid,
+								"-jobdir", jobdir,
+								"-e", vdl:executable(tr, rhost), 
+								"-out", stdout, 
+								"-err", stderr, 
+								"-i", maybe(stdin),
+								"-d", flatten(each(fileDirs)),
+								"-if", flatten(infiles(stagein)), 
+								"-of", flatten(outfiles(stageout)),
+								"-k", kickstart,
+								"-status", statusMode
+								"-a", maybe(each(arguments)))
+							directory=wfdir
+							redirect=false
+							host=rhost
+							vdl:tcprofile(tr, rhost) //this gets various app params from the tc, such as environment, walltime, etc
+							replicationGroup=replicationGroup
+							replicationChannel=replicationChannel
+							jobid=jobid
+						)
+						
+						if(statusMode == "files"
+							checkJobStatus(rhost, wfdir, jobid, tr, jobdir)
+						)
+		
+						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)
+						if(
+							kickstart != "" & vdl:configProperty("kickstart.always.transfer") == "true"
+							discard(transferKickstartRec(rhost, wfdir, jobid, jobdir))
+						)
+						if(
+							vdl:configProperty("wrapperlog.always.transfer") == "true"
+							discard(transferWrapperLog(rhost, wfdir, jobid, jobdir))
+						)
+						vdl:cacheUnlockFiles(stagein, sharedDir, rhost, cleanupFiles(cacheFilesToRemove, rhost))
+						log(LOG:DEBUG, "JOB_END jobid={jobid}")
+					)
+					catch("^Abort$"
+						log(LOG:DEBUG, "JOB_CANCELED jobid={jobid}")
+						vdl:cacheUnlockFiles(stagein, sharedDir, rhost, force=false
+							cleanupFiles(cacheFilesToRemove, rhost)
+						)
+						throw(exception)
+					)
+					catch("^(?!Abort$).*"
+						vdl:setprogress("Failed but can retry")
+						log(LOG:DEBUG, "APPLICATION_EXCEPTION jobid={jobid} - Application exception: ", exception)
+						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(
+							kickstart == "" ""
+							else(
+								try(
+									(
+										recfile := transferKickstartRec(rhost, wfdir, jobid, jobdir)
+										"KickstartRecord: {recfile}"
+									)
+									""
+								)
+							)
+						)
+						
+						throw(
+							exception(
+								concat(
+									"Exception in {tr}:", nl(),
+									maybe("Arguments: {arguments}", nl()),
+									"Host: {rhost}", nl(),
+									"Directory: {tmpdir}",
+									"{outs}", nl(),
+									"----", nl(),
+									kickstartRec
+								)
+								exception
+							)
+						)
+					)
+				)
+			)
+		)
+		
+		element(generateProvenanceGraph, [gdata]
+			pgraph := vdl:configProperty("pgraph")
+			gname := if(pgraph == "true" "{VDL:SCRIPTNAME}-{VDL:RUNID}.dot" pgraph)
+			file:write(gname
+				"digraph SwiftProvenance {{", nl()
+				"	graph [", vdl:configProperty("pgraph.graph.options"), "];", nl()
+				"	node [", vdl:configProperty("pgraph.node.options"), "];", nl()
+						
+				for(i, gdata
+					"	", i, nl()
+				)
+				"}", nl()
+			)
+			log(LOG:INFO, "Provenance graph saved in ", gname)
+		)
+	)
+)

Added: usertools/cio/swift/libexec/wrapper.sh
===================================================================
--- usertools/cio/swift/libexec/wrapper.sh	                        (rev 0)
+++ usertools/cio/swift/libexec/wrapper.sh	2009-03-25 20:49:49 UTC (rev 2744)
@@ -0,0 +1,339 @@
+# this script must be invoked inside of bash, not plain sh
+
+infosection() {
+	echo >& "$INFO"
+	echo "_____________________________________________________________________________" >& "$INFO"
+	echo >& "$INFO"
+	echo "        $1" >& "$INFO" 
+	echo "_____________________________________________________________________________" >& "$INFO"
+	echo >& "$INFO"
+}
+
+info() {
+	infosection "uname -a"
+	uname -a 2>&1 >& "$INFO"
+	infosection "id"
+	id 2>&1 >& "$INFO"
+	infosection "env"
+	env 2>&1 >& "$INFO"
+	infosection "df"
+	df 2>&1 >& "$INFO"
+	infosection "/proc/cpuinfo"
+	cat /proc/cpuinfo 2>&1 >& "$INFO"
+	infosection "/proc/meminfo"
+	cat /proc/meminfo 2>&1 >& "$INFO"
+	infosection "command line"
+	echo $COMMANDLINE 2>&1 >& "$INFO"
+	if [ -f "$STDOUT" ] ; then
+		infosection "stdout"
+		cat $STDOUT >& "$INFO"
+	fi
+	if [ -f "$STDERR" ] ; then
+		infosection "stderr"
+		cat $STDERR >& "$INFO"
+	fi
+}
+
+logstate() {
+	echo "Progress " `date +"%Y-%m-%d %H:%M:%S.%N%z"` " $@" >& "$INFO"
+}
+
+log() {
+	echo "$@" >& "$INFO"
+echo `date`: "$@" >>/tmp/wrapper.log 2>&1
+}
+
+fail() {
+	EC=$1
+	shift
+	if [ "$STATUSMODE" = "files" ]; then
+		echo $@ >"$WFDIR/status/$JOBDIR/${ID}-error"
+	fi
+	log $@
+	info
+	if [ "$STATUSMODE" = "files" ]; then
+		exit 0
+	else
+		exit $EC
+	fi
+}
+
+checkError() {
+	if [ "$?" != "0" ]; then
+		fail $@
+	fi
+}
+
+checkEmpty() {
+	if [ "$1" == "" ]; then
+		shift
+		fail 254 $@
+	fi
+}
+
+getarg() {
+	NAME=$1
+	shift
+	VALUE=""
+	SHIFTCOUNT=0
+	if [ "$1" == "$NAME" ]; then
+		shift
+		let "SHIFTCOUNT=$SHIFTCOUNT+1"
+		while [ "${1:0:1}" != "-" ] && [ "$#" != "0" ]; do
+			VALUE="$VALUE $1"
+			shift
+			let "SHIFTCOUNT=$SHIFTCOUNT+1"
+		done
+	else
+		fail 254 "Missing $NAME argument"
+	fi
+	VALUE="${VALUE:1}"
+}
+
+openinfo() {
+	exec 3<> $1
+	INFO=3
+}
+
+closeinfo() {
+	exec 3>&-
+}
+
+COMMANDLINE=$@
+
+# get the parent directory of the directory containing wrapper.sh, to use
+# as the run directory
+# this assumes that wrapper.sh is being executed from the top level of
+# the shared directory, and that shared directory is in the top level
+# of the workflow run directory
+WFDIR=$(dirname $(dirname $0))
+
+cd $WFDIR
+
+# make the WFDIR absolute
+WFDIR=$(pwd)
+
+openinfo "wrapper.log"
+ID=$1
+checkEmpty "$ID" "Missing job ID"
+
+shift
+
+getarg "-jobdir" "$@"
+JOBDIR=$VALUE
+shift $SHIFTCOUNT
+
+checkEmpty "$JOBDIR" "Missing job directory prefix"
+mkdir -p $WFDIR/info/$JOBDIR
+closeinfo
+rm -f "$WFDIR/info/$JOBDIR/${ID}-info"
+openinfo "$WFDIR/info/$JOBDIR/${ID}-info"
+
+logstate "LOG_START"
+infosection "Wrapper"
+
+
+getarg "-e" "$@"
+EXEC=$VALUE
+shift $SHIFTCOUNT
+
+getarg "-out" "$@"
+STDOUT=$VALUE
+shift $SHIFTCOUNT
+
+getarg "-err" "$@"
+STDERR=$VALUE
+shift $SHIFTCOUNT
+
+getarg "-i" "$@"
+STDIN=$VALUE
+shift $SHIFTCOUNT
+
+getarg "-d" "$@"
+DIRS=$VALUE
+shift $SHIFTCOUNT
+
+getarg "-if" "$@"
+INF=$VALUE
+shift $SHIFTCOUNT
+
+getarg "-of" "$@"
+OUTF=$VALUE
+shift $SHIFTCOUNT
+
+getarg "-k" "$@"
+KICKSTART=$VALUE
+shift $SHIFTCOUNT
+
+getarg "-status" "$@"
+STATUSMODE=$VALUE
+shift $SHIFTCOUNT
+
+if [ "$1" == "-a" ]; then
+	shift
+else
+	fail 254 "Missing arguments (-a option)"
+fi
+
+if [ "$STATUSMODE" = "files" ]; then
+	mkdir -p $WFDIR/status/$JOBDIR
+fi
+
+if [ "X$SWIFT_JOBDIR_PATH" != "X" ]; then
+  log "Job directory mode is: local copy"
+  DIR=${SWIFT_JOBDIR_PATH}/$JOBDIR/$ID
+  COPYNOTLINK=1
+elif [ "`uname -m`" = "ppc" ]; then
+  log "Job directory mode is: BG/P compute node - local copy to /dev/shm"
+
+  log "BG/P-specific info:"
+  log "CONTROL_INIT=$CONTROL_INIT"
+  log "`grep BG_BLOCKID /proc/personality.sh`"
+  log "`grep BG_LOCATION /proc/personality.sh`"
+
+  SWIFT_JOBDIR_PATH=/dev/shm
+  DIR=${SWIFT_JOBDIR_PATH}/$JOBDIR/$ID
+  COPYNOTLINK=1
+else
+  log "Job directory mode is: link on shared filesystem"
+  DIR=jobs/$JOBDIR/$ID
+  COPYNOTLINK=0
+fi
+
+PATH=$PATH:/bin:/usr/bin
+
+if [ "$PATHPREFIX" != "" ]; then
+export PATH=$PATHPREFIX:$PATH
+fi
+
+if [ "X${EXEC:0:1}" != "X/" ] ; then
+export ORIGEXEC=$EXEC
+export EXEC=$(which $EXEC)
+if [ "X$EXEC" = "X" ] ; then
+fail 254 "Cannot find executable $ORIGEXEC on site system path"
+fi
+fi
+
+log "DIR=$DIR"
+log "EXEC=$EXEC"
+log "STDIN=$STDIN"
+log "STDOUT=$STDOUT"
+log "STDERR=$STDERR"
+log "DIRS=$DIRS"
+log "INF=$INF"
+log "OUTF=$OUTF"
+log "KICKSTART=$KICKSTART"
+log "ARGS=$@"
+log "ARGC=$#"
+
+IFS="^"
+
+logstate "CREATE_JOBDIR"
+mkdir -p $DIR
+checkError 254 "Failed to create job directory $DIR"
+log "Created job directory: $DIR"
+
+logstate "CREATE_INPUTDIR"
+for D in $DIRS ; do
+	mkdir -p "$DIR/$D" 2>&1 >>"$INFO"
+	checkError 254 "Failed to create input directory $D"
+	log "Created output directory: $DIR/$D"
+done
+
+logstate "LINK_INPUTS"
+for L in $INF ; do
+	if [ $COPYNOTLINK = 1 ]; then
+		cp "$PWD/shared/$L" "$DIR/$L" 2>&1 >& $INFO
+		checkError 254 "Failed to copy input file $L"
+		log "Copied input: $PWD/shared/$L to $DIR/$L"
+	else
+		ln -s "$PWD/shared/$L" "$DIR/$L" 2>&1 >& $INFO
+		checkError 254 "Failed to link input file $L"
+		log "Linked input: $PWD/shared/$L to $DIR/$L"
+	fi
+done
+
+logstate "EXECUTE"
+cd $DIR
+
+
+#ls >>$WRAPPERLOG
+if [ ! -f "$EXEC" ]; then
+	fail 254 "The executable $EXEC does not exist"
+fi
+if [ ! -x "$EXEC" ]; then
+	fail 254 "The executable $EXEC does not have the executable bit set"
+fi
+if [ "$KICKSTART" == "" ]; then
+	if [ "$STDIN" == "" ]; then
+		"$EXEC" "$@" 1>"$STDOUT" 2>"$STDERR"
+	else
+		"$EXEC" "$@" 1>"$STDOUT" 2>"$STDERR" <"$STDIN"
+	fi
+	checkError $? "Exit code $?"
+else
+	if [ ! -f "$KICKSTART" ]; then
+		log "Kickstart executable ($KICKSTART) not found"
+		fail 254 "The Kickstart executable ($KICKSTART) was not found"		
+	elif [ ! -x "$KICKSTART" ]; then
+		log "Kickstart executable ($KICKSTART) is not executable"
+		fail 254 "The Kickstart executable ($KICKSTART) does not have the executable bit set"
+	else
+		mkdir -p $WFDIR/kickstart/$JOBDIR
+		log "Using Kickstart ($KICKSTART)"
+		if [ "$STDIN" == "" ]; then
+			"$KICKSTART" -H -o "$STDOUT" -e "$STDERR" "$EXEC" "$@" 1>kickstart.xml 2>"$STDERR"
+		else
+			"$KICKSTART" -H -o "$STDOUT" -i "$STDIN" -e "$STDERR" "$EXEC" "$@" 1>kickstart.xml 2>"$STDERR"
+		fi
+		export APPEXIT=$?
+		mv -f kickstart.xml "$WFDIR/kickstart/$JOBDIR/$ID-kickstart.xml" 2>&1 >& "$INFO"
+		checkError 254 "Failed to copy Kickstart record to shared directory"
+		if [ "$APPEXIT" != "0" ]; then
+			fail $APPEXIT "Exit code $APPEXIT"
+		fi
+	fi
+fi
+
+cd $WFDIR
+
+log "Moving back to workflow directory $WFDIR"
+logstate "EXECUTE_DONE"
+log "Job ran successfully"
+
+MISSING=
+for O in $OUTF ; do
+	if [ ! -f "$DIR/$O" ]; then
+		if [ "$MISSING" == "" ]; then
+			MISSING=$O
+		else
+			MISSING="$MISSING, $O"
+		fi
+	fi
+done
+if [ "$MISSING" != "" ]; then
+	fail 254 "The following output files were not created by the application: $MISSING"
+fi
+
+logstate "COPYING_OUTPUTS"
+for O in $OUTF ; do
+	cp "$DIR/$O" "shared/$O" 2>&1 >& "$INFO"
+	checkError 254 "Failed to copy output file $O to shared directory"
+done
+
+logstate "RM_JOBDIR"
+rm -rf "$DIR" 2>&1 >& "$INFO"
+checkError 254 "Failed to remove job directory $DIR" 
+
+if [ "$STATUSMODE" = "files" ]; then
+	logstate "TOUCH_SUCCESS"
+	touch status/${JOBDIR}/${ID}-success
+fi
+
+logstate "END"
+
+closeinfo
+
+# ensure we exit with a 0 after a successful exection
+exit 0
+


Property changes on: usertools/cio/swift/libexec/wrapper.sh
___________________________________________________________________
Name: svn:executable
   + *

Added: usertools/cio/swift/modswift.sh
===================================================================
--- usertools/cio/swift/modswift.sh	                        (rev 0)
+++ usertools/cio/swift/modswift.sh	2009-03-25 20:49:49 UTC (rev 2744)
@@ -0,0 +1,4 @@
+#! /bin/bash
+
+# this script should copy all the mods below this dir into the right place in th swift source tree.
+


Property changes on: usertools/cio/swift/modswift.sh
___________________________________________________________________
Name: svn:executable
   + *




More information about the Swift-commit mailing list