nifi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jperciv...@apache.org
Subject nifi-minifi git commit: MINIFI-128 Adjusting handling of change ingestor configuration and error messaging.
Date Thu, 22 Dec 2016 21:43:16 GMT
Repository: nifi-minifi
Updated Branches:
  refs/heads/master 2fcf5ec60 -> a2f6e9d8c


MINIFI-128 Adjusting handling of change ingestor configuration and error messaging.

This closes #68

Signed-off-by: Joseph Percivall <JPercivall@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/nifi-minifi/repo
Commit: http://git-wip-us.apache.org/repos/asf/nifi-minifi/commit/a2f6e9d8
Tree: http://git-wip-us.apache.org/repos/asf/nifi-minifi/tree/a2f6e9d8
Diff: http://git-wip-us.apache.org/repos/asf/nifi-minifi/diff/a2f6e9d8

Branch: refs/heads/master
Commit: a2f6e9d8c336071dfb44aafdd3b4391230fe1193
Parents: 2fcf5ec
Author: Aldrin Piri <aldrin@apache.org>
Authored: Tue Dec 20 15:42:03 2016 -0500
Committer: Joseph Percivall <JPercivall@apache.org>
Committed: Thu Dec 22 16:43:51 2016 -0500

----------------------------------------------------------------------
 .../apache/nifi/minifi/bootstrap/RunMiNiFi.java | 50 ++++++++++++--------
 .../nifi/minifi/bootstrap/ShutdownHook.java     | 10 ++--
 2 files changed, 35 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/nifi-minifi/blob/a2f6e9d8/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/RunMiNiFi.java
----------------------------------------------------------------------
diff --git a/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/RunMiNiFi.java
b/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/RunMiNiFi.java
index 9ac7e23..b46f312 100644
--- a/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/RunMiNiFi.java
+++ b/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/RunMiNiFi.java
@@ -16,6 +16,21 @@
  */
 package org.apache.nifi.minifi.bootstrap;
 
+import org.apache.commons.io.input.TeeInputStream;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.nifi.minifi.bootstrap.configuration.ConfigurationChangeCoordinator;
+import org.apache.nifi.minifi.bootstrap.configuration.ConfigurationChangeException;
+import org.apache.nifi.minifi.bootstrap.configuration.ConfigurationChangeListener;
+import org.apache.nifi.minifi.bootstrap.status.PeriodicStatusReporter;
+import org.apache.nifi.minifi.bootstrap.util.ConfigTransformer;
+import org.apache.nifi.minifi.commons.status.FlowStatusReport;
+import org.apache.nifi.stream.io.ByteArrayInputStream;
+import org.apache.nifi.stream.io.ByteArrayOutputStream;
+import org.apache.nifi.util.Tuple;
+import org.apache.nifi.util.file.FileUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import java.io.BufferedReader;
 import java.io.EOFException;
 import java.io.File;
@@ -63,21 +78,6 @@ import java.util.concurrent.locks.Condition;
 import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReentrantLock;
 
-import org.apache.commons.io.input.TeeInputStream;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.nifi.minifi.bootstrap.configuration.ConfigurationChangeException;
-import org.apache.nifi.minifi.bootstrap.configuration.ConfigurationChangeListener;
-import org.apache.nifi.minifi.bootstrap.status.PeriodicStatusReporter;
-import org.apache.nifi.minifi.bootstrap.configuration.ConfigurationChangeCoordinator;
-import org.apache.nifi.minifi.bootstrap.util.ConfigTransformer;
-import org.apache.nifi.minifi.commons.status.FlowStatusReport;
-import org.apache.nifi.stream.io.ByteArrayInputStream;
-import org.apache.nifi.stream.io.ByteArrayOutputStream;
-import org.apache.nifi.util.Tuple;
-import org.apache.nifi.util.file.FileUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
 import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
 
 /**
@@ -1187,18 +1187,26 @@ public class RunMiNiFi implements QueryableStatusAggregator, ConfigurationFileHo
             return;
         }
 
+        // Instantiate configuration listener and configured ingestors
+        this.changeListener = new MiNiFiConfigurationChangeListener(this, defaultLogger);
+        this.periodicStatusReporters = initializePeriodicNotifiers();
+        startPeriodicNotifiers();
+        try {
+            this.changeCoordinator = initializeNotifier(this.changeListener);
+        } catch (Exception e) {
+            final String errorMsg = "Unable to start as {} is not properly configured due
to: {}";
+            cmdLogger.error(errorMsg, this.changeListener.getDescriptor(), e.getMessage());
+            defaultLogger.error("Unable to initialize notifier.", e);
+            // if we fail to initialize, exit without attempting to start
+            System.exit(1);
+        }
+
         Tuple<ProcessBuilder, Process> tuple = startMiNiFi();
         if (tuple == null) {
             cmdLogger.info("Start method returned null, ending start command.");
             return;
         }
 
-        // Instantiate configuration listener and configured ingestors
-        this.changeListener = new MiNiFiConfigurationChangeListener(this, defaultLogger);
-        this.periodicStatusReporters = initializePeriodicNotifiers();
-        startPeriodicNotifiers();
-        this.changeCoordinator = initializeNotifier(this.changeListener);
-
         ProcessBuilder builder = tuple.getKey();
         Process process = tuple.getValue();
 

http://git-wip-us.apache.org/repos/asf/nifi-minifi/blob/a2f6e9d8/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/ShutdownHook.java
----------------------------------------------------------------------
diff --git a/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/ShutdownHook.java
b/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/ShutdownHook.java
index c0060f5..3aabc96 100644
--- a/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/ShutdownHook.java
+++ b/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/ShutdownHook.java
@@ -55,10 +55,12 @@ public class ShutdownHook extends Thread {
 
         System.out.println("Initiating shutdown of bootstrap change ingestors...");
         ConfigurationChangeCoordinator notifier = runner.getChangeCoordinator();
-        try {
-            notifier.close();
-        } catch (IOException ioe) {
-            System.out.println("Could not successfully stop notifier due to " + ioe);
+        if (notifier != null) {
+            try {
+                notifier.close();
+            } catch (IOException ioe) {
+                System.out.println("Could not successfully stop notifier due to " + ioe);
+            }
         }
 
         System.out.println("Initiating shutdown of bootstrap periodic status reporters...");


Mime
View raw message