flume-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From esam...@apache.org
Subject svn commit: r1158899 - /incubator/flume/branches/flume-728/flume-ng-node/src/main/java/org/apache/flume/node/Application.java
Date Wed, 17 Aug 2011 20:55:01 GMT
Author: esammer
Date: Wed Aug 17 20:55:01 2011
New Revision: 1158899

URL: http://svn.apache.org/viewvc?rev=1158899&view=rev
Log:
- Added skeletal main() run loop for FlumeNode.

Added:
    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-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=1158899&view=auto
==============================================================================
--- 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-node/src/main/java/org/apache/flume/node/Application.java
Wed Aug 17 20:55:01 2011
@@ -0,0 +1,69 @@
+package org.apache.flume.node;
+
+import org.apache.flume.Context;
+import org.apache.flume.lifecycle.LifecycleController;
+import org.apache.flume.lifecycle.LifecycleException;
+import org.apache.flume.lifecycle.LifecycleState;
+import org.apache.flume.node.nodemanager.DefaultLogicalNodeManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class Application {
+
+  private static final Logger logger = LoggerFactory
+      .getLogger(Application.class);
+
+  private String[] args;
+
+  public static void main(String[] args) {
+    Application application = new Application();
+
+    application.setArgs(args);
+
+    try {
+      application.run();
+    } catch (Exception e) {
+      logger.error("A fatal error occurred while running. Exception follows.",
+          e);
+    }
+  }
+
+  public void run() throws LifecycleException, InterruptedException {
+    final Context context = new Context();
+    final FlumeNode node = new FlumeNode();
+    NodeManager nodeManager = new DefaultLogicalNodeManager();
+
+    node.setName("node");
+    node.setNodeManager(nodeManager);
+
+    Runtime.getRuntime().addShutdownHook(new Thread("node-shutdownHook") {
+
+      @Override
+      public void run() {
+        try {
+          node.stop(context);
+        } catch (LifecycleException e) {
+          // TODO Auto-generated catch block
+          e.printStackTrace();
+        } catch (InterruptedException e) {
+          // TODO Auto-generated catch block
+          e.printStackTrace();
+        }
+      }
+
+    });
+
+    node.start(context);
+
+    LifecycleController.waitForOneOf(node, LifecycleState.STOP_OR_ERROR);
+  }
+
+  public String[] getArgs() {
+    return args;
+  }
+
+  public void setArgs(String[] args) {
+    this.args = args;
+  }
+
+}



Mime
View raw message