Author: riverma
Date: Wed Apr 24 01:31:29 2013
New Revision: 1471223

URL: http://svn.apache.org/r1471223
Log:
OODT-603: Enable Resource Manager start/stop within RADiX

Modified:
    
oodt/trunk/mvn/archetypes/radix/src/main/resources/archetype-resources/distribution/src/main/resources/bin/env.sh
    
oodt/trunk/mvn/archetypes/radix/src/main/resources/archetype-resources/distribution/src/main/resources/bin/oodt
    
oodt/trunk/mvn/archetypes/radix/src/main/resources/archetype-resources/resmgr/src/main/resources/bin/resmgr
    
oodt/trunk/mvn/archetypes/radix/src/main/resources/archetype-resources/resmgr/src/main/resources/etc/resource.properties
    
oodt/trunk/mvn/archetypes/radix/src/main/resources/archetype-resources/workflow/src/main/resources/etc/workflow.properties

Modified: 
oodt/trunk/mvn/archetypes/radix/src/main/resources/archetype-resources/distribution/src/main/resources/bin/env.sh
URL: 
http://svn.apache.org/viewvc/oodt/trunk/mvn/archetypes/radix/src/main/resources/archetype-resources/distribution/src/main/resources/bin/env.sh?rev=1471223&r1=1471222&r2=1471223&view=diff
==============================================================================
--- 
oodt/trunk/mvn/archetypes/radix/src/main/resources/archetype-resources/distribution/src/main/resources/bin/env.sh
 (original)
+++ 
oodt/trunk/mvn/archetypes/radix/src/main/resources/archetype-resources/distribution/src/main/resources/bin/env.sh
 Wed Apr 24 01:31:29 2013
@@ -105,6 +105,11 @@ if [ -z "$WORKFLOW_HOME" ]; then
   export WORKFLOW_HOME
 fi
 
+if [ -z "$RESMGR_HOME" ]; then
+  RESMGR_HOME="$OODT_HOME"/resmgr
+  export RESMGR_HOME
+fi
+
 if [ -z "$CRAWLER_HOME" ]; then
   CRAWLER_HOME="$OODT_HOME"/crawler
   export CRAWLER_HOME
@@ -156,6 +161,11 @@ if [ -z "$WORKFLOW_URL" ]; then
   export WORKFLOW_URL
 fi
 
+if [ -z "$RESMGR_URL" ]; then
+  RESMGR_URL=http://"$OODT_SERVICES_HOST":"$RESMGR_PORT";
+  export RESMGR_URL
+fi
+
 if [ -z "$CRAWLER_URL" ]; then
   CRAWLER_URL=http://"$OODT_SERVICES_HOST":"$CRAWLER_PORT";
   export CRAWLER_URL

Modified: 
oodt/trunk/mvn/archetypes/radix/src/main/resources/archetype-resources/distribution/src/main/resources/bin/oodt
URL: 
http://svn.apache.org/viewvc/oodt/trunk/mvn/archetypes/radix/src/main/resources/archetype-resources/distribution/src/main/resources/bin/oodt?rev=1471223&r1=1471222&r2=1471223&view=diff
==============================================================================
--- 
oodt/trunk/mvn/archetypes/radix/src/main/resources/archetype-resources/distribution/src/main/resources/bin/oodt
 (original)
+++ 
oodt/trunk/mvn/archetypes/radix/src/main/resources/archetype-resources/distribution/src/main/resources/bin/oodt
 Wed Apr 24 01:31:29 2013
@@ -63,6 +63,7 @@ if [ $have_tty -eq 1 ]; then
 fi
 
 WORKFLOW_EXEC=wmgr
+RESMGR_EXEC=resmgr
 FILEMGR_EXEC=filemgr
 TOMCAT_EXEC=catalina.sh
 
