You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by al...@apache.org on 2016/02/06 04:36:08 UTC

[12/50] nifi git commit: NIFI-259: Minor bug fixes

NIFI-259: Minor bug fixes


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

Branch: refs/heads/master
Commit: e943c41a4760b4f72b0743e2ba9e425d4602ff7b
Parents: 1a7e6c7
Author: Mark Payne <ma...@hotmail.com>
Authored: Thu Jan 14 09:26:26 2016 -0500
Committer: Mark Payne <ma...@hotmail.com>
Committed: Thu Jan 14 09:26:26 2016 -0500

----------------------------------------------------------------------
 .../nifi/controller/AbstractControllerService.java    | 10 ++++++++++
 .../org/apache/nifi/controller/FlowController.java    | 14 ++++++++++++++
 .../controller/state/server/ZooKeeperStateServer.java |  7 ++++++-
 3 files changed, 30 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/nifi/blob/e943c41a/nifi-api/src/main/java/org/apache/nifi/controller/AbstractControllerService.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/controller/AbstractControllerService.java b/nifi-api/src/main/java/org/apache/nifi/controller/AbstractControllerService.java
index cd3b9bd..2d9a1f3 100644
--- a/nifi-api/src/main/java/org/apache/nifi/controller/AbstractControllerService.java
+++ b/nifi-api/src/main/java/org/apache/nifi/controller/AbstractControllerService.java
@@ -21,6 +21,7 @@ import java.util.Map;
 import org.apache.nifi.components.AbstractConfigurableComponent;
 import org.apache.nifi.components.PropertyDescriptor;
 import org.apache.nifi.components.PropertyValue;
+import org.apache.nifi.components.state.StateManager;
 import org.apache.nifi.controller.annotation.OnConfigured;
 import org.apache.nifi.logging.ComponentLog;
 import org.apache.nifi.processor.ProcessorInitializationContext;
@@ -32,12 +33,14 @@ public abstract class AbstractControllerService extends AbstractConfigurableComp
     private ControllerServiceLookup serviceLookup;
     private volatile ConfigurationContext configContext;
     private ComponentLog logger;
+    private StateManager stateManager;
 
     @Override
     public final void initialize(final ControllerServiceInitializationContext context) throws InitializationException {
         this.identifier = context.getIdentifier();
         serviceLookup = context.getControllerServiceLookup();
         logger = context.getLogger();
+        stateManager = context.getStateManager();
         init(context);
     }
 
@@ -93,4 +96,11 @@ public abstract class AbstractControllerService extends AbstractConfigurableComp
     protected ComponentLog getLogger() {
         return logger;
     }
+
+    /**
+     * @return the StateManager that can be used to store and retrieve state for this Controller Service
+     */
+    protected StateManager getStateManager() {
+        return stateManager;
+    }
 }

http://git-wip-us.apache.org/repos/asf/nifi/blob/e943c41a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/FlowController.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/FlowController.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/FlowController.java
index 8f3af55..c0e201b 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/FlowController.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/FlowController.java
@@ -3096,6 +3096,20 @@ public class FlowController implements EventAccess, ControllerServiceProvider, R
                                     zooKeeperStateServer.start();
                                 } catch (final Exception e) {
                                     LOG.error("NiFi was connected to the cluster but failed to start embedded ZooKeeper Server", e);
+                                    final Bulletin bulletin = BulletinFactory.createBulletin("Embedded ZooKeeper Server", Severity.ERROR.name(),
+                                        "Unable to started embedded ZooKeeper Server. See logs for more details. Will continue trying to start embedded server.");
+                                    getBulletinRepository().addBulletin(bulletin);
+
+                                    // We failed to start the server. Wait a bit and try again.
+                                    try {
+                                        Thread.sleep(TimeUnit.SECONDS.toMillis(5));
+                                    } catch (final InterruptedException ie) {
+                                        // If we are interrupted, stop trying.
+                                        Thread.currentThread().interrupt();
+                                        return;
+                                    }
+
+                                    processScheduler.submitFrameworkTask(this);
                                 }
                             }
                         });

http://git-wip-us.apache.org/repos/asf/nifi/blob/e943c41a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/state/server/ZooKeeperStateServer.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/state/server/ZooKeeperStateServer.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/state/server/ZooKeeperStateServer.java
index b532a48..1a646b0 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/state/server/ZooKeeperStateServer.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/state/server/ZooKeeperStateServer.java
@@ -36,6 +36,7 @@ public class ZooKeeperStateServer extends ZooKeeperServerMain {
     private static final Logger logger = LoggerFactory.getLogger(ZooKeeperStateServer.class);
 
     private QuorumPeerConfig quorumPeerConfig;
+    private boolean started = false;
 
     private ZooKeeperStateServer(final Properties zkProperties) throws IOException, ConfigException {
         quorumPeerConfig = new QuorumPeerConfig();
@@ -49,6 +50,7 @@ public class ZooKeeperStateServer extends ZooKeeperServerMain {
         serverConfig.readFrom(quorumPeerConfig);
         try {
             runFromConfig(serverConfig);
+            started = true;
         } catch (final IOException ioe) {
             throw new IOException("Failed to start embedded ZooKeeper Server", ioe);
         } catch (final Exception e) {
@@ -58,7 +60,10 @@ public class ZooKeeperStateServer extends ZooKeeperServerMain {
 
     @Override
     public synchronized void shutdown() {
-        super.shutdown();
+        if (started) {
+            started = false;
+            super.shutdown();
+        }
     }
 
     public static ZooKeeperStateServer create(final NiFiProperties properties) throws IOException, ConfigException {