flume-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r1327540 - in /incubator/flume/trunk: bin/flume-ng conf/flume-env.sh.template
Date Wed, 18 Apr 2012 15:17:18 GMT
Author: brock
Date: Wed Apr 18 15:17:17 2012
New Revision: 1327540

URL: http://svn.apache.org/viewvc?rev=1327540&view=rev
Log:
FLUME-1125: flume-ng script allows flume-env.sh to clobber some command-line arguments

(Mike Percy via Brock Noland)

Modified:
    incubator/flume/trunk/bin/flume-ng
    incubator/flume/trunk/conf/flume-env.sh.template

Modified: incubator/flume/trunk/bin/flume-ng
URL: http://svn.apache.org/viewvc/incubator/flume/trunk/bin/flume-ng?rev=1327540&r1=1327539&r2=1327540&view=diff
==============================================================================
--- incubator/flume/trunk/bin/flume-ng (original)
+++ incubator/flume/trunk/bin/flume-ng Wed Apr 18 15:17:17 2012
@@ -105,6 +105,7 @@ commands:
 global options:
   --conf,-c <conf>      use configs in <conf> directory
   --classpath,-C <cp>   append to the classpath
+  --dryrun,-d           do not actually start Flume, just print the command
   -Dproperty=value      sets a JDK system property value
 
 agent options:
@@ -135,7 +136,7 @@ run_flume() {
   fi
 
   set -x
-  exec $JAVA_HOME/bin/java $JAVA_OPTS -cp "$FLUME_CLASSPATH" \
+  $EXEC $JAVA_HOME/bin/java $JAVA_OPTS -cp "$FLUME_CLASSPATH" \
       -Djava.library.path=$FLUME_JAVA_LIBRARY_PATH "$FLUME_APPLICATION_CLASS" $*
 }
 
@@ -149,6 +150,9 @@ FLUME_JAVA_LIBRARY_PATH=""
 JAVA_OPTS="-Xmx20m"
 
 opt_conf=""
+opt_classpath=""
+opt_java_props=""
+opt_dryrun=""
 
 mode=$1
 shift
@@ -188,11 +192,14 @@ while [ -n "$*" ] ; do
       ;;
     --classpath|-C)
       [ -n "$1" ] || error "Option --classpath requires an argument" 1
-      FLUME_CLASSPATH=$1
+      opt_classpath=$1
       shift
       ;;
+    --dryrun|-d)
+      opt_dryrun="1"
+      ;;
     -D*)
-      JAVA_OPTS="${JAVA_OPTS} $arg"
+      opt_java_props="$opt_java_props $arg"
       ;;
     *)
       args="$args $arg"
@@ -209,9 +216,31 @@ fi
 if [ -z "$opt_conf" ]; then
   warn "No configuration directory set! Use --conf <dir> to override."
 elif [ -f "$opt_conf/flume-env.sh" ]; then
+  info "Sourcing environment configuration script $opt_conf/flume-env.sh"
   source "$opt_conf/flume-env.sh"
 fi
 
+# append command-line java options to stock or env script JAVA_OPTS
+if [ -n "${opt_java_props}" ]; then
+  JAVA_OPTS="${JAVA_OPTS} ${opt_java_props}"
+fi
+
+# prepend command-line classpath to env script classpath
+if [ -n "${opt_classpath}" ]; then
+  if [ -n "${FLUME_CLASSPATH}" ]; then
+    FLUME_CLASSPATH="${opt_classpath}:${FLUME_CLASSPATH}"
+  else
+    FLUME_CLASSPATH="${opt_classpath}"
+  fi
+fi
+
+# prepend flume jars to the specified classpath (if any)
+if [ -n "${FLUME_CLASSPATH}" ] ; then
+  FLUME_CLASSPATH="${FLUME_HOME}/lib/*:$FLUME_CLASSPATH"
+else
+  FLUME_CLASSPATH="${FLUME_HOME}/lib/*"
+fi
+
 # find java
 if [ -z "${JAVA_HOME}" ] ; then
   echo "Warning: JAVA_HOME not set!"
@@ -234,13 +263,6 @@ if [ -z "${FLUME_HOME}" ] ; then
   FLUME_HOME=$(cd $(dirname $0)/..; pwd)
 fi
 
-# Append to the classpath
-if [ -n "${FLUME_CLASSPATH}" ] ; then
-  FLUME_CLASSPATH="${FLUME_HOME}/lib/*:$FLUME_CLASSPATH"
-else
-  FLUME_CLASSPATH="${FLUME_HOME}/lib/*"
-fi
-
 # look for hadoop libs
 add_hadoop_paths
 
@@ -249,6 +271,13 @@ if [ -n "$opt_conf" ]; then
   FLUME_CLASSPATH="$opt_conf:$FLUME_CLASSPATH"
 fi
 
+# allow dryrun
+EXEC="exec"
+if [ -n "${opt_dryrun}" ]; then
+  warn "Dryrun mode enabled (will not actually initiate startup)"
+  EXEC="echo"
+fi
+
 # finally, invoke the appropriate command
 if [ -n "$opt_agent" ] ; then
   run_flume $FLUME_AGENT_CLASS $args

Modified: incubator/flume/trunk/conf/flume-env.sh.template
URL: http://svn.apache.org/viewvc/incubator/flume/trunk/conf/flume-env.sh.template?rev=1327540&r1=1327539&r2=1327540&view=diff
==============================================================================
--- incubator/flume/trunk/conf/flume-env.sh.template (original)
+++ incubator/flume/trunk/conf/flume-env.sh.template Wed Apr 18 15:17:17 2012
@@ -14,19 +14,16 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-
-# If this file is is FLUME_CONF_DIR/flume-env.sh, it sourced during execution
-# of the flume script and the flume-daemon.sh script.
+# If this file is placed at FLUME_CONF_DIR/flume-env.sh, it will be sourced
+# during Flume startup.
 
 # Enviroment variables can be set here.
 
+#JAVA_HOME=/usr/lib/jvm/java-6-sun
 
-#export JAVA_HOME=/usr/lib/jvm/java-6-sun
-
-#export JAVA_OPTS="-Xmx20m"
-
-
-#Note that the conf directory is always included in the classpath.
-#export FLUME_CLASSPATH=""
+# Give Flume more memory
+#JAVA_OPTS="-Xmx200m"
 
+# Note that the Flume conf directory is always included in the classpath.
+#FLUME_CLASSPATH=""
 



Mime
View raw message