Review Board 1.7.22


FLUME-1948: plugins.d directory(ies) should be separately overridable, independent of FLUME_HOME

Review Request #10453 - Created April 15, 2013 and submitted

Mike Percy
FLUME-1948
Reviewers
Flume
flume-git
Added capability to specify one or more plugins directories on the command line.
Manually tested with config file and 2 plugins.d directories

Diff revision 2 (Latest)

1 2
1 2

  1. bin/flume-ng: Loading...
bin/flume-ng
Revision ee86c95 New Change
[20] 179 lines
[+20]
180

    
   
180

   
181
global options:
181
global options:
182
  --conf,-c <conf>      use configs in <conf> directory
182
  --conf,-c <conf>      use configs in <conf> directory
183
  --classpath,-C <cp>   append to the classpath
183
  --classpath,-C <cp>   append to the classpath
184
  --dryrun,-d           do not actually start Flume, just print the command
184
  --dryrun,-d           do not actually start Flume, just print the command
185
  -Dproperty=value      sets a JDK system property value
185
  --plugins-path <dirs> colon-separated list of plugins.d directories. See the

    
   
186
                        plugins.d section in the user guide for more details.

    
   
187
                        Default: \$FLUME_HOME/plugins.d

    
   
188
  -Dproperty=value      sets a Java system property value

    
   
189
  -Xproperty=value      sets a Java -X option
186

    
   
190

   
187
agent options:
191
agent options:
188
  --conf-file,-f <file> specify a config file (required)
192
  --conf-file,-f <file> specify a config file (required)
189
  --name,-n <name>      the name of this agent (required)
193
  --name,-n <name>      the name of this agent (required)
190
  --help,-h             display help text
194
  --help,-h             display help text
[+20] [20] 42 lines
[+20]
233
JAVA_OPTS="-Xmx20m"
237
JAVA_OPTS="-Xmx20m"
234
LD_LIBRARY_PATH=""
238
LD_LIBRARY_PATH=""
235

    
   
239

   
236
opt_conf=""
240
opt_conf=""
237
opt_classpath=""
241
opt_classpath=""

    
   
242
opt_plugins_dirs=""
238
opt_java_props=""
243
opt_java_props=""
239
opt_dryrun=""
244
opt_dryrun=""
240

    
   
245

   
241
mode=$1
246
mode=$1
242
shift
247
shift
[+20] [20] 23 lines
[+20]
266
    display_help
271
    display_help
267
    exit 1
272
    exit 1
268
    ;;
273
    ;;
269
esac
274
esac
270

    
   
275

   

    
   
276
args=""
271
while [ -n "$*" ] ; do
277
while [ -n "$*" ] ; do
272
  arg=$1
278
  arg=$1
273
  shift
279
  shift
274

    
   
280

   
275
  case "$arg" in
281
  case "$arg" in
[+20] [20] 8 lines
[+20]
284
      shift
290
      shift
285
      ;;
291
      ;;
286
    --dryrun|-d)
292
    --dryrun|-d)
287
      opt_dryrun="1"
293
      opt_dryrun="1"
288
      ;;
294
      ;;

    
   
295
    --plugins-path)

    
   
296
      opt_plugins_dirs=$1

    
   
297
      shift

    
   
298
      ;;
289
    -D*)
299
    -D*)
290
      opt_java_props="$opt_java_props $arg"
300
      opt_java_props="$opt_java_props $arg"
291
      ;;
301
      ;;
292
    -X*)
302
    -X*)
293
      opt_java_props="$opt_java_props $arg"
303
      opt_java_props="$opt_java_props $arg"
[+20] [20] 40 lines
[+20]
334
  FLUME_CLASSPATH="${FLUME_HOME}/lib/*:$FLUME_CLASSPATH"
344
  FLUME_CLASSPATH="${FLUME_HOME}/lib/*:$FLUME_CLASSPATH"
335
else
345
else
336
  FLUME_CLASSPATH="${FLUME_HOME}/lib/*"
346
  FLUME_CLASSPATH="${FLUME_HOME}/lib/*"
337
fi
347
fi
338

    
   
348

   
339
# load plugins.d
349
# load plugins.d directories

    
   
350
PLUGINS_DIRS=""

    
   
351
if [ -n "${opt_plugins_dirs}" ]; then

    
   
352
  PLUGINS_DIRS=$(sed -e 's/:/ /g' <<<${opt_plugins_dirs})

    
   
353
else

    
   
354
  PLUGINS_DIRS="${FLUME_HOME}/plugins.d"

    
   
355
fi

    
   
356

   
340
unset plugin_lib plugin_libext plugin_native
357
unset plugin_lib plugin_libext plugin_native
341
PLUGINS_DIR=${FLUME_HOME}/plugins.d
358
for PLUGINS_DIR in $PLUGINS_DIRS; do
342
if [[ -d ${PLUGINS_DIR} ]]
359
  if [[ -d ${PLUGINS_DIR} ]]; then
343
then
360
    for plugin in ${PLUGINS_DIR}/*; do
344
  for plugin in ${PLUGINS_DIR}/*
361
      if [[ -d "$plugin/lib" ]]; then
345
  do

   
346
    if [[ -d $plugin/lib ]]

   
347
    then

   
348
      plugin_lib="${plugin_lib}${plugin_lib+:}${plugin}/lib/*"
362
        plugin_lib="${plugin_lib}${plugin_lib+:}${plugin}/lib/*"
349
    fi 
363
      fi
350
    if [[ -d $plugin/libext ]]
364
      if [[ -d "$plugin/libext" ]]; then
351
    then

   
352
      plugin_libext="${plugin_libext}${plugin_libext+:}${plugin}/libext/*"
365
        plugin_libext="${plugin_libext}${plugin_libext+:}${plugin}/libext/*"
353
    fi 
366
      fi
354
    if [[ -d $plugin/native ]]
367
      if [[ -d "$plugin/native" ]]; then
355
    then

   
356
      plugin_native="${plugin_native}${plugin_native+:}${plugin}/native"
368
        plugin_native="${plugin_native}${plugin_native+:}${plugin}/native"
357
    fi 
369
      fi
358
  done
370
    done
359
fi
371
  fi

    
   
372
done

    
   
373

   
360
if [[ -n "${plugin_lib}" ]]
374
if [[ -n "${plugin_lib}" ]]
361
then
375
then
362
  FLUME_CLASSPATH="${FLUME_CLASSPATH}:${plugin_lib}"
376
  FLUME_CLASSPATH="${FLUME_CLASSPATH}:${plugin_lib}"
363
fi
377
fi

    
   
378

   
364
if [[ -n "${plugin_libext}" ]]
379
if [[ -n "${plugin_libext}" ]]
365
then
380
then
366
  FLUME_CLASSPATH="${FLUME_CLASSPATH}:${plugin_libext}"
381
  FLUME_CLASSPATH="${FLUME_CLASSPATH}:${plugin_libext}"
367
fi
382
fi

    
   
383

   
368
if [[ -n "${plugin_native}" ]]
384
if [[ -n "${plugin_native}" ]]
369
then
385
then
370
  if [[ -n "${FLUME_JAVA_LIBRARY_PATH}" ]]
386
  if [[ -n "${FLUME_JAVA_LIBRARY_PATH}" ]]
371
  then
387
  then
372
    FLUME_JAVA_LIBRARY_PATH="${FLUME_JAVA_LIBRARY_PATH}:${plugin_native}"
388
    FLUME_JAVA_LIBRARY_PATH="${FLUME_JAVA_LIBRARY_PATH}:${plugin_native}"
[+20] [20] 52 lines
  1. bin/flume-ng: Loading...