@@ -81,6 +82,13 @@ if [ ! -x "$WORKFLOW_HOME"/bin/"$WORKFLO
 fi
 
 # Check that target executable exists
+if [ ! -x "$RESMGR_HOME"/bin/"$RESMGR_EXEC" ]; then
+  echo "Cannot find $RESMGR_HOME/bin/$RESMGR_EXEC"
+  echo "This file is needed to run this program"
+  exit 1
+fi
+
+# Check that target executable exists
 if [ ! -x "$OODT_BASE"/tomcat/bin/"$TOMCAT_EXEC" ]; then
   echo "Cannot find $OODT_BASE/tomcat/bin/$TOMCAT_EXEC"
   echo "This file is needed to run this program"
@@ -90,10 +98,12 @@ fi
 if [ "$1" = "start" ]; then
   exec "$FILEMGR_HOME"/bin/"$FILEMGR_EXEC" start "$@" >> "$OODT_OUT" 2>&1  &
   exec "$WORKFLOW_HOME"/bin/"$WORKFLOW_EXEC" start "$@" >> "$OODT_OUT" 2>&1  &
+  exec "$RESMGR_HOME"/bin/"$RESMGR_EXEC" start "$@" >> "$OODT_OUT" 2>&1  &  
   exec "$OODT_BASE"/tomcat/bin/"$TOMCAT_EXEC" start "$@" >> "$OODT_OUT" 2>&1 &
 elif [ "$1" = "stop" ]; then
   exec "$FILEMGR_HOME"/bin/"$FILEMGR_EXEC" stop "$@" >> "$OODT_OUT" 2>&1  &
   exec "$WORKFLOW_HOME"/bin/"$WORKFLOW_EXEC" stop "$@" >> "$OODT_OUT" 2>&1 &
+  exec "$RESMGR_HOME"/bin/"$RESMGR_EXEC" stop "$@" >> "$OODT_OUT" 2>&1 &
   exec "$OODT_BASE"/tomcat/bin/"$TOMCAT_EXEC" stop "$@" >> "$OODT_OUT" 2>&1 &
 else
   echo "Usage: oodt.sh ( commands ... )"

Modified: 
oodt/trunk/mvn/archetypes/radix/src/main/resources/archetype-resources/resmgr/src/main/resources/bin/resmgr
URL: 
http://svn.apache.org/viewvc/oodt/trunk/mvn/archetypes/radix/src/main/resources/archetype-resources/resmgr/src/main/resources/bin/resmgr?rev=1471223&r1=1471222&r2=1471223&view=diff
==============================================================================
--- 
oodt/trunk/mvn/archetypes/radix/src/main/resources/archetype-resources/resmgr/src/main/resources/bin/resmgr
 (original)
+++ 
oodt/trunk/mvn/archetypes/radix/src/main/resources/archetype-resources/resmgr/src/main/resources/bin/resmgr
 Wed Apr 24 01:31:29 2013
@@ -22,52 +22,152 @@
 #
 # $Id$
 
-[ -f /etc/sysconfig/java ] && . /etc/sysconfig/java
-#[ -f /etc/sysconfig/cas-filemgr] && . /etc/sysconfig/cas-filemgr
+# OS specific support.  $var _must_ be set to either true or false.
+cygwin=false
+os400=false
+darwin=false
+case "`uname`" in
+CYGWIN*) cygwin=true;;
+OS400*) os400=true;;
+Darwin*) darwin=true;;
+esac
 
