keith-turner commented on a change in pull request #883: Fixes #842 Support 
multiple ways for running Fluo applications
URL: https://github.com/apache/incubator-fluo/pull/883#discussion_r128266154
 
 

 ##########
 File path: modules/distribution/src/main/scripts/fluo
 ##########
 @@ -97,60 +124,140 @@ function check_hadoop {
   fi
 }
 
+function setup_service {
+  check_conn_props
+  mkdir -p "$FLUO_LOG_DIR"
+  app_lib=$lib/apps/$1
+  mkdir -p "$app_lib"
+  java org.apache.fluo.command.FluoGetJars "$connection_props" "$1" "$app_lib"
+  export CLASSPATH="$conf:$app_lib/*:$CLASSPATH"
+}
+
 case "$1" in
-new)
-  validate_app
-  java org.apache.fluo.cluster.util.ValidateAppName $APP
-  if [ -d $APP_DIR ]; then
-    echo "The Fluo '$APP' application already has a directory in apps/"
+setup)
+  check_conn_props
+  app_props=$2
+  if [ ! -f "$app_props" ]; then
+    echo "Application properties file '$app_props' does not exist"
     exit 1
   fi
-  mkdir -p $APP_DIR
-  mkdir -p $APP_CONF_DIR
-  mkdir -p $APP_LIB_DIR
-  copy_config fluo.properties
-  $SED "s/fluo.client.application.name=/fluo.client.application.name=$APP/g" 
$APP_CONF_DIR/fluo.properties
-  copy_config logback.xml
+  init_dir=$(java org.apache.fluo.command.FluoGetProp "$connection_props" 
"$app_props" fluo.observer.init.dir)
+  if [ -d "$init_dir" ]; then
+    echo "Adding $init_dir/* to CLASSPATH"
+    export CLASSPATH="$init_dir/*:$CLASSPATH"
+  fi
+  java org.apache.fluo.command.FluoSetup "$connection_props" "$app_props" 
${*:3}
   ;;
-init)
-  validate_app_full
-  check_hadoop
-  if [[ $@ != *"-h"* && $@ != *"-u"* ]]; then
-    echo "Copying Fluo jars to HDFS at /fluo/lib to be accessible by Accumulo 
for iterators"
-    $HADOOP_PREFIX/bin/hdfs dfs -mkdir -p /fluo/lib
-    echo "Copying `ls $FLUO_HOME/lib/fluo-api-*.jar` to HDFS"
-    $HADOOP_PREFIX/bin/hdfs dfs -copyFromLocal -f 
$FLUO_HOME/lib/fluo-api-*.jar /fluo/lib/
-    echo "Copying `ls $FLUO_HOME/lib/fluo-accumulo-*.jar` to HDFS"
-    $HADOOP_PREFIX/bin/hdfs dfs -copyFromLocal -f 
$FLUO_HOME/lib/fluo-accumulo-*.jar /fluo/lib/
+oracle)
+  setup_service $2
+  nohup java "${JAVA_OPTS[@]}" org.apache.fluo.command.FluoOracle 
"$connection_props" "$2" > "${FLUO_LOG_DIR}/${FLUO_LOG_ID}.out" 2> 
"${FLUO_LOG_DIR}/${FLUO_LOG_ID}.err" &
+  echo "$!" > "$basedir/run/${FLUO_LOG_ID}.pid"
+  echo "Started Oracle for '$2' Fluo application. Logs can be found in 
${FLUO_LOG_DIR}"
+  ;;
+worker)
+  setup_service $2
+  nohup java "${JAVA_OPTS[@]}" org.apache.fluo.command.FluoWorker 
"$connection_props" "$2" > "${FLUO_LOG_DIR}/${FLUO_LOG_ID}.out" 2> 
"${FLUO_LOG_DIR}/${FLUO_LOG_ID}.err" &
+  echo "$!" > "$basedir/run/${FLUO_LOG_ID}.pid"
+  echo "Started Worker for '$2' Fluo application. Logs can be found in 
${FLUO_LOG_DIR}"
+  ;;
+scan)
+  if [ -f "$conf/connection.properties" ]; then
+    check_conn_props
+    java org.apache.fluo.command.FluoScan "$connection_props" ${*:2}
+  else 
+    check_hadoop
+    java org.apache.fluo.cluster.command.FluoCommand "$basedir" 
"$HADOOP_PREFIX" "$@"
   fi
-  export CLASSPATH="$APP_LIB_DIR/*:$CLASSPATH"
-  java org.apache.fluo.cluster.command.FluoCommand $FLUO_HOME $HADOOP_PREFIX 
"$@"
   ;;
-start)
-  validate_app_full
-  check_hadoop
-  export CLASSPATH="$APP_LIB_DIR/*:$CLASSPATH"
-  java org.apache.fluo.cluster.command.FluoCommand $FLUO_HOME $HADOOP_PREFIX 
"$@"
+stop)
+  if [ -f "$conf/connection.properties" ]; then
+    echo "Stopping all processes for ${2} application"
+    for pid_file in $basedir/run/${2}_*.pid; do
+      if [ -f "$pid_file" ]; then
+        kill -s KILL "$(cat "$pid_file")" 2>/dev/null
+        rm -f "${pid_file}" 2>/dev/null
+      fi 
+    done
+  else 
+    check_hadoop
+    java org.apache.fluo.cluster.command.FluoCommand "$basedir" 
"$HADOOP_PREFIX" "$@"
+  fi
   ;;
-stop|kill|status|info|scan|wait)
-  validate_app
-  check_hadoop
-  java org.apache.fluo.cluster.command.FluoCommand $FLUO_HOME $HADOOP_PREFIX 
"$@"
+ps) 
+  jps -m | grep Fluo
   ;;
 list)
-  check_hadoop
-  java org.apache.fluo.cluster.command.FluoCommand $FLUO_HOME $HADOOP_PREFIX 
$1 app ${*:2}
+  if [ -f "$conf/connection.properties" ]; then
 
 Review comment:
   Instead of checking for non-existence, could checks that 
connection.properties has no props set.  This would allow old code that only 
modifies fluo.props to work w/o having to delete this file.
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to