[Swift-commit] r3521 - in trunk: . bin

noreply at svn.ci.uchicago.edu noreply at svn.ci.uchicago.edu
Tue Aug 10 23:50:29 CDT 2010


Author: davidk
Date: 2010-08-10 23:50:29 -0500 (Tue, 10 Aug 2010)
New Revision: 3521

Added:
   trunk/bin/swift
   trunk/bin/swift.bat
Modified:
   trunk/build.xml
   trunk/launchers.xml
Log:
Swift usage statistics


Added: trunk/bin/swift
===================================================================
--- trunk/bin/swift	                        (rev 0)
+++ trunk/bin/swift	2010-08-11 04:50:29 UTC (rev 3521)
@@ -0,0 +1,152 @@
+#! /bin/sh
+
+EXEC=org.griphyn.vdl.karajan.Loader
+OPTIONS=
+
+CYGWIN=
+CPDELIM=":"
+HEAPMAX=256M
+
+if echo `uname` | grep -i "cygwin"; then
+    CYGWIN="yes"
+    CPDELIM=";"
+fi
+
+fixCommandLine() {
+
+    COMMANDLINE=
+
+    while [ "X$1" !=  "X" ] ; do
+        COMMANDLINE="${COMMANDLINE} '$1'"
+        shift
+    done
+
+    echo $COMMANDLINE
+}
+
+updateOptions() {
+ 
+    if [ "X$1" != "X" ] ; then
+	OPTIONS="$OPTIONS -D$2=$1"
+    fi
+
+}
+
+####### MAIN BODY ##########
+
+if [ ! -d "$SWIFT_HOME" ] ; then
+    SWIFT_HOME=`dirname $0`"/.."
+    if [ ! -f "$SWIFT_HOME/lib/cog-swift-svn.jar" ] && [ ! -f "$SWIFT_HOME/lib/cog.jar" ] ; then
+		MY_PATH=`which $0`
+		SWIFT_HOME=`dirname $MY_PATH`"/.."
+		if [ ! -f "$SWIFT_HOME/lib/cog-swift-svn.jar" ] && [ ! -f "$SWIFT_HOME/lib/cog.jar" ] ; then
+	    	echo "Error: SWIFT_HOME is not set, and all attempts at guessing it failed"
+	    	exit
+		fi
+    fi
+fi
+
+OPTIONS="$OPTIONS -Djava.endorsed.dirs=$SWIFT_HOME/lib/endorsed"
+
+LOCALCLASSPATH=$SWIFT_HOME/etc$CPDELIM$SWIFT_HOME/libexec
+for JAR in $SWIFT_HOME/lib/*.jar; do
+	LOCALCLASSPATH="$LOCALCLASSPATH$CPDELIM$JAR"
+done
+LOCALCLASSPATH=$LOCALCLASSPATH$CPDELIM$CLASSPATH
+
+CMDLINE=`fixCommandLine "$@"`
+
+### SETUP OTHER ENV VARIABLES ####
+
+USERID=`id | awk '{printf("%s\n", substr($1, 5, index($1, "(")-5 ) ) }'`
+
+if [ "X$GLOBUS_HOSTNAME" = "X" ] && [ "X$HOSTNAME" != "X" ]; then 
+	GLOBUS_HOSTNAME=$HOSTNAME  
+fi
+
+updateOptions "$USERID" "UID"
+updateOptions "$GLOBUS_INSTALL_PATH" "GLOBUS_INSTALL_PATH"
+updateOptions "$GLOBUS_DEPLOY_PATH" "GLOBUS_DEPLOY_PATH"
+updateOptions "$GLOBUS_TCP_PORT_RANGE" "GLOBUS_TCP_PORT_RANGE"
+updateOptions "$GLOBUS_TCP_SOURCE_PORT_RANGE" "GLOBUS_TCP_SOURCE_PORT_RANGE"
+updateOptions "$GLOBUS_UDP_SOURCE_PORT_RANGE" "GLOBUS_UDP_SOURCE_PORT_RANGE"
+updateOptions "$GLOBUS_HOSTNAME" "GLOBUS_HOSTNAME"
+updateOptions "$X509_USER_CERT" "X509_USER_CERT"
+updateOptions "$X509_USER_KEY" "X509_USER_KEY"
+updateOptions "$X509_CERT_DIR" "X509_CERT_DIR"
+updateOptions "$X509_USER_PROXY" "X509_USER_PROXY"
+updateOptions "$SWIFT_HOME" "COG_INSTALL_PATH"
+updateOptions "$SWIFT_HOME" "swift.home"
+#Use /dev/urandom instead of /dev/random for seeding RNGs
+#This will lower the randomness of the seed, but avoid
+#large delays if /dev/random does not have enough entropy collected
+updateOptions "file:///dev/urandom" "java.security.egd"
+
+if [ "X$HEAPMAX" != "X" ]; then
+	OPTIONS="-Xmx$HEAPMAX $OPTIONS"
+fi
+
+# Anonymous usage statistics
+LISTENER="bridled.ci.uchicago.edu"
+PORT="9999"
+
+if [ -z "$SWIFT_USAGE_STATS" ]; then
+    SWIFT_USAGE_STATS=1
+fi
+
+# To disable usage statistics, uncomment the line below
+#SWIFT_USAGE_STATS=0
+
+PATH=$PATH:/sbin
+IFCONFIG=`which ifconfig`
+if [ -x "$IFCONFIG" ]; then
+    MAC=`$IFCONFIG |grep HWaddr`
+fi
+
+MD5SUM=`which md5sum`
+if [ ! -x "$MD5SUM" ]; then
+    echo "warning: unable to find md5sum"
+    SWIFT_USAGE_STATS=0
+fi
+
+NC=`which nc`
+if [ ! -x "$NC" ]; then
+    echo "warning: unable to find nc"
+    SWIFT_USAGE_STATS=0
+fi
+
+if [ "$SWIFT_USAGE_STATS" = 1 ]; then
+    for var in "$@"
+    do
+        SCRIPT=`echo $var|grep -i .swift`
+        if [ -e "$SCRIPT" ]; then
+            SCRIPT=$var
+            SCRIPTID=`$MD5SUM $SCRIPT|cut -d ' ' -f1`
+            SCRIPTLENGTH=`wc -l $SCRIPT|cut -d ' ' -f1`
+        fi 
+    done
+    HOSTNAME=`hostname`
+    USERID=`echo $USERID $HOSTNAME $MAC | $MD5SUM |cut -d ' ' -f1`
+    DATE=`date`
+    KEY=`echo $USERID $DATE $$ | $MD5SUM | cut -d ' ' -f1`
+    echo $KEY $USERID $SCRIPTID $SCRIPTLENGTH -1 0| $NC -u $LISTENER $PORT
+fi
+
+### EXECUTE ############
+if test -n "$CYGWIN"; then
+    set CLASSPATHSAVE=$CLASSPATH
+    export CLASSPATH="$LOCALCLASSPATH"
+    eval java ${OPTIONS} ${COG_OPTS} ${EXEC} ${CMDLINE}
+    export CLASSPATH=$CLASSPATHSAVE
+else
+    eval java ${OPTIONS} ${COG_OPTS} -classpath ${LOCALCLASSPATH} ${EXEC} ${CMDLINE}
+fi
+return_code=$?
+
+if [ "$SWIFT_USAGE_STATS" = 1 ]; then
+	echo $KEY $USERID $SCRIPTID $SCRIPTLENGTH $return_code 1| $NC -u $LISTENER $PORT
+fi
+
+exit $return_code
+
+


Property changes on: trunk/bin/swift
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/bin/swift.bat
===================================================================
--- trunk/bin/swift.bat	                        (rev 0)
+++ trunk/bin/swift.bat	2010-08-11 04:50:29 UTC (rev 3521)
@@ -0,0 +1,78 @@
+ at echo off
+
+if "X%SWIFT_HOME%" == "X" goto nocogpath
+goto cogpath
+
+:nocogpath
+    set UNSET_SWIFT_HOME=1
+    set SWIFT_HOME=..
+    if NOT EXIST "%SWIFT_HOME%\lib\cog-swift-svn.jar" goto nocogpath15
+    goto cogpath
+	
+:nocogpath15
+	if NOT EXIST "%SWIFT_HOME%\lib\cog.jar" goto nocogpath2
+	goto cogpath
+    
+:nocogpath2
+    rem test for expansion extensions first, so that we don't enter an infinite loop
+    set PARTIAL_PATH=test
+    set PARTIAL_PATH=%PARTIAL_PATH:~-2%
+    if NOT "%PARTIAL_PATH%" == "st" goto nocogpath3
+    set PARTIAL_PATH=%~f0
+    set FIRST_BACKSLASH=1
+    
+:loop
+    set LAST_CHAR=%PARTIAL_PATH:~-1%
+    set PARTIAL_PATH=%PARTIAL_PATH:~0,-1%
+    if "%LAST_CHAR%" == "\" goto found
+    if "X%PARTIAL_PATH%" == "X" goto nocogpath3
+    goto loop
+
+    
+:found
+    if "%FIRST_BACKSLASH%" == "0" goto found2
+    set FIRST_BACKSLASH=0
+    goto loop
+     
+:found2
+    set SWIFT_HOME=%PARTIAL_PATH%
+    if NOT EXIST "%SWIFT_HOME%\lib\cog-swift-svn.jar" goto nocogpath25
+    goto cogpath
+	
+:nocogpath25
+	if NOT EXIST "%SWIFT_HOME%\lib\cog.jar" goto nocogpath3
+	goto cogpath
+    
+:nocogpath3
+    echo Error: SWIFT_HOME not set and all attempts at guessing it failed
+    goto end
+
+:cogpath
+
+	set OPTS=-DCOG_INSTALL_PATH="%SWIFT_HOME%" -Dswift.home="%SWIFT_HOME%"%COG_OPTS% -Djava.endorsed.dirs="%SWIFT_HOME%\lib\endorsed"
+
+	set LOCALCLASSPATH=%CLASSPATH%;%SWIFT_HOME%\etc;%SWIFT_HOME%\libexec
+	
+	for %%J in ("%SWIFT_HOME%\lib\*.jar") DO call :setpath %%J
+    
+    set SAVECLASSPATH=%CLASSPATH%
+    set CLASSPATH=%LOCALCLASSPATH%
+    java %OPTS% org.griphyn.vdl.karajan.Loader %*
+    set CLASSPATH=%SAVECLASSPATH%
+
+:end
+    if "%UNSET_SWIFT_HOME%"=="1" goto restore
+    goto done
+    
+:setpath
+    set LOCALCLASSPATH=%LOCALCLASSPATH%;%*
+    goto done
+
+:restore
+    set SWIFT_HOME=
+    set PARTIAL_PATH=
+    set LAST_CHAR=
+    set UNSET_SWIFT_HOME=
+    set FIRST_BAKSLASH=
+
+:done

Modified: trunk/build.xml
===================================================================
--- trunk/build.xml	2010-08-10 21:32:56 UTC (rev 3520)
+++ trunk/build.xml	2010-08-11 04:50:29 UTC (rev 3521)
@@ -213,45 +213,6 @@
 		<copy todir="${dist.dir}/etc" 
 			file="${cog.dir}/modules/${module.name}/etc/log4j.properties" 
 			overwrite="true"/>
-		<replace file="${dist.dir}/bin/swift">
-			<replacetoken>COG_INSTALL_PATH</replacetoken>
-			<replacevalue>SWIFT_HOME</replacevalue>
-		</replace>
-		<replace file="${dist.dir}/bin/swift">
-			<replacetoken>LOCALCLASSPATH=$SWIFT_HOME/etc</replacetoken>
-			<replacevalue>LOCALCLASSPATH=$SWIFT_HOME/etc$CPDELIM$SWIFT_HOME/libexec</replacevalue>
-		</replace>
-		<replace file="${dist.dir}/bin/swift">
-			<replacetoken>HEAPMAX=
-</replacetoken>
-			<replacevalue>HEAPMAX=256M
-</replacevalue>
-		</replace>
-		<replace file="${dist.dir}/bin/swift">
-			<replacetoken>updateOptions "$SWIFT_HOME" "SWIFT_HOME"
-</replacetoken>
-			<replacevalue>updateOptions "$SWIFT_HOME" "COG_INSTALL_PATH"
-updateOptions "$SWIFT_HOME" "swift.home"
-#Use /dev/urandom instead of /dev/random for seeding RNGs
-#This will lower the randomness of the seed, but avoid
-#large delays if /dev/random does not have enough entropy collected
-updateOptions "file:///dev/urandom" "java.security.egd"
-
-</replacevalue>
-		</replace>
-
-		<replace file="${dist.dir}/bin/swift.bat">
-			<replacetoken>COG_INSTALL_PATH</replacetoken>
-			<replacevalue>SWIFT_HOME</replacevalue>
-		</replace>
-		<replace file="${dist.dir}/bin/swift.bat">
-			<replacetoken>set LOCALCLASSPATH=%CLASSPATH%;%SWIFT_HOME%\etc</replacetoken>
-			<replacevalue>set LOCALCLASSPATH=%CLASSPATH%;%SWIFT_HOME%\etc;%SWIFT_HOME%\libexec</replacevalue>
-		</replace>
-		<replace file="${dist.dir}/bin/swift.bat">
-			<replacetoken>set OPTS=</replacetoken>
-			<replacevalue>set OPTS=-DCOG_INSTALL_PATH="%SWIFT_HOME%" -Dswift.home="%SWIFT_HOME%"</replacevalue>
-		</replace>
 		<chmod perm="+x" file="${dist.dir}/bin/swift"/>
 		<chmod perm="+x" file="${dist.dir}/bin/swift-osg-ress-site-catalog"/>
 		<chmod perm="+x" file="${dist.dir}/libexec/cdm_broadcast.sh"/>

Modified: trunk/launchers.xml
===================================================================
--- trunk/launchers.xml	2010-08-10 21:32:56 UTC (rev 3520)
+++ trunk/launchers.xml	2010-08-11 04:50:29 UTC (rev 3521)
@@ -1,7 +1,5 @@
 <project name="Launchers" default="create" basedir=".">
 	<target name="create">
-		<delete file="${dist.dir}/bin/swift.bat"/>
-		<delete file="${dist.dir}/bin/swift"/>
 		<ant antfile="${main.buildfile}" target="launcher">
 			<property name="launcher-name" value="VDLx2Karajan"/>
 			<property name="class-name" value="org.griphyn.vdl.engine.Karajan"/>
@@ -10,10 +8,6 @@
 			<property name="launcher-name" value="VDLt2VDLx"/>
 			<property name="class-name" value="org.griphyn.vdl.toolkit.VDLt2VDLx"/>
 		</ant>
-		<ant antfile="${main.buildfile}" target="launcher">
-			<property name="launcher-name" value="swift"/>
-			<property name="class-name" value="org.griphyn.vdl.karajan.Loader"/>
-		</ant>
 	</target>
 	<target name="webstart">
 	</target>




More information about the Swift-commit mailing list