-SERVER_PORT=9002
-export SERVER_PORT
-if [ -z $JAVA_HOME ] ; then
-       JAVA_HOME=/path/to/java/home
-else
-       JAVA_HOME=${JAVA_HOME}
+# resolve links - $0 may be a softlink
+PRG="$0"
+
+while [ -h "$PRG" ]; do
+  ls=`ls -ld "$PRG"`
+  link=`expr "$ls" : '.*-> \(.*\)$'`
+  if expr "$link" : '/.*' > /dev/null; then
+    PRG="$link"
+  else
+    PRG=`dirname "$PRG"`/"$link"
+  fi
+done
+
+# Get standard environment variables
+PRGDIR=`dirname "$PRG"`
+
+# Only set OODT_HOME if not already set
+[ -z "$OODT_HOME" ] && OODT_HOME=`cd "$PRGDIR/../.." ; pwd`
+
+# Get OODT environment set up
+if [ -r "$OODT_HOME"/bin/env.sh ]; then
+  . "$OODT_HOME"/bin/env.sh
+fi
+
+# Only set RESMGR_HOME if not already set
+if [ -z "$RESMGR_HOME" ]; then
+  RESMGR_HOME="$OODT_HOME"/resmgr
+  export RESMGR_HOME
+fi
+
+if [ -z "$RESMGR_PID" ]; then
+  RESMGR_PID="$RESMGR_HOME"/run/cas.resmgr.pid
+fi
+
+# For Cygwin, ensure paths are in UNIX format before anything is touched
+if $cygwin; then
+  [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
+  [ -n "$JRE_HOME" ] && JRE_HOME=`cygpath --unix "$JRE_HOME"`
+  [ -n "$OODT_HOME" ] && OODT_HOME=`cygpath --unix "$OODT_HOME"`
+  [ -n "$RESMGR_HOME" ] && RESMGR_HOME=`cygpath --unix "$RESMGR_HOME"`
+  [ -n "$CLASSPATH" ] && CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
 fi
 
-export JAVA_HOME
-CAS_RESMGR_HOME=..
-export CAS_RESMGR_HOME
-RUN_HOME=${CAS_RESMGR_HOME}/../run
-export RUN_HOME
-CAS_RESMGR_PROPS=../etc/resource.properties
-export CAS_RESMGR_PROPS
-
-PATH=${JAVA_HOME}/bin:${CAS_RESMGR_HOME}/bin:/usr/bin:/bin:/usr/sbin:/sbin
-export PATH
-
-# See how we were called.
-case "$1" in
-  start)
-        echo -n "Starting cas resource manager: "
-        $JAVA_HOME/bin/java -Djava.ext.dirs=${CAS_RESMGR_HOME}/lib \
-        
-Djava.util.logging.config.file=${CAS_RESMGR_HOME}/etc/logging.properties \
-        -Dorg.apache.oodt.cas.resource.properties=${CAS_RESMGR_PROPS} \
-        org.apache.oodt.cas.resource.system.XmlRpcResourceManager --portNum 
$SERVER_PORT &       
-        echo $! >${RUN_HOME}/cas.resmgr.pid 
-        echo "OK"
-        sleep 5
-        ;;
-  stop)
-        echo -n "Shutting down cas resource manager: "
-        kill `cat ${RUN_HOME}/cas.resmgr.pid`
-        echo "OK"
-        ;;
-  restart)
-        $0 stop
-        $0 start
-        ;;
-  *)
-        echo "Usage: $0 {start|stop|restart}"
+if [ "$1" = "start" ]; then
+  if [ ! -z "$RESMGR_PID" ]; then
+    if [ -f "$RESMGR_PID" ]; then
+      echo "PID file ($RESMGR_PID) found. Is Resource Manager still running? 
Start aborted."
+      exit 1
+    fi
+  fi
+
+  # In case this script was run from somewhere else cd to this directory
+  cd "$RESMGR_HOME"/bin
+
+  "$_RUNJAVA" $JAVA_OPTS $OODT_OPTS \
+    -Djava.ext.dirs="$RESMGR_HOME"/lib \
+    -Djava.util.logging.config.file="$RESMGR_HOME"/etc/logging.properties \
+    
-Dorg.apache.oodt.cas.resource.properties="$RESMGR_HOME"/etc/resource.properties
 \
+    -Djava.io.tmpdir="$OODT_TMPDIR" \
+    org.apache.oodt.cas.resource.system.XmlRpcResourceManager \
+    --portNum "$RESMGR_PORT" 2>&1 &
+
+  if [ ! -z "$RESMGR_PID" ]; then
+    echo $! > $RESMGR_PID
+  fi
+
+  if [ $have_tty -eq 1 ]; then
+    echo "Resource Manager started PID file ($RESMGR_PID)."
+  fi
+
+elif [ "$1" = "stop" ]; then
+
+  shift
+
+  SLEEP=5
+  if [ ! -z "$1" ]; then
+    echo $1 | grep "[^0-9]" > /dev/null 2>&1
+    if [ $? -eq 1 ]; then
+      SLEEP=$1
+      shift
+    fi
+  fi
+
+  FORCE=0
+  if [ "$1" = "-force" ]; then
+    shift
+    FORCE=1
+  fi
+
+  if [ ! -z "$RESMGR_PID" ]; then
+    if [ -f "$RESMGR_PID" ]; then
+      kill `cat $RESMGR_PID` >/dev/null 2>&1
+      if [ $? -eq 1 ]; then
+        echo "PID file ($RESMGR_PID) found but no matching process was found. 
Stop aborted."
         exit 1
-esac
+      fi
+    else
+      echo "\$RESMGR_PID was set ($RESMGR_PID) but the specified file does not 
exist. Is Resource Manager running? Stop aborted."
+      exit 1
+    fi
+  fi
+
+  if [ ! -z "$RESMGR_PID" ]; then
+    if [ -f "$RESMGR_PID" ]; then
+      while [ $SLEEP -ge 0 ]; do
+        kill -0 `cat $RESMGR_PID` >/dev/null 2>&1
+        if [ $? -eq 1 ]; then
+          rm $RESMGR_PID
+          break
+        fi
+        if [ $SLEEP -gt 0 ]; then
+          sleep 1
+        fi
+        if [ $SLEEP -eq 0 ]; then
+          if [ $FORCE -eq 0 ]; then
+            echo "Resource Manager did not stop in time. PID file was not 
removed."
+          fi
+        fi
+        SLEEP=`expr $SLEEP - 1 `
+      done
+    fi
+  fi
+
+  if [ $FORCE -eq 1 ]; then
+    if [ -z "$RESMGR_PID" ]; then
+      echo "Kill failed: \$RESMGR_PID not set"
+    else
+      if [ -f "$RESMGR_PID" ]; then
+        echo "Killing: `cat $RESMGR_PID`"
+        kill -9 `cat $RESMGR_PID`
+        rm $RESMGR_PID
+      fi
+    fi
+  fi
 
-exit 0
+else
+  echo "Usage: resmgr {start|stop}"
+  exit 1
+fi

Modified: 
oodt/trunk/mvn/archetypes/radix/src/main/resources/archetype-resources/resmgr/src/main/resources/etc/resource.properties
URL: 
http://svn.apache.org/viewvc/oodt/trunk/mvn/archetypes/radix/src/main/resources/archetype-resources/resmgr/src/main/resources/etc/resource.properties?rev=1471223&r1=1471222&r2=1471223&view=diff
==============================================================================
--- 
oodt/trunk/mvn/archetypes/radix/src/main/resources/archetype-resources/resmgr/src/main/resources/etc/resource.properties
 (original)
+++ 
oodt/trunk/mvn/archetypes/radix/src/main/resources/archetype-resources/resmgr/src/main/resources/etc/resource.properties
 Wed Apr 24 01:31:29 2013
@@ -52,10 +52,10 @@ org.apache.oodt.cas.resource.jobrepo.xst
 org.apache.oodt.cas.resource.jobrepo.xstream.max.history=4000
 
 # XML Node Repository config properties
-org.apache.oodt.cas.resource.nodes.dirs=file://[HOME]/nodes,file://[HOME]/nodes2
+org.apache.oodt.cas.resource.nodes.dirs=file://[RESMGR_HOME]/policy
 
 # XML Queue Repository config properties
-org.apache.oodt.cas.resource.nodetoqueues.dirs=file://[HOME]/nodes,file://[HOME]/nodes2
+org.apache.oodt.cas.resource.nodetoqueues.dirs=file://[RESMGR_HOME]/policy
 
 
 

Modified: 
oodt/trunk/mvn/archetypes/radix/src/main/resources/archetype-resources/workflow/src/main/resources/etc/workflow.properties
URL: 
http://svn.apache.org/viewvc/oodt/trunk/mvn/archetypes/radix/src/main/resources/archetype-resources/workflow/src/main/resources/etc/workflow.properties?rev=1471223&r1=1471222&r2=1471223&view=diff
==============================================================================
--- 
oodt/trunk/mvn/archetypes/radix/src/main/resources/archetype-resources/workflow/src/main/resources/etc/workflow.properties
 (original)
+++ 
oodt/trunk/mvn/archetypes/radix/src/main/resources/archetype-resources/workflow/src/main/resources/etc/workflow.properties
 Wed Apr 24 01:31:29 2013
@@ -33,7 +33,7 @@ org.apache.oodt.cas.workflow.engine.unli
 org.apache.oodt.cas.workflow.engine.preConditionWaitTime=10
 
 # set this if you want the workflow manager to submit jobs through the 
resource mgr
-org.apache.oodt.cas.workflow.engine.resourcemgr.url=[RESMGR_URL]
+org.apache.oodt.cas.workflow.engine.resourcemgr.url=http://localhost:9300
 
 # if you use the resource mgr submission, you can specify how many seconds the 
 # workflow manager should wait inbetween checking to see if a job is complete


Reply via email to