You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flume.apache.org by ar...@apache.org on 2011/11/30 19:21:56 UTC

svn commit: r1208634 - in /incubator/flume/branches/flume-728: flume-ng-core/src/main/java/org/apache/flume/Constants.java flume-ng-node/src/main/java/org/apache/flume/node/Application.java

Author: arvind
Date: Wed Nov 30 18:21:56 2011
New Revision: 1208634

URL: http://svn.apache.org/viewvc?rev=1208634&view=rev
Log:
FLUME-823. Agent must fail when invoked from CLI with a missing config file.

Added:
    incubator/flume/branches/flume-728/flume-ng-core/src/main/java/org/apache/flume/Constants.java   (with props)
Modified:
    incubator/flume/branches/flume-728/flume-ng-node/src/main/java/org/apache/flume/node/Application.java

Added: incubator/flume/branches/flume-728/flume-ng-core/src/main/java/org/apache/flume/Constants.java
URL: http://svn.apache.org/viewvc/incubator/flume/branches/flume-728/flume-ng-core/src/main/java/org/apache/flume/Constants.java?rev=1208634&view=auto
==============================================================================
--- incubator/flume/branches/flume-728/flume-ng-core/src/main/java/org/apache/flume/Constants.java (added)
+++ incubator/flume/branches/flume-728/flume-ng-core/src/main/java/org/apache/flume/Constants.java Wed Nov 30 18:21:56 2011
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.flume;
+
+public final class Constants {
+
+  public static final String SYSPROP_CALLED_FROM_SERVICE
+          = "flume.called.from.service";
+
+  private Constants() {
+    // disable explicit object creation
+  }
+}

Propchange: incubator/flume/branches/flume-728/flume-ng-core/src/main/java/org/apache/flume/Constants.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/flume/branches/flume-728/flume-ng-node/src/main/java/org/apache/flume/node/Application.java
URL: http://svn.apache.org/viewvc/incubator/flume/branches/flume-728/flume-ng-node/src/main/java/org/apache/flume/node/Application.java?rev=1208634&r1=1208633&r2=1208634&view=diff
==============================================================================
--- incubator/flume/branches/flume-728/flume-ng-node/src/main/java/org/apache/flume/node/Application.java (original)
+++ incubator/flume/branches/flume-728/flume-ng-node/src/main/java/org/apache/flume/node/Application.java Wed Nov 30 18:21:56 2011
@@ -20,6 +20,7 @@
 package org.apache.flume.node;
 
 import java.io.File;
+import java.io.IOException;
 
 import org.apache.commons.cli.CommandLine;
 import org.apache.commons.cli.CommandLineParser;
@@ -29,6 +30,7 @@ import org.apache.commons.cli.Option;
 import org.apache.commons.cli.Options;
 import org.apache.commons.cli.ParseException;
 import org.apache.flume.ChannelFactory;
+import org.apache.flume.Constants;
 import org.apache.flume.SinkFactory;
 import org.apache.flume.SourceFactory;
 import org.apache.flume.channel.DefaultChannelFactory;
@@ -127,6 +129,20 @@ public class Application {
 
     if (commandLine.hasOption('f')) {
       configurationFile = new File(commandLine.getOptionValue('f'));
+
+      if (!configurationFile.exists()) {
+        // If command line invocation, then need to fail fast
+        if (System.getProperty(Constants.SYSPROP_CALLED_FROM_SERVICE) == null) {
+          String path = configurationFile.getPath();
+          try {
+            path = configurationFile.getCanonicalPath();
+          } catch (IOException ex) {
+            logger.error("Failed to read canonical path for file: " + path, ex);
+          }
+          throw new ParseException(
+              "The specified configuration file does not exist: " + path);
+        }
+      }
     }
 
     if (commandLine.hasOption('n')) {