You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by jo...@apache.org on 2015/03/17 03:48:36 UTC

[01/20] incubator-nifi git commit: NIFI-410 pushed RAT exclusions down to the relevant modules and stopped doing broad test resource exclusion - is now specific

Repository: incubator-nifi
Updated Branches:
  refs/heads/develop eb757a484 -> 761e64a41


http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/pom.xml
----------------------------------------------------------------------
diff --git a/nifi/pom.xml b/nifi/pom.xml
index 72838bd..8ba4108 100644
--- a/nifi/pom.xml
+++ b/nifi/pom.xml
@@ -65,7 +65,7 @@
         <module>nifi-assembly</module>
         <module>nifi-docs</module>
         <module>nifi-maven-archetypes</module>
-		<module>nifi-external</module>
+        <module>nifi-external</module>
     </modules>
     <scm>
         <connection>scm:git:git://git.apache.org/incubator-nifi.git</connection>
@@ -538,10 +538,10 @@
                 <version>${hadoop.version}</version>
             </dependency>
             <dependency>
-	        	<groupId>org.apache.avro</groupId>
-	        	<artifactId>avro</artifactId>
-	        	<version>1.7.6</version>
-	        </dependency>
+                <groupId>org.apache.avro</groupId>
+                <artifactId>avro</artifactId>
+                <version>1.7.6</version>
+            </dependency>
             
             <dependency>
                 <groupId>com.sun.jersey</groupId>
@@ -654,11 +654,11 @@
                 <artifactId>nifi-utils</artifactId>
                 <version>0.0.3-incubating-SNAPSHOT</version>
             </dependency>
-			<dependency>
-				<groupId>org.apache.nifi</groupId>
-				<artifactId>nifi-site-to-site-client</artifactId>
-				<version>0.0.3-incubating-SNAPSHOT</version>
-			</dependency>
+            <dependency>
+                <groupId>org.apache.nifi</groupId>
+                <artifactId>nifi-site-to-site-client</artifactId>
+                <version>0.0.3-incubating-SNAPSHOT</version>
+            </dependency>
             <dependency>
                 <groupId>org.apache.nifi</groupId>
                 <artifactId>nifi-web-utils</artifactId>
@@ -775,7 +775,7 @@
                 <version>0.0.3-incubating-SNAPSHOT</version>
                 <type>nar</type>
             </dependency>
-			<dependency>
+            <dependency>
                 <groupId>org.apache.nifi</groupId>
                 <artifactId>nifi-kite-nar</artifactId>
                 <version>0.0.3-incubating-SNAPSHOT</version>
@@ -787,7 +787,7 @@
                 <version>0.0.3-incubating-SNAPSHOT</version>
                 <type>nar</type>
             </dependency>
-			<dependency>
+            <dependency>
                 <groupId>org.apache.nifi</groupId>
                 <artifactId>nifi-http-context-map-nar</artifactId>
                 <version>0.0.3-incubating-SNAPSHOT</version>
@@ -1008,15 +1008,9 @@
                 <artifactId>apache-rat-plugin</artifactId>
                 <configuration>
                     <excludes>
-                        <exclude>src/main/webapp/js/json2.js</exclude> <!-- license/notice accounted for -->
-                        <exclude>src/main/webapp/js/jquery/</exclude> <!-- license/notice accounted for -->
-                        <exclude>src/main/webapp/js/d3/d3.min.js</exclude> <!-- license/notice accounted for -->
-                        <exclude>src/main/webapp/js/codemirror/</exclude> <!-- license/notice accounted for -->
-                        <exclude>src/main/webapp/css/reset.css</exclude> <!-- license/notice accounted for -->
-                        <exclude>src/test/resources/</exclude> <!-- Test datasets -->
-                        <exclude>nb-configuration.xml</exclude><!-- courtesy exclude for netbeans users -->
-                        <exclude>nbactions.xml</exclude> <!-- courtesy exclude for netbeans users -->
-                        <exclude>DEPENDENCIES</exclude> <!-- auto generated file by maven while building sources.zip -->
+                        <exclude>nb-configuration.xml</exclude> <!-- courtesy excludes for netbeans users -->
+                        <exclude>nbactions.xml</exclude> <!-- courtesy excludes for netbeans users -->
+                        <exclude>DEPENDENCIES</exclude> <!-- auto generated file by apache's maven config while building sources.zip -->
                     </excludes>
                 </configuration>
             </plugin>


[12/20] incubator-nifi git commit: NIFI-410 pushed RAT exclusions down to the relevant modules and stopped doing broad test resource exclusion - is now specific

Posted by jo...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/node/Node.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/node/Node.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/node/Node.java
deleted file mode 100644
index 84565da..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/node/Node.java
+++ /dev/null
@@ -1,252 +0,0 @@
-/*
- * 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.nifi.cluster.node;
-
-import java.util.concurrent.atomic.AtomicLong;
-
-import org.apache.nifi.cluster.HeartbeatPayload;
-import org.apache.nifi.cluster.protocol.Heartbeat;
-import org.apache.nifi.cluster.protocol.NodeIdentifier;
-import org.apache.nifi.cluster.protocol.ProtocolException;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Represents a connected flow controller. Nodes always have an immutable
- * identifier and a status. The status may be changed, but never null.
- *
- * A Node may be cloned, but the cloning is a shallow copy of the instance.
- *
- * This class overrides hashCode and equals and considers two instances to be
- * equal if they have the equal NodeIdentifiers.
- *
- * @author unattributed
- */
-public class Node implements Cloneable, Comparable<Node> {
-
-    private static final Logger lockLogger = LoggerFactory.getLogger("cluster.lock");
-
-    /**
-     * The semantics of a Node status are as follows:
-     * <ul>
-     * <li>CONNECTED -- a flow controller that is connected to the cluster. A
-     * connecting node transitions to connected after the cluster receives the
-     * flow controller's first heartbeat. A connected node can transition to
-     * disconnecting.</li>
-     * <li>CONNECTING -- a flow controller has issued a connection request to
-     * the cluster, but has not yet sent a heartbeat. A connecting node can
-     * transition to disconnecting or connected. The cluster will not accept any
-     * external requests to change the flow while any node is connecting.</li>
-     * <li>DISCONNECTED -- a flow controller that is not connected to the
-     * cluster. A disconnected node can transition to connecting.</li>
-     * <li>DISCONNECTING -- a flow controller that is in the process of
-     * disconnecting from the cluster. A disconnecting node will always
-     * transition to disconnected.</li>
-     * </ul>
-     */
-    public static enum Status {
-
-        CONNECTED,
-        CONNECTING,
-        DISCONNECTED,
-        DISCONNECTING
-    }
-
-    /**
-     * the node's unique identifier
-     */
-    private final NodeIdentifier nodeId;
-
-    /**
-     * the node statue
-     */
-    private Status status;
-
-    /**
-     * the last heartbeat received by from the node
-     */
-    private Heartbeat lastHeartbeat;
-
-    /**
-     * the payload of the last heartbeat received from the node
-     */
-    private HeartbeatPayload lastHeartbeatPayload;
-
-    /**
-     * the last time the connection for this node was requested
-     */
-    private AtomicLong connectionRequestedTimestamp = new AtomicLong(0L);
-
-    /**
-     * a flag to indicate this node was disconnected because of a lack of
-     * heartbeat
-     */
-    private boolean heartbeatDisconnection;
-
-    public Node(final NodeIdentifier id, final Status status) {
-        if (id == null) {
-            throw new IllegalArgumentException("ID may not be null.");
-        } else if (status == null) {
-            throw new IllegalArgumentException("Status may not be null.");
-        }
-        this.nodeId = id;
-        this.status = status;
-    }
-
-    public NodeIdentifier getNodeId() {
-        return nodeId;
-    }
-
-    /**
-     * Returns the last received heartbeat or null if no heartbeat has been set.
-     *
-     * @return a heartbeat or null
-     */
-    public Heartbeat getHeartbeat() {
-        return lastHeartbeat;
-    }
-
-    public HeartbeatPayload getHeartbeatPayload() {
-        return lastHeartbeatPayload;
-    }
-
-    /**
-     * Sets the last heartbeat received.
-     *
-     * @param heartbeat a heartbeat
-     *
-     * @throws ProtocolException if the heartbeat's payload failed unmarshalling
-     */
-    public void setHeartbeat(final Heartbeat heartbeat) throws ProtocolException {
-        this.lastHeartbeat = heartbeat;
-        if (this.lastHeartbeat == null) {
-            this.lastHeartbeatPayload = null;
-        } else {
-            final byte[] payload = lastHeartbeat.getPayload();
-            if (payload == null || payload.length == 0) {
-                this.lastHeartbeatPayload = null;
-            } else {
-                this.lastHeartbeatPayload = HeartbeatPayload.unmarshal(payload);
-            }
-        }
-    }
-
-    /**
-     * Returns the time of the last received connection request for this node.
-     *
-     * @return the time when the connection request for this node was received.
-     */
-    public long getConnectionRequestedTimestamp() {
-        return connectionRequestedTimestamp.get();
-    }
-
-    /**
-     * Sets the time when the connection request for this node was last
-     * received.
-     *
-     * This method is thread-safe and may be called without obtaining any lock.
-     *
-     * @param connectionRequestedTimestamp
-     */
-    public void setConnectionRequestedTimestamp(long connectionRequestedTimestamp) {
-        this.connectionRequestedTimestamp.set(connectionRequestedTimestamp);
-    }
-
-    /**
-     * Returns true if the node was disconnected due to lack of heartbeat; false
-     * otherwise.
-     *
-     * @return true if the node was disconnected due to lack of heartbeat; false
-     * otherwise.
-     */
-    public boolean isHeartbeatDisconnection() {
-        return heartbeatDisconnection;
-    }
-
-    /**
-     * Sets the status to disconnected and flags the node as being disconnected
-     * by lack of heartbeat.
-     */
-    public void setHeartbeatDisconnection() {
-        setStatus(Status.DISCONNECTED);
-        heartbeatDisconnection = true;
-    }
-
-    /**
-     * @return the status
-     */
-    public Status getStatus() {
-        return status;
-    }
-
-    /**
-     * @param status a status
-     */
-    public void setStatus(final Status status) {
-        if (status == null) {
-            throw new IllegalArgumentException("Status may not be null.");
-        }
-        this.status = status;
-        heartbeatDisconnection = false;
-    }
-
-    @Override
-    public Node clone() {
-        final Node clone = new Node(nodeId, status);
-        clone.lastHeartbeat = lastHeartbeat;
-        clone.lastHeartbeatPayload = lastHeartbeatPayload;
-        clone.heartbeatDisconnection = heartbeatDisconnection;
-        clone.connectionRequestedTimestamp = connectionRequestedTimestamp;
-        return clone;
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-        if (obj == null) {
-            return false;
-        }
-        if (getClass() != obj.getClass()) {
-            return false;
-        }
-        final Node other = (Node) obj;
-        if (this.nodeId != other.nodeId && (this.nodeId == null || !this.nodeId.equals(other.nodeId))) {
-            return false;
-        }
-        return true;
-    }
-
-    @Override
-    public int hashCode() {
-        int hash = 7;
-        hash = 53 * hash + (this.nodeId != null ? this.nodeId.hashCode() : 0);
-        return hash;
-    }
-
-    @Override
-    public String toString() {
-        return nodeId.toString();
-    }
-
-    @Override
-    public int compareTo(final Node o) {
-        if (o == null) {
-            return -1;
-        }
-        return getNodeId().getId().compareTo(o.getNodeId().getId());
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/spring/ClusterManagerProtocolServiceLocatorFactoryBean.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/spring/ClusterManagerProtocolServiceLocatorFactoryBean.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/spring/ClusterManagerProtocolServiceLocatorFactoryBean.java
deleted file mode 100644
index e26d196..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/spring/ClusterManagerProtocolServiceLocatorFactoryBean.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * 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.nifi.cluster.spring;
-
-import java.net.InetSocketAddress;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.nifi.cluster.protocol.impl.ClusterServiceDiscovery;
-import org.apache.nifi.cluster.protocol.impl.ClusterServiceLocator;
-import org.apache.nifi.io.socket.multicast.DiscoverableService;
-import org.apache.nifi.io.socket.multicast.DiscoverableServiceImpl;
-import org.apache.nifi.util.FormatUtils;
-import org.apache.nifi.util.NiFiProperties;
-
-import org.springframework.beans.BeansException;
-import org.springframework.beans.factory.DisposableBean;
-import org.springframework.beans.factory.FactoryBean;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.ApplicationContextAware;
-
-/**
- * Factory bean for creating a singleton ClusterManagerProtocolServiceLocator
- * instance. If the application is configured to act as the cluster manager,
- * then null is always returned as the created instance.
- *
- * The cluster manager protocol service represents the socket endpoint for
- * sending internal socket messages to the cluster manager.
- */
-public class ClusterManagerProtocolServiceLocatorFactoryBean implements FactoryBean, ApplicationContextAware, DisposableBean {
-
-    private ApplicationContext applicationContext;
-
-    private ClusterServiceLocator locator;
-
-    private NiFiProperties properties;
-
-    @Override
-    public Object getObject() throws Exception {
-        /*
-         * If configured for the cluster manager, then the service locator is never used.  
-         */
-        if (properties.isClusterManager()) {
-            return null;
-        } else if (locator == null) {
-
-            if (properties.getClusterProtocolUseMulticast()) {
-
-                // get the service discovery instance
-                final ClusterServiceDiscovery serviceDiscovery = applicationContext.getBean("clusterManagerProtocolServiceDiscovery", ClusterServiceDiscovery.class);
-
-                // create service location configuration
-                final ClusterServiceLocator.AttemptsConfig config = new ClusterServiceLocator.AttemptsConfig();
-                config.setNumAttempts(properties.getClusterProtocolMulticastServiceLocatorAttempts());
-
-                final int delay = (int) FormatUtils.getTimeDuration(properties.getClusterProtocolMulticastServiceLocatorAttemptsDelay(), TimeUnit.SECONDS);
-                config.setTimeBetweenAttempts(delay);
-                config.setTimeBetweenAttempsUnit(TimeUnit.SECONDS);
-
-                locator = new ClusterServiceLocator(serviceDiscovery);
-                locator.setAttemptsConfig(config);
-
-            } else {
-                final String serviceName = applicationContext.getBean("clusterManagerProtocolServiceName", String.class);
-                final InetSocketAddress serviceAddress = properties.getClusterNodeUnicastManagerProtocolAddress();
-                final DiscoverableService service = new DiscoverableServiceImpl(serviceName, serviceAddress);
-                locator = new ClusterServiceLocator(service);
-            }
-
-            // start the locator
-            locator.start();
-
-        }
-        return locator;
-
-    }
-
-    @Override
-    public Class getObjectType() {
-        return ClusterServiceLocator.class;
-    }
-
-    @Override
-    public boolean isSingleton() {
-        return true;
-    }
-
-    @Override
-    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
-        this.applicationContext = applicationContext;
-    }
-
-    @Override
-    public void destroy() throws Exception {
-        if (locator != null && locator.isRunning()) {
-            locator.stop();
-        }
-    }
-
-    public void setProperties(NiFiProperties properties) {
-        this.properties = properties;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/spring/FileBasedClusterNodeFirewallFactoryBean.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/spring/FileBasedClusterNodeFirewallFactoryBean.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/spring/FileBasedClusterNodeFirewallFactoryBean.java
deleted file mode 100644
index ef72298..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/spring/FileBasedClusterNodeFirewallFactoryBean.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * 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.nifi.cluster.spring;
-
-import java.io.File;
-import org.apache.nifi.cluster.firewall.impl.FileBasedClusterNodeFirewall;
-import org.apache.nifi.util.NiFiProperties;
-import org.springframework.beans.factory.FactoryBean;
-
-/**
- * Factory bean for creating a singleton FileBasedClusterNodeFirewall instance.
- */
-public class FileBasedClusterNodeFirewallFactoryBean implements FactoryBean {
-
-    private FileBasedClusterNodeFirewall firewall;
-
-    private NiFiProperties properties;
-
-    @Override
-    public Object getObject() throws Exception {
-        if (firewall == null) {
-            final File config = properties.getClusterManagerNodeFirewallFile();
-            final File restoreDirectory = properties.getRestoreDirectory();
-            if (config != null) {
-                firewall = new FileBasedClusterNodeFirewall(config, restoreDirectory);
-            }
-        }
-        return firewall;
-    }
-
-    @Override
-    public Class getObjectType() {
-        return FileBasedClusterNodeFirewall.class;
-    }
-
-    @Override
-    public boolean isSingleton() {
-        return true;
-    }
-
-    public void setProperties(NiFiProperties properties) {
-        this.properties = properties;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/spring/WebClusterManagerFactoryBean.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/spring/WebClusterManagerFactoryBean.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/spring/WebClusterManagerFactoryBean.java
deleted file mode 100644
index 7169730..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/spring/WebClusterManagerFactoryBean.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * 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.nifi.cluster.spring;
-
-import java.nio.file.Paths;
-import org.apache.nifi.admin.service.AuditService;
-import org.apache.nifi.cluster.event.EventManager;
-import org.apache.nifi.cluster.firewall.ClusterNodeFirewall;
-import org.apache.nifi.cluster.flow.DataFlowManagementService;
-import org.apache.nifi.cluster.manager.HttpRequestReplicator;
-import org.apache.nifi.cluster.manager.HttpResponseMapper;
-import org.apache.nifi.cluster.manager.impl.WebClusterManager;
-import org.apache.nifi.cluster.protocol.impl.ClusterManagerProtocolSenderListener;
-import org.apache.nifi.cluster.protocol.impl.ClusterServicesBroadcaster;
-import org.apache.nifi.controller.service.ControllerServiceLoader;
-import org.apache.nifi.encrypt.StringEncryptor;
-import org.apache.nifi.io.socket.multicast.DiscoverableService;
-import org.apache.nifi.io.socket.multicast.DiscoverableServiceImpl;
-import org.apache.nifi.util.NiFiProperties;
-import org.springframework.beans.BeansException;
-import org.springframework.beans.factory.FactoryBean;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.ApplicationContextAware;
-
-/**
- * Factory bean for creating a singleton WebClusterManager instance. If the
- * application is not configured to act as the cluster manager, then null is
- * always returned as the created instance.
- */
-public class WebClusterManagerFactoryBean implements FactoryBean, ApplicationContextAware {
-
-    private ApplicationContext applicationContext;
-
-    private WebClusterManager clusterManager;
-
-    private NiFiProperties properties;
-
-    private StringEncryptor encryptor;
-
-    @Override
-    public Object getObject() throws Exception {
-        if (properties.isClusterManager() && properties.isNode()) {
-            throw new IllegalStateException("Application may be configured as a cluster manager or a node, but not both.");
-        } else if (!properties.isClusterManager()) {
-            /*
-             * If not configured for the cluster manager, then the cluster manager is never used.  
-             * null is returned so that we don't instantiate a thread pool or other resources. 
-             */
-            return null;
-        } else if (clusterManager == null) {
-
-            // get the service configuration path (fail early)
-            final String serviceConfigurationFile = properties.getProperty(NiFiProperties.SERVICE_CONFIGURATION_FILE);
-            if (serviceConfigurationFile == null) {
-                throw new NullPointerException("The service configuration file has not been specified.");
-            }
-
-            final HttpRequestReplicator requestReplicator = applicationContext.getBean("httpRequestReplicator", HttpRequestReplicator.class);
-            final HttpResponseMapper responseMapper = applicationContext.getBean("httpResponseMapper", HttpResponseMapper.class);
-            final DataFlowManagementService dataFlowService = applicationContext.getBean("dataFlowManagementService", DataFlowManagementService.class);
-            final ClusterManagerProtocolSenderListener senderListener = applicationContext.getBean("clusterManagerProtocolSenderListener", ClusterManagerProtocolSenderListener.class);
-
-            // create the manager
-            clusterManager = new WebClusterManager(
-                    requestReplicator,
-                    responseMapper,
-                    dataFlowService,
-                    senderListener,
-                    properties,
-                    encryptor
-            );
-
-            // set the service broadcaster
-            if (properties.getClusterProtocolUseMulticast()) {
-
-                // create broadcaster
-                final ClusterServicesBroadcaster broadcaster = applicationContext.getBean("clusterServicesBroadcaster", ClusterServicesBroadcaster.class);
-
-                // register the cluster manager protocol service
-                final String clusterManagerProtocolServiceName = applicationContext.getBean("clusterManagerProtocolServiceName", String.class);
-                final DiscoverableService clusterManagerProtocolService = new DiscoverableServiceImpl(clusterManagerProtocolServiceName, properties.getClusterManagerProtocolAddress());
-                broadcaster.addService(clusterManagerProtocolService);
-
-                clusterManager.setServicesBroadcaster(broadcaster);
-            }
-
-            // set the event manager
-            clusterManager.setEventManager(applicationContext.getBean("nodeEventHistoryManager", EventManager.class));
-
-            // set the cluster firewall
-            clusterManager.setClusterFirewall(applicationContext.getBean("clusterFirewall", ClusterNodeFirewall.class));
-
-            // set the audit service
-            clusterManager.setAuditService(applicationContext.getBean("auditService", AuditService.class));
-
-            // load the controller services
-            final ControllerServiceLoader serviceLoader = new ControllerServiceLoader(Paths.get(serviceConfigurationFile));
-            serviceLoader.loadControllerServices(clusterManager);
-        }
-        return clusterManager;
-    }
-
-    @Override
-    public Class getObjectType() {
-        return WebClusterManager.class;
-    }
-
-    @Override
-    public boolean isSingleton() {
-        return true;
-    }
-
-    @Override
-    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
-        this.applicationContext = applicationContext;
-    }
-
-    public void setProperties(NiFiProperties properties) {
-        this.properties = properties;
-    }
-
-    public void setEncryptor(final StringEncryptor encryptor) {
-        this.encryptor = encryptor;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/controller/reporting/ClusteredReportingTaskNode.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/controller/reporting/ClusteredReportingTaskNode.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/controller/reporting/ClusteredReportingTaskNode.java
deleted file mode 100644
index 1ed5b30..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/controller/reporting/ClusteredReportingTaskNode.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * 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.nifi.controller.reporting;
-
-import org.apache.nifi.cluster.manager.impl.ClusteredReportingContext;
-import org.apache.nifi.controller.ProcessScheduler;
-import org.apache.nifi.controller.ValidationContextFactory;
-import org.apache.nifi.controller.service.ControllerServiceProvider;
-import org.apache.nifi.reporting.BulletinRepository;
-import org.apache.nifi.reporting.EventAccess;
-import org.apache.nifi.reporting.ReportingContext;
-import org.apache.nifi.reporting.ReportingTask;
-
-public class ClusteredReportingTaskNode extends AbstractReportingTaskNode {
-
-    private final EventAccess eventAccess;
-    private final BulletinRepository bulletinRepository;
-    private final ControllerServiceProvider serviceProvider;
-
-    public ClusteredReportingTaskNode(final ReportingTask reportingTask, final String id, final ProcessScheduler scheduler,
-            final EventAccess eventAccess, final BulletinRepository bulletinRepository, final ControllerServiceProvider serviceProvider,
-            final ValidationContextFactory validationContextFactory) {
-        super(reportingTask, id, serviceProvider, scheduler, validationContextFactory);
-
-        this.eventAccess = eventAccess;
-        this.bulletinRepository = bulletinRepository;
-        this.serviceProvider = serviceProvider;
-    }
-
-    @Override
-    public ReportingContext getReportingContext() {
-        return new ClusteredReportingContext(eventAccess, bulletinRepository, getProperties(), serviceProvider);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/resources/nifi-cluster-manager-context.xml
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/resources/nifi-cluster-manager-context.xml b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/resources/nifi-cluster-manager-context.xml
deleted file mode 100644
index 68c29bc..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/resources/nifi-cluster-manager-context.xml
+++ /dev/null
@@ -1,124 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-  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.
--->
-<!-- marked as lazy so that clustering beans are not created when applications runs in non-clustered mode -->
-<beans default-lazy-init="true"
-       xmlns="http://www.springframework.org/schema/beans"
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-       xmlns:util="http://www.springframework.org/schema/util"
-       xmlns:context="http://www.springframework.org/schema/context"
-       xmlns:aop="http://www.springframework.org/schema/aop"
-       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
-    http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.1.xsd
-    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
-    http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd">
-
-    <!-- jersey client -->
-    <bean id="jersey-client" class="org.apache.nifi.web.util.WebUtils" factory-method="createClient">
-        <constructor-arg>
-            <bean class="com.sun.jersey.api.client.config.DefaultClientConfig"/>
-        </constructor-arg>
-        <constructor-arg>
-            <bean class="org.apache.nifi.framework.security.util.SslContextFactory" factory-method="createSslContext">
-                <constructor-arg ref="nifiProperties"/>
-            </bean>
-        </constructor-arg>
-    </bean>
-
-    <!-- http request replicator -->
-    <bean id="httpRequestReplicator" class="org.apache.nifi.cluster.manager.impl.HttpRequestReplicatorImpl">
-        <constructor-arg index="0">
-            <bean factory-bean="nifiProperties" factory-method="getClusterManagerNodeApiRequestThreads"/>
-        </constructor-arg>
-        <constructor-arg ref="jersey-client" index="1"/>
-        <constructor-arg index="2">
-            <bean factory-bean="nifiProperties" factory-method="getClusterManagerNodeApiConnectionTimeout"/>
-        </constructor-arg>
-        <constructor-arg index="3">
-            <bean factory-bean="nifiProperties" factory-method="getClusterManagerNodeApiReadTimeout"/>
-        </constructor-arg>
-        <property name="nodeProtocolScheme">
-            <bean factory-bean="nifiProperties" factory-method="getClusterProtocolManagerToNodeApiScheme"/>
-        </property>
-    </bean>
-    
-    <!-- http response mapper -->
-    <bean id="httpResponseMapper" class="org.apache.nifi.cluster.manager.impl.HttpResponseMapperImpl"/>
-
-    <!-- cluster flow DAO -->
-    <bean id="dataFlowDao" class="org.apache.nifi.cluster.flow.impl.DataFlowDaoImpl">
-        <constructor-arg index="0">
-            <bean factory-bean="nifiProperties" factory-method="getFlowConfigurationFileDir"/>
-        </constructor-arg>
-        <constructor-arg index="1">
-            <bean factory-bean="nifiProperties" factory-method="getRestoreDirectory"/>
-        </constructor-arg>
-        <constructor-arg index="2">
-            <bean factory-bean="nifiProperties" factory-method="getAutoResumeState"/>
-        </constructor-arg>
-    </bean>
-    
-    <!-- dataflow management service -->
-    <bean id="dataFlowManagementService" class="org.apache.nifi.cluster.flow.impl.DataFlowManagementServiceImpl">
-        <constructor-arg ref="dataFlowDao"/>
-        <constructor-arg ref="clusterManagerProtocolSender"/>
-        <property name="retrievalDelay">
-            <bean factory-bean="nifiProperties" factory-method="getClusterManagerFlowRetrievalDelay"/>
-        </property>
-    </bean>
-
-    <!-- node event history manager -->
-    <bean id="nodeEventHistoryManager" class="org.apache.nifi.cluster.event.impl.EventManagerImpl">
-        <constructor-arg>
-            <bean factory-bean="nifiProperties" factory-method="getClusterManagerNodeEventHistorySize"/>
-        </constructor-arg>
-    </bean>
-
-    <!-- cluster firewall -->
-    <bean id="clusterFirewall" class="org.apache.nifi.cluster.spring.FileBasedClusterNodeFirewallFactoryBean">
-        <property name="properties" ref="nifiProperties"/>
-    </bean>
-
-    <!-- cluster manager -->
-    <bean id="clusterManager" class="org.apache.nifi.cluster.spring.WebClusterManagerFactoryBean">
-        <property name="properties" ref="nifiProperties"/>
-        <property name="encryptor" ref="stringEncryptor"/>
-    </bean>
-    
-    <!-- discoverable services -->
-    
-    <!-- cluster manager protocol discoverable service -->
-    
-    <!-- service name for communicating with the cluster manager using sockets -->
-    <bean id="clusterManagerProtocolServiceName" class="java.lang.String">
-        <constructor-arg value="cluster-manager-protocol" />
-    </bean>
-    
-    <!-- cluster manager protocol service discovery -->
-    <bean id="clusterManagerProtocolServiceDiscovery" class="org.apache.nifi.cluster.protocol.impl.ClusterServiceDiscovery">
-        <constructor-arg ref="clusterManagerProtocolServiceName" index="0"/>
-        <constructor-arg index="1">
-            <bean factory-bean="nifiProperties" factory-method="getClusterProtocolMulticastAddress"/>
-        </constructor-arg>
-        <constructor-arg ref="protocolMulticastConfiguration" index="2"/>
-        <constructor-arg ref="protocolContext" index="3"/>
-    </bean>
-    
-    <!-- cluster manager protocol service locator -->
-    <bean id="clusterManagerProtocolServiceLocator" class="org.apache.nifi.cluster.spring.ClusterManagerProtocolServiceLocatorFactoryBean">
-        <property name="properties" ref="nifiProperties"/>
-    </bean>
-        
-</beans>

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/test/java/org/apache/nifi/cluster/event/impl/EventManagerImplTest.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/test/java/org/apache/nifi/cluster/event/impl/EventManagerImplTest.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/test/java/org/apache/nifi/cluster/event/impl/EventManagerImplTest.java
deleted file mode 100644
index 09ea44b..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/test/java/org/apache/nifi/cluster/event/impl/EventManagerImplTest.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * 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.nifi.cluster.event.impl;
-
-import org.apache.nifi.cluster.event.impl.EventManagerImpl;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import org.apache.nifi.cluster.event.Event;
-import org.apache.nifi.cluster.event.Event.Category;
-import org.apache.nifi.cluster.event.EventManager;
-import org.junit.Test;
-import static org.junit.Assert.*;
-
-/**
- * @author unattributed
- */
-public class EventManagerImplTest {
-
-    @Test(expected = IllegalArgumentException.class)
-    public void testNonPositiveHistorySize() {
-        new EventManagerImpl(0);
-    }
-
-    @Test
-    public void testGetEventsUnknownSource() {
-        EventManager manager = new EventManagerImpl(1);
-        assertEquals(Collections.EMPTY_LIST, manager.getEvents("unknown value"));
-    }
-
-    @Test
-    public void testGetEvents() {
-
-        EventManager manager = new EventManagerImpl(2);
-
-        Event e1 = new Event("1", "Event1", Category.INFO, 0);
-        Event e2 = new Event("1", "Event2", Category.INFO, 1);
-
-        manager.addEvent(e1);
-        manager.addEvent(e2);
-
-        List<Event> events = manager.getEvents("1");
-
-        // assert newest to oldest
-        assertEquals(Arrays.asList(e2, e1), events);
-    }
-
-    @Test
-    public void testGetMostRecentEventUnknownSource() {
-        EventManager manager = new EventManagerImpl(1);
-        assertNull(manager.getMostRecentEvent("unknown value"));
-    }
-
-    @Test
-    public void testGetMostRecentEvent() {
-
-        EventManager manager = new EventManagerImpl(2);
-
-        Event e1 = new Event("1", "Event1", Category.INFO, 0);
-        Event e2 = new Event("1", "Event2", Category.INFO, 1);
-
-        manager.addEvent(e1);
-        manager.addEvent(e2);
-
-        // assert newest to oldest
-        assertEquals(e2, manager.getMostRecentEvent("1"));
-    }
-
-    @Test
-    public void testAddEventExceedsHistorySize() {
-
-        EventManager manager = new EventManagerImpl(1);
-
-        Event e1 = new Event("1", "Event1", Category.INFO, 0);
-        Event e2 = new Event("1", "Event2", Category.INFO, 1);
-
-        manager.addEvent(e1);
-        manager.addEvent(e2);
-
-        List<Event> events = manager.getEvents("1");
-
-        // assert oldest evicted
-        assertEquals(Arrays.asList(e2), events);
-
-    }
-
-    @Test
-    public void testClearHistory() {
-
-        EventManager manager = new EventManagerImpl(1);
-
-        Event e1 = new Event("1", "Event1", Category.INFO, 0);
-        Event e2 = new Event("1", "Event2", Category.INFO, 1);
-
-        manager.addEvent(e1);
-        manager.addEvent(e2);
-
-        manager.clearEventHistory("1");
-
-        // assert oldest evicted
-        assertTrue(manager.getEvents("1").isEmpty());
-
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/test/java/org/apache/nifi/cluster/firewall/impl/FileBasedClusterNodeFirewallTest.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/test/java/org/apache/nifi/cluster/firewall/impl/FileBasedClusterNodeFirewallTest.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/test/java/org/apache/nifi/cluster/firewall/impl/FileBasedClusterNodeFirewallTest.java
deleted file mode 100644
index e5db7ca..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/test/java/org/apache/nifi/cluster/firewall/impl/FileBasedClusterNodeFirewallTest.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * 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.nifi.cluster.firewall.impl;
-
-import java.io.File;
-import java.io.IOException;
-import org.apache.nifi.util.file.FileUtils;
-import org.junit.After;
-import org.junit.Before;
-import static org.junit.Assert.*;
-import org.junit.Test;
-
-public class FileBasedClusterNodeFirewallTest {
-
-    private FileBasedClusterNodeFirewall ipsFirewall;
-
-    private FileBasedClusterNodeFirewall acceptAllFirewall;
-
-    private File ipsConfig;
-
-    private File emptyConfig;
-
-    private File restoreDirectory;
-
-    @Before
-    public void setup() throws Exception {
-
-        ipsConfig = new File("src/test/resources/org/apache/nifi/cluster/firewall/impl/ips.txt");
-        emptyConfig = new File("src/test/resources/org/apache/nifi/cluster/firewall/impl/empty.txt");
-
-        restoreDirectory = new File(System.getProperty("java.io.tmpdir") + "/firewall_restore");
-
-        ipsFirewall = new FileBasedClusterNodeFirewall(ipsConfig, restoreDirectory);
-        acceptAllFirewall = new FileBasedClusterNodeFirewall(emptyConfig);
-    }
-
-    @After
-    public void teardown() throws IOException {
-        deleteFile(restoreDirectory);
-    }
-
-    @Test
-    public void testSyncWithRestore() {
-        assertEquals(ipsConfig.length(), new File(restoreDirectory, ipsConfig.getName()).length());
-    }
-
-    @Test
-    public void testIsPermissibleWithExactMatch() {
-        assertTrue(ipsFirewall.isPermissible("2.2.2.2"));
-    }
-
-    @Test
-    public void testIsPermissibleWithSubnetMatch() {
-        assertTrue(ipsFirewall.isPermissible("3.3.3.255"));
-    }
-
-    @Test
-    public void testIsPermissibleWithNoMatch() {
-        assertFalse(ipsFirewall.isPermissible("255.255.255.255"));
-    }
-
-    @Test
-    public void testIsPermissibleWithMalformedData() {
-        assertFalse(ipsFirewall.isPermissible("abc"));
-    }
-
-    @Test
-    public void testIsPermissibleWithEmptyConfig() {
-        assertTrue(acceptAllFirewall.isPermissible("1.1.1.1"));
-    }
-
-    @Test
-    public void testIsPermissibleWithEmptyConfigWithMalformedData() {
-        assertTrue(acceptAllFirewall.isPermissible("abc"));
-    }
-
-    private boolean deleteFile(final File file) {
-        if (file.isDirectory()) {
-            FileUtils.deleteFilesInDir(file, null, null, true, true);
-        }
-        return FileUtils.deleteFile(file, null, 10);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/test/java/org/apache/nifi/cluster/flow/impl/DataFlowManagementServiceImplTest.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/test/java/org/apache/nifi/cluster/flow/impl/DataFlowManagementServiceImplTest.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/test/java/org/apache/nifi/cluster/flow/impl/DataFlowManagementServiceImplTest.java
deleted file mode 100644
index f9ba016..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/test/java/org/apache/nifi/cluster/flow/impl/DataFlowManagementServiceImplTest.java
+++ /dev/null
@@ -1,343 +0,0 @@
-/*
- * 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.nifi.cluster.flow.impl;
-
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Set;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-
-import org.apache.nifi.cluster.flow.DataFlowDao;
-import org.apache.nifi.cluster.flow.PersistedFlowState;
-import org.apache.nifi.cluster.protocol.ClusterManagerProtocolSender;
-import org.apache.nifi.cluster.protocol.NodeIdentifier;
-import org.apache.nifi.cluster.protocol.ProtocolContext;
-import org.apache.nifi.cluster.protocol.ProtocolException;
-import org.apache.nifi.cluster.protocol.ProtocolHandler;
-import org.apache.nifi.cluster.protocol.StandardDataFlow;
-import org.apache.nifi.cluster.protocol.impl.ClusterManagerProtocolSenderImpl;
-import org.apache.nifi.cluster.protocol.impl.SocketProtocolListener;
-import org.apache.nifi.cluster.protocol.jaxb.JaxbProtocolContext;
-import org.apache.nifi.cluster.protocol.jaxb.message.JaxbProtocolUtils;
-import org.apache.nifi.cluster.protocol.message.FlowResponseMessage;
-import org.apache.nifi.cluster.protocol.message.ProtocolMessage;
-import org.apache.nifi.io.socket.ServerSocketConfiguration;
-import org.apache.nifi.io.socket.SocketConfiguration;
-
-import org.apache.commons.io.FileUtils;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.xml.sax.SAXException;
-
-/**
- * @author unattributed
- */
-public class DataFlowManagementServiceImplTest {
-
-    private DataFlowManagementServiceImpl service;
-    private File restoreLocation;
-    private File primaryLocation;
-    private DataFlowDao dao;
-    private int apiDummyPort;
-    private int socketPort;
-    private SocketConfiguration socketConfig;
-    private ClusterManagerProtocolSender sender;
-    private ServerSocketConfiguration serverSocketConfig;
-    private SocketProtocolListener listener;
-
-    @Before
-    public void setup() throws IOException {
-
-        primaryLocation = new File(System.getProperty("java.io.tmpdir") + "/primary" + this.getClass().getSimpleName());
-        restoreLocation = new File(System.getProperty("java.io.tmpdir") + "/restore" + this.getClass().getSimpleName());
-
-        FileUtils.deleteDirectory(primaryLocation);
-        FileUtils.deleteDirectory(restoreLocation);
-
-        ProtocolContext protocolContext = new JaxbProtocolContext(JaxbProtocolUtils.JAXB_CONTEXT);
-
-        socketConfig = new SocketConfiguration();
-        socketConfig.setSocketTimeout(1000);
-        serverSocketConfig = new ServerSocketConfiguration();
-
-        dao = new DataFlowDaoImpl(primaryLocation, restoreLocation, false);
-
-        sender = new ClusterManagerProtocolSenderImpl(socketConfig, protocolContext);
-
-        service = new DataFlowManagementServiceImpl(dao, sender);
-        service.start();
-
-        listener = new SocketProtocolListener(1, 0, serverSocketConfig, protocolContext);
-        listener.start();
-
-        apiDummyPort = 7777;
-        socketPort = listener.getPort();
-    }
-
-    @After
-    public void teardown() throws IOException {
-
-        if (service != null && service.isRunning()) {
-            service.stop();
-        }
-
-        if (listener != null && listener.isRunning()) {
-            try {
-                listener.stop();
-            } catch (final Exception ex) {
-                ex.printStackTrace(System.out);
-            }
-        }
-        FileUtils.deleteDirectory(primaryLocation);
-        FileUtils.deleteDirectory(restoreLocation);
-
-    }
-
-    @Test
-    public void testLoadFlowWithNonExistentFlow() throws ParserConfigurationException, SAXException, IOException {
-        verifyFlow();
-    }
-
-    @Test
-    public void testLoadFlowWithNonExistentFlowWhenServiceStopped() throws IOException, SAXException, ParserConfigurationException {
-        service.stop();
-        verifyFlow();
-    }
-
-    private void verifyFlow() throws ParserConfigurationException, SAXException, IOException {
-        final byte[] flowBytes = service.loadDataFlow().getDataFlow().getFlow();
-        final DocumentBuilder docBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
-        final Document doc = docBuilder.parse(new ByteArrayInputStream(flowBytes));
-        final Element controller = (Element) doc.getElementsByTagName("flowController").item(0);
-        final Element rootGroup = (Element) controller.getElementsByTagName("rootGroup").item(0);
-        final String rootGroupName = rootGroup.getElementsByTagName("name").item(0).getTextContent();
-        assertEquals("NiFi Flow", rootGroupName);
-    }
-
-    @Test
-    public void testLoadFlowSingleNode() throws Exception {
-        String flowStr = "<rootGroup />";
-        byte[] flowBytes = flowStr.getBytes();
-        listener.addHandler(new FlowRequestProtocolHandler(new StandardDataFlow(flowStr.getBytes("UTF-8"), new byte[0], new byte[0])));
-
-        NodeIdentifier nodeId = new NodeIdentifier("1", "localhost", apiDummyPort, "localhost", socketPort);
-        service.setNodeIds(new HashSet<>(Arrays.asList(nodeId)));
-        service.setPersistedFlowState(PersistedFlowState.STALE);
-
-        assertEquals(PersistedFlowState.STALE, service.getPersistedFlowState());
-
-        // sleep long enough for the flow retriever to run
-        waitForState(PersistedFlowState.CURRENT);
-
-        assertEquals(PersistedFlowState.CURRENT, service.getPersistedFlowState());
-        assertArrayEquals(flowBytes, service.loadDataFlow().getDataFlow().getFlow());
-
-    }
-
-    @Test
-    public void testLoadFlowWithSameNodeIds() throws Exception {
-
-        String flowStr = "<rootGroup />";
-        listener.addHandler(new FlowRequestProtocolHandler(new StandardDataFlow(flowStr.getBytes("UTF-8"), new byte[0], new byte[0])));
-
-        NodeIdentifier nodeId1 = new NodeIdentifier("1", "localhost", apiDummyPort, "localhost", socketPort);
-        NodeIdentifier nodeId2 = new NodeIdentifier("2", "localhost", apiDummyPort, "localhost", socketPort);
-        service.setNodeIds(new HashSet<>(Arrays.asList(nodeId1, nodeId2)));
-        service.setPersistedFlowState(PersistedFlowState.STALE);
-
-        assertEquals(PersistedFlowState.STALE, service.getPersistedFlowState());
-
-        // sleep long enough for the flow retriever to run
-        waitForState(PersistedFlowState.CURRENT);
-
-        // verify that flow is current
-        assertEquals(PersistedFlowState.CURRENT, service.getPersistedFlowState());
-
-        // add same ids in different order
-        service.setNodeIds(new HashSet<>(Arrays.asList(nodeId2, nodeId1)));
-
-        // verify flow is still current
-        assertEquals(PersistedFlowState.CURRENT, service.getPersistedFlowState());
-
-    }
-
-    @Test
-    public void testLoadFlowWithABadNode() throws Exception {
-
-        String flowStr = "<rootGroup />";
-        byte[] flowBytes = flowStr.getBytes();
-        listener.addHandler(new FlowRequestProtocolHandler(new StandardDataFlow(flowStr.getBytes("UTF-8"), new byte[0], new byte[0])));
-
-        NodeIdentifier nodeId1 = new NodeIdentifier("1", "localhost", apiDummyPort, "localhost", socketPort + 1);
-        NodeIdentifier nodeId2 = new NodeIdentifier("2", "localhost", apiDummyPort, "localhost", socketPort);
-        service.setNodeIds(new HashSet<>(Arrays.asList(nodeId1, nodeId2)));
-        service.setPersistedFlowState(PersistedFlowState.STALE);
-
-        assertEquals(PersistedFlowState.STALE, service.getPersistedFlowState());
-
-        // sleep long enough for the flow retriever to run
-        waitForState(PersistedFlowState.CURRENT);
-
-        assertEquals(PersistedFlowState.CURRENT, service.getPersistedFlowState());
-        assertArrayEquals(flowBytes, service.loadDataFlow().getDataFlow().getFlow());
-
-    }
-
-    @Test
-    public void testLoadFlowWithConstantNodeIdChanging() throws Exception {
-        String flowStr = "<rootGroup />";
-        byte[] flowBytes = flowStr.getBytes();
-        listener.addHandler(new FlowRequestProtocolHandler(new StandardDataFlow(flowStr.getBytes("UTF-8"), new byte[0], new byte[0])));
-
-        NodeIdentifier nodeId1 = new NodeIdentifier("1", "localhost", apiDummyPort, "localhost", socketPort + 1);
-        NodeIdentifier nodeId2 = new NodeIdentifier("2", "localhost", apiDummyPort, "localhost", socketPort);
-
-        for (int i = 0; i < 1000; i++) {
-            service.setNodeIds(new HashSet<>(Arrays.asList(nodeId1, nodeId2)));
-            service.setPersistedFlowState(PersistedFlowState.STALE);
-            assertEquals(PersistedFlowState.STALE, service.getPersistedFlowState());
-        }
-
-        // sleep long enough for the flow retriever to run
-        waitForState(PersistedFlowState.CURRENT);
-
-        assertEquals(PersistedFlowState.CURRENT, service.getPersistedFlowState());
-        assertArrayEquals(flowBytes, service.loadDataFlow().getDataFlow().getFlow());
-    }
-
-    @Test
-    public void testLoadFlowWithConstantNodeIdChangingWithRetrievalDelay() throws Exception {
-
-        String flowStr = "<rootGroup />";
-        listener.addHandler(new FlowRequestProtocolHandler(new StandardDataFlow(flowStr.getBytes("UTF-8"), new byte[0], new byte[0])));
-
-        NodeIdentifier nodeId1 = new NodeIdentifier("1", "localhost", apiDummyPort, "localhost", socketPort + 1);
-        NodeIdentifier nodeId2 = new NodeIdentifier("2", "localhost", apiDummyPort, "localhost", socketPort);
-
-        service.setRetrievalDelay("5 sec");
-        for (int i = 0; i < 1000; i++) {
-            service.setNodeIds(new HashSet<>(Arrays.asList(nodeId1, nodeId2)));
-            service.setPersistedFlowState(PersistedFlowState.STALE);
-            assertEquals(PersistedFlowState.STALE, service.getPersistedFlowState());
-        }
-
-        // sleep long enough for the flow retriever to run
-        waitForState(PersistedFlowState.STALE);
-
-        assertEquals(PersistedFlowState.STALE, service.getPersistedFlowState());
-
-    }
-
-    @Test
-    public void testStopRequestedWhileRetrieving() throws Exception {
-
-        String flowStr = "<rootGroup />";
-        listener.addHandler(new FlowRequestProtocolHandler(new StandardDataFlow(flowStr.getBytes("UTF-8"), new byte[0], new byte[0])));
-        Set<NodeIdentifier> nodeIds = new HashSet<>();
-        for (int i = 0; i < 1000; i++) {
-            nodeIds.add(new NodeIdentifier("1", "localhost", apiDummyPort, "localhost", socketPort + 1));
-        }
-        nodeIds.add(new NodeIdentifier("1", "localhost", apiDummyPort, "localhost", socketPort));
-
-        long lastRetrievalTime = service.getLastRetrievalTime();
-
-        service.setNodeIds(nodeIds);
-        service.setPersistedFlowState(PersistedFlowState.STALE);
-        assertEquals(PersistedFlowState.STALE, service.getPersistedFlowState());
-
-        // sleep long enough for the flow retriever to run
-        waitForState(PersistedFlowState.STALE);
-
-        service.stop();
-
-        service.setPersistedFlowState(PersistedFlowState.STALE);
-        assertEquals(PersistedFlowState.STALE, service.getPersistedFlowState());
-
-        assertEquals(lastRetrievalTime, service.getLastRetrievalTime());
-
-    }
-
-    @Test
-    public void testLoadFlowUnknownState() throws Exception {
-
-        String flowStr = "<rootGroup />";
-        byte[] flowBytes = flowStr.getBytes();
-        listener.addHandler(new FlowRequestProtocolHandler(new StandardDataFlow(flowStr.getBytes("UTF-8"), new byte[0], new byte[0])));
-        NodeIdentifier nodeId = new NodeIdentifier("1", "localhost", apiDummyPort, "localhost", socketPort);
-
-        service.setNodeIds(new HashSet<>(Arrays.asList(nodeId)));
-        service.setPersistedFlowState(PersistedFlowState.STALE);
-        assertEquals(PersistedFlowState.STALE, service.getPersistedFlowState());
-
-        service.setPersistedFlowState(PersistedFlowState.UNKNOWN);
-
-        assertEquals(PersistedFlowState.UNKNOWN, service.getPersistedFlowState());
-
-        service.setPersistedFlowState(PersistedFlowState.STALE);
-        assertEquals(PersistedFlowState.STALE, service.getPersistedFlowState());
-
-        // sleep long enough for the flow retriever to run
-        waitForState(PersistedFlowState.CURRENT);
-
-        assertArrayEquals(flowBytes, service.loadDataFlow().getDataFlow().getFlow());
-
-    }
-
-    private class FlowRequestProtocolHandler implements ProtocolHandler {
-
-        private StandardDataFlow dataFlow;
-
-        public FlowRequestProtocolHandler(final StandardDataFlow dataFlow) {
-            this.dataFlow = dataFlow;
-        }
-
-        @Override
-        public boolean canHandle(ProtocolMessage msg) {
-            return true;
-        }
-
-        @Override
-        public ProtocolMessage handle(ProtocolMessage msg) throws ProtocolException {
-            FlowResponseMessage response = new FlowResponseMessage();
-            response.setDataFlow(dataFlow);
-            return response;
-        }
-
-    }
-
-    private void waitForState(PersistedFlowState state) throws InterruptedException {
-        for (int i = 0; i < 30; i++) {
-            if (service.getPersistedFlowState() == state) {
-                break;
-            } else {
-                Thread.sleep(1000);
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/test/java/org/apache/nifi/cluster/manager/impl/HttpRequestReplicatorImplTest.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/test/java/org/apache/nifi/cluster/manager/impl/HttpRequestReplicatorImplTest.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/test/java/org/apache/nifi/cluster/manager/impl/HttpRequestReplicatorImplTest.java
deleted file mode 100644
index 0c65aba..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/test/java/org/apache/nifi/cluster/manager/impl/HttpRequestReplicatorImplTest.java
+++ /dev/null
@@ -1,368 +0,0 @@
-/*
- * 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.nifi.cluster.manager.impl;
-
-import org.apache.nifi.cluster.manager.impl.HttpRequestReplicatorImpl;
-import javax.ws.rs.core.Response;
-import javax.xml.bind.annotation.XmlRootElement;
-import javax.ws.rs.HttpMethod;
-import javax.ws.rs.core.MultivaluedMap;
-import java.net.URISyntaxException;
-import java.util.Arrays;
-import java.util.Iterator;
-import javax.ws.rs.core.StreamingOutput;
-import org.apache.nifi.cluster.manager.testutils.HttpResponse;
-import org.apache.nifi.cluster.manager.testutils.HttpServer;
-import com.sun.jersey.api.client.Client;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.net.URI;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import javax.ws.rs.core.Response.Status;
-import org.apache.nifi.cluster.manager.NodeResponse;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.apache.nifi.cluster.manager.testutils.HttpResponseAction;
-import org.apache.nifi.cluster.protocol.NodeIdentifier;
-import static org.junit.Assert.*;
-
-/**
- * @author unattributed
- */
-public class HttpRequestReplicatorImplTest {
-
-    private Client client;
-    private HttpRequestReplicatorImpl replicator;
-    private int executorThreadCount;
-    private int serverThreadCount;
-    private int serverPort;
-    private HttpServer server;
-    private Map<String, List<String>> expectedRequestParameters;
-    private Map<String, String> expectedRequestHeaders;
-    private Map<String, String> expectedResponseHeaders;
-    private Object expectedEntity;
-    private String expectedBody;
-    private URI prototypeUri;
-
-    @Before
-    public void setUp() throws IOException, URISyntaxException {
-
-        executorThreadCount = 5;
-        serverThreadCount = 3;
-
-        client = Client.create();
-
-        replicator = new HttpRequestReplicatorImpl(executorThreadCount, client, "1 sec", "1 sec");
-        replicator.start();
-
-        expectedRequestHeaders = new HashMap<>();
-        expectedRequestHeaders.put("header1", "header value1");
-        expectedRequestHeaders.put("header2", "header value2");
-
-        expectedRequestParameters = new HashMap<>();
-        expectedRequestParameters.put("param1", Arrays.asList("p value1"));
-        expectedRequestParameters.put("param2", Arrays.asList("p value2"));
-
-        expectedResponseHeaders = new HashMap<>();
-        expectedResponseHeaders.put("header1", "header value1");
-        expectedResponseHeaders.put("header2", "header value2");
-
-        expectedEntity = new Entity();
-
-        expectedBody = "some text";
-
-        prototypeUri = new URI("http://prototype.host/path/to/resource");
-
-        server = new HttpServer(serverThreadCount, 0);
-        server.start();
-        serverPort = server.getPort();
-    }
-
-    @After
-    public void teardown() {
-        if (server.isRunning()) {
-            server.stop();
-        }
-        if (replicator.isRunning()) {
-            replicator.stop();
-        }
-    }
-
-    @Test
-    public void testReplicateGetLessNodesThanReplicatorThreads() throws Throwable {
-        testReplicateXXX(executorThreadCount - 1, HttpMethod.GET);
-    }
-
-    @Test
-    public void testReplicateGetMoreNodesThanReplicatorThreads() throws Throwable {
-        testReplicateXXX(executorThreadCount + 1, HttpMethod.GET);
-    }
-
-    @Test
-    public void testReplicateGetWithUnresponsiveNode() throws Throwable {
-
-        // nodes
-        Set<NodeIdentifier> nodeIds = createNodes(2, "localhost", serverPort);
-
-        // response
-        HttpResponse expectedResponse = new HttpResponse(Status.OK, expectedBody);
-
-        // first response normal, second response slow
-        server.addResponseAction(new HttpResponseAction(expectedResponse));
-        server.addResponseAction(new HttpResponseAction(expectedResponse, 3500));
-
-        Set<NodeResponse> responses = replicator.replicate(
-                nodeIds,
-                HttpMethod.GET,
-                prototypeUri,
-                expectedRequestParameters,
-                expectedRequestHeaders);
-
-        assertEquals(nodeIds.size(), responses.size());
-
-        Iterator<NodeResponse> nodeResponseItr = responses.iterator();
-
-        NodeResponse firstResponse = nodeResponseItr.next();
-        NodeResponse secondResponse = nodeResponseItr.next();
-        NodeResponse goodResponse;
-        NodeResponse badResponse;
-        if (firstResponse.hasThrowable()) {
-            goodResponse = secondResponse;
-            badResponse = firstResponse;
-        } else {
-            goodResponse = firstResponse;
-            badResponse = secondResponse;
-        }
-
-        // good response
-        // check status
-        assertEquals(Status.OK.getStatusCode(), goodResponse.getStatus());
-
-        // check entity stream
-        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
-        ((StreamingOutput) goodResponse.getResponse().getEntity()).write(baos);
-        assertEquals("some text", new String(baos.toByteArray()));
-
-        // bad response
-        assertTrue(badResponse.hasThrowable());
-        assertEquals(Status.INTERNAL_SERVER_ERROR.getStatusCode(), badResponse.getStatus());
-
-    }
-
-    @Test(expected = IllegalArgumentException.class)
-    public void testReplicateGetWithEntity() throws Throwable {
-        testReplicateXXXEntity(HttpMethod.GET);
-    }
-
-    @Test
-    public void testReplicatePost() throws Throwable {
-        testReplicateXXX(HttpMethod.POST);
-    }
-
-    @Test
-    public void testReplicatePostWithEntity() throws Throwable {
-        testReplicateXXXEntity(HttpMethod.POST);
-    }
-
-    @Test
-    public void testReplicatePut() throws Throwable {
-        testReplicateXXX(HttpMethod.PUT);
-    }
-
-    @Test
-    public void testReplicatePutWithEntity() throws Throwable {
-        testReplicateXXXEntity(HttpMethod.PUT);
-    }
-
-    @Test
-    public void testReplicateDelete() throws Throwable {
-        testReplicateXXX(HttpMethod.DELETE);
-    }
-
-    @Test(expected = IllegalArgumentException.class)
-    public void testReplicateDeleteWithEntity() throws Throwable {
-        testReplicateXXXEntity(HttpMethod.DELETE);
-    }
-
-    @Test
-    public void testReplicateHead() throws Throwable {
-        testReplicateXXX(HttpMethod.HEAD);
-    }
-
-    @Test(expected = IllegalArgumentException.class)
-    public void testReplicateHeadWithEntity() throws Throwable {
-        testReplicateXXXEntity(HttpMethod.HEAD);
-    }
-
-    @Test
-    public void testReplicateOptions() throws Throwable {
-        testReplicateXXX(HttpMethod.OPTIONS);
-    }
-
-    @Test(expected = IllegalArgumentException.class)
-    public void testReplicateOptionsWithEntity() throws Throwable {
-        testReplicateXXXEntity(HttpMethod.OPTIONS);
-    }
-
-    private void testReplicateXXX(final String method) throws Throwable {
-        testReplicateXXX(executorThreadCount, method);
-    }
-
-    private void testReplicateXXX(final int numNodes, final String method) throws Throwable {
-
-        // nodes
-        Set<NodeIdentifier> nodeIds = createNodes(numNodes, "localhost", serverPort);
-
-        // set up responses
-        for (int i = 0; i < nodeIds.size(); i++) {
-            HttpResponse response = new HttpResponse(Status.OK, expectedBody);
-            response.addHeaders(expectedResponseHeaders);
-            server.addResponseAction(new HttpResponseAction(response));
-        }
-
-        // setup request parameters
-        server.addCheckedParameters(expectedRequestParameters);
-
-        // request headers
-        server.addCheckedHeaders(expectedRequestHeaders);
-
-        Set<NodeResponse> responses = replicator.replicate(
-                nodeIds,
-                method,
-                prototypeUri,
-                expectedRequestParameters,
-                expectedRequestHeaders);
-
-        Set<NodeIdentifier> returnedNodeIds = new HashSet<>();
-        for (NodeResponse response : responses) {
-
-            // check if we received an exception
-            if (response.hasThrowable()) {
-                throw response.getThrowable();
-            }
-
-            // gather ids to verify later
-            returnedNodeIds.add(response.getNodeId());
-
-            // check status
-            assertEquals(Status.OK.getStatusCode(), response.getStatus());
-
-            Response serverResponse = response.getResponse();
-
-            // check response headers are copied
-            assertTrue(containsHeaders(expectedResponseHeaders, serverResponse.getMetadata()));
-
-            // check entity stream
-            if (HttpMethod.HEAD.equalsIgnoreCase(method)) {
-                assertNull(serverResponse.getEntity());
-            } else {
-                assertTrue(isEquals((StreamingOutput) serverResponse.getEntity(), expectedBody));
-            }
-
-        }
-
-        // check node Ids
-        assertEquals(nodeIds, returnedNodeIds);
-    }
-
-    private void testReplicateXXXEntity(final String method) throws Throwable {
-        testReplicateXXXEntity(executorThreadCount, method);
-    }
-
-    private void testReplicateXXXEntity(final int numNodes, final String method) throws Throwable {
-
-        // nodes
-        Set<NodeIdentifier> nodeIds = createNodes(numNodes, "localhost", serverPort);
-
-        // set up responses
-        for (int i = 0; i < nodeIds.size(); i++) {
-            HttpResponse response = new HttpResponse(Status.OK, expectedBody);
-            response.addHeaders(expectedResponseHeaders);
-            server.addResponseAction(new HttpResponseAction(response));
-        }
-
-        // headers
-        expectedRequestHeaders.put("Content-Type", "application/xml");
-
-        Set<NodeResponse> responses = replicator.replicate(
-                nodeIds,
-                method,
-                prototypeUri,
-                expectedEntity,
-                expectedRequestHeaders);
-
-        Set<NodeIdentifier> returnedNodeIds = new HashSet<>();
-        for (NodeResponse response : responses) {
-
-            // check if we received an exception
-            if (response.hasThrowable()) {
-                throw response.getThrowable();
-            }
-
-            // gather ids to verify later
-            returnedNodeIds.add(response.getNodeId());
-
-            // check status
-            assertEquals(Status.OK.getStatusCode(), response.getStatus());
-
-            Response serverResponse = response.getResponse();
-
-            // check response headers are copied
-            assertTrue(containsHeaders(expectedResponseHeaders, serverResponse.getMetadata()));
-
-            // check entity stream
-            assertTrue(isEquals((StreamingOutput) serverResponse.getEntity(), expectedBody));
-
-        }
-
-        // check node Ids
-        assertEquals(nodeIds, returnedNodeIds);
-    }
-
-    private Set<NodeIdentifier> createNodes(int num, String host, int apiPort) {
-        Set<NodeIdentifier> result = new HashSet<>();
-        for (int i = 0; i < num; i++) {
-            result.add(new NodeIdentifier(String.valueOf(i), host, apiPort, host, 1));
-        }
-        return result;
-    }
-
-    private boolean isEquals(StreamingOutput so, String expectedText) throws IOException {
-        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
-        so.write(baos);
-        return expectedText.equals(new String(baos.toByteArray()));
-    }
-
-    private boolean containsHeaders(Map<String, String> expectedHeaders, MultivaluedMap<String, Object> metadata) {
-        for (Map.Entry<String, String> expectedEntry : expectedHeaders.entrySet()) {
-            if (expectedEntry.getValue().equals(metadata.getFirst(expectedEntry.getKey())) == false) {
-                return false;
-            }
-        }
-        return true;
-    }
-
-}
-
-@XmlRootElement
-class Entity {
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/test/java/org/apache/nifi/cluster/manager/impl/HttpResponseMapperImplTest.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/test/java/org/apache/nifi/cluster/manager/impl/HttpResponseMapperImplTest.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/test/java/org/apache/nifi/cluster/manager/impl/HttpResponseMapperImplTest.java
deleted file mode 100644
index d45a4d1..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/test/java/org/apache/nifi/cluster/manager/impl/HttpResponseMapperImplTest.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * 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.nifi.cluster.manager.impl;
-
-import org.apache.nifi.cluster.manager.impl.HttpResponseMapperImpl;
-import com.sun.jersey.api.client.ClientResponse;
-import com.sun.jersey.core.util.MultivaluedMapImpl;
-import java.io.ByteArrayInputStream;
-import java.util.Map;
-import java.util.HashSet;
-import java.util.Set;
-import java.net.URI;
-import java.net.URISyntaxException;
-import org.apache.nifi.cluster.manager.NodeResponse;
-import org.apache.nifi.cluster.node.Node;
-import org.apache.nifi.cluster.node.Node.Status;
-import org.apache.nifi.cluster.protocol.NodeIdentifier;
-import org.junit.Before;
-import org.junit.Test;
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.*;
-
-/**
- * @author unattributed
- */
-public class HttpResponseMapperImplTest {
-
-    private HttpResponseMapperImpl mapper;
-
-    private URI dummyUri;
-
-    @Before
-    public void setup() throws URISyntaxException {
-        mapper = new HttpResponseMapperImpl();
-        dummyUri = new URI("http://dummy.com");
-    }
-
-    @Test
-    public void testToNodeStatusWithNo2xxResponses() {
-
-        Set<NodeResponse> nodeResponses = new HashSet<>();
-        nodeResponses.add(createNodeResourceResponse("1", 400));
-        nodeResponses.add(createNodeResourceResponse("2", 100));
-        nodeResponses.add(createNodeResourceResponse("3", 300));
-        nodeResponses.add(createNodeResourceResponse("4", 500));
-
-        Map<NodeResponse, Status> map = mapper.map(dummyUri, nodeResponses);
-
-        // since no 2xx responses, any 5xx is disconnected
-        for (Map.Entry<NodeResponse, Status> entry : map.entrySet()) {
-            NodeResponse response = entry.getKey();
-            Status status = entry.getValue();
-            switch (response.getNodeId().getId()) {
-                case "1":
-                    assertTrue(status == Node.Status.CONNECTED);
-                    break;
-                case "2":
-                    assertTrue(status == Node.Status.CONNECTED);
-                    break;
-                case "3":
-                    assertTrue(status == Node.Status.CONNECTED);
-                    break;
-                case "4":
-                    assertTrue(status == Node.Status.DISCONNECTED);
-                    break;
-            }
-        }
-    }
-
-    @Test
-    public void testToNodeStatusWith2xxResponses() {
-
-        Set<NodeResponse> nodeResponses = new HashSet<>();
-        nodeResponses.add(createNodeResourceResponse("1", 200));
-        nodeResponses.add(createNodeResourceResponse("2", 100));
-        nodeResponses.add(createNodeResourceResponse("3", 300));
-        nodeResponses.add(createNodeResourceResponse("4", 500));
-
-        Map<NodeResponse, Status> map = mapper.map(dummyUri, nodeResponses);
-
-        // since there were 2xx responses, any non-2xx is disconnected
-        for (Map.Entry<NodeResponse, Status> entry : map.entrySet()) {
-            NodeResponse response = entry.getKey();
-            Status status = entry.getValue();
-            switch (response.getNodeId().getId()) {
-                case "1":
-                    assertTrue(status == Node.Status.CONNECTED);
-                    break;
-                case "2":
-                    assertTrue(status == Node.Status.DISCONNECTED);
-                    break;
-                case "3":
-                    assertTrue(status == Node.Status.DISCONNECTED);
-                    break;
-                case "4":
-                    assertTrue(status == Node.Status.DISCONNECTED);
-                    break;
-            }
-        }
-    }
-
-    private NodeResponse createNodeResourceResponse(String nodeId, int statusCode) {
-
-        ClientResponse clientResponse = mock(ClientResponse.class);
-        when(clientResponse.getStatus()).thenReturn(statusCode);
-        when(clientResponse.getHeaders()).thenReturn(new MultivaluedMapImpl());
-        when(clientResponse.getEntityInputStream()).thenReturn(new ByteArrayInputStream(new byte[0]));
-
-        NodeIdentifier nodeIdentifier = new NodeIdentifier(nodeId, "localhost", 1, "localhost", 1);
-        return new NodeResponse(nodeIdentifier, "GET", dummyUri, clientResponse, 1L, "111");
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/test/java/org/apache/nifi/cluster/manager/impl/TestWebClusterManager.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/test/java/org/apache/nifi/cluster/manager/impl/TestWebClusterManager.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/test/java/org/apache/nifi/cluster/manager/impl/TestWebClusterManager.java
deleted file mode 100644
index 13a192f..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/test/java/org/apache/nifi/cluster/manager/impl/TestWebClusterManager.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * 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.nifi.cluster.manager.impl;
-
-import org.apache.nifi.cluster.manager.impl.WebClusterManager;
-
-import static org.junit.Assert.assertEquals;
-
-import java.text.DateFormat;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.Locale;
-
-import org.junit.Test;
-
-public class TestWebClusterManager {
-
-    @Test
-    public void testNormalizedStatusSnapshotDate() throws ParseException {
-        final DateFormat df = new SimpleDateFormat("yyyy/MM/dd HH:mm:SS.SSS", Locale.US);
-        final Date date1 = df.parse("2014/01/01 00:00:00.000");
-        final Date date2 = df.parse("2014/01/01 00:04:59.999");
-        final Date date3 = df.parse("2014/01/01 00:05:00.000");
-        final Date date4 = df.parse("2014/01/01 00:05:00.001");
-
-        final Date normalized1 = WebClusterManager.normalizeStatusSnapshotDate(date1, 300000);
-        assertEquals(date1, normalized1);
-
-        final Date normalized2 = WebClusterManager.normalizeStatusSnapshotDate(date2, 300000);
-        assertEquals(date1, normalized2);
-
-        final Date normalized3 = WebClusterManager.normalizeStatusSnapshotDate(date3, 300000);
-        assertEquals(date3, normalized3);
-
-        final Date normalized4 = WebClusterManager.normalizeStatusSnapshotDate(date4, 300000);
-        assertEquals(date3, normalized4);
-    }
-
-}


[19/20] incubator-nifi git commit: NIFI-410 pushed RAT exclusions down to the relevant modules and stopped doing broad test resource exclusion - is now specific

Posted by jo...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/ClusterManagerProtocolSenderListener.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/ClusterManagerProtocolSenderListener.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/ClusterManagerProtocolSenderListener.java
deleted file mode 100644
index 933e5fa..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/ClusterManagerProtocolSenderListener.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * 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.nifi.cluster.protocol.impl;
-
-import java.io.IOException;
-import java.util.Collection;
-
-import org.apache.nifi.cluster.protocol.ClusterManagerProtocolSender;
-import org.apache.nifi.cluster.protocol.ProtocolException;
-import org.apache.nifi.cluster.protocol.ProtocolHandler;
-import org.apache.nifi.cluster.protocol.ProtocolListener;
-import org.apache.nifi.cluster.protocol.message.DisconnectMessage;
-import org.apache.nifi.cluster.protocol.message.FlowRequestMessage;
-import org.apache.nifi.cluster.protocol.message.FlowResponseMessage;
-import org.apache.nifi.cluster.protocol.message.PrimaryRoleAssignmentMessage;
-import org.apache.nifi.cluster.protocol.message.ReconnectionRequestMessage;
-import org.apache.nifi.cluster.protocol.message.ReconnectionResponseMessage;
-import org.apache.nifi.reporting.BulletinRepository;
-
-/**
- * A wrapper class for consolidating a protocol sender and listener for the cluster
- * manager.
- * 
- * @author unattributed
- */
-public class ClusterManagerProtocolSenderListener implements ClusterManagerProtocolSender, ProtocolListener {
-    
-    private final ClusterManagerProtocolSender sender;
-    
-    private final ProtocolListener listener;
-    
-    public ClusterManagerProtocolSenderListener(final ClusterManagerProtocolSender sender, final ProtocolListener listener) {
-        if(sender == null) {
-            throw new IllegalArgumentException("ClusterManagerProtocolSender may not be null.");
-        } else if(listener == null) {
-            throw new IllegalArgumentException("ProtocolListener may not be null.");
-        }
-        this.sender = sender;
-        this.listener = listener;
-    }
-
-    @Override
-    public void stop() throws IOException {
-        if(!isRunning()) {
-            throw new IllegalStateException("Instance is already stopped.");
-        }
-        listener.stop();
-    }
-
-    @Override
-    public void start() throws IOException {
-        if(isRunning()) {
-            throw new IllegalStateException("Instance is already started.");
-        }
-        listener.start();
-    }
-
-    @Override
-    public boolean isRunning() {
-        return listener.isRunning();
-    }
-
-    @Override
-    public boolean removeHandler(final ProtocolHandler handler) {
-        return listener.removeHandler(handler);
-    }
-
-    @Override
-    public Collection<ProtocolHandler> getHandlers() {
-        return listener.getHandlers();
-    }
-
-    @Override
-    public void addHandler(final ProtocolHandler handler) {
-        listener.addHandler(handler);
-    }
-    
-    @Override
-    public void setBulletinRepository(final BulletinRepository bulletinRepository) {
-        listener.setBulletinRepository(bulletinRepository);
-        sender.setBulletinRepository(bulletinRepository);
-    }
-    
-    @Override
-    public FlowResponseMessage requestFlow(final FlowRequestMessage msg) throws ProtocolException {
-        return sender.requestFlow(msg);
-    }
-
-    @Override
-    public ReconnectionResponseMessage requestReconnection(final ReconnectionRequestMessage msg) throws ProtocolException {
-        return sender.requestReconnection(msg);
-    }
-
-    @Override
-    public void disconnect(DisconnectMessage msg) throws ProtocolException {
-        sender.disconnect(msg);
-    }
-    
-    @Override
-    public void assignPrimaryRole(PrimaryRoleAssignmentMessage msg) throws ProtocolException {
-        sender.assignPrimaryRole(msg);
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/ClusterServiceDiscovery.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/ClusterServiceDiscovery.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/ClusterServiceDiscovery.java
deleted file mode 100644
index 24e51e0..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/ClusterServiceDiscovery.java
+++ /dev/null
@@ -1,181 +0,0 @@
-/*
- * 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.nifi.cluster.protocol.impl;
-
-import java.io.IOException;
-import java.net.InetSocketAddress;
-import java.util.Collection;
-import java.util.Collections;
-import org.apache.nifi.io.socket.multicast.DiscoverableService;
-import org.apache.nifi.io.socket.multicast.DiscoverableServiceImpl;
-import org.apache.nifi.io.socket.multicast.MulticastConfiguration;
-import org.apache.nifi.io.socket.multicast.MulticastServiceDiscovery;
-import org.apache.nifi.reporting.BulletinRepository;
-
-import org.apache.commons.lang3.StringUtils;
-import org.apache.nifi.cluster.protocol.ProtocolContext;
-import org.apache.nifi.cluster.protocol.ProtocolException;
-import org.apache.nifi.cluster.protocol.ProtocolHandler;
-import org.apache.nifi.cluster.protocol.ProtocolListener;
-import org.apache.nifi.cluster.protocol.message.ProtocolMessage;
-import org.apache.nifi.cluster.protocol.message.ProtocolMessage.MessageType;
-import org.apache.nifi.cluster.protocol.message.ServiceBroadcastMessage;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * An implementation for discovering services by way of "service broadcast" type
- * protocol messages over multicast.
- *
- * The client caller is responsible for starting and stopping the service
- * discovery. The instance must be stopped before termination of the JVM to
- * ensure proper resource clean-up.
- *
- * @author unattributed
- */
-public class ClusterServiceDiscovery implements MulticastServiceDiscovery, ProtocolListener {
-
-    private static final Logger logger = LoggerFactory.getLogger(ClusterServiceDiscovery.class);
-    private final String serviceName;
-    private final MulticastConfiguration multicastConfiguration;
-    private final MulticastProtocolListener listener;
-    private volatile BulletinRepository bulletinRepository;
-
-    /*
-     * guarded by this
-     */
-    private DiscoverableService service;
-
-    
-    public ClusterServiceDiscovery(final String serviceName, final InetSocketAddress multicastAddress,
-            final MulticastConfiguration multicastConfiguration, final ProtocolContext<ProtocolMessage> protocolContext) {
-
-        if (StringUtils.isBlank(serviceName)) {
-            throw new IllegalArgumentException("Service name may not be null or empty.");
-        } else if (multicastAddress == null) {
-            throw new IllegalArgumentException("Multicast address may not be null.");
-        } else if (multicastAddress.getAddress().isMulticastAddress() == false) {
-            throw new IllegalArgumentException("Multicast group must be a Class D address.");
-        } else if (protocolContext == null) {
-            throw new IllegalArgumentException("Protocol Context may not be null.");
-        } else if (multicastConfiguration == null) {
-            throw new IllegalArgumentException("Multicast configuration may not be null.");
-        }
-
-        this.serviceName = serviceName;
-        this.multicastConfiguration = multicastConfiguration;
-        this.listener = new MulticastProtocolListener(1, multicastAddress, multicastConfiguration, protocolContext);
-        listener.addHandler(new ClusterManagerServiceBroadcastHandler());
-    }
-
-    @Override
-    public void setBulletinRepository(final BulletinRepository bulletinRepository) {
-        this.bulletinRepository = bulletinRepository;
-    }
-
-    @Override
-    public synchronized DiscoverableService getService() {
-        return service;
-    }
-
-    @Override
-    public InetSocketAddress getMulticastAddress() {
-        return listener.getMulticastAddress();
-    }
-
-    @Override
-    public Collection<ProtocolHandler> getHandlers() {
-        return Collections.unmodifiableCollection(listener.getHandlers());
-    }
-
-    @Override
-    public void addHandler(ProtocolHandler handler) {
-        listener.addHandler(handler);
-    }
-
-    @Override
-    public boolean removeHandler(ProtocolHandler handler) {
-        return listener.removeHandler(handler);
-    }
-
-    @Override
-    public boolean isRunning() {
-        return listener.isRunning();
-    }
-
-    @Override
-    public void start() throws IOException {
-        if (isRunning()) {
-            throw new IllegalStateException("Instance is already running.");
-        }
-        listener.start();
-    }
-
-    @Override
-    public void stop() throws IOException {
-        if (isRunning() == false) {
-            throw new IllegalStateException("Instance is already stopped.");
-        }
-        listener.stop();
-    }
-
-    public String getServiceName() {
-        return serviceName;
-    }
-
-    public MulticastConfiguration getMulticastConfiguration() {
-        return multicastConfiguration;
-    }
-
-    private class ClusterManagerServiceBroadcastHandler implements ProtocolHandler {
-
-        @Override
-        public boolean canHandle(final ProtocolMessage msg) {
-            return MessageType.SERVICE_BROADCAST == msg.getType();
-        }
-
-        @Override
-        public ProtocolMessage handle(final ProtocolMessage msg) throws ProtocolException {
-            synchronized (ClusterServiceDiscovery.this) {
-                if (canHandle(msg) == false) {
-                    throw new ProtocolException("Handler cannot handle message type: " + msg.getType());
-                } else {
-                    final ServiceBroadcastMessage broadcastMsg = (ServiceBroadcastMessage) msg;
-                    if (serviceName.equals(broadcastMsg.getServiceName())) {
-                        final DiscoverableService oldService = service;
-                        if (oldService == null
-                                || broadcastMsg.getAddress().equalsIgnoreCase(oldService.getServiceAddress().getHostName()) == false
-                                || broadcastMsg.getPort() != oldService.getServiceAddress().getPort()) {
-                            service = new DiscoverableServiceImpl(serviceName, InetSocketAddress.createUnresolved(broadcastMsg.getAddress(), broadcastMsg.getPort()));
-                            final InetSocketAddress oldServiceAddress = (oldService == null) ? null : oldService.getServiceAddress();
-                            logger.info(String.format("Updating cluster service address for '%s' from '%s' to '%s'", serviceName, prettyPrint(oldServiceAddress), prettyPrint(service.getServiceAddress())));
-                        }
-                    }
-                    return null;
-                }
-            }
-        }
-    }
-
-    private String prettyPrint(final InetSocketAddress address) {
-        if (address == null) {
-            return "0.0.0.0:0";
-        } else {
-            return address.getHostName() + ":" + address.getPort();
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/ClusterServiceLocator.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/ClusterServiceLocator.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/ClusterServiceLocator.java
deleted file mode 100644
index bebfde8..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/ClusterServiceLocator.java
+++ /dev/null
@@ -1,229 +0,0 @@
-/*
- * 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.nifi.cluster.protocol.impl;
-
-import java.io.IOException;
-import java.net.InetSocketAddress;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicBoolean;
-import org.apache.nifi.io.socket.multicast.DiscoverableService;
-import org.apache.nifi.io.socket.multicast.DiscoverableServiceImpl;
-import org.apache.nifi.io.socket.multicast.ServiceDiscovery;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Implements the ServiceLocator interface for locating the socket address
- * of a cluster service.  Depending on configuration, the address may be located
- * using service discovery.  If using service discovery, then the service methods
- * must be used for starting and stopping discovery.
- * 
- * Service discovery may be used in conjunction with a fixed port.  In this case,
- * the service discovery will yield the service IP/host while the fixed port will
- * be used for the port.
- * 
- * Alternatively, the instance may be configured with exact service location, in
- * which case, no service discovery occurs and the caller will always receive the
- * configured service.
- * 
- * @author unattributed
- */
-public class ClusterServiceLocator implements ServiceDiscovery {
-    
-    private static final Logger logger = LoggerFactory.getLogger(ClusterServiceLocator.class);
-    
-    private final String serviceName;
-    
-    private final ClusterServiceDiscovery serviceDiscovery;
-    
-    private final DiscoverableService fixedService;
-
-    private final int fixedServicePort;
-    
-    private final AttemptsConfig attemptsConfig = new AttemptsConfig();
-    
-    private final AtomicBoolean running = new AtomicBoolean(false);
-    
-    public ClusterServiceLocator(final ClusterServiceDiscovery serviceDiscovery) {
-        if(serviceDiscovery == null) {
-            throw new IllegalArgumentException("ClusterServiceDiscovery may not be null.");
-        }
-        this.serviceDiscovery = serviceDiscovery;
-        this.fixedService = null;
-        this.fixedServicePort = 0;
-        this.serviceName = serviceDiscovery.getServiceName();
-    }
-    
-    public ClusterServiceLocator(final ClusterServiceDiscovery serviceDiscovery, final int fixedServicePort) {
-        if(serviceDiscovery == null) {
-            throw new IllegalArgumentException("ClusterServiceDiscovery may not be null.");
-        }
-        this.serviceDiscovery = serviceDiscovery;
-        this.fixedService = null;
-        this.fixedServicePort = fixedServicePort;
-        this.serviceName = serviceDiscovery.getServiceName();
-    }
-    
-    public ClusterServiceLocator(final DiscoverableService fixedService) {
-        if(fixedService == null) {
-            throw new IllegalArgumentException("Service may not be null.");
-        }
-        this.serviceDiscovery = null;
-        this.fixedService = fixedService;
-        this.fixedServicePort = 0;
-        this.serviceName = fixedService.getServiceName();
-    }
-    
-    @Override
-    public DiscoverableService getService() {
-        
-        final int numAttemptsValue;
-        final int secondsBetweenAttempts;
-        synchronized(this) {
-            numAttemptsValue = attemptsConfig.numAttempts;
-            secondsBetweenAttempts = attemptsConfig.getTimeBetweenAttempts();
-        }
-        
-        // try for a configured amount of attempts to retrieve the service address
-        for(int i = 0; i < numAttemptsValue; i++) {
-
-            if(fixedService != null) {
-                return fixedService;
-            } else if(serviceDiscovery != null) {
-                
-                final DiscoverableService discoveredService = serviceDiscovery.getService();
-                
-                // if we received an address
-                if(discoveredService != null) {
-                    // if we were configured with a fixed port, then use the discovered host and fixed port; otherwise use the discovered address
-                    if(fixedServicePort > 0) {
-                        // create service using discovered service name and address with fixed service port
-                        final InetSocketAddress addr = InetSocketAddress.createUnresolved(discoveredService.getServiceAddress().getHostName(), fixedServicePort);
-                        final DiscoverableService result = new DiscoverableServiceImpl(discoveredService.getServiceName(), addr);
-                        return result;
-                    } else {
-                        return discoveredService;
-                    }
-                }
-            }
-            
-            // could not obtain service address, so sleep a bit
-            try {
-                logger.debug(String.format("Locating Cluster Service '%s' Attempt: %d of %d failed.  Trying again in %d seconds.", 
-                    serviceName, (i + 1), numAttemptsValue, secondsBetweenAttempts));
-                Thread.sleep(secondsBetweenAttempts * 1000);
-            } catch(final InterruptedException ie) {
-                break;
-            }
-            
-        }
-
-        return null;
-    }
-
-    public boolean isRunning() {
-        if(serviceDiscovery != null) {
-            return serviceDiscovery.isRunning();
-        } else {
-            return running.get();
-        }
-    }
-
-    public void start() throws IOException {
-        
-        if(isRunning()) {
-            throw new IllegalStateException("Instance is already started.");
-        }
-        
-        if(serviceDiscovery != null) {
-            serviceDiscovery.start();
-        }
-        running.set(true);
-    }
-
-    public void stop() throws IOException {
-        
-        if(isRunning() == false) {
-            throw new IllegalStateException("Instance is already stopped.");
-        }
-        
-        if(serviceDiscovery != null) {
-            serviceDiscovery.stop();
-        }
-        running.set(false);
-    }
-    
-    public synchronized void setAttemptsConfig(final AttemptsConfig config) {
-        if(config == null) {
-            throw new IllegalArgumentException("Attempts configuration may not be null.");
-        }
-        this.attemptsConfig.numAttempts = config.numAttempts;
-        this.attemptsConfig.timeBetweenAttempts = config.timeBetweenAttempts;
-        this.attemptsConfig.timeBetweenAttempsUnit = config.timeBetweenAttempsUnit;
-    }
-
-    public synchronized AttemptsConfig getAttemptsConfig() {
-        final AttemptsConfig config = new AttemptsConfig();
-        config.numAttempts = this.attemptsConfig.numAttempts;
-        config.timeBetweenAttempts = this.attemptsConfig.timeBetweenAttempts;
-        config.timeBetweenAttempsUnit = this.attemptsConfig.timeBetweenAttempsUnit;
-        return config;
-    }
-    
-    public static class AttemptsConfig {
-        
-        private int numAttempts = 1;
-        
-        private int timeBetweenAttempts = 1;
-        
-        private TimeUnit timeBetweenAttempsUnit = TimeUnit.SECONDS;
-        
-        public int getNumAttempts() {
-            return numAttempts;
-        }
-
-        public void setNumAttempts(int numAttempts) {
-            if(numAttempts <= 0) {
-                throw new IllegalArgumentException("Number of attempts must be positive: " + numAttempts);
-            }
-            this.numAttempts = numAttempts;
-        }
-
-        public TimeUnit getTimeBetweenAttemptsUnit() {
-            return timeBetweenAttempsUnit;
-        }
-
-        public void setTimeBetweenAttempsUnit(TimeUnit timeBetweenAttempsUnit) {
-            if(timeBetweenAttempts <= 0) {
-                throw new IllegalArgumentException("Time between attempts must be positive: " + numAttempts);
-            } 
-            this.timeBetweenAttempsUnit = timeBetweenAttempsUnit;
-        }
-
-        public int getTimeBetweenAttempts() {
-            return timeBetweenAttempts;
-        }
-
-        public void setTimeBetweenAttempts(int timeBetweenAttempts) {
-            if(timeBetweenAttempts <= 0) {
-            throw new IllegalArgumentException("Time between attempts must be positive: " + numAttempts);
-        } 
-            this.timeBetweenAttempts = timeBetweenAttempts;
-        }
-
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/ClusterServicesBroadcaster.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/ClusterServicesBroadcaster.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/ClusterServicesBroadcaster.java
deleted file mode 100644
index e9e7d5b..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/ClusterServicesBroadcaster.java
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
- * 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.nifi.cluster.protocol.impl;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.net.DatagramPacket;
-import java.net.InetSocketAddress;
-import java.net.MulticastSocket;
-import java.util.*;
-import java.util.concurrent.CopyOnWriteArraySet;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.nifi.io.socket.multicast.DiscoverableService;
-import org.apache.nifi.io.socket.multicast.MulticastConfiguration;
-import org.apache.nifi.io.socket.multicast.MulticastServicesBroadcaster;
-import org.apache.nifi.io.socket.multicast.MulticastUtils;
-import org.apache.nifi.logging.NiFiLog;
-import org.apache.nifi.util.FormatUtils;
-import org.apache.nifi.cluster.protocol.ProtocolContext;
-import org.apache.nifi.cluster.protocol.ProtocolMessageMarshaller;
-import org.apache.nifi.cluster.protocol.message.ProtocolMessage;
-import org.apache.nifi.cluster.protocol.message.ServiceBroadcastMessage;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Broadcasts services used by the clustering software using multicast communication.
- * A configurable delay occurs after broadcasting the collection of services.
- * 
- * The client caller is responsible for starting and stopping the broadcasting.
- * The instance must be stopped before termination of the JVM to ensure proper
- * resource clean-up.
- * 
- * @author unattributed
- */
-public class ClusterServicesBroadcaster implements MulticastServicesBroadcaster {
-    
-    private static final Logger logger = new NiFiLog(LoggerFactory.getLogger(ClusterServicesBroadcaster.class));
-    
-    private final Set<DiscoverableService> services = new CopyOnWriteArraySet<>();
-
-    private final InetSocketAddress multicastAddress;
-    
-    private final MulticastConfiguration multicastConfiguration;
-    
-    private final ProtocolContext<ProtocolMessage> protocolContext;
-    
-    private final int broadcastDelayMs;
-    
-    private Timer broadcaster;
-    
-    private MulticastSocket multicastSocket;
-    
-    public ClusterServicesBroadcaster(final InetSocketAddress multicastAddress, 
-            final MulticastConfiguration multicastConfiguration, 
-            final ProtocolContext<ProtocolMessage> protocolContext, final String broadcastDelay) {
-        
-        if(multicastAddress == null) {
-            throw new IllegalArgumentException("Multicast address may not be null.");
-        } else if(multicastAddress.getAddress().isMulticastAddress() == false) {
-            throw new IllegalArgumentException("Multicast group address is not a Class D IP address.");
-        } else if(protocolContext == null) {
-            throw new IllegalArgumentException("Protocol Context may not be null.");
-        } else if(multicastConfiguration == null) {
-            throw new IllegalArgumentException("Multicast configuration may not be null.");
-        }
-        
-        this.services.addAll(services);
-        this.multicastAddress = multicastAddress;
-        this.multicastConfiguration = multicastConfiguration;
-        this.protocolContext = protocolContext;
-        this.broadcastDelayMs = (int) FormatUtils.getTimeDuration(broadcastDelay, TimeUnit.MILLISECONDS);
-    }
-    
-    public void start() throws IOException {
-
-        if(isRunning()) {
-            throw new IllegalStateException("Instance is already started.");
-        }
-        
-        // setup socket
-        multicastSocket = MulticastUtils.createMulticastSocket(multicastConfiguration);
-        
-        // setup broadcaster
-        broadcaster = new Timer("Cluster Services Broadcaster", /* is daemon */ true);
-        broadcaster.schedule(new TimerTask() {
-            @Override
-            public void run() {
-                for(final DiscoverableService service : services) {
-                    try {
-
-                        final InetSocketAddress serviceAddress = service.getServiceAddress();
-                        logger.debug(String.format("Broadcasting Cluster Service '%s' at address %s:%d", 
-                            service.getServiceName(), serviceAddress.getHostName(), serviceAddress.getPort()));
-                        
-                        // create message
-                        final ServiceBroadcastMessage msg = new ServiceBroadcastMessage();
-                        msg.setServiceName(service.getServiceName());
-                        msg.setAddress(serviceAddress.getHostName());
-                        msg.setPort(serviceAddress.getPort());
-
-                        // marshal message to output stream
-                        final ProtocolMessageMarshaller<ProtocolMessage> marshaller = protocolContext.createMarshaller();
-                        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
-                        marshaller.marshal(msg, baos);
-                        final byte[] packetBytes = baos.toByteArray();
-
-                        // send message
-                        final DatagramPacket packet = new DatagramPacket(packetBytes, packetBytes.length, multicastAddress);
-                        multicastSocket.send(packet);
-
-                    } catch(final Exception ex) {
-                        logger.warn(String.format("Cluster Services Broadcaster failed broadcasting service '%s' due to: %s", service.getServiceName(), ex), ex);
-                    }
-                }
-            }
-        }, 0, broadcastDelayMs);
-    }
-    
-    public boolean isRunning() {
-        return (broadcaster != null);
-    }
-    
-    public void stop() {
-        
-        if(isRunning() == false) {
-            throw new IllegalStateException("Instance is already stopped.");
-        }
-        
-        broadcaster.cancel();
-        broadcaster = null;
-
-        // close socket
-        MulticastUtils.closeQuietly(multicastSocket);
-        
-    }
-
-    @Override
-    public int getBroadcastDelayMs() {
-        return broadcastDelayMs;
-    }
-    
-    @Override
-    public Set<DiscoverableService> getServices() {
-        return Collections.unmodifiableSet(services);
-    }
-
-    @Override
-    public InetSocketAddress getMulticastAddress() {
-        return multicastAddress;
-    }
-    
-    @Override
-    public boolean addService(final DiscoverableService service) {
-        return services.add(service);
-    }
-    
-    @Override
-    public boolean removeService(final String serviceName) {
-        for(final DiscoverableService service : services) {
-            if(service.getServiceName().equals(serviceName)) {
-                return services.remove(service);
-            }
-        }
-        return false;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/CopyingInputStream.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/CopyingInputStream.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/CopyingInputStream.java
deleted file mode 100644
index 680df65..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/CopyingInputStream.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * 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.nifi.cluster.protocol.impl;
-
-import java.io.ByteArrayOutputStream;
-import java.io.FilterInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-public class CopyingInputStream extends FilterInputStream {
-    private final ByteArrayOutputStream baos = new ByteArrayOutputStream();
-    private final int maxBytesToCopy;
-    private final InputStream in;
-
-    public CopyingInputStream(final InputStream in, final int maxBytesToCopy) {
-        super(in);
-        this.maxBytesToCopy = maxBytesToCopy;
-        this.in = in;
-    }
-    
-    @Override
-    public int read() throws IOException {
-        final int delegateRead = in.read();
-        if ( delegateRead != -1 && getNumberOfBytesCopied() < maxBytesToCopy ) {
-            baos.write(delegateRead);
-        }
-        
-        return delegateRead;
-    }
-    
-    @Override
-    public int read(byte[] b) throws IOException {
-        final int delegateRead = in.read(b);
-        if ( delegateRead >= 0 ) {
-            baos.write(b, 0, Math.min(delegateRead, maxBytesToCopy - getNumberOfBytesCopied()));
-        }
-        
-        return delegateRead;
-    }
-    
-    @Override
-    public int read(byte[] b, int off, int len) throws IOException {
-        final int delegateRead = in.read(b, off, len);
-        if ( delegateRead >= 0 ) {
-            baos.write(b, off, Math.min(delegateRead, maxBytesToCopy - getNumberOfBytesCopied()));
-        }
-        
-        return delegateRead;
-    }
-    
-    public byte[] getBytesRead() {
-        return baos.toByteArray();
-    }
-    
-    public void writeBytes(final OutputStream out) throws IOException {
-        baos.writeTo(out);
-    }
-    
-    public int getNumberOfBytesCopied() {
-        return baos.size();
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/MulticastProtocolListener.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/MulticastProtocolListener.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/MulticastProtocolListener.java
deleted file mode 100644
index d3764b3..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/MulticastProtocolListener.java
+++ /dev/null
@@ -1,204 +0,0 @@
-/*
- * 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.nifi.cluster.protocol.impl;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.net.DatagramPacket;
-import java.net.InetSocketAddress;
-import java.net.MulticastSocket;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.UUID;
-import java.util.concurrent.CopyOnWriteArrayList;
-import org.apache.nifi.io.socket.multicast.MulticastConfiguration;
-import org.apache.nifi.io.socket.multicast.MulticastListener;
-import org.apache.nifi.logging.NiFiLog;
-import org.apache.nifi.reporting.Bulletin;
-import org.apache.nifi.reporting.BulletinRepository;
-import org.apache.nifi.cluster.protocol.ProtocolContext;
-import org.apache.nifi.cluster.protocol.ProtocolException;
-import org.apache.nifi.cluster.protocol.ProtocolHandler;
-import org.apache.nifi.cluster.protocol.ProtocolListener;
-import org.apache.nifi.cluster.protocol.ProtocolMessageMarshaller;
-import org.apache.nifi.cluster.protocol.ProtocolMessageUnmarshaller;
-import org.apache.nifi.cluster.protocol.message.MulticastProtocolMessage;
-import org.apache.nifi.cluster.protocol.message.ProtocolMessage;
-import org.apache.nifi.events.BulletinFactory;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Implements a listener for protocol messages sent over multicast.  If a message
- * is of type MulticastProtocolMessage, then the underlying protocol message is
- * passed to the handler.  If the receiving handler produces a message response,
- * then the message is wrapped with a MulticastProtocolMessage before being 
- * sent to the originator.
- * 
- * The client caller is responsible for starting and stopping the listener.
- * The instance must be stopped before termination of the JVM to ensure proper
- * resource clean-up.
- * 
- * @author unattributed
- */
-public class MulticastProtocolListener extends MulticastListener implements ProtocolListener {
-    
-    private static final Logger logger = new NiFiLog(LoggerFactory.getLogger(MulticastProtocolListener.class));
-
-    // immutable members
-    private final Collection<ProtocolHandler> handlers = new CopyOnWriteArrayList<>();
-    private final String listenerId = UUID.randomUUID().toString();
-    private final ProtocolContext<ProtocolMessage> protocolContext;
-    private volatile BulletinRepository bulletinRepository;
-
-    public MulticastProtocolListener(
-            final int numThreads,
-            final InetSocketAddress multicastAddress,
-            final MulticastConfiguration configuration,
-            final ProtocolContext<ProtocolMessage> protocolContext) {
-
-        super(numThreads, multicastAddress, configuration);
-        
-        if (protocolContext == null) {
-            throw new IllegalArgumentException("Protocol Context may not be null.");
-        }
-        this.protocolContext = protocolContext;
-    }
-
-    @Override
-    public void setBulletinRepository(final BulletinRepository bulletinRepository) {
-        this.bulletinRepository = bulletinRepository;
-    }
-
-    @Override
-    public void start() throws IOException {
-
-        if(super.isRunning()) {
-            throw new IllegalStateException("Instance is already started.");
-        }
-        
-        super.start();
-        
-    }
-
-    @Override
-    public void stop() throws IOException {
-
-        if(super.isRunning() == false) {
-            throw new IllegalStateException("Instance is already stopped.");
-        }
-        
-        // shutdown listener
-        super.stop();
-
-    }
-
-    @Override
-    public Collection<ProtocolHandler> getHandlers() {
-        return Collections.unmodifiableCollection(handlers);
-    }
-
-    @Override
-    public void addHandler(final ProtocolHandler handler) {
-        if(handler == null) {
-            throw new NullPointerException("Protocol handler may not be null.");
-        }
-        handlers.add(handler);
-    }
-    
-    @Override
-    public boolean removeHandler(final ProtocolHandler handler) {
-        return handlers.remove(handler);
-    }
-    
-    @Override
-    public void dispatchRequest(final MulticastSocket multicastSocket, final DatagramPacket packet) {
-
-        try {
-
-            // unmarshall message
-            final ProtocolMessageUnmarshaller<ProtocolMessage> unmarshaller = protocolContext.createUnmarshaller();
-            final ProtocolMessage request = unmarshaller.unmarshal(new ByteArrayInputStream(packet.getData(), 0, packet.getLength()));
-
-            // unwrap multicast message, if necessary
-            final ProtocolMessage unwrappedRequest;
-            if(request instanceof MulticastProtocolMessage) {
-                final MulticastProtocolMessage multicastRequest = (MulticastProtocolMessage) request;
-                // don't process a message we sent
-                if(listenerId.equals(multicastRequest.getId())) {
-                    return;
-                } else {
-                    unwrappedRequest = multicastRequest.getProtocolMessage();
-                }
-            } else {
-                unwrappedRequest = request;
-            }
-            
-            // dispatch message to handler
-            ProtocolHandler desiredHandler = null;
-            for (final ProtocolHandler handler : getHandlers()) {
-                if (handler.canHandle(unwrappedRequest)) {
-                    desiredHandler = handler;
-                    break;
-                }
-            }
-
-            // if no handler found, throw exception; otherwise handle request
-            if (desiredHandler == null) {
-                throw new ProtocolException("No handler assigned to handle message type: " + request.getType());
-            } else {
-                final ProtocolMessage response = desiredHandler.handle(request);
-                if(response != null) {
-                    try {
-                        
-                        // wrap with listener id
-                        final MulticastProtocolMessage multicastResponse = new MulticastProtocolMessage(listenerId, response);
-                        
-                        // marshal message
-                        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
-                        final ProtocolMessageMarshaller<ProtocolMessage> marshaller = protocolContext.createMarshaller();
-                        marshaller.marshal(multicastResponse, baos);
-                        final byte[] responseBytes = baos.toByteArray();
-                        
-                        final int maxPacketSizeBytes = getMaxPacketSizeBytes();
-                        if(responseBytes.length > maxPacketSizeBytes) {
-                            logger.warn("Cluster protocol handler '" + desiredHandler.getClass() + 
-                                "' produced a multicast response with length greater than configured max packet size '" + maxPacketSizeBytes + "'");
-                        }
-                        
-                        // create and send packet
-                        final DatagramPacket responseDatagram = new DatagramPacket(responseBytes, responseBytes.length, getMulticastAddress().getAddress(), getMulticastAddress().getPort()); 
-                        multicastSocket.send(responseDatagram);
-                        
-                    } catch (final IOException ioe) {
-                        throw new ProtocolException("Failed marshalling protocol message in response to message type: " + request.getType() + " due to: " + ioe, ioe);
-                    }
-                }
-            }
-
-        } catch (final Throwable t) {
-            logger.warn("Failed processing protocol message due to " + t, t);
-            
-            if ( bulletinRepository != null ) {
-                final Bulletin bulletin = BulletinFactory.createBulletin("Clustering", "WARNING", "Failed to process Protocol Message due to " + t.toString());
-                bulletinRepository.addBulletin(bulletin);
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/NodeProtocolSenderImpl.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/NodeProtocolSenderImpl.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/NodeProtocolSenderImpl.java
deleted file mode 100644
index dc86d24..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/NodeProtocolSenderImpl.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- * 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.nifi.cluster.protocol.impl;
-
-import java.io.IOException;
-import java.net.Socket;
-
-import javax.net.ssl.SSLSocket;
-import javax.security.cert.X509Certificate;
-
-import org.apache.nifi.cluster.protocol.NodeProtocolSender;
-import org.apache.nifi.cluster.protocol.ProtocolContext;
-import org.apache.nifi.cluster.protocol.ProtocolException;
-import org.apache.nifi.cluster.protocol.ProtocolMessageMarshaller;
-import org.apache.nifi.cluster.protocol.ProtocolMessageUnmarshaller;
-import org.apache.nifi.cluster.protocol.UnknownServiceAddressException;
-import org.apache.nifi.cluster.protocol.message.ConnectionRequestMessage;
-import org.apache.nifi.cluster.protocol.message.ConnectionResponseMessage;
-import org.apache.nifi.cluster.protocol.message.ControllerStartupFailureMessage;
-import org.apache.nifi.cluster.protocol.message.HeartbeatMessage;
-import org.apache.nifi.cluster.protocol.message.NodeBulletinsMessage;
-import org.apache.nifi.cluster.protocol.message.ProtocolMessage;
-import org.apache.nifi.cluster.protocol.message.ProtocolMessage.MessageType;
-import org.apache.nifi.cluster.protocol.message.ReconnectionFailureMessage;
-import org.apache.nifi.io.socket.SocketConfiguration;
-import org.apache.nifi.io.socket.SocketUtils;
-import org.apache.nifi.io.socket.multicast.DiscoverableService;
-
-public class NodeProtocolSenderImpl implements NodeProtocolSender {
-    private final SocketConfiguration socketConfiguration;
-    private final ClusterServiceLocator clusterManagerProtocolServiceLocator;
-    private final ProtocolContext<ProtocolMessage> protocolContext;
-    
-    public NodeProtocolSenderImpl(final ClusterServiceLocator clusterManagerProtocolServiceLocator, 
-            final SocketConfiguration socketConfiguration, final ProtocolContext<ProtocolMessage> protocolContext) {
-        if(clusterManagerProtocolServiceLocator == null) {
-            throw new IllegalArgumentException("Protocol Service Locator may not be null.");
-        } else if(socketConfiguration == null) {
-            throw new IllegalArgumentException("Socket configuration may not be null.");
-        } else if(protocolContext == null) {
-            throw new IllegalArgumentException("Protocol Context may not be null.");
-        }
-        
-        this.clusterManagerProtocolServiceLocator = clusterManagerProtocolServiceLocator;
-        this.socketConfiguration = socketConfiguration;
-        this.protocolContext = protocolContext;
-    }
-    
-    
-    @Override
-    public ConnectionResponseMessage requestConnection(final ConnectionRequestMessage msg) throws ProtocolException, UnknownServiceAddressException {
-        Socket socket = null;
-        try {
-            socket = createSocket();
-            
-            String ncmDn = null;
-            if ( socket instanceof SSLSocket ) {
-                final SSLSocket sslSocket = (SSLSocket) socket;
-                try {
-                    final X509Certificate[] certChains = sslSocket.getSession().getPeerCertificateChain();
-                    if ( certChains != null && certChains.length > 0 ) {
-                        ncmDn = certChains[0].getSubjectDN().getName();
-                    }
-                } catch (final ProtocolException pe) {
-                    throw pe;
-                } catch (final Exception e) {
-                    throw new ProtocolException(e);
-                }
-            }
-            
-            try {
-                // marshal message to output stream
-                final ProtocolMessageMarshaller<ProtocolMessage> marshaller = protocolContext.createMarshaller();
-                marshaller.marshal(msg, socket.getOutputStream());
-            } catch(final IOException ioe) {
-                throw new ProtocolException("Failed marshalling '" + msg.getType() + "' protocol message due to: " + ioe, ioe);
-            } 
-            
-            final ProtocolMessage response;
-            try {
-                // unmarshall response and return
-                final ProtocolMessageUnmarshaller<ProtocolMessage> unmarshaller = protocolContext.createUnmarshaller();
-                response = unmarshaller.unmarshal(socket.getInputStream());
-            } catch(final IOException ioe) {
-                throw new ProtocolException("Failed unmarshalling '" + MessageType.CONNECTION_RESPONSE + "' protocol message due to: " + ioe, ioe);
-            } 
-            
-            if(MessageType.CONNECTION_RESPONSE == response.getType()) {
-                final ConnectionResponseMessage connectionResponse = (ConnectionResponseMessage) response;
-                connectionResponse.setClusterManagerDN(ncmDn);
-                return connectionResponse;
-            } else {
-                throw new ProtocolException("Expected message type '" + MessageType.CONNECTION_RESPONSE + "' but found '" + response.getType() + "'");
-            }
-        } finally {
-            SocketUtils.closeQuietly(socket);
-        }
-    }
-    
-    
-    @Override
-    public void heartbeat(final HeartbeatMessage msg) throws ProtocolException, UnknownServiceAddressException {
-        sendProtocolMessage(msg);
-    }
-
-    @Override
-    public void sendBulletins(NodeBulletinsMessage msg) throws ProtocolException, UnknownServiceAddressException {
-        sendProtocolMessage(msg);
-    }
-
-    @Override
-    public void notifyControllerStartupFailure(final ControllerStartupFailureMessage msg) throws ProtocolException, UnknownServiceAddressException {
-        sendProtocolMessage(msg);
-    }
-
-    @Override
-    public void notifyReconnectionFailure(ReconnectionFailureMessage msg) throws ProtocolException, UnknownServiceAddressException {
-        sendProtocolMessage(msg);
-    }
-    
-    private Socket createSocket() {
-        // determine the cluster manager's address
-        final DiscoverableService service = clusterManagerProtocolServiceLocator.getService(); 
-        if(service == null) {
-            throw new UnknownServiceAddressException("Cluster Manager's service is not known.  Verify a cluster manager is running.");
-        }
-        
-        try {
-            // create a socket
-            return SocketUtils.createSocket(service.getServiceAddress(), socketConfiguration); 
-        } catch(final IOException ioe) {
-            throw new ProtocolException("Failed to create socket due to: " + ioe, ioe);
-        }
-    }
-    
-    private void sendProtocolMessage(final ProtocolMessage msg) {
-        Socket socket = null;
-        try {
-            socket = createSocket();
-
-            try {
-                // marshal message to output stream
-                final ProtocolMessageMarshaller<ProtocolMessage> marshaller = protocolContext.createMarshaller();
-                marshaller.marshal(msg, socket.getOutputStream());
-            } catch(final IOException ioe) {
-                throw new ProtocolException("Failed marshalling '" + msg.getType() + "' protocol message due to: " + ioe, ioe);
-            }
-        } finally {
-            SocketUtils.closeQuietly(socket);
-        }
-    }
-    
-    public SocketConfiguration getSocketConfiguration() {
-        return socketConfiguration;
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/NodeProtocolSenderListener.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/NodeProtocolSenderListener.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/NodeProtocolSenderListener.java
deleted file mode 100644
index 4b359f4..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/NodeProtocolSenderListener.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * 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.nifi.cluster.protocol.impl;
-
-import java.io.IOException;
-import java.util.Collection;
-
-import org.apache.nifi.cluster.protocol.NodeProtocolSender;
-import org.apache.nifi.cluster.protocol.ProtocolException;
-import org.apache.nifi.cluster.protocol.ProtocolHandler;
-import org.apache.nifi.cluster.protocol.ProtocolListener;
-import org.apache.nifi.cluster.protocol.UnknownServiceAddressException;
-import org.apache.nifi.cluster.protocol.message.NodeBulletinsMessage;
-import org.apache.nifi.cluster.protocol.message.ConnectionRequestMessage;
-import org.apache.nifi.cluster.protocol.message.ConnectionResponseMessage;
-import org.apache.nifi.cluster.protocol.message.ControllerStartupFailureMessage;
-import org.apache.nifi.cluster.protocol.message.HeartbeatMessage;
-import org.apache.nifi.cluster.protocol.message.ReconnectionFailureMessage;
-import org.apache.nifi.reporting.BulletinRepository;
-
-public class NodeProtocolSenderListener implements NodeProtocolSender, ProtocolListener {
-    
-    private final NodeProtocolSender sender;
-    private final ProtocolListener listener;
-    
-    public NodeProtocolSenderListener(final NodeProtocolSender sender, final ProtocolListener listener) {
-        if(sender == null) {
-            throw new IllegalArgumentException("NodeProtocolSender may not be null.");
-        } else if(listener == null) {
-            throw new IllegalArgumentException("ProtocolListener may not be null.");
-        }
-        this.sender = sender;
-        this.listener = listener;
-    }
-
-    @Override
-    public void stop() throws IOException {
-        if(!isRunning()) {
-            throw new IllegalStateException("Instance is already stopped.");
-        }
-        listener.stop();
-    }
-
-    @Override
-    public void start() throws IOException {
-        if(isRunning()) {
-            throw new IllegalStateException("Instance is already started.");
-        }
-        listener.start();
-    }
-
-    @Override
-    public boolean isRunning() {
-        return listener.isRunning();
-    }
-
-    @Override
-    public boolean removeHandler(final ProtocolHandler handler) {
-        return listener.removeHandler(handler);
-    }
-
-    @Override
-    public Collection<ProtocolHandler> getHandlers() {
-        return listener.getHandlers();
-    }
-
-    @Override
-    public void addHandler(final ProtocolHandler handler) {
-        listener.addHandler(handler);
-    }
-
-    @Override
-    public void heartbeat(final HeartbeatMessage msg) throws ProtocolException, UnknownServiceAddressException {
-        sender.heartbeat(msg);
-    }
-
-    @Override
-    public ConnectionResponseMessage requestConnection(final ConnectionRequestMessage msg) throws ProtocolException, UnknownServiceAddressException {
-        return sender.requestConnection(msg);
-    }
-    
-    @Override
-    public void notifyControllerStartupFailure(final ControllerStartupFailureMessage msg) throws ProtocolException, UnknownServiceAddressException {
-        sender.notifyControllerStartupFailure(msg);
-    }
-    
-    @Override
-    public void notifyReconnectionFailure(final ReconnectionFailureMessage msg) throws ProtocolException, UnknownServiceAddressException {
-        sender.notifyReconnectionFailure(msg);
-    }
-
-    @Override
-    public void sendBulletins(NodeBulletinsMessage msg) throws ProtocolException, UnknownServiceAddressException {
-        sender.sendBulletins(msg);
-    }
-
-    @Override
-    public void setBulletinRepository(final BulletinRepository bulletinRepository) {
-        listener.setBulletinRepository(bulletinRepository);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/SocketProtocolListener.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/SocketProtocolListener.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/SocketProtocolListener.java
deleted file mode 100644
index ca30d9b..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/SocketProtocolListener.java
+++ /dev/null
@@ -1,205 +0,0 @@
-/*
- * 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.nifi.cluster.protocol.impl;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.Socket;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.UUID;
-import java.util.concurrent.CopyOnWriteArrayList;
-import java.util.concurrent.TimeUnit;
-
-import javax.net.ssl.SSLSocket;
-import javax.security.cert.X509Certificate;
-
-import org.apache.nifi.cluster.protocol.ProtocolContext;
-import org.apache.nifi.cluster.protocol.ProtocolException;
-import org.apache.nifi.cluster.protocol.ProtocolHandler;
-import org.apache.nifi.cluster.protocol.ProtocolListener;
-import org.apache.nifi.cluster.protocol.ProtocolMessageMarshaller;
-import org.apache.nifi.cluster.protocol.ProtocolMessageUnmarshaller;
-import org.apache.nifi.cluster.protocol.message.ProtocolMessage;
-import org.apache.nifi.events.BulletinFactory;
-import org.apache.nifi.io.socket.ServerSocketConfiguration;
-import org.apache.nifi.io.socket.SocketListener;
-import org.apache.nifi.logging.NiFiLog;
-import org.apache.nifi.reporting.Bulletin;
-import org.apache.nifi.reporting.BulletinRepository;
-import org.apache.nifi.util.StopWatch;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Implements a listener for protocol messages sent over unicast socket. 
- * 
- * @author unattributed
- */
-public class SocketProtocolListener extends SocketListener implements ProtocolListener {
-
-    private static final Logger logger = new NiFiLog(LoggerFactory.getLogger(SocketProtocolListener.class));
-    private final ProtocolContext<ProtocolMessage> protocolContext;
-    private final Collection<ProtocolHandler> handlers = new CopyOnWriteArrayList<>();
-    private volatile BulletinRepository bulletinRepository;
-    
-    public SocketProtocolListener(
-            final int numThreads,
-            final int port,
-            final ServerSocketConfiguration configuration,
-            final ProtocolContext<ProtocolMessage> protocolContext) {
-
-        super(numThreads, port, configuration);
-        
-        if(protocolContext == null) {
-            throw new IllegalArgumentException("Protocol Context may not be null.");
-        }
-        
-        this.protocolContext = protocolContext;
-    }
-
-    @Override
-    public void setBulletinRepository(final BulletinRepository bulletinRepository) {
-        this.bulletinRepository = bulletinRepository;
-    }
-    
-    @Override
-    public void start() throws IOException {
-
-        if(super.isRunning()) {
-            throw new IllegalStateException("Instance is already started.");
-        }
-        
-        super.start();
-    }
-
-    @Override
-    public void stop() throws IOException {
-
-        if(super.isRunning() == false) {
-            throw new IOException("Instance is already stopped.");
-        }
-        
-        super.stop();
-
-    }
-
-    @Override
-    public Collection<ProtocolHandler> getHandlers() {
-        return Collections.unmodifiableCollection(handlers);
-    }
-
-    @Override
-    public void addHandler(final ProtocolHandler handler) {
-        if(handler == null) {
-            throw new NullPointerException("Protocol handler may not be null.");
-        }
-        handlers.add(handler);
-    }
-    
-    @Override
-    public boolean removeHandler(final ProtocolHandler handler) {
-        return handlers.remove(handler);
-    }
-
-    @Override
-    public void dispatchRequest(final Socket socket) {
-        byte[] receivedMessage = null;
-        String hostname = null;
-        final int maxMsgBuffer = 1024 * 1024;   // don't buffer more than 1 MB of the message
-        try {
-            final StopWatch stopWatch = new StopWatch(true);
-            hostname = socket.getInetAddress().getHostName();
-            final String requestId = UUID.randomUUID().toString();
-            logger.info("Received request {} from {}", requestId, hostname);
-            
-            String requestorDn = null;
-            if ( socket instanceof SSLSocket ) {
-                final SSLSocket sslSocket = (SSLSocket) socket;
-                try {
-                    final X509Certificate[] certChains = sslSocket.getSession().getPeerCertificateChain();
-                    if ( certChains != null && certChains.length > 0 ) {
-                        requestorDn = certChains[0].getSubjectDN().getName();
-                    }
-                } catch (final ProtocolException pe) {
-                    throw pe;
-                } catch (final Exception e) {
-                    throw new ProtocolException(e);
-                }
-            }
-            
-            // unmarshall message
-            final ProtocolMessageUnmarshaller<ProtocolMessage> unmarshaller = protocolContext.createUnmarshaller();
-            final InputStream inStream = socket.getInputStream();
-            final CopyingInputStream copyingInputStream = new CopyingInputStream(inStream, maxMsgBuffer); // don't copy more than 1 MB
-            logger.debug("Request {} has a message length of {}", requestId, copyingInputStream.getNumberOfBytesCopied());
-            
-            final ProtocolMessage request;
-            try {
-                request = unmarshaller.unmarshal(copyingInputStream);
-            } finally {
-                receivedMessage = copyingInputStream.getBytesRead();
-            }
-            
-            request.setRequestorDN(requestorDn);
-            
-            // dispatch message to handler
-            ProtocolHandler desiredHandler = null;
-            for (final ProtocolHandler handler : getHandlers()) {
-                if (handler.canHandle(request)) {
-                    desiredHandler = handler;
-                    break;
-                }
-            }
-
-            // if no handler found, throw exception; otherwise handle request
-            if (desiredHandler == null) {
-                throw new ProtocolException("No handler assigned to handle message type: " + request.getType());
-            } else {
-                final ProtocolMessage response = desiredHandler.handle(request);
-                if(response != null) {
-                    try {
-                        logger.debug("Sending response for request {}", requestId);
-                            
-                        // marshal message to output stream
-                        final ProtocolMessageMarshaller<ProtocolMessage> marshaller = protocolContext.createMarshaller();
-                        marshaller.marshal(response, socket.getOutputStream());
-                    } catch (final IOException ioe) {
-                        throw new ProtocolException("Failed marshalling protocol message in response to message type: " + request.getType() + " due to " + ioe, ioe);
-                    }
-                }
-            }
-            
-            stopWatch.stop();
-            logger.info("Finished processing request {} (type={}, length={} bytes) in {} millis", requestId, request.getType(), receivedMessage.length, stopWatch.getDuration(TimeUnit.MILLISECONDS));
-        } catch (final IOException e) {
-            logger.warn("Failed processing protocol message from " + hostname + " due to " + e, e);
-            
-            if ( bulletinRepository != null ) {
-                final Bulletin bulletin = BulletinFactory.createBulletin("Clustering", "WARNING", String.format("Failed to process protocol message from %s due to: %s", hostname, e.toString()));
-                bulletinRepository.addBulletin(bulletin);
-            }
-        } catch (final ProtocolException e) {
-            logger.warn("Failed processing protocol message from " + hostname + " due to " + e, e);
-            if ( bulletinRepository != null ) {
-                final Bulletin bulletin = BulletinFactory.createBulletin("Clustering", "WARNING", String.format("Failed to process protocol message from %s due to: %s", hostname, e.toString()));
-                bulletinRepository.addBulletin(bulletin);
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/JaxbProtocolContext.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/JaxbProtocolContext.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/JaxbProtocolContext.java
deleted file mode 100644
index bc68630..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/JaxbProtocolContext.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * 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.nifi.cluster.protocol.jaxb;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
-import java.io.EOFException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.nio.ByteBuffer;
-
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Marshaller;
-import javax.xml.bind.Unmarshaller;
-
-import org.apache.nifi.cluster.protocol.ProtocolContext;
-import org.apache.nifi.cluster.protocol.ProtocolMessageMarshaller;
-import org.apache.nifi.cluster.protocol.ProtocolMessageUnmarshaller;
-
-/**
- * Implements a context for communicating internally amongst the cluster using
- * JAXB.
- * 
- * @param <T> The type of protocol message.
- *
- * @author unattributed
- */
-public class JaxbProtocolContext<T> implements ProtocolContext {
-
-    private static final int BUF_SIZE = (int) Math.pow(2, 10);  // 1k
-    
-    /*
-     * A sentinel is used to detect corrupted messages.  Relying on the integrity
-     * of the message size can cause memory issues if the value is corrupted 
-     * and equal to a number larger than the memory size.
-     */
-    private static final byte MESSAGE_PROTOCOL_START_SENTINEL = 0x5A;
-    
-    private final JAXBContext jaxbCtx;
-    
-    public JaxbProtocolContext(final JAXBContext jaxbCtx) {
-        this.jaxbCtx = jaxbCtx;
-    }
-    
-    @Override
-    public ProtocolMessageMarshaller<T> createMarshaller() {
-        return new ProtocolMessageMarshaller<T>() {
-
-            @Override
-            public void marshal(final T msg, final OutputStream os) throws IOException {
-
-                try {
-
-                    // marshal message to output stream
-                    final Marshaller marshaller = jaxbCtx.createMarshaller();
-                    final ByteArrayOutputStream msgBytes = new ByteArrayOutputStream();
-                    marshaller.marshal(msg, msgBytes);
-
-                    final DataOutputStream dos = new DataOutputStream(os);
-
-                    // write message protocol sentinel
-                    dos.write(MESSAGE_PROTOCOL_START_SENTINEL);
-                    
-                    // write message size in bytes
-                    dos.writeInt(msgBytes.size());
-
-                    // write message
-                    dos.write(msgBytes.toByteArray());
-
-                    dos.flush();
-
-                } catch (final JAXBException je) {
-                    throw new IOException("Failed marshalling protocol message due to: " + je, je);
-                }
-
-            }
-        };
-    }
-
-    @Override
-    public ProtocolMessageUnmarshaller<T> createUnmarshaller() {
-        return new ProtocolMessageUnmarshaller<T>() {
-
-            @Override
-            public T unmarshal(final InputStream is) throws IOException {
-
-                try {
-
-                    final DataInputStream dis = new DataInputStream(is);
-
-                    // check for the presence of the message protocol sentinel
-                    final byte sentinel = (byte) dis.read();
-                    if ( sentinel == -1 ) {
-                        throw new EOFException();
-                    }
-
-                    if(MESSAGE_PROTOCOL_START_SENTINEL != sentinel) {
-                        throw new IOException("Failed reading protocol message due to malformed header");
-                    }
-                    
-                    // read the message size
-                    final int msgBytesSize = dis.readInt();
-
-                    // read the message
-                    final ByteBuffer buffer = ByteBuffer.allocate(msgBytesSize);
-                    int totalBytesRead = 0;
-                    do {
-                        final int bytesToRead;
-                        if ((msgBytesSize - totalBytesRead) >= BUF_SIZE) {
-                            bytesToRead = BUF_SIZE;
-                        } else {
-                            bytesToRead = msgBytesSize - totalBytesRead;
-                        }
-                        totalBytesRead += dis.read(buffer.array(), totalBytesRead, bytesToRead);
-                    } while (totalBytesRead < msgBytesSize);
-
-                    // unmarshall message and return
-                    final Unmarshaller unmarshaller = jaxbCtx.createUnmarshaller();
-                    final byte[] msg = new byte[totalBytesRead];
-                    buffer.get(msg);
-                    return (T) unmarshaller.unmarshal(new ByteArrayInputStream(msg));
-
-                } catch (final JAXBException je) {
-                    throw new IOException("Failed unmarshalling protocol message due to: " + je, je);
-                }
-
-            }
-        };
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/AdaptedConnectionRequest.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/AdaptedConnectionRequest.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/AdaptedConnectionRequest.java
deleted file mode 100644
index d9de24f..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/AdaptedConnectionRequest.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * 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.nifi.cluster.protocol.jaxb.message;
-
-import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
-import org.apache.nifi.cluster.protocol.NodeIdentifier;
-
-/**
- * @author unattributed
- */
-public class AdaptedConnectionRequest {
-    
-    private NodeIdentifier nodeIdentifier;
-    
-    public AdaptedConnectionRequest() {}
-
-    @XmlJavaTypeAdapter(NodeIdentifierAdapter.class)
-    public NodeIdentifier getNodeIdentifier() {
-        return nodeIdentifier;
-    }
-
-    public void setNodeIdentifier(final NodeIdentifier nodeIdentifier) {
-        this.nodeIdentifier = nodeIdentifier;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/AdaptedConnectionResponse.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/AdaptedConnectionResponse.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/AdaptedConnectionResponse.java
deleted file mode 100644
index c7c783b..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/AdaptedConnectionResponse.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * 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.nifi.cluster.protocol.jaxb.message;
-
-import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
-
-import org.apache.nifi.cluster.protocol.NodeIdentifier;
-import org.apache.nifi.cluster.protocol.StandardDataFlow;
-
-/**
- * @author unattributed
- */
-public class AdaptedConnectionResponse {
-    
-    private StandardDataFlow dataFlow;
-    private NodeIdentifier nodeIdentifier;
-    private boolean blockedByFirewall;
-    private boolean primary;
-    private int tryLaterSeconds;
-    private Integer managerRemoteInputPort;
-    private Boolean managerRemoteCommsSecure;
-    private String instanceId;
-    
-    public AdaptedConnectionResponse() {}
-
-    @XmlJavaTypeAdapter(DataFlowAdapter.class)
-    public StandardDataFlow getDataFlow() {
-        return dataFlow;
-    }
-
-    public void setDataFlow(StandardDataFlow dataFlow) {
-        this.dataFlow = dataFlow;
-    }
-
-    @XmlJavaTypeAdapter(NodeIdentifierAdapter.class)
-    public NodeIdentifier getNodeIdentifier() {
-        return nodeIdentifier;
-    }
-
-    public void setNodeIdentifier(NodeIdentifier nodeIdentifier) {
-        this.nodeIdentifier = nodeIdentifier;
-    }
-
-    public int getTryLaterSeconds() {
-        return tryLaterSeconds;
-    }
-
-    public void setTryLaterSeconds(int tryLaterSeconds) {
-        this.tryLaterSeconds = tryLaterSeconds;
-    }
-
-    public boolean isBlockedByFirewall() {
-        return blockedByFirewall;
-    }
-
-    public void setBlockedByFirewall(boolean blockedByFirewall) {
-        this.blockedByFirewall = blockedByFirewall;
-    }
-
-    public boolean isPrimary() {
-        return primary;
-    }
-
-    public void setPrimary(boolean primary) {
-        this.primary = primary;
-    }
-
-    public boolean shouldTryLater() {
-        return tryLaterSeconds > 0;
-    }
-    
-    public void setManagerRemoteInputPort(Integer managerRemoteInputPort) {
-        this.managerRemoteInputPort = managerRemoteInputPort;
-    }
-    
-    public Integer getManagerRemoteInputPort() {
-        return managerRemoteInputPort;
-    }
-    
-    public void setManagerRemoteCommsSecure(Boolean secure) {
-        this.managerRemoteCommsSecure = secure;
-    }
-    
-    public Boolean isManagerRemoteCommsSecure() {
-        return managerRemoteCommsSecure;
-    }
-    
-    public void setInstanceId(String instanceId) {
-        this.instanceId = instanceId;
-    }
-    
-    public String getInstanceId() {
-        return instanceId;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/AdaptedCounter.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/AdaptedCounter.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/AdaptedCounter.java
deleted file mode 100644
index 89d903b..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/AdaptedCounter.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * 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.nifi.cluster.protocol.jaxb.message;
-
-/**
- * @author unattributed
- */
-public class AdaptedCounter {
-    
-    private String groupName;
-    
-    private String name;
-    
-    private long value;
-
-    public AdaptedCounter() {}
-
-    public String getGroupName() {
-        return groupName;
-    }
-
-    public void setGroupName(String counterGroupName) {
-        this.groupName = counterGroupName;
-    }
-
-    public String getName() {
-        return name;
-    }
-
-    public void setName(String counterName) {
-        this.name = counterName;
-    }
-
-    public long getValue() {
-        return value;
-    }
-
-    public void setValue(long value) {
-        this.value = value;
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/AdaptedDataFlow.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/AdaptedDataFlow.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/AdaptedDataFlow.java
deleted file mode 100644
index bb97619..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/AdaptedDataFlow.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * 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.nifi.cluster.protocol.jaxb.message;
-
-/**
- * @author unattributed
- */
-public class AdaptedDataFlow {
-    
-    private byte[] flow;
-    private byte[] templates;
-    private byte[] snippets;
-    
-    private boolean autoStartProcessors;
-    
-    public AdaptedDataFlow() {}
-
-    public byte[] getFlow() {
-        return flow;
-    }
-
-    public void setFlow(byte[] flow) {
-        this.flow = flow;
-    }
-
-    public byte[] getTemplates() {
-        return templates;
-    }
-
-    public void setTemplates(byte[] templates) {
-        this.templates = templates;
-    }
-
-    public byte[] getSnippets() {
-        return snippets;
-    }
-
-    public void setSnippets(byte[] snippets) {
-        this.snippets = snippets;
-    }
-
-    public boolean isAutoStartProcessors() {
-        return autoStartProcessors;
-    }
-
-    public void setAutoStartProcessors(boolean runningAllProcessors) {
-        this.autoStartProcessors = runningAllProcessors;
-    }
-
-}


[17/20] incubator-nifi git commit: NIFI-410 pushed RAT exclusions down to the relevant modules and stopped doing broad test resource exclusion - is now specific

Posted by jo...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/resources/nifi-cluster-protocol-context.xml
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/resources/nifi-cluster-protocol-context.xml b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/resources/nifi-cluster-protocol-context.xml
deleted file mode 100644
index 07ea7a4..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/resources/nifi-cluster-protocol-context.xml
+++ /dev/null
@@ -1,110 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-  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.
--->
-<!-- marked as lazy so that cluster protocol beans are not created when applications runs in standalone mode -->
-<beans default-lazy-init="true"
-       xmlns="http://www.springframework.org/schema/beans"
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-       xmlns:util="http://www.springframework.org/schema/util"
-       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
-        http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.1.xsd">
-
-    <!-- protocol context -->
-    <bean id="protocolContext" class="org.apache.nifi.cluster.protocol.jaxb.JaxbProtocolContext">
-        <constructor-arg>
-            <util:constant static-field="org.apache.nifi.cluster.protocol.jaxb.message.JaxbProtocolUtils.JAXB_CONTEXT"/>
-        </constructor-arg>
-    </bean>
-    
-    <!-- socket configuration -->
-    <bean id="protocolSocketConfiguration" class="org.apache.nifi.cluster.protocol.spring.SocketConfigurationFactoryBean">
-        <property name="properties" ref="nifiProperties"/>
-    </bean>
-    
-    <!-- server socket configuration -->
-    <bean id="protocolServerSocketConfiguration" class="org.apache.nifi.cluster.protocol.spring.ServerSocketConfigurationFactoryBean">
-        <property name="properties" ref="nifiProperties"/>
-    </bean>
-    
-    <!-- multicast configuration -->
-    <bean id="protocolMulticastConfiguration" class="org.apache.nifi.cluster.protocol.spring.MulticastConfigurationFactoryBean">
-        <property name="properties" ref="nifiProperties"/>
-    </bean>
-
-    <!-- cluster manager protocol sender -->
-    <bean id="clusterManagerProtocolSender" class="org.apache.nifi.cluster.protocol.impl.ClusterManagerProtocolSenderImpl">
-        <constructor-arg ref="protocolSocketConfiguration"/>
-        <constructor-arg ref="protocolContext"/>
-        <property name="handshakeTimeout">
-            <bean factory-bean="nifiProperties" factory-method="getClusterProtocolConnectionHandshakeTimeout"/>
-        </property>
-    </bean>
-    
-    <!-- cluster manager protocol listener -->
-    <bean id="clusterManagerProtocolListener" class="org.apache.nifi.cluster.protocol.impl.SocketProtocolListener">
-        <constructor-arg index="0">
-            <bean factory-bean="nifiProperties" factory-method="getClusterManagerProtocolThreads"/>
-        </constructor-arg>
-        <constructor-arg index="1">
-            <bean factory-bean="nifiProperties" factory-method="getClusterManagerProtocolPort"/>
-        </constructor-arg>
-        <constructor-arg ref="protocolServerSocketConfiguration" index="2"/>
-        <constructor-arg ref="protocolContext" index="3"/>
-    </bean>
-    
-    <!-- cluster manager sender/listener -->
-    <bean id="clusterManagerProtocolSenderListener" class="org.apache.nifi.cluster.protocol.impl.ClusterManagerProtocolSenderListener">
-        <constructor-arg ref="clusterManagerProtocolSender"/>
-        <constructor-arg ref="clusterManagerProtocolListener"/>
-    </bean>
-    
-    <!-- node protocol sender -->
-    <bean id="nodeProtocolSender" class="org.apache.nifi.cluster.protocol.impl.NodeProtocolSenderImpl">
-        <constructor-arg ref="clusterManagerProtocolServiceLocator"/>
-        <constructor-arg ref="protocolSocketConfiguration"/>
-        <constructor-arg ref="protocolContext"/>
-    </bean>
-    
-    <!-- node protocol listener -->
-    <bean id="nodeProtocolListener" class="org.apache.nifi.cluster.protocol.impl.SocketProtocolListener">
-        <constructor-arg index="0">
-            <bean factory-bean="nifiProperties" factory-method="getClusterNodeProtocolThreads"/>
-        </constructor-arg>
-        <constructor-arg index="1">
-            <bean factory-bean="nifiProperties" factory-method="getClusterNodeProtocolPort"/>
-        </constructor-arg>
-        <constructor-arg ref="protocolServerSocketConfiguration" index="2"/>
-        <constructor-arg ref="protocolContext" index="3"/>
-    </bean>
-    
-    <!-- node sender/listener -->
-    <bean id="nodeProtocolSenderListener" class="org.apache.nifi.cluster.protocol.impl.NodeProtocolSenderListener">
-        <constructor-arg ref="nodeProtocolSender"/>
-        <constructor-arg ref="nodeProtocolListener"/>
-    </bean>
-    
-    <!-- cluster services broadcaster -->
-    <bean id="clusterServicesBroadcaster" class="org.apache.nifi.cluster.protocol.impl.ClusterServicesBroadcaster">
-        <constructor-arg index="0">
-            <bean factory-bean="nifiProperties" factory-method="getClusterProtocolMulticastAddress"/>
-        </constructor-arg>
-        <constructor-arg ref="protocolMulticastConfiguration" index="1"/>
-        <constructor-arg ref="protocolContext" index="2"/>
-        <constructor-arg index="3">
-            <bean factory-bean="nifiProperties" factory-method="getClusterProtocolMulticastServiceBroadcastDelay"/>
-        </constructor-arg>
-    </bean>
- 
-</beans>

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/ClusterManagerProtocolSenderImplTest.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/ClusterManagerProtocolSenderImplTest.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/ClusterManagerProtocolSenderImplTest.java
deleted file mode 100644
index 59837c1..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/ClusterManagerProtocolSenderImplTest.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * 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.nifi.cluster.protocol.impl;
-
-import org.apache.nifi.cluster.protocol.impl.SocketProtocolListener;
-import org.apache.nifi.cluster.protocol.impl.ClusterManagerProtocolSenderImpl;
-import java.io.IOException;
-import java.net.InetAddress;
-import org.apache.nifi.cluster.protocol.NodeIdentifier;
-import org.apache.nifi.cluster.protocol.ProtocolContext;
-import org.apache.nifi.cluster.protocol.ProtocolException;
-import org.apache.nifi.cluster.protocol.ProtocolHandler;
-import org.apache.nifi.cluster.protocol.jaxb.JaxbProtocolContext;
-import org.apache.nifi.cluster.protocol.jaxb.message.JaxbProtocolUtils;
-import org.apache.nifi.cluster.protocol.message.FlowRequestMessage;
-import org.apache.nifi.cluster.protocol.message.FlowResponseMessage;
-import org.apache.nifi.cluster.protocol.message.PingMessage;
-import org.apache.nifi.cluster.protocol.message.ProtocolMessage;
-import org.apache.nifi.io.socket.ServerSocketConfiguration;
-import org.apache.nifi.io.socket.SocketConfiguration;
-import org.junit.After;
-import static org.junit.Assert.*;
-import org.junit.Before;
-import org.junit.Test;
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.*;
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.stubbing.Answer;
-
-/**
- * @author unattributed
- */
-public class ClusterManagerProtocolSenderImplTest {
-    
-    private InetAddress address;
-    
-    private int port;
-    
-    private SocketProtocolListener listener;
-    
-    private ClusterManagerProtocolSenderImpl sender;
-    
-    private ProtocolHandler mockHandler;
-    
-    @Before
-    public void setup() throws IOException {
-        
-        address = InetAddress.getLocalHost();
-        ServerSocketConfiguration serverSocketConfiguration = new ServerSocketConfiguration();
-        serverSocketConfiguration.setSocketTimeout(2000);
-
-        mockHandler = mock(ProtocolHandler.class);
-        
-        ProtocolContext protocolContext = new JaxbProtocolContext(JaxbProtocolUtils.JAXB_CONTEXT);
-        
-        listener = new SocketProtocolListener(5, 0, serverSocketConfiguration, protocolContext);
-        listener.addHandler(mockHandler);
-        listener.start();
-        
-        port = listener.getPort();
-        
-        SocketConfiguration socketConfiguration = new SocketConfiguration();
-        sender = new ClusterManagerProtocolSenderImpl(socketConfiguration, protocolContext);
-    }
-    
-    @After
-    public void teardown() throws IOException {
-        if(listener.isRunning()) {
-            listener.stop();
-        }
-    }
-    
-    @Test
-    public void testRequestFlow() throws Exception {
-        
-        when(mockHandler.canHandle(any(ProtocolMessage.class))).thenReturn(Boolean.TRUE);
-        when(mockHandler.handle(any(ProtocolMessage.class))).thenReturn(new FlowResponseMessage());
-        FlowRequestMessage request = new FlowRequestMessage();
-        request.setNodeId(new NodeIdentifier("id", "api-address", 1, address.getHostAddress(), port));
-        FlowResponseMessage response = sender.requestFlow(request);
-        assertNotNull(response);
-    }
-    
-    @Test
-    public void testRequestFlowWithBadResponseMessage() throws Exception {
-        
-        when(mockHandler.canHandle(any(ProtocolMessage.class))).thenReturn(Boolean.TRUE);
-        when(mockHandler.handle(any(ProtocolMessage.class))).thenReturn(new PingMessage());
-        FlowRequestMessage request = new FlowRequestMessage();
-        request.setNodeId(new NodeIdentifier("id", "api-address", 1, address.getHostAddress(), port));
-        try {
-            sender.requestFlow(request);
-            fail("failed to throw exception");
-        } catch(ProtocolException pe) {}
-        
-    }
-    
-    @Test
-    public void testRequestFlowDelayedResponse() throws Exception {
-        
-        final int time = 250;
-        sender.getSocketConfiguration().setSocketTimeout(time);
-        
-        when(mockHandler.canHandle(any(ProtocolMessage.class))).thenReturn(Boolean.TRUE);
-        when(mockHandler.handle(any(ProtocolMessage.class))).thenAnswer(new Answer<FlowResponseMessage>() {
-            @Override
-            public FlowResponseMessage answer(InvocationOnMock invocation) throws Throwable {
-                Thread.sleep(time * 3);
-                return new FlowResponseMessage();
-            }
-        });
-        FlowRequestMessage request = new FlowRequestMessage();
-        request.setNodeId(new NodeIdentifier("id", "api-address", 1, address.getHostAddress(), port));
-        try {
-            sender.requestFlow(request);
-            fail("failed to throw exception");
-        } catch(ProtocolException pe) {}
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/ClusterServiceDiscoveryTest.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/ClusterServiceDiscoveryTest.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/ClusterServiceDiscoveryTest.java
deleted file mode 100644
index e3703e2..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/ClusterServiceDiscoveryTest.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * 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.nifi.cluster.protocol.impl;
-
-import org.apache.nifi.cluster.protocol.impl.ClusterServiceDiscovery;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.net.DatagramPacket;
-import java.net.InetSocketAddress;
-import java.net.MulticastSocket;
-import org.apache.nifi.cluster.protocol.ProtocolContext;
-import org.apache.nifi.cluster.protocol.ProtocolMessageMarshaller;
-import org.apache.nifi.cluster.protocol.jaxb.JaxbProtocolContext;
-import org.apache.nifi.cluster.protocol.jaxb.message.JaxbProtocolUtils;
-import org.apache.nifi.cluster.protocol.message.PingMessage;
-import org.apache.nifi.cluster.protocol.message.ProtocolMessage;
-import org.apache.nifi.cluster.protocol.message.ServiceBroadcastMessage;
-import org.apache.nifi.io.socket.multicast.MulticastConfiguration;
-import org.apache.nifi.io.socket.multicast.MulticastUtils;
-import org.junit.After;
-import static org.junit.Assert.*;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-
-/**
- * @author unattributed
- */
-public class ClusterServiceDiscoveryTest {
-    
-    private ClusterServiceDiscovery discovery;
-    
-    private String serviceName;
-    
-    private MulticastSocket socket;
-    
-    private InetSocketAddress multicastAddress;
-    
-    private MulticastConfiguration configuration;
-    
-    private ProtocolContext protocolContext;
-    
-    @Before
-    public void setup() throws Exception {
-
-        serviceName = "some-service";
-        multicastAddress = new InetSocketAddress("225.1.1.1", 22222);
-        configuration = new MulticastConfiguration();
-        
-        protocolContext = new JaxbProtocolContext(JaxbProtocolUtils.JAXB_CONTEXT);
-        
-        discovery = new ClusterServiceDiscovery(serviceName, multicastAddress, configuration, protocolContext);
-        discovery.start();
-
-        socket = MulticastUtils.createMulticastSocket(multicastAddress.getPort(), configuration);
-    }
-    
-    @After
-    public void teardown() throws IOException {
-        try {
-            if(discovery.isRunning()) {
-                discovery.stop();
-            }
-        } finally {
-            MulticastUtils.closeQuietly(socket);
-        }
-    }
-    
-    @Ignore("Test needs to be fixed.  Requires an active network connection")
-    @Test
-    public void testGetAddressOnStartup() {
-        assertNull(discovery.getService());
-    }   
-            
-    @Ignore("This test has an NPE after ignoring another...perhaps has a bad inter-test dependency")
-    @Test
-    public void testGetAddressAfterBroadcast() throws Exception {
-        
-        ServiceBroadcastMessage msg = new ServiceBroadcastMessage();
-        msg.setServiceName("some-service");
-        msg.setAddress("3.3.3.3");
-        msg.setPort(1234);
-        
-        // marshal message to output stream
-        ProtocolMessageMarshaller marshaller = protocolContext.createMarshaller();
-        ByteArrayOutputStream baos = new ByteArrayOutputStream();
-        marshaller.marshal(msg, baos);
-        byte[] requestPacketBytes = baos.toByteArray();
-        DatagramPacket packet = new DatagramPacket(requestPacketBytes, requestPacketBytes.length, multicastAddress);
-        socket.send(packet);
-        
-        Thread.sleep(250);
-       
-        InetSocketAddress updatedAddress = discovery.getService().getServiceAddress();
-        assertEquals("some-service", discovery.getServiceName());
-        assertEquals("3.3.3.3", updatedAddress.getHostName());
-        assertEquals(1234, updatedAddress.getPort());
-        
-    }
-    
-    @Ignore("Test needs to be fixed.  Requires an active network connection")
-    @Test
-    public void testBadBroadcastMessage() throws Exception {
-        
-        ProtocolMessage msg = new PingMessage();
-        
-        // marshal message to output stream
-        ProtocolMessageMarshaller marshaller = protocolContext.createMarshaller();
-        ByteArrayOutputStream baos = new ByteArrayOutputStream();
-        marshaller.marshal(msg, baos);
-        byte[] requestPacketBytes = baos.toByteArray();
-        DatagramPacket packet = new DatagramPacket(requestPacketBytes, requestPacketBytes.length, multicastAddress);
-        socket.send(packet);
-        
-        Thread.sleep(250);
-       
-        assertNull(discovery.getService());
-        
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/ClusterServiceLocatorTest.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/ClusterServiceLocatorTest.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/ClusterServiceLocatorTest.java
deleted file mode 100644
index b1c156b..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/ClusterServiceLocatorTest.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * 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.nifi.cluster.protocol.impl;
-
-import org.apache.nifi.cluster.protocol.impl.ClusterServiceLocator;
-import org.apache.nifi.cluster.protocol.impl.ClusterServiceDiscovery;
-import java.net.InetSocketAddress;
-import java.util.concurrent.TimeUnit;
-import org.apache.nifi.io.socket.multicast.DiscoverableService;
-import org.apache.nifi.io.socket.multicast.DiscoverableServiceImpl;
-import static org.junit.Assert.*;
-import org.junit.Before;
-import org.junit.Test;
-import static org.mockito.Mockito.*;
-import org.mockito.stubbing.OngoingStubbing;
-
-public class ClusterServiceLocatorTest {
-    
-    private ClusterServiceDiscovery mockServiceDiscovery;
-    
-    private int fixedPort;
-    
-    private DiscoverableService fixedService;
-    
-    private ClusterServiceLocator serviceDiscoveryLocator;
-    
-    private ClusterServiceLocator serviceDiscoveryFixedPortLocator;
-    
-    private ClusterServiceLocator fixedServiceLocator;
-    
-    @Before
-    public void setup() throws Exception {
-        
-        fixedPort = 1;
-        mockServiceDiscovery = mock(ClusterServiceDiscovery.class);
-        fixedService = new DiscoverableServiceImpl("some-service", InetSocketAddress.createUnresolved("some-host", 20));
-        
-        serviceDiscoveryLocator = new ClusterServiceLocator(mockServiceDiscovery);
-        serviceDiscoveryFixedPortLocator = new ClusterServiceLocator(mockServiceDiscovery, fixedPort);
-        fixedServiceLocator = new ClusterServiceLocator(fixedService);
-        
-    }
-    
-    @Test
-    public void getServiceWhenServiceDiscoveryNotStarted() {
-        assertNull(serviceDiscoveryLocator.getService());
-    }
-    
-    @Test
-    public void getServiceWhenServiceDiscoveryFixedPortNotStarted() {
-        assertNull(serviceDiscoveryLocator.getService());
-    }
-    
-    @Test
-    public void getServiceWhenFixedServiceNotStarted() {
-        assertEquals(fixedService, fixedServiceLocator.getService());
-    }
-    
-    @Test
-    public void getServiceNotOnFirstAttempt() {
-                
-        ClusterServiceLocator.AttemptsConfig config = new ClusterServiceLocator.AttemptsConfig();
-        config.setNumAttempts(2);
-        config.setTimeBetweenAttempsUnit(TimeUnit.SECONDS);
-        config.setTimeBetweenAttempts(1);
-        
-        serviceDiscoveryLocator.setAttemptsConfig(config);
-        
-        OngoingStubbing<DiscoverableService> stubbing = null;
-        for(int i = 0; i < config.getNumAttempts() - 1; i++) {
-            if(stubbing == null) {
-                stubbing = when(mockServiceDiscovery.getService()).thenReturn(null);
-            } else {
-                stubbing.thenReturn(null);
-            }
-        }
-        stubbing.thenReturn(fixedService);
-        
-        assertEquals(fixedService, serviceDiscoveryLocator.getService());
-        
-    }
-    
-    @Test
-    public void getServiceNotOnFirstAttemptWithFixedPort() {
-        
-        ClusterServiceLocator.AttemptsConfig config = new ClusterServiceLocator.AttemptsConfig();
-        config.setNumAttempts(2);
-        config.setTimeBetweenAttempsUnit(TimeUnit.SECONDS);
-        config.setTimeBetweenAttempts(1);
-        
-        serviceDiscoveryFixedPortLocator.setAttemptsConfig(config);
-        
-        OngoingStubbing<DiscoverableService> stubbing = null;
-        for(int i = 0; i < config.getNumAttempts() - 1; i++) {
-            if(stubbing == null) {
-                stubbing = when(mockServiceDiscovery.getService()).thenReturn(null);
-            } else {
-                stubbing.thenReturn(null);
-            }
-        }
-        stubbing.thenReturn(fixedService);
-        
-        InetSocketAddress resultAddress = InetSocketAddress.createUnresolved(fixedService.getServiceAddress().getHostName(), fixedPort);
-        DiscoverableService resultService = new DiscoverableServiceImpl(fixedService.getServiceName(), resultAddress);
-        assertEquals(resultService, serviceDiscoveryFixedPortLocator.getService());
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/ClusterServicesBroadcasterTest.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/ClusterServicesBroadcasterTest.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/ClusterServicesBroadcasterTest.java
deleted file mode 100644
index ec1f26d..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/ClusterServicesBroadcasterTest.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * 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.nifi.cluster.protocol.impl;
-
-import org.apache.nifi.cluster.protocol.impl.ClusterServicesBroadcaster;
-import org.apache.nifi.cluster.protocol.impl.MulticastProtocolListener;
-import java.net.InetSocketAddress;
-import org.apache.nifi.cluster.protocol.ProtocolContext;
-import org.apache.nifi.cluster.protocol.ProtocolException;
-import org.apache.nifi.cluster.protocol.ProtocolHandler;
-import org.apache.nifi.cluster.protocol.jaxb.JaxbProtocolContext;
-import org.apache.nifi.cluster.protocol.jaxb.message.JaxbProtocolUtils;
-import org.apache.nifi.cluster.protocol.message.ProtocolMessage;
-import org.apache.nifi.cluster.protocol.message.ServiceBroadcastMessage;
-import org.apache.nifi.io.socket.multicast.DiscoverableService;
-import org.apache.nifi.io.socket.multicast.DiscoverableServiceImpl;
-import org.apache.nifi.io.socket.multicast.MulticastConfiguration;
-import org.junit.After;
-import static org.junit.Assert.*;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-
-/**
- * @author unattributed
- */
-public class ClusterServicesBroadcasterTest {
-    
-    private ClusterServicesBroadcaster broadcaster;
-    
-    private MulticastProtocolListener listener;
-    
-    private DummyProtocolHandler handler;
-    
-    private InetSocketAddress multicastAddress;
-    
-    private DiscoverableService broadcastedService;
-
-    private ProtocolContext protocolContext;
-    
-    private MulticastConfiguration configuration;
-    
-    @Before
-    public void setup() throws Exception {
-
-        broadcastedService = new DiscoverableServiceImpl("some-service", new InetSocketAddress("localhost", 11111));
-        
-        multicastAddress = new InetSocketAddress("225.1.1.1", 22222);
-        
-        configuration = new MulticastConfiguration();
-        
-        protocolContext = new JaxbProtocolContext(JaxbProtocolUtils.JAXB_CONTEXT);
-        
-        broadcaster = new ClusterServicesBroadcaster(multicastAddress, configuration, protocolContext, "500 ms");
-        broadcaster.addService(broadcastedService);
-        
-        handler = new DummyProtocolHandler();
-        listener = new MulticastProtocolListener(5, multicastAddress, configuration, protocolContext);
-        listener.addHandler(handler);
-    }
-    
-    @After
-    public void teardown() {
-        
-        if(broadcaster.isRunning()) {
-            broadcaster.stop();
-        }
-        
-        try {
-            if(listener.isRunning()) {
-                listener.stop();
-            }
-        } catch(Exception ex) {
-            ex.printStackTrace(System.out);
-        }
-        
-    }
-    
-    @Ignore("fails needs to be fixed")
-    @Test
-    public void testBroadcastReceived() throws Exception {
-        
-        broadcaster.start();
-        listener.start();
-        
-        Thread.sleep(1000);
-        
-        listener.stop();
-        
-        assertNotNull(handler.getProtocolMessage());
-        assertEquals(ProtocolMessage.MessageType.SERVICE_BROADCAST, handler.getProtocolMessage().getType());
-        final ServiceBroadcastMessage msg = (ServiceBroadcastMessage) handler.getProtocolMessage();
-        assertEquals(broadcastedService.getServiceName(), msg.getServiceName());
-        assertEquals(broadcastedService.getServiceAddress().getHostName(), msg.getAddress());
-        assertEquals(broadcastedService.getServiceAddress().getPort(), msg.getPort());
-    }
-    
-    private class DummyProtocolHandler implements ProtocolHandler {
-
-        private ProtocolMessage protocolMessage;
-        
-        @Override
-        public boolean canHandle(ProtocolMessage msg) {
-            return true;
-        }
-
-        @Override
-        public ProtocolMessage handle(ProtocolMessage msg) throws ProtocolException {
-            this.protocolMessage = msg;
-            return null;
-        }
-        
-        public ProtocolMessage getProtocolMessage() {
-            return protocolMessage;
-        }
-        
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/MulticastProtocolListenerTest.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/MulticastProtocolListenerTest.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/MulticastProtocolListenerTest.java
deleted file mode 100644
index 4233d88..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/MulticastProtocolListenerTest.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- * 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.nifi.cluster.protocol.impl;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.net.DatagramPacket;
-import java.net.InetSocketAddress;
-import java.net.MulticastSocket;
-import java.util.ArrayList;
-import java.util.List;
-import org.apache.nifi.cluster.protocol.ProtocolContext;
-import org.apache.nifi.cluster.protocol.ProtocolException;
-import org.apache.nifi.cluster.protocol.ProtocolHandler;
-import org.apache.nifi.cluster.protocol.ProtocolMessageMarshaller;
-import org.apache.nifi.cluster.protocol.jaxb.JaxbProtocolContext;
-import org.apache.nifi.cluster.protocol.jaxb.message.JaxbProtocolUtils;
-import org.apache.nifi.cluster.protocol.message.MulticastProtocolMessage;
-import org.apache.nifi.cluster.protocol.message.PingMessage;
-import org.apache.nifi.cluster.protocol.message.ProtocolMessage;
-import org.apache.nifi.io.socket.multicast.MulticastConfiguration;
-import org.apache.nifi.io.socket.multicast.MulticastUtils;
-import org.junit.After;
-import static org.junit.Assert.*;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-
-/**
- * @author unattributed
- */
-public class MulticastProtocolListenerTest {
-    
-    private MulticastProtocolListener listener;
-    
-    private MulticastSocket socket;
-    
-    private InetSocketAddress address;
-    
-    private MulticastConfiguration configuration;
-    
-    private ProtocolContext protocolContext;
-    
-    @Before
-    public void setup() throws Exception {
-
-        address = new InetSocketAddress("226.1.1.1", 60000);
-        configuration = new MulticastConfiguration();
-        
-        protocolContext = new JaxbProtocolContext(JaxbProtocolUtils.JAXB_CONTEXT);
-        
-        listener = new MulticastProtocolListener(5, address, configuration, protocolContext);
-        listener.start();
-
-        socket = MulticastUtils.createMulticastSocket(address.getPort(), configuration);
-    }
-    
-    @After
-    public void teardown() throws IOException {
-        try {
-            if(listener.isRunning()) {
-                listener.stop();
-            }
-        } finally {
-            MulticastUtils.closeQuietly(socket);
-        }
-    }
-    
-    @Ignore("Test needs to be reworked.  Fails if on a system without actiev network connection")
-    @Test
-    public void testBadRequest() throws Exception {
-        DelayedProtocolHandler handler = new DelayedProtocolHandler(0);
-        listener.addHandler(handler);
-        DatagramPacket packet = new DatagramPacket(new byte[] {5}, 1, address);
-        socket.send(packet);
-        Thread.sleep(250);
-        assertEquals(0, handler.getMessages().size());
-    }
-    
-    @Ignore("this test works sometimes and fails others - needs work to be reliable")
-    @Test
-    public void testRequest() throws Exception {
-
-        ReflexiveProtocolHandler handler = new ReflexiveProtocolHandler();
-        listener.addHandler(handler);
-        
-        ProtocolMessage msg = new PingMessage();
-        MulticastProtocolMessage multicastMsg = new MulticastProtocolMessage("some-id", msg);
-
-        // marshal message to output stream
-        ProtocolMessageMarshaller marshaller = protocolContext.createMarshaller();
-        ByteArrayOutputStream baos = new ByteArrayOutputStream();
-        marshaller.marshal(multicastMsg, baos);
-        byte[] requestPacketBytes = baos.toByteArray();
-        DatagramPacket packet = new DatagramPacket(requestPacketBytes, requestPacketBytes.length, address);
-        socket.send(packet);
-
-        Thread.sleep(250);
-        assertEquals(1, handler.getMessages().size());
-        assertEquals(msg.getType(), handler.getMessages().get(0).getType());
-        
-    }
-    
-    private class ReflexiveProtocolHandler implements ProtocolHandler {
-        
-        private List<ProtocolMessage> messages = new ArrayList<>();
-        
-        @Override
-        public ProtocolMessage handle(ProtocolMessage msg) throws ProtocolException {
-            messages.add(msg);
-            return msg;
-        }
-
-        @Override
-        public boolean canHandle(ProtocolMessage msg) {
-            return true;
-        }
-        
-        public List<ProtocolMessage> getMessages() {
-            return messages;
-        }
-        
-    }
-
-    private class DelayedProtocolHandler implements ProtocolHandler {
-            
-        private int delay = 0;
-        
-        private List<ProtocolMessage> messages = new ArrayList<>();
-            
-        public DelayedProtocolHandler(int delay) {
-            this.delay = delay;
-        }
-        
-        @Override
-        public ProtocolMessage handle(ProtocolMessage msg) throws ProtocolException {
-            try {
-                messages.add(msg);
-                Thread.sleep(delay);
-                return null;
-            } catch(final InterruptedException ie) {
-                throw new ProtocolException(ie);
-            }
-
-        }
-
-        @Override
-        public boolean canHandle(ProtocolMessage msg) {
-            return true;
-        }
-        
-        public List<ProtocolMessage> getMessages() {
-            return messages;
-        }
-        
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/NodeProtocolSenderImplTest.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/NodeProtocolSenderImplTest.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/NodeProtocolSenderImplTest.java
deleted file mode 100644
index 1c5ba9e..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/NodeProtocolSenderImplTest.java
+++ /dev/null
@@ -1,203 +0,0 @@
-/*
- * 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.nifi.cluster.protocol.impl;
-
-import org.apache.nifi.cluster.protocol.impl.ClusterServiceLocator;
-import org.apache.nifi.cluster.protocol.impl.SocketProtocolListener;
-import org.apache.nifi.cluster.protocol.impl.NodeProtocolSenderImpl;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import java.io.IOException;
-import java.net.InetSocketAddress;
-import java.util.UUID;
-
-import org.apache.nifi.cluster.protocol.ConnectionRequest;
-import org.apache.nifi.cluster.protocol.ConnectionResponse;
-import org.apache.nifi.cluster.protocol.Heartbeat;
-import org.apache.nifi.cluster.protocol.NodeIdentifier;
-import org.apache.nifi.cluster.protocol.ProtocolContext;
-import org.apache.nifi.cluster.protocol.ProtocolException;
-import org.apache.nifi.cluster.protocol.ProtocolHandler;
-import org.apache.nifi.cluster.protocol.StandardDataFlow;
-import org.apache.nifi.cluster.protocol.UnknownServiceAddressException;
-import org.apache.nifi.cluster.protocol.jaxb.JaxbProtocolContext;
-import org.apache.nifi.cluster.protocol.jaxb.message.JaxbProtocolUtils;
-import org.apache.nifi.cluster.protocol.message.ConnectionRequestMessage;
-import org.apache.nifi.cluster.protocol.message.ConnectionResponseMessage;
-import org.apache.nifi.cluster.protocol.message.ControllerStartupFailureMessage;
-import org.apache.nifi.cluster.protocol.message.HeartbeatMessage;
-import org.apache.nifi.cluster.protocol.message.PingMessage;
-import org.apache.nifi.cluster.protocol.message.ProtocolMessage;
-import org.apache.nifi.io.socket.ServerSocketConfiguration;
-import org.apache.nifi.io.socket.SocketConfiguration;
-import org.apache.nifi.io.socket.multicast.DiscoverableService;
-import org.apache.nifi.io.socket.multicast.DiscoverableServiceImpl;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.stubbing.Answer;
-
-/**
- * @author unattributed
- */
-@Ignore("Randomly tests... probably timing-specific")
-public class NodeProtocolSenderImplTest {
-    
-    private SocketProtocolListener listener;
-    
-    private NodeProtocolSenderImpl sender;
-    
-    private DiscoverableService service;
-    
-    private ServerSocketConfiguration serverSocketConfiguration;
-    
-    private ClusterServiceLocator mockServiceLocator;
-    
-    private ProtocolHandler mockHandler;
-    
-    private NodeIdentifier nodeIdentifier;
-    
-    @Before
-    public void setup() throws IOException {
-        
-        serverSocketConfiguration = new ServerSocketConfiguration();
-
-        mockServiceLocator = mock(ClusterServiceLocator.class);
-        mockHandler = mock(ProtocolHandler.class);
-        
-        nodeIdentifier = new NodeIdentifier("1", "localhost", 1234, "localhost", 5678);
-        
-        ProtocolContext protocolContext = new JaxbProtocolContext(JaxbProtocolUtils.JAXB_CONTEXT);
-        
-        listener = new SocketProtocolListener(5, 0, serverSocketConfiguration, protocolContext);
-        listener.setShutdownListenerSeconds(3);
-        listener.addHandler(mockHandler);
-        listener.start();
-        
-        service = new DiscoverableServiceImpl("some-service", new InetSocketAddress("localhost", listener.getPort()));
-        
-        SocketConfiguration socketConfiguration = new SocketConfiguration();
-        socketConfiguration.setReuseAddress(true);
-        sender = new NodeProtocolSenderImpl(mockServiceLocator, socketConfiguration, protocolContext);
-    }
-    
-    @After
-    public void teardown() throws IOException {
-        if(listener.isRunning()) {
-            listener.stop();
-        }
-    }
-    
-    @Test
-    public void testConnect() throws Exception {
-        
-        when(mockServiceLocator.getService()).thenReturn(service);
-        when(mockHandler.canHandle(any(ProtocolMessage.class))).thenReturn(Boolean.TRUE);
-        ConnectionResponseMessage mockMessage = new ConnectionResponseMessage();
-        mockMessage.setConnectionResponse(new ConnectionResponse(nodeIdentifier, new StandardDataFlow("flow".getBytes("UTF-8"), new byte[0], new byte[0]), false, null, null, UUID.randomUUID().toString()));
-        when(mockHandler.handle(any(ProtocolMessage.class))).thenReturn(mockMessage);
-        
-        ConnectionRequestMessage request = new ConnectionRequestMessage();
-        request.setConnectionRequest(new ConnectionRequest(nodeIdentifier));
-        ConnectionResponseMessage response = sender.requestConnection(request);
-        assertNotNull(response);
-    }
-    
-    @Test(expected = UnknownServiceAddressException.class)
-    public void testConnectNoClusterManagerAddress() throws Exception {
-        
-        when(mockServiceLocator.getService()).thenReturn(null);
-        when(mockHandler.canHandle(any(ProtocolMessage.class))).thenReturn(Boolean.TRUE);
-        when(mockHandler.handle(any(ProtocolMessage.class))).thenReturn(new ConnectionResponseMessage());
-        
-        ConnectionRequestMessage request = new ConnectionRequestMessage();
-        request.setConnectionRequest(new ConnectionRequest(nodeIdentifier));
-
-        sender.requestConnection(request);
-        fail("failed to throw exception");
-    }
-    
-    @Test(expected = ProtocolException.class)
-    public void testConnectBadResponse() throws Exception {
-        
-        when(mockServiceLocator.getService()).thenReturn(service);
-        when(mockHandler.canHandle(any(ProtocolMessage.class))).thenReturn(Boolean.TRUE);
-        when(mockHandler.handle(any(ProtocolMessage.class))).thenReturn(new PingMessage());
-        
-        ConnectionRequestMessage request = new ConnectionRequestMessage();
-        request.setConnectionRequest(new ConnectionRequest(nodeIdentifier));
-        
-        sender.requestConnection(request);
-        fail("failed to throw exception");
-        
-    }
-    
-    @Test(expected = ProtocolException.class)
-    public void testConnectDelayedResponse() throws Exception {
-        
-        final int time = 250;
-        sender.getSocketConfiguration().setSocketTimeout(time);
-        when(mockServiceLocator.getService()).thenReturn(service);
-        when(mockHandler.canHandle(any(ProtocolMessage.class))).thenReturn(Boolean.TRUE);
-        when(mockHandler.handle(any(ProtocolMessage.class))).thenAnswer(new Answer<ConnectionResponseMessage>() {
-            @Override
-            public ConnectionResponseMessage answer(InvocationOnMock invocation) throws Throwable {
-                Thread.sleep(time * 3);
-                return new ConnectionResponseMessage();
-            }
-        });
-        ConnectionRequestMessage request = new ConnectionRequestMessage();
-        request.setConnectionRequest(new ConnectionRequest(nodeIdentifier));
-
-        sender.requestConnection(request);
-        fail("failed to throw exception");
-        
-    }
-    
-    @Test
-    public void testHeartbeat() throws Exception {
-        
-        when(mockServiceLocator.getService()).thenReturn(service);
-        when(mockHandler.canHandle(any(ProtocolMessage.class))).thenReturn(Boolean.TRUE);
-        when(mockHandler.handle(any(ProtocolMessage.class))).thenReturn(null);
-        
-        HeartbeatMessage hb = new HeartbeatMessage();
-        hb.setHeartbeat(new Heartbeat(new NodeIdentifier("id", "localhost", 3, "localhost", 4), false, false, new byte[] {1, 2, 3}));
-        sender.heartbeat(hb);
-    }
-    
-    @Test
-    public void testNotifyControllerStartupFailure() throws Exception {
-        
-        when(mockServiceLocator.getService()).thenReturn(service);
-        when(mockHandler.canHandle(any(ProtocolMessage.class))).thenReturn(Boolean.TRUE);
-        when(mockHandler.handle(any(ProtocolMessage.class))).thenReturn(null);
-        
-        ControllerStartupFailureMessage msg = new ControllerStartupFailureMessage();
-        msg.setNodeId(new NodeIdentifier("some-id", "some-addr", 1, "some-addr", 1));
-        msg.setExceptionMessage("some exception");
-        sender.notifyControllerStartupFailure(msg);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/testutils/DelayedProtocolHandler.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/testutils/DelayedProtocolHandler.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/testutils/DelayedProtocolHandler.java
deleted file mode 100644
index 07ee83a..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/testutils/DelayedProtocolHandler.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * 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.nifi.cluster.protocol.impl.testutils;
-
-import java.util.ArrayList;
-import java.util.List;
-import org.apache.nifi.cluster.protocol.ProtocolException;
-import org.apache.nifi.cluster.protocol.ProtocolHandler;
-import org.apache.nifi.cluster.protocol.message.ProtocolMessage;
-
-/**
- * @author unattributed
- */
-public class DelayedProtocolHandler implements ProtocolHandler {
-
-    private int delay = 0;
-    private List<ProtocolMessage> messages = new ArrayList<>();
-
-    public DelayedProtocolHandler(int delay) {
-        this.delay = delay;
-    }
-
-    @Override
-    public ProtocolMessage handle(ProtocolMessage msg) throws ProtocolException {
-        try {
-            messages.add(msg);
-            Thread.sleep(delay);
-            return null;
-        } catch (final InterruptedException ie) {
-            throw new ProtocolException(ie);
-        }
-
-    }
-
-    @Override
-    public boolean canHandle(ProtocolMessage msg) {
-        return true;
-    }
-
-    public List<ProtocolMessage> getMessages() {
-        return messages;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/testutils/ReflexiveProtocolHandler.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/testutils/ReflexiveProtocolHandler.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/testutils/ReflexiveProtocolHandler.java
deleted file mode 100644
index 4e3b932..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/testutils/ReflexiveProtocolHandler.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * 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.nifi.cluster.protocol.impl.testutils;
-
-import java.util.ArrayList;
-import java.util.List;
-import org.apache.nifi.cluster.protocol.ProtocolException;
-import org.apache.nifi.cluster.protocol.ProtocolHandler;
-import org.apache.nifi.cluster.protocol.message.ProtocolMessage;
-
-/**
- * @author unattributed
- */
-public class ReflexiveProtocolHandler implements ProtocolHandler {
-    
-    private List<ProtocolMessage> messages = new ArrayList<>();
-        
-    @Override
-    public ProtocolMessage handle(ProtocolMessage msg) throws ProtocolException {
-        messages.add(msg);
-        return msg;
-    }
-
-    @Override
-    public boolean canHandle(ProtocolMessage msg) {
-        return true;
-    }
-
-    public List<ProtocolMessage> getMessages() {
-        return messages;
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-web/.gitignore
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-web/.gitignore b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-web/.gitignore
deleted file mode 100755
index ea8c4bf..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-web/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-/target

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-web/pom.xml
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-web/pom.xml b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-web/pom.xml
deleted file mode 100644
index 18e4ba4..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-web/pom.xml
+++ /dev/null
@@ -1,48 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-  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.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-    <modelVersion>4.0.0</modelVersion>
-    <parent>
-        <groupId>org.apache.nifi</groupId>
-        <artifactId>nifi-framework</artifactId>
-        <version>0.0.3-incubating-SNAPSHOT</version>
-    </parent>
-    <artifactId>nifi-framework-cluster-web</artifactId>
-    <packaging>jar</packaging>
-    <description>The clustering software for communicating with the NiFi web api.</description>
-    <dependencies>
-        <dependency>
-            <groupId>org.apache.nifi</groupId>
-            <artifactId>nifi-api</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.nifi</groupId>
-            <artifactId>nifi-properties</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.nifi</groupId>
-            <artifactId>nifi-web-optimistic-locking</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.nifi</groupId>
-            <artifactId>nifi-administration</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.nifi</groupId>
-            <artifactId>nifi-user-actions</artifactId>
-        </dependency>
-    </dependencies>
-</project>

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-web/src/main/java/org/apache/nifi/cluster/context/ClusterContext.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-web/src/main/java/org/apache/nifi/cluster/context/ClusterContext.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-web/src/main/java/org/apache/nifi/cluster/context/ClusterContext.java
deleted file mode 100644
index 44fb25a..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-web/src/main/java/org/apache/nifi/cluster/context/ClusterContext.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * 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.nifi.cluster.context;
-
-import java.io.Serializable;
-import java.util.List;
-import org.apache.nifi.action.Action;
-import org.apache.nifi.web.Revision;
-
-/**
- * Contains contextual information about clustering that may be serialized 
- * between manager and node when communicating over HTTP.
- */
-public interface ClusterContext extends Serializable {
-    
-    /**
-     * Returns a list of auditable actions.  The list is modifiable
-     * and will never be null.
-     * @return a collection of actions
-     */
-    List<Action> getActions();
-    
-    Revision getRevision();
-    
-    void setRevision(Revision revision);
-    
-    /**
-     * @return true if the request was sent by the cluster manager; false otherwise
-     */
-    boolean isRequestSentByClusterManager();
-    
-    /**
-     * Sets the flag to indicate if a request was sent by the cluster manager.
-     * @param flag true if the request was sent by the cluster manager; false otherwise
-     */
-    void setRequestSentByClusterManager(boolean flag);
-    
-    /**
-     * Gets an id generation seed. This is used to ensure that nodes are able to generate the
-     * same id across the cluster. This is usually handled by the cluster manager creating the
-     * id, however for some actions (snippets, templates, etc) this is not possible.
-     * @return 
-     */
-    String getIdGenerationSeed();
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-web/src/main/java/org/apache/nifi/cluster/context/ClusterContextImpl.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-web/src/main/java/org/apache/nifi/cluster/context/ClusterContextImpl.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-web/src/main/java/org/apache/nifi/cluster/context/ClusterContextImpl.java
deleted file mode 100644
index 06907d2..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-web/src/main/java/org/apache/nifi/cluster/context/ClusterContextImpl.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * 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.nifi.cluster.context;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.UUID;
-import org.apache.nifi.action.Action;
-import org.apache.nifi.web.Revision;
-
-/**
- * A basic implementation of the context.
- */
-public class ClusterContextImpl implements ClusterContext, Serializable {
-
-    private final List<Action> actions = new ArrayList<>();
-    
-    private Revision revision;
-    
-    private boolean requestSentByClusterManager;
-    
-    private final String idGenerationSeed = UUID.randomUUID().toString();
-    
-    @Override
-    public List<Action> getActions() {
-        return actions;
-    }
-
-    @Override
-    public Revision getRevision() {
-        return revision;
-    }
-
-    @Override
-    public void setRevision(Revision revision) {
-        this.revision = revision;
-    }
-
-    @Override
-    public boolean isRequestSentByClusterManager() {
-        return requestSentByClusterManager;
-    }
-    
-    @Override
-    public void setRequestSentByClusterManager(boolean requestSentByClusterManager) {
-        this.requestSentByClusterManager = requestSentByClusterManager;
-    }
-
-    @Override
-    public String getIdGenerationSeed() {
-        return this.idGenerationSeed;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-web/src/main/java/org/apache/nifi/cluster/context/ClusterContextThreadLocal.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-web/src/main/java/org/apache/nifi/cluster/context/ClusterContextThreadLocal.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-web/src/main/java/org/apache/nifi/cluster/context/ClusterContextThreadLocal.java
deleted file mode 100644
index 012e7c7..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-web/src/main/java/org/apache/nifi/cluster/context/ClusterContextThreadLocal.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * 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.nifi.cluster.context;
-
-/**
- * Manages a cluster context on a threadlocal.
- */
-public class ClusterContextThreadLocal {
-    
-    private static final ThreadLocal<ClusterContext> contextHolder = new ThreadLocal<>();
-    
-    public static void removeContext() {
-        contextHolder.remove();
-    }
-    
-    public static ClusterContext createEmptyContext() {
-        return new ClusterContextImpl();
-    }
-    
-    public static ClusterContext getContext() {
-        ClusterContext ctx = contextHolder.get();
-        if(ctx == null) {
-            ctx = createEmptyContext();
-            contextHolder.set(ctx);
-        }
-        return ctx;
-    }
-    
-    public static void setContext(final ClusterContext context) {
-        contextHolder.set(context);
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-web/src/main/java/org/apache/nifi/web/ClusterAwareOptimisticLockingManager.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-web/src/main/java/org/apache/nifi/web/ClusterAwareOptimisticLockingManager.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-web/src/main/java/org/apache/nifi/web/ClusterAwareOptimisticLockingManager.java
deleted file mode 100644
index 90b8a37..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-web/src/main/java/org/apache/nifi/web/ClusterAwareOptimisticLockingManager.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * 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.nifi.web;
-
-import org.apache.nifi.cluster.context.ClusterContext;
-import org.apache.nifi.cluster.context.ClusterContextThreadLocal;
-
-/**
- * An optimistic locking manager that provides for optimistic locking in a clustered
- * environment.
- * 
- * @author unattributed
- */
-public class ClusterAwareOptimisticLockingManager implements OptimisticLockingManager {
-
-    private final OptimisticLockingManager optimisticLockingManager;
-    
-    public ClusterAwareOptimisticLockingManager(final OptimisticLockingManager optimisticLockingManager) {
-        this.optimisticLockingManager = optimisticLockingManager;
-    }
-    
-    @Override
-    public Revision checkRevision(Revision revision) throws InvalidRevisionException {
-        final Revision currentRevision = getRevision();
-        if(currentRevision.equals(revision) == false) {
-            throw new InvalidRevisionException(String.format("Given revision %s does not match current revision %s.", revision, currentRevision));
-        } else {
-            return revision.increment(revision.getClientId());
-        }
-    }
-
-    @Override
-    public boolean isCurrent(Revision revision) {
-        return getRevision().equals(revision);
-    }
-
-    @Override
-    public Revision getRevision() {
-        final ClusterContext ctx = ClusterContextThreadLocal.getContext();
-        if(ctx == null || ctx.getRevision() == null) {
-            return optimisticLockingManager.getRevision();
-        } else {
-            return ctx.getRevision();
-        }
-    }
-
-    @Override
-    public void setRevision(final Revision revision) {
-        final ClusterContext ctx = ClusterContextThreadLocal.getContext();
-        if(ctx != null) {
-            ctx.setRevision(revision);
-        }
-        optimisticLockingManager.setRevision(revision);
-    }
-
-    @Override
-    public Revision incrementRevision() {
-        final Revision currentRevision = getRevision();
-        final Revision incRevision = currentRevision.increment();
-        setRevision(incRevision);
-        return incRevision;
-    }
-
-    @Override
-    public Revision incrementRevision(final String clientId) {
-        final Revision currentRevision = getRevision();
-        final Revision incRevision = currentRevision.increment(clientId);
-        setRevision(incRevision);
-        return incRevision;
-    }
-
-    @Override
-    public String getLastModifier() {
-        return optimisticLockingManager.getLastModifier();
-    }
-
-    @Override
-    public void setLastModifier(final String lastModifier) {
-        optimisticLockingManager.setLastModifier(lastModifier);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/.gitignore
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/.gitignore b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/.gitignore
deleted file mode 100755
index ea8c4bf..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-/target

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/pom.xml
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/pom.xml b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/pom.xml
deleted file mode 100644
index dd24804..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/pom.xml
+++ /dev/null
@@ -1,130 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-  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.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-    <modelVersion>4.0.0</modelVersion>
-    <parent>
-        <groupId>org.apache.nifi</groupId>
-        <artifactId>nifi-framework</artifactId>
-        <version>0.0.3-incubating-SNAPSHOT</version>
-    </parent>
-    <artifactId>nifi-framework-cluster</artifactId>
-    <packaging>jar</packaging>
-    <description>The clustering software for NiFi.</description>
-    <dependencies>
-        <!-- application core dependencies -->
-        <dependency>
-            <groupId>org.apache.nifi</groupId>
-            <artifactId>nifi-api</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.nifi</groupId>
-            <artifactId>nifi-properties</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.nifi</groupId>
-            <artifactId>nifi-logging-utils</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.nifi</groupId>
-            <artifactId>nifi-utils</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.nifi</groupId>
-            <artifactId>nifi-client-dto</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.nifi</groupId>
-            <artifactId>nifi-framework-core</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.nifi</groupId>
-            <artifactId>nifi-framework-core-api</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.nifi</groupId>
-            <artifactId>nifi-framework-cluster-protocol</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.nifi</groupId>
-            <artifactId>nifi-framework-cluster-web</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.nifi</groupId>
-            <artifactId>nifi-web-utils</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.nifi</groupId>
-            <artifactId>nifi-administration</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.nifi</groupId>
-            <artifactId>nifi-site-to-site</artifactId>
-        </dependency>
-        <dependency>
-        	<groupId>org.apache.nifi</groupId>
-        	<artifactId>nifi-site-to-site-client</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.commons</groupId>
-            <artifactId>commons-compress</artifactId>
-        </dependency>
-        <!-- third party dependencies -->
-        
-        <!-- sun dependencies -->
-        <dependency>
-            <groupId>javax.servlet</groupId>
-            <artifactId>javax.servlet-api</artifactId>
-        </dependency>
-        
-        <!-- commons dependencies -->
-        <dependency>
-            <groupId>commons-io</groupId>
-            <artifactId>commons-io</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>commons-net</groupId>
-            <artifactId>commons-net</artifactId>
-        </dependency>
-        
-        <!-- jersey dependencies -->
-        <dependency>
-            <groupId>com.sun.jersey</groupId>
-            <artifactId>jersey-client</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>com.sun.jersey</groupId>
-            <artifactId>jersey-server</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>com.sun.jersey</groupId>
-            <artifactId>jersey-json</artifactId>
-        </dependency>
-        
-        <!-- spring dependencies -->
-        <dependency>
-            <groupId>org.springframework</groupId>
-            <artifactId>spring-core</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.springframework</groupId>
-            <artifactId>spring-beans</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.springframework</groupId>
-            <artifactId>spring-context</artifactId>
-        </dependency>
-    </dependencies>
-</project>

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/client/MulticastTestClient.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/client/MulticastTestClient.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/client/MulticastTestClient.java
deleted file mode 100644
index 0b70c61..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/client/MulticastTestClient.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * 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.nifi.cluster.client;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.net.DatagramPacket;
-import java.net.InetSocketAddress;
-import java.net.MulticastSocket;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.Locale;
-import java.util.Timer;
-import java.util.TimerTask;
-
-import org.apache.nifi.cluster.protocol.ProtocolContext;
-import org.apache.nifi.cluster.protocol.ProtocolException;
-import org.apache.nifi.cluster.protocol.ProtocolHandler;
-import org.apache.nifi.cluster.protocol.ProtocolMessageMarshaller;
-import org.apache.nifi.cluster.protocol.impl.MulticastProtocolListener;
-import org.apache.nifi.cluster.protocol.jaxb.JaxbProtocolContext;
-import org.apache.nifi.cluster.protocol.jaxb.message.JaxbProtocolUtils;
-import org.apache.nifi.cluster.protocol.message.PingMessage;
-import org.apache.nifi.cluster.protocol.message.ProtocolMessage;
-import org.apache.nifi.io.socket.multicast.MulticastConfiguration;
-import org.apache.nifi.io.socket.multicast.MulticastUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Simple multicast test client that sends ping messages to a group address.
- */
-public class MulticastTestClient {
-
-    private static final Logger logger = LoggerFactory.getLogger(MulticastTestClient.class);
-
-    private static final int PING_DELAY_SECONDS = 3;
-
-    public static void main(final String... args) throws IOException {
-
-        String group = System.getProperty("group", "225.0.0.0");
-        if (group == null) {
-            System.out.println("Host system property 'group' was not given.");
-            return;
-        }
-        group = group.trim();
-        if (group.length() == 0) {
-            System.out.println("Host system property 'group' must be non-empty.");
-            return;
-        }
-
-        final String portStr = System.getProperty("port", "2222");
-        final int port;
-        try {
-            port = Integer.parseInt(portStr);
-        } catch (final NumberFormatException nfe) {
-            System.out.println("Port system property 'port' was not a valid port.");
-            return;
-        }
-
-        logger.info(String.format("Pinging every %s seconds using multicast address: %s:%s.", PING_DELAY_SECONDS, group, port));
-        logger.info("Override defaults by using system properties '-Dgroup=<Class D IP>' and '-Dport=<unused port>'.");
-        logger.info("The test client may be stopped by entering a newline at the command line.");
-
-        final InetSocketAddress addr = new InetSocketAddress(group, port);
-        final ProtocolContext<ProtocolMessage> protocolContext = new JaxbProtocolContext<ProtocolMessage>(JaxbProtocolUtils.JAXB_CONTEXT);
-        final MulticastConfiguration multicastConfig = new MulticastConfiguration();
-        multicastConfig.setReuseAddress(true);
-
-        // setup listener
-        final MulticastProtocolListener listener = new MulticastProtocolListener(1, addr, multicastConfig, protocolContext);
-        listener.addHandler(new ProtocolHandler() {
-            @Override
-            public ProtocolMessage handle(ProtocolMessage msg) throws ProtocolException {
-                final PingMessage pingMsg = (PingMessage) msg;
-                final SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss", Locale.US);
-                logger.info("Pinged at: " + sdf.format(pingMsg.getDate()));
-                return null;
-            }
-
-            @Override
-            public boolean canHandle(ProtocolMessage msg) {
-                return true;
-            }
-        });
-
-        // setup socket
-        final MulticastSocket multicastSocket = MulticastUtils.createMulticastSocket(multicastConfig);
-
-        // setup broadcaster
-        final Timer broadcaster = new Timer("Multicast Test Client", /**
-                 * is daemon *
-                 */
-                true);
-
-        try {
-
-            // start listening
-            listener.start();
-
-            // start broadcasting
-            broadcaster.schedule(new TimerTask() {
-
-                @Override
-                public void run() {
-                    try {
-
-                        final PingMessage msg = new PingMessage();
-                        msg.setDate(new Date());
-
-                        // marshal message to output stream
-                        final ProtocolMessageMarshaller<ProtocolMessage> marshaller = protocolContext.createMarshaller();
-                        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
-                        marshaller.marshal(msg, baos);
-                        final byte[] packetBytes = baos.toByteArray();
-
-                        // send message
-                        final DatagramPacket packet = new DatagramPacket(packetBytes, packetBytes.length, addr);
-                        multicastSocket.send(packet);
-
-                    } catch (final Exception ex) {
-                        logger.warn("Failed to send message due to: " + ex, ex);
-                    }
-                }
-            }, 0, PING_DELAY_SECONDS * 1000);
-
-            // block until any input is received
-            System.in.read();
-
-        } finally {
-            broadcaster.cancel();
-            if (listener.isRunning()) {
-                listener.stop();
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/event/Event.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/event/Event.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/event/Event.java
deleted file mode 100644
index 6bc5d6c..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/event/Event.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * 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.nifi.cluster.event;
-
-import java.util.Date;
-import org.apache.commons.lang3.StringUtils;
-
-/**
- * Events describe the occurrence of something noteworthy. They record the
- * event's source, a timestamp, a description, and a category.
- *
- * @author unattributed
- *
- * @Immutable
- */
-public class Event {
-
-    public static enum Category {
-
-        DEBUG,
-        INFO,
-        WARN
-    }
-
-    private final String source;
-
-    private final long timestamp;
-
-    private final Category category;
-
-    private final String message;
-
-    /**
-     * Creates an event with the current time as the timestamp and a category of
-     * "INFO".
-     *
-     * @param source the source
-     * @param message the description
-     */
-    public Event(final String source, final String message) {
-        this(source, message, Category.INFO);
-    }
-
-    /**
-     * Creates an event with the current time as the timestamp.
-     *
-     * @param source the source
-     * @param message the description
-     * @param category the event category
-     */
-    public Event(final String source, final String message, final Category category) {
-        this(source, message, category, new Date().getTime());
-    }
-
-    /**
-     * Creates an event with the a category of "INFO".
-     *
-     * @param source the source
-     * @param message the description
-     * @param timestamp the time of occurrence
-     */
-    public Event(final String source, final String message, final long timestamp) {
-        this(source, message, Category.INFO, timestamp);
-    }
-
-    /**
-     * Creates an event.
-     *
-     * @param source the source
-     * @param message the description
-     * @param category the event category
-     * @param timestamp the time of occurrence
-     */
-    public Event(final String source, final String message, final Category category, final long timestamp) {
-
-        if (StringUtils.isBlank(source)) {
-            throw new IllegalArgumentException("Source may not be empty or null.");
-        } else if (StringUtils.isBlank(message)) {
-            throw new IllegalArgumentException("Event message may not be empty or null.");
-        } else if (category == null) {
-            throw new IllegalArgumentException("Event category may not be null.");
-        } else if (timestamp < 0) {
-            throw new IllegalArgumentException("Timestamp may not be negative: " + timestamp);
-        }
-
-        this.source = source;
-        this.message = message;
-        this.category = category;
-        this.timestamp = timestamp;
-    }
-
-    public Category getCategory() {
-        return category;
-    }
-
-    public String getMessage() {
-        return message;
-    }
-
-    public String getSource() {
-        return source;
-    }
-
-    public long getTimestamp() {
-        return timestamp;
-    }
-
-}


[07/20] incubator-nifi git commit: NIFI-410 pushed RAT exclusions down to the relevant modules and stopped doing broad test resource exclusion - is now specific

Posted by jo...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/MulticastProtocolListenerTest.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/MulticastProtocolListenerTest.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/MulticastProtocolListenerTest.java
new file mode 100644
index 0000000..4233d88
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/MulticastProtocolListenerTest.java
@@ -0,0 +1,171 @@
+/*
+ * 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.nifi.cluster.protocol.impl;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.net.DatagramPacket;
+import java.net.InetSocketAddress;
+import java.net.MulticastSocket;
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.nifi.cluster.protocol.ProtocolContext;
+import org.apache.nifi.cluster.protocol.ProtocolException;
+import org.apache.nifi.cluster.protocol.ProtocolHandler;
+import org.apache.nifi.cluster.protocol.ProtocolMessageMarshaller;
+import org.apache.nifi.cluster.protocol.jaxb.JaxbProtocolContext;
+import org.apache.nifi.cluster.protocol.jaxb.message.JaxbProtocolUtils;
+import org.apache.nifi.cluster.protocol.message.MulticastProtocolMessage;
+import org.apache.nifi.cluster.protocol.message.PingMessage;
+import org.apache.nifi.cluster.protocol.message.ProtocolMessage;
+import org.apache.nifi.io.socket.multicast.MulticastConfiguration;
+import org.apache.nifi.io.socket.multicast.MulticastUtils;
+import org.junit.After;
+import static org.junit.Assert.*;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ * @author unattributed
+ */
+public class MulticastProtocolListenerTest {
+    
+    private MulticastProtocolListener listener;
+    
+    private MulticastSocket socket;
+    
+    private InetSocketAddress address;
+    
+    private MulticastConfiguration configuration;
+    
+    private ProtocolContext protocolContext;
+    
+    @Before
+    public void setup() throws Exception {
+
+        address = new InetSocketAddress("226.1.1.1", 60000);
+        configuration = new MulticastConfiguration();
+        
+        protocolContext = new JaxbProtocolContext(JaxbProtocolUtils.JAXB_CONTEXT);
+        
+        listener = new MulticastProtocolListener(5, address, configuration, protocolContext);
+        listener.start();
+
+        socket = MulticastUtils.createMulticastSocket(address.getPort(), configuration);
+    }
+    
+    @After
+    public void teardown() throws IOException {
+        try {
+            if(listener.isRunning()) {
+                listener.stop();
+            }
+        } finally {
+            MulticastUtils.closeQuietly(socket);
+        }
+    }
+    
+    @Ignore("Test needs to be reworked.  Fails if on a system without actiev network connection")
+    @Test
+    public void testBadRequest() throws Exception {
+        DelayedProtocolHandler handler = new DelayedProtocolHandler(0);
+        listener.addHandler(handler);
+        DatagramPacket packet = new DatagramPacket(new byte[] {5}, 1, address);
+        socket.send(packet);
+        Thread.sleep(250);
+        assertEquals(0, handler.getMessages().size());
+    }
+    
+    @Ignore("this test works sometimes and fails others - needs work to be reliable")
+    @Test
+    public void testRequest() throws Exception {
+
+        ReflexiveProtocolHandler handler = new ReflexiveProtocolHandler();
+        listener.addHandler(handler);
+        
+        ProtocolMessage msg = new PingMessage();
+        MulticastProtocolMessage multicastMsg = new MulticastProtocolMessage("some-id", msg);
+
+        // marshal message to output stream
+        ProtocolMessageMarshaller marshaller = protocolContext.createMarshaller();
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        marshaller.marshal(multicastMsg, baos);
+        byte[] requestPacketBytes = baos.toByteArray();
+        DatagramPacket packet = new DatagramPacket(requestPacketBytes, requestPacketBytes.length, address);
+        socket.send(packet);
+
+        Thread.sleep(250);
+        assertEquals(1, handler.getMessages().size());
+        assertEquals(msg.getType(), handler.getMessages().get(0).getType());
+        
+    }
+    
+    private class ReflexiveProtocolHandler implements ProtocolHandler {
+        
+        private List<ProtocolMessage> messages = new ArrayList<>();
+        
+        @Override
+        public ProtocolMessage handle(ProtocolMessage msg) throws ProtocolException {
+            messages.add(msg);
+            return msg;
+        }
+
+        @Override
+        public boolean canHandle(ProtocolMessage msg) {
+            return true;
+        }
+        
+        public List<ProtocolMessage> getMessages() {
+            return messages;
+        }
+        
+    }
+
+    private class DelayedProtocolHandler implements ProtocolHandler {
+            
+        private int delay = 0;
+        
+        private List<ProtocolMessage> messages = new ArrayList<>();
+            
+        public DelayedProtocolHandler(int delay) {
+            this.delay = delay;
+        }
+        
+        @Override
+        public ProtocolMessage handle(ProtocolMessage msg) throws ProtocolException {
+            try {
+                messages.add(msg);
+                Thread.sleep(delay);
+                return null;
+            } catch(final InterruptedException ie) {
+                throw new ProtocolException(ie);
+            }
+
+        }
+
+        @Override
+        public boolean canHandle(ProtocolMessage msg) {
+            return true;
+        }
+        
+        public List<ProtocolMessage> getMessages() {
+            return messages;
+        }
+        
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/NodeProtocolSenderImplTest.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/NodeProtocolSenderImplTest.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/NodeProtocolSenderImplTest.java
new file mode 100644
index 0000000..1c5ba9e
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/NodeProtocolSenderImplTest.java
@@ -0,0 +1,203 @@
+/*
+ * 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.nifi.cluster.protocol.impl;
+
+import org.apache.nifi.cluster.protocol.impl.ClusterServiceLocator;
+import org.apache.nifi.cluster.protocol.impl.SocketProtocolListener;
+import org.apache.nifi.cluster.protocol.impl.NodeProtocolSenderImpl;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.util.UUID;
+
+import org.apache.nifi.cluster.protocol.ConnectionRequest;
+import org.apache.nifi.cluster.protocol.ConnectionResponse;
+import org.apache.nifi.cluster.protocol.Heartbeat;
+import org.apache.nifi.cluster.protocol.NodeIdentifier;
+import org.apache.nifi.cluster.protocol.ProtocolContext;
+import org.apache.nifi.cluster.protocol.ProtocolException;
+import org.apache.nifi.cluster.protocol.ProtocolHandler;
+import org.apache.nifi.cluster.protocol.StandardDataFlow;
+import org.apache.nifi.cluster.protocol.UnknownServiceAddressException;
+import org.apache.nifi.cluster.protocol.jaxb.JaxbProtocolContext;
+import org.apache.nifi.cluster.protocol.jaxb.message.JaxbProtocolUtils;
+import org.apache.nifi.cluster.protocol.message.ConnectionRequestMessage;
+import org.apache.nifi.cluster.protocol.message.ConnectionResponseMessage;
+import org.apache.nifi.cluster.protocol.message.ControllerStartupFailureMessage;
+import org.apache.nifi.cluster.protocol.message.HeartbeatMessage;
+import org.apache.nifi.cluster.protocol.message.PingMessage;
+import org.apache.nifi.cluster.protocol.message.ProtocolMessage;
+import org.apache.nifi.io.socket.ServerSocketConfiguration;
+import org.apache.nifi.io.socket.SocketConfiguration;
+import org.apache.nifi.io.socket.multicast.DiscoverableService;
+import org.apache.nifi.io.socket.multicast.DiscoverableServiceImpl;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.mockito.invocation.InvocationOnMock;
+import org.mockito.stubbing.Answer;
+
+/**
+ * @author unattributed
+ */
+@Ignore("Randomly tests... probably timing-specific")
+public class NodeProtocolSenderImplTest {
+    
+    private SocketProtocolListener listener;
+    
+    private NodeProtocolSenderImpl sender;
+    
+    private DiscoverableService service;
+    
+    private ServerSocketConfiguration serverSocketConfiguration;
+    
+    private ClusterServiceLocator mockServiceLocator;
+    
+    private ProtocolHandler mockHandler;
+    
+    private NodeIdentifier nodeIdentifier;
+    
+    @Before
+    public void setup() throws IOException {
+        
+        serverSocketConfiguration = new ServerSocketConfiguration();
+
+        mockServiceLocator = mock(ClusterServiceLocator.class);
+        mockHandler = mock(ProtocolHandler.class);
+        
+        nodeIdentifier = new NodeIdentifier("1", "localhost", 1234, "localhost", 5678);
+        
+        ProtocolContext protocolContext = new JaxbProtocolContext(JaxbProtocolUtils.JAXB_CONTEXT);
+        
+        listener = new SocketProtocolListener(5, 0, serverSocketConfiguration, protocolContext);
+        listener.setShutdownListenerSeconds(3);
+        listener.addHandler(mockHandler);
+        listener.start();
+        
+        service = new DiscoverableServiceImpl("some-service", new InetSocketAddress("localhost", listener.getPort()));
+        
+        SocketConfiguration socketConfiguration = new SocketConfiguration();
+        socketConfiguration.setReuseAddress(true);
+        sender = new NodeProtocolSenderImpl(mockServiceLocator, socketConfiguration, protocolContext);
+    }
+    
+    @After
+    public void teardown() throws IOException {
+        if(listener.isRunning()) {
+            listener.stop();
+        }
+    }
+    
+    @Test
+    public void testConnect() throws Exception {
+        
+        when(mockServiceLocator.getService()).thenReturn(service);
+        when(mockHandler.canHandle(any(ProtocolMessage.class))).thenReturn(Boolean.TRUE);
+        ConnectionResponseMessage mockMessage = new ConnectionResponseMessage();
+        mockMessage.setConnectionResponse(new ConnectionResponse(nodeIdentifier, new StandardDataFlow("flow".getBytes("UTF-8"), new byte[0], new byte[0]), false, null, null, UUID.randomUUID().toString()));
+        when(mockHandler.handle(any(ProtocolMessage.class))).thenReturn(mockMessage);
+        
+        ConnectionRequestMessage request = new ConnectionRequestMessage();
+        request.setConnectionRequest(new ConnectionRequest(nodeIdentifier));
+        ConnectionResponseMessage response = sender.requestConnection(request);
+        assertNotNull(response);
+    }
+    
+    @Test(expected = UnknownServiceAddressException.class)
+    public void testConnectNoClusterManagerAddress() throws Exception {
+        
+        when(mockServiceLocator.getService()).thenReturn(null);
+        when(mockHandler.canHandle(any(ProtocolMessage.class))).thenReturn(Boolean.TRUE);
+        when(mockHandler.handle(any(ProtocolMessage.class))).thenReturn(new ConnectionResponseMessage());
+        
+        ConnectionRequestMessage request = new ConnectionRequestMessage();
+        request.setConnectionRequest(new ConnectionRequest(nodeIdentifier));
+
+        sender.requestConnection(request);
+        fail("failed to throw exception");
+    }
+    
+    @Test(expected = ProtocolException.class)
+    public void testConnectBadResponse() throws Exception {
+        
+        when(mockServiceLocator.getService()).thenReturn(service);
+        when(mockHandler.canHandle(any(ProtocolMessage.class))).thenReturn(Boolean.TRUE);
+        when(mockHandler.handle(any(ProtocolMessage.class))).thenReturn(new PingMessage());
+        
+        ConnectionRequestMessage request = new ConnectionRequestMessage();
+        request.setConnectionRequest(new ConnectionRequest(nodeIdentifier));
+        
+        sender.requestConnection(request);
+        fail("failed to throw exception");
+        
+    }
+    
+    @Test(expected = ProtocolException.class)
+    public void testConnectDelayedResponse() throws Exception {
+        
+        final int time = 250;
+        sender.getSocketConfiguration().setSocketTimeout(time);
+        when(mockServiceLocator.getService()).thenReturn(service);
+        when(mockHandler.canHandle(any(ProtocolMessage.class))).thenReturn(Boolean.TRUE);
+        when(mockHandler.handle(any(ProtocolMessage.class))).thenAnswer(new Answer<ConnectionResponseMessage>() {
+            @Override
+            public ConnectionResponseMessage answer(InvocationOnMock invocation) throws Throwable {
+                Thread.sleep(time * 3);
+                return new ConnectionResponseMessage();
+            }
+        });
+        ConnectionRequestMessage request = new ConnectionRequestMessage();
+        request.setConnectionRequest(new ConnectionRequest(nodeIdentifier));
+
+        sender.requestConnection(request);
+        fail("failed to throw exception");
+        
+    }
+    
+    @Test
+    public void testHeartbeat() throws Exception {
+        
+        when(mockServiceLocator.getService()).thenReturn(service);
+        when(mockHandler.canHandle(any(ProtocolMessage.class))).thenReturn(Boolean.TRUE);
+        when(mockHandler.handle(any(ProtocolMessage.class))).thenReturn(null);
+        
+        HeartbeatMessage hb = new HeartbeatMessage();
+        hb.setHeartbeat(new Heartbeat(new NodeIdentifier("id", "localhost", 3, "localhost", 4), false, false, new byte[] {1, 2, 3}));
+        sender.heartbeat(hb);
+    }
+    
+    @Test
+    public void testNotifyControllerStartupFailure() throws Exception {
+        
+        when(mockServiceLocator.getService()).thenReturn(service);
+        when(mockHandler.canHandle(any(ProtocolMessage.class))).thenReturn(Boolean.TRUE);
+        when(mockHandler.handle(any(ProtocolMessage.class))).thenReturn(null);
+        
+        ControllerStartupFailureMessage msg = new ControllerStartupFailureMessage();
+        msg.setNodeId(new NodeIdentifier("some-id", "some-addr", 1, "some-addr", 1));
+        msg.setExceptionMessage("some exception");
+        sender.notifyControllerStartupFailure(msg);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/testutils/DelayedProtocolHandler.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/testutils/DelayedProtocolHandler.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/testutils/DelayedProtocolHandler.java
new file mode 100644
index 0000000..07ee83a
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/testutils/DelayedProtocolHandler.java
@@ -0,0 +1,57 @@
+/*
+ * 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.nifi.cluster.protocol.impl.testutils;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.nifi.cluster.protocol.ProtocolException;
+import org.apache.nifi.cluster.protocol.ProtocolHandler;
+import org.apache.nifi.cluster.protocol.message.ProtocolMessage;
+
+/**
+ * @author unattributed
+ */
+public class DelayedProtocolHandler implements ProtocolHandler {
+
+    private int delay = 0;
+    private List<ProtocolMessage> messages = new ArrayList<>();
+
+    public DelayedProtocolHandler(int delay) {
+        this.delay = delay;
+    }
+
+    @Override
+    public ProtocolMessage handle(ProtocolMessage msg) throws ProtocolException {
+        try {
+            messages.add(msg);
+            Thread.sleep(delay);
+            return null;
+        } catch (final InterruptedException ie) {
+            throw new ProtocolException(ie);
+        }
+
+    }
+
+    @Override
+    public boolean canHandle(ProtocolMessage msg) {
+        return true;
+    }
+
+    public List<ProtocolMessage> getMessages() {
+        return messages;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/testutils/ReflexiveProtocolHandler.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/testutils/ReflexiveProtocolHandler.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/testutils/ReflexiveProtocolHandler.java
new file mode 100644
index 0000000..4e3b932
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/testutils/ReflexiveProtocolHandler.java
@@ -0,0 +1,47 @@
+/*
+ * 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.nifi.cluster.protocol.impl.testutils;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.nifi.cluster.protocol.ProtocolException;
+import org.apache.nifi.cluster.protocol.ProtocolHandler;
+import org.apache.nifi.cluster.protocol.message.ProtocolMessage;
+
+/**
+ * @author unattributed
+ */
+public class ReflexiveProtocolHandler implements ProtocolHandler {
+    
+    private List<ProtocolMessage> messages = new ArrayList<>();
+        
+    @Override
+    public ProtocolMessage handle(ProtocolMessage msg) throws ProtocolException {
+        messages.add(msg);
+        return msg;
+    }
+
+    @Override
+    public boolean canHandle(ProtocolMessage msg) {
+        return true;
+    }
+
+    public List<ProtocolMessage> getMessages() {
+        return messages;
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-web/.gitignore
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-web/.gitignore b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-web/.gitignore
new file mode 100755
index 0000000..ea8c4bf
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-web/.gitignore
@@ -0,0 +1 @@
+/target

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-web/pom.xml
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-web/pom.xml b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-web/pom.xml
new file mode 100644
index 0000000..18e4ba4
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-web/pom.xml
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.nifi</groupId>
+        <artifactId>nifi-framework</artifactId>
+        <version>0.0.3-incubating-SNAPSHOT</version>
+    </parent>
+    <artifactId>nifi-framework-cluster-web</artifactId>
+    <packaging>jar</packaging>
+    <description>The clustering software for communicating with the NiFi web api.</description>
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.nifi</groupId>
+            <artifactId>nifi-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.nifi</groupId>
+            <artifactId>nifi-properties</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.nifi</groupId>
+            <artifactId>nifi-web-optimistic-locking</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.nifi</groupId>
+            <artifactId>nifi-administration</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.nifi</groupId>
+            <artifactId>nifi-user-actions</artifactId>
+        </dependency>
+    </dependencies>
+</project>

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-web/src/main/java/org/apache/nifi/cluster/context/ClusterContext.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-web/src/main/java/org/apache/nifi/cluster/context/ClusterContext.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-web/src/main/java/org/apache/nifi/cluster/context/ClusterContext.java
new file mode 100644
index 0000000..44fb25a
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-web/src/main/java/org/apache/nifi/cluster/context/ClusterContext.java
@@ -0,0 +1,59 @@
+/*
+ * 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.nifi.cluster.context;
+
+import java.io.Serializable;
+import java.util.List;
+import org.apache.nifi.action.Action;
+import org.apache.nifi.web.Revision;
+
+/**
+ * Contains contextual information about clustering that may be serialized 
+ * between manager and node when communicating over HTTP.
+ */
+public interface ClusterContext extends Serializable {
+    
+    /**
+     * Returns a list of auditable actions.  The list is modifiable
+     * and will never be null.
+     * @return a collection of actions
+     */
+    List<Action> getActions();
+    
+    Revision getRevision();
+    
+    void setRevision(Revision revision);
+    
+    /**
+     * @return true if the request was sent by the cluster manager; false otherwise
+     */
+    boolean isRequestSentByClusterManager();
+    
+    /**
+     * Sets the flag to indicate if a request was sent by the cluster manager.
+     * @param flag true if the request was sent by the cluster manager; false otherwise
+     */
+    void setRequestSentByClusterManager(boolean flag);
+    
+    /**
+     * Gets an id generation seed. This is used to ensure that nodes are able to generate the
+     * same id across the cluster. This is usually handled by the cluster manager creating the
+     * id, however for some actions (snippets, templates, etc) this is not possible.
+     * @return 
+     */
+    String getIdGenerationSeed();
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-web/src/main/java/org/apache/nifi/cluster/context/ClusterContextImpl.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-web/src/main/java/org/apache/nifi/cluster/context/ClusterContextImpl.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-web/src/main/java/org/apache/nifi/cluster/context/ClusterContextImpl.java
new file mode 100644
index 0000000..06907d2
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-web/src/main/java/org/apache/nifi/cluster/context/ClusterContextImpl.java
@@ -0,0 +1,69 @@
+/*
+ * 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.nifi.cluster.context;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
+import org.apache.nifi.action.Action;
+import org.apache.nifi.web.Revision;
+
+/**
+ * A basic implementation of the context.
+ */
+public class ClusterContextImpl implements ClusterContext, Serializable {
+
+    private final List<Action> actions = new ArrayList<>();
+    
+    private Revision revision;
+    
+    private boolean requestSentByClusterManager;
+    
+    private final String idGenerationSeed = UUID.randomUUID().toString();
+    
+    @Override
+    public List<Action> getActions() {
+        return actions;
+    }
+
+    @Override
+    public Revision getRevision() {
+        return revision;
+    }
+
+    @Override
+    public void setRevision(Revision revision) {
+        this.revision = revision;
+    }
+
+    @Override
+    public boolean isRequestSentByClusterManager() {
+        return requestSentByClusterManager;
+    }
+    
+    @Override
+    public void setRequestSentByClusterManager(boolean requestSentByClusterManager) {
+        this.requestSentByClusterManager = requestSentByClusterManager;
+    }
+
+    @Override
+    public String getIdGenerationSeed() {
+        return this.idGenerationSeed;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-web/src/main/java/org/apache/nifi/cluster/context/ClusterContextThreadLocal.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-web/src/main/java/org/apache/nifi/cluster/context/ClusterContextThreadLocal.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-web/src/main/java/org/apache/nifi/cluster/context/ClusterContextThreadLocal.java
new file mode 100644
index 0000000..012e7c7
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-web/src/main/java/org/apache/nifi/cluster/context/ClusterContextThreadLocal.java
@@ -0,0 +1,47 @@
+/*
+ * 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.nifi.cluster.context;
+
+/**
+ * Manages a cluster context on a threadlocal.
+ */
+public class ClusterContextThreadLocal {
+    
+    private static final ThreadLocal<ClusterContext> contextHolder = new ThreadLocal<>();
+    
+    public static void removeContext() {
+        contextHolder.remove();
+    }
+    
+    public static ClusterContext createEmptyContext() {
+        return new ClusterContextImpl();
+    }
+    
+    public static ClusterContext getContext() {
+        ClusterContext ctx = contextHolder.get();
+        if(ctx == null) {
+            ctx = createEmptyContext();
+            contextHolder.set(ctx);
+        }
+        return ctx;
+    }
+    
+    public static void setContext(final ClusterContext context) {
+        contextHolder.set(context);
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-web/src/main/java/org/apache/nifi/web/ClusterAwareOptimisticLockingManager.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-web/src/main/java/org/apache/nifi/web/ClusterAwareOptimisticLockingManager.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-web/src/main/java/org/apache/nifi/web/ClusterAwareOptimisticLockingManager.java
new file mode 100644
index 0000000..90b8a37
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-web/src/main/java/org/apache/nifi/web/ClusterAwareOptimisticLockingManager.java
@@ -0,0 +1,96 @@
+/*
+ * 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.nifi.web;
+
+import org.apache.nifi.cluster.context.ClusterContext;
+import org.apache.nifi.cluster.context.ClusterContextThreadLocal;
+
+/**
+ * An optimistic locking manager that provides for optimistic locking in a clustered
+ * environment.
+ * 
+ * @author unattributed
+ */
+public class ClusterAwareOptimisticLockingManager implements OptimisticLockingManager {
+
+    private final OptimisticLockingManager optimisticLockingManager;
+    
+    public ClusterAwareOptimisticLockingManager(final OptimisticLockingManager optimisticLockingManager) {
+        this.optimisticLockingManager = optimisticLockingManager;
+    }
+    
+    @Override
+    public Revision checkRevision(Revision revision) throws InvalidRevisionException {
+        final Revision currentRevision = getRevision();
+        if(currentRevision.equals(revision) == false) {
+            throw new InvalidRevisionException(String.format("Given revision %s does not match current revision %s.", revision, currentRevision));
+        } else {
+            return revision.increment(revision.getClientId());
+        }
+    }
+
+    @Override
+    public boolean isCurrent(Revision revision) {
+        return getRevision().equals(revision);
+    }
+
+    @Override
+    public Revision getRevision() {
+        final ClusterContext ctx = ClusterContextThreadLocal.getContext();
+        if(ctx == null || ctx.getRevision() == null) {
+            return optimisticLockingManager.getRevision();
+        } else {
+            return ctx.getRevision();
+        }
+    }
+
+    @Override
+    public void setRevision(final Revision revision) {
+        final ClusterContext ctx = ClusterContextThreadLocal.getContext();
+        if(ctx != null) {
+            ctx.setRevision(revision);
+        }
+        optimisticLockingManager.setRevision(revision);
+    }
+
+    @Override
+    public Revision incrementRevision() {
+        final Revision currentRevision = getRevision();
+        final Revision incRevision = currentRevision.increment();
+        setRevision(incRevision);
+        return incRevision;
+    }
+
+    @Override
+    public Revision incrementRevision(final String clientId) {
+        final Revision currentRevision = getRevision();
+        final Revision incRevision = currentRevision.increment(clientId);
+        setRevision(incRevision);
+        return incRevision;
+    }
+
+    @Override
+    public String getLastModifier() {
+        return optimisticLockingManager.getLastModifier();
+    }
+
+    @Override
+    public void setLastModifier(final String lastModifier) {
+        optimisticLockingManager.setLastModifier(lastModifier);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/.gitignore
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/.gitignore b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/.gitignore
new file mode 100755
index 0000000..ea8c4bf
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/.gitignore
@@ -0,0 +1 @@
+/target

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/pom.xml
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/pom.xml b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/pom.xml
new file mode 100644
index 0000000..ef927a3
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/pom.xml
@@ -0,0 +1,144 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.nifi</groupId>
+        <artifactId>nifi-framework</artifactId>
+        <version>0.0.3-incubating-SNAPSHOT</version>
+    </parent>
+    <artifactId>nifi-framework-cluster</artifactId>
+    <packaging>jar</packaging>
+    <description>The clustering software for NiFi.</description>
+    <dependencies>
+        <!-- application core dependencies -->
+        <dependency>
+            <groupId>org.apache.nifi</groupId>
+            <artifactId>nifi-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.nifi</groupId>
+            <artifactId>nifi-properties</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.nifi</groupId>
+            <artifactId>nifi-logging-utils</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.nifi</groupId>
+            <artifactId>nifi-utils</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.nifi</groupId>
+            <artifactId>nifi-client-dto</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.nifi</groupId>
+            <artifactId>nifi-framework-core</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.nifi</groupId>
+            <artifactId>nifi-framework-core-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.nifi</groupId>
+            <artifactId>nifi-framework-cluster-protocol</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.nifi</groupId>
+            <artifactId>nifi-framework-cluster-web</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.nifi</groupId>
+            <artifactId>nifi-web-utils</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.nifi</groupId>
+            <artifactId>nifi-administration</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.nifi</groupId>
+            <artifactId>nifi-site-to-site</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.nifi</groupId>
+            <artifactId>nifi-site-to-site-client</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-compress</artifactId>
+        </dependency>
+        <!-- third party dependencies -->
+        
+        <!-- sun dependencies -->
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>javax.servlet-api</artifactId>
+        </dependency>
+        
+        <!-- commons dependencies -->
+        <dependency>
+            <groupId>commons-io</groupId>
+            <artifactId>commons-io</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>commons-net</groupId>
+            <artifactId>commons-net</artifactId>
+        </dependency>
+        
+        <!-- jersey dependencies -->
+        <dependency>
+            <groupId>com.sun.jersey</groupId>
+            <artifactId>jersey-client</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.sun.jersey</groupId>
+            <artifactId>jersey-server</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.sun.jersey</groupId>
+            <artifactId>jersey-json</artifactId>
+        </dependency>
+        
+        <!-- spring dependencies -->
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-core</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-beans</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-context</artifactId>
+        </dependency>
+    </dependencies>
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.rat</groupId>
+                <artifactId>apache-rat-plugin</artifactId>
+                <configuration>
+                    <excludes>
+                        <exclude>src/test/resources/org/apache/nifi/cluster/firewall/impl/empty.txt</exclude>
+                        <exclude>src/test/resources/org/apache/nifi/cluster/firewall/impl/ips.txt</exclude>
+                    </excludes>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>  
+</project>

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/client/MulticastTestClient.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/client/MulticastTestClient.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/client/MulticastTestClient.java
new file mode 100644
index 0000000..0b70c61
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/client/MulticastTestClient.java
@@ -0,0 +1,151 @@
+/*
+ * 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.nifi.cluster.client;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.net.DatagramPacket;
+import java.net.InetSocketAddress;
+import java.net.MulticastSocket;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Locale;
+import java.util.Timer;
+import java.util.TimerTask;
+
+import org.apache.nifi.cluster.protocol.ProtocolContext;
+import org.apache.nifi.cluster.protocol.ProtocolException;
+import org.apache.nifi.cluster.protocol.ProtocolHandler;
+import org.apache.nifi.cluster.protocol.ProtocolMessageMarshaller;
+import org.apache.nifi.cluster.protocol.impl.MulticastProtocolListener;
+import org.apache.nifi.cluster.protocol.jaxb.JaxbProtocolContext;
+import org.apache.nifi.cluster.protocol.jaxb.message.JaxbProtocolUtils;
+import org.apache.nifi.cluster.protocol.message.PingMessage;
+import org.apache.nifi.cluster.protocol.message.ProtocolMessage;
+import org.apache.nifi.io.socket.multicast.MulticastConfiguration;
+import org.apache.nifi.io.socket.multicast.MulticastUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Simple multicast test client that sends ping messages to a group address.
+ */
+public class MulticastTestClient {
+
+    private static final Logger logger = LoggerFactory.getLogger(MulticastTestClient.class);
+
+    private static final int PING_DELAY_SECONDS = 3;
+
+    public static void main(final String... args) throws IOException {
+
+        String group = System.getProperty("group", "225.0.0.0");
+        if (group == null) {
+            System.out.println("Host system property 'group' was not given.");
+            return;
+        }
+        group = group.trim();
+        if (group.length() == 0) {
+            System.out.println("Host system property 'group' must be non-empty.");
+            return;
+        }
+
+        final String portStr = System.getProperty("port", "2222");
+        final int port;
+        try {
+            port = Integer.parseInt(portStr);
+        } catch (final NumberFormatException nfe) {
+            System.out.println("Port system property 'port' was not a valid port.");
+            return;
+        }
+
+        logger.info(String.format("Pinging every %s seconds using multicast address: %s:%s.", PING_DELAY_SECONDS, group, port));
+        logger.info("Override defaults by using system properties '-Dgroup=<Class D IP>' and '-Dport=<unused port>'.");
+        logger.info("The test client may be stopped by entering a newline at the command line.");
+
+        final InetSocketAddress addr = new InetSocketAddress(group, port);
+        final ProtocolContext<ProtocolMessage> protocolContext = new JaxbProtocolContext<ProtocolMessage>(JaxbProtocolUtils.JAXB_CONTEXT);
+        final MulticastConfiguration multicastConfig = new MulticastConfiguration();
+        multicastConfig.setReuseAddress(true);
+
+        // setup listener
+        final MulticastProtocolListener listener = new MulticastProtocolListener(1, addr, multicastConfig, protocolContext);
+        listener.addHandler(new ProtocolHandler() {
+            @Override
+            public ProtocolMessage handle(ProtocolMessage msg) throws ProtocolException {
+                final PingMessage pingMsg = (PingMessage) msg;
+                final SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss", Locale.US);
+                logger.info("Pinged at: " + sdf.format(pingMsg.getDate()));
+                return null;
+            }
+
+            @Override
+            public boolean canHandle(ProtocolMessage msg) {
+                return true;
+            }
+        });
+
+        // setup socket
+        final MulticastSocket multicastSocket = MulticastUtils.createMulticastSocket(multicastConfig);
+
+        // setup broadcaster
+        final Timer broadcaster = new Timer("Multicast Test Client", /**
+                 * is daemon *
+                 */
+                true);
+
+        try {
+
+            // start listening
+            listener.start();
+
+            // start broadcasting
+            broadcaster.schedule(new TimerTask() {
+
+                @Override
+                public void run() {
+                    try {
+
+                        final PingMessage msg = new PingMessage();
+                        msg.setDate(new Date());
+
+                        // marshal message to output stream
+                        final ProtocolMessageMarshaller<ProtocolMessage> marshaller = protocolContext.createMarshaller();
+                        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+                        marshaller.marshal(msg, baos);
+                        final byte[] packetBytes = baos.toByteArray();
+
+                        // send message
+                        final DatagramPacket packet = new DatagramPacket(packetBytes, packetBytes.length, addr);
+                        multicastSocket.send(packet);
+
+                    } catch (final Exception ex) {
+                        logger.warn("Failed to send message due to: " + ex, ex);
+                    }
+                }
+            }, 0, PING_DELAY_SECONDS * 1000);
+
+            // block until any input is received
+            System.in.read();
+
+        } finally {
+            broadcaster.cancel();
+            if (listener.isRunning()) {
+                listener.stop();
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/event/Event.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/event/Event.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/event/Event.java
new file mode 100644
index 0000000..6bc5d6c
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/event/Event.java
@@ -0,0 +1,122 @@
+/*
+ * 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.nifi.cluster.event;
+
+import java.util.Date;
+import org.apache.commons.lang3.StringUtils;
+
+/**
+ * Events describe the occurrence of something noteworthy. They record the
+ * event's source, a timestamp, a description, and a category.
+ *
+ * @author unattributed
+ *
+ * @Immutable
+ */
+public class Event {
+
+    public static enum Category {
+
+        DEBUG,
+        INFO,
+        WARN
+    }
+
+    private final String source;
+
+    private final long timestamp;
+
+    private final Category category;
+
+    private final String message;
+
+    /**
+     * Creates an event with the current time as the timestamp and a category of
+     * "INFO".
+     *
+     * @param source the source
+     * @param message the description
+     */
+    public Event(final String source, final String message) {
+        this(source, message, Category.INFO);
+    }
+
+    /**
+     * Creates an event with the current time as the timestamp.
+     *
+     * @param source the source
+     * @param message the description
+     * @param category the event category
+     */
+    public Event(final String source, final String message, final Category category) {
+        this(source, message, category, new Date().getTime());
+    }
+
+    /**
+     * Creates an event with the a category of "INFO".
+     *
+     * @param source the source
+     * @param message the description
+     * @param timestamp the time of occurrence
+     */
+    public Event(final String source, final String message, final long timestamp) {
+        this(source, message, Category.INFO, timestamp);
+    }
+
+    /**
+     * Creates an event.
+     *
+     * @param source the source
+     * @param message the description
+     * @param category the event category
+     * @param timestamp the time of occurrence
+     */
+    public Event(final String source, final String message, final Category category, final long timestamp) {
+
+        if (StringUtils.isBlank(source)) {
+            throw new IllegalArgumentException("Source may not be empty or null.");
+        } else if (StringUtils.isBlank(message)) {
+            throw new IllegalArgumentException("Event message may not be empty or null.");
+        } else if (category == null) {
+            throw new IllegalArgumentException("Event category may not be null.");
+        } else if (timestamp < 0) {
+            throw new IllegalArgumentException("Timestamp may not be negative: " + timestamp);
+        }
+
+        this.source = source;
+        this.message = message;
+        this.category = category;
+        this.timestamp = timestamp;
+    }
+
+    public Category getCategory() {
+        return category;
+    }
+
+    public String getMessage() {
+        return message;
+    }
+
+    public String getSource() {
+        return source;
+    }
+
+    public long getTimestamp() {
+        return timestamp;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/event/EventManager.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/event/EventManager.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/event/EventManager.java
new file mode 100644
index 0000000..f9dfb00
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/event/EventManager.java
@@ -0,0 +1,65 @@
+/*
+ * 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.nifi.cluster.event;
+
+import java.util.List;
+
+/**
+ * Manages an ordered list of events. The event history size dictates the total
+ * number of events to manage for a given source at a given time. When the size
+ * is exceeded, the oldest event for that source is evicted.
+ *
+ * @author unattributed
+ */
+public interface EventManager {
+
+    /**
+     * Adds an event to the manager.
+     *
+     * @param event an Event
+     */
+    void addEvent(Event event);
+
+    /**
+     * Returns a list of events for a given source sorted by the event's
+     * timestamp where the most recent event is first in the list.
+     *
+     * @param eventSource the source
+     *
+     * @return the list of events
+     */
+    List<Event> getEvents(String eventSource);
+
+    /*
+     * Returns the most recent event for the source.  If no events exist, then
+     * null is returned.
+     */
+    Event getMostRecentEvent(String eventSource);
+
+    /*
+     * Clears all events for the given source.
+     */
+    void clearEventHistory(String eventSource);
+
+    /**
+     * Returns the history size.
+     *
+     * @return the history size
+     */
+    int getEventHistorySize();
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/event/impl/EventManagerImpl.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/event/impl/EventManagerImpl.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/event/impl/EventManagerImpl.java
new file mode 100644
index 0000000..7fadc78
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/event/impl/EventManagerImpl.java
@@ -0,0 +1,143 @@
+/*
+ * 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.nifi.cluster.event.impl;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.PriorityQueue;
+import java.util.Queue;
+import org.apache.nifi.cluster.event.Event;
+import org.apache.nifi.cluster.event.EventManager;
+
+/**
+ * Implements the EventManager.
+ *
+ * @author unattributed
+ */
+public class EventManagerImpl implements EventManager {
+
+    /**
+     * associates the source ID with an ordered queue of events, ordered by most
+     * recent event
+     */
+    private final Map<String, Queue<Event>> eventsMap = new HashMap<>();
+
+    /**
+     * the number of events to maintain for a given source
+     */
+    private final int eventHistorySize;
+
+    /**
+     * Creates an instance.
+     *
+     * @param eventHistorySize the number of events to manage for a given
+     * source. Value must be positive.
+     */
+    public EventManagerImpl(final int eventHistorySize) {
+        if (eventHistorySize <= 0) {
+            throw new IllegalArgumentException("Event history size must be positive: " + eventHistorySize);
+        }
+        this.eventHistorySize = eventHistorySize;
+    }
+
+    @Override
+    public void addEvent(final Event event) {
+
+        if (event == null) {
+            throw new IllegalArgumentException("Event may not be null.");
+        }
+
+        Queue<Event> events = eventsMap.get(event.getSource());
+        if (events == null) {
+            // no events from this source, so add a new queue to the map
+            events = new PriorityQueue<>(eventHistorySize, createEventComparator());
+            eventsMap.put(event.getSource(), events);
+        }
+
+        // add event
+        events.add(event);
+
+        // if we exceeded the history size, then evict the oldest event
+        if (events.size() > eventHistorySize) {
+            removeOldestEvent(events);
+        }
+
+    }
+
+    @Override
+    public List<Event> getEvents(final String eventSource) {
+        final Queue<Event> events = eventsMap.get(eventSource);
+        if (events == null) {
+            return Collections.EMPTY_LIST;
+        } else {
+            return Collections.unmodifiableList(new ArrayList<>(events));
+        }
+    }
+
+    @Override
+    public int getEventHistorySize() {
+        return eventHistorySize;
+    }
+
+    @Override
+    public Event getMostRecentEvent(final String eventSource) {
+        final Queue<Event> events = eventsMap.get(eventSource);
+        if (events == null) {
+            return null;
+        } else {
+            return events.peek();
+        }
+    }
+
+    @Override
+    public void clearEventHistory(final String eventSource) {
+        eventsMap.remove(eventSource);
+    }
+
+    private Comparator createEventComparator() {
+        return new Comparator<Event>() {
+            @Override
+            public int compare(final Event o1, final Event o2) {
+                // orders events by most recent first
+                return (int) (o2.getTimestamp() - o1.getTimestamp());
+            }
+        };
+    }
+
+    private void removeOldestEvent(final Collection<Event> events) {
+
+        if (events.isEmpty()) {
+            return;
+        }
+
+        Event oldestEvent = null;
+        for (final Event event : events) {
+            if (oldestEvent == null || oldestEvent.getTimestamp() > event.getTimestamp()) {
+                oldestEvent = event;
+            }
+        }
+
+        events.remove(oldestEvent);
+
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/firewall/ClusterNodeFirewall.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/firewall/ClusterNodeFirewall.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/firewall/ClusterNodeFirewall.java
new file mode 100644
index 0000000..2e3d278
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/firewall/ClusterNodeFirewall.java
@@ -0,0 +1,35 @@
+/*
+ * 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.nifi.cluster.firewall;
+
+/**
+ * Defines the interface for restricting external client connections to a set of
+ * hosts or IPs.
+ */
+public interface ClusterNodeFirewall {
+
+    /**
+     * Returns true if the given host or IP is permissible through the firewall;
+     * false otherwise.
+     *
+     * If an IP is given, then it must be formatted in dotted decimal notation.
+     * @param hostOrIp
+     * @return 
+     */
+    boolean isPermissible(String hostOrIp);
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/firewall/impl/FileBasedClusterNodeFirewall.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/firewall/impl/FileBasedClusterNodeFirewall.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/firewall/impl/FileBasedClusterNodeFirewall.java
new file mode 100644
index 0000000..916ec14
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/firewall/impl/FileBasedClusterNodeFirewall.java
@@ -0,0 +1,207 @@
+/*
+ * 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.nifi.cluster.firewall.impl;
+
+import java.io.*;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.*;
+import org.apache.commons.net.util.SubnetUtils;
+import org.apache.nifi.cluster.firewall.ClusterNodeFirewall;
+import org.apache.nifi.util.file.FileUtils;
+import org.apache.nifi.logging.NiFiLog;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * A file-based implementation of the ClusterFirewall interface. The class is
+ * configured with a file. If the file is empty, then everything is permissible.
+ * Otherwise, the file should contain hostnames or IPs formatted as dotted
+ * decimals with an optional CIDR suffix. Each entry must be separated by a
+ * newline. An example configuration is given below:
+ *
+ * <code>
+ * # hash character is a comment delimiter
+ * 1.2.3.4         # exact IP
+ * some.host.name  # a host name
+ * 4.5.6.7/8       # range of CIDR IPs
+ * 9.10.11.12/13   # a smaller range of CIDR IPs
+ * </code>
+ *
+ * This class allows for synchronization with an optionally configured restore
+ * directory. If configured, then at startup, if the either the config file or
+ * the restore directory's copy is missing, then the configuration file will be
+ * copied to the appropriate location. If both restore directory contains a copy
+ * that is different in content to configuration file, then an exception is
+ * thrown at construction time.
+ */
+public class FileBasedClusterNodeFirewall implements ClusterNodeFirewall {
+
+    private final File config;
+
+    private final File restoreDirectory;
+
+    private final Collection<SubnetUtils.SubnetInfo> subnetInfos = new ArrayList<>();
+
+    private static final Logger logger = new NiFiLog(LoggerFactory.getLogger(FileBasedClusterNodeFirewall.class));
+
+    public FileBasedClusterNodeFirewall(final File config) throws IOException {
+        this(config, null);
+    }
+
+    public FileBasedClusterNodeFirewall(final File config, final File restoreDirectory) throws IOException {
+
+        if (config == null) {
+            throw new IllegalArgumentException("Firewall configuration file may not be null.");
+        }
+
+        this.config = config;
+        this.restoreDirectory = restoreDirectory;
+
+        if (restoreDirectory != null) {
+            // synchronize with restore directory
+            try {
+                syncWithRestoreDirectory();
+            } catch (final IOException ioe) {
+                throw new RuntimeException(ioe);
+            }
+        }
+
+        if (!config.exists() && !config.createNewFile()) {
+            throw new IOException("Firewall configuration file did not exist and could not be created: " + config.getAbsolutePath());
+        }
+
+        logger.info("Loading cluster firewall configuration.");
+        parseConfig(config);
+        logger.info("Cluster firewall configuration loaded.");
+    }
+
+    @Override
+    public boolean isPermissible(final String hostOrIp) {
+        try {
+
+            // if no rules, then permit everything
+            if (subnetInfos.isEmpty()) {
+                return true;
+            }
+
+            final String ip;
+            try {
+                ip = InetAddress.getByName(hostOrIp).getHostAddress();
+            } catch (final UnknownHostException uhe) {
+                logger.warn("Blocking unknown host: " + hostOrIp, uhe);
+                return false;
+            }
+
+            // check each subnet to see if IP is in range
+            for (final SubnetUtils.SubnetInfo subnetInfo : subnetInfos) {
+                if (subnetInfo.isInRange(ip)) {
+                    return true;
+                }
+            }
+
+            // no match
+            return false;
+
+        } catch (final IllegalArgumentException iae) {
+            return false;
+        }
+    }
+
+    private void syncWithRestoreDirectory() throws IOException {
+
+        // sanity check that restore directory is a directory, creating it if necessary
+        FileUtils.ensureDirectoryExistAndCanAccess(restoreDirectory);
+
+        // check that restore directory is not the same as the primary directory
+        if (config.getParentFile().getAbsolutePath().equals(restoreDirectory.getAbsolutePath())) {
+            throw new IllegalStateException(
+                    String.format("Cluster firewall configuration file '%s' cannot be in the restore directory '%s' ",
+                            config.getAbsolutePath(), restoreDirectory.getAbsolutePath()));
+        }
+
+        // the restore copy will have same file name, but reside in a different directory
+        final File restoreFile = new File(restoreDirectory, config.getName());
+
+        // sync the primary copy with the restore copy
+        FileUtils.syncWithRestore(config, restoreFile, logger);
+
+    }
+
+    private void parseConfig(final File config) throws IOException {
+
+        // clear old information
+        subnetInfos.clear();
+        try (BufferedReader br = new BufferedReader(new FileReader(config))) {
+
+            String ipOrHostLine;
+            String ipCidr;
+            int totalIpsAdded = 0;
+            while ((ipOrHostLine = br.readLine()) != null) {
+
+                // cleanup whitespace
+                ipOrHostLine = ipOrHostLine.trim();
+
+                if (ipOrHostLine.isEmpty() || ipOrHostLine.startsWith("#")) {
+                    // skip empty lines or comments
+                    continue;
+                } else if (ipOrHostLine.contains("#")) {
+                    // parse out comments in IP containing lines
+                    ipOrHostLine = ipOrHostLine.substring(0, ipOrHostLine.indexOf("#")).trim();
+                }
+
+                // if given a complete IP, then covert to CIDR
+                if (ipOrHostLine.contains("/")) {
+                    ipCidr = ipOrHostLine;
+                } else if (ipOrHostLine.contains("\\")) {
+                    logger.warn("CIDR IP notation uses forward slashes '/'.  Replacing backslash '\\' with forward slash'/' for '" + ipOrHostLine + "'");
+                    ipCidr = ipOrHostLine.replace("\\", "/");
+                } else {
+                    try {
+                        ipCidr = InetAddress.getByName(ipOrHostLine).getHostAddress();
+                        if (!ipOrHostLine.equals(ipCidr)) {
+                            logger.debug(String.format("Resolved host '%s' to ip '%s'", ipOrHostLine, ipCidr));
+                        }
+                        ipCidr += "/32";
+                        logger.debug("Adding CIDR to exact IP: " + ipCidr);
+                    } catch (final UnknownHostException uhe) {
+                        logger.warn("Firewall is skipping unknown host address: " + ipOrHostLine);
+                        continue;
+                    }
+                }
+
+                try {
+                    logger.debug("Adding CIDR IP to firewall: " + ipCidr);
+                    final SubnetUtils subnetUtils = new SubnetUtils(ipCidr);
+                    subnetUtils.setInclusiveHostCount(true);
+                    subnetInfos.add(subnetUtils.getInfo());
+                    totalIpsAdded++;
+                } catch (final IllegalArgumentException iae) {
+                    logger.warn("Firewall is skipping invalid CIDR address: " + ipOrHostLine);
+                }
+
+            }
+
+            if (totalIpsAdded == 0) {
+                logger.info("No IPs added to firewall.  Firewall will accept all requests.");
+            } else {
+                logger.info(String.format("Added %d IP(s) to firewall.  Only requests originating from the configured IPs will be accepted.", totalIpsAdded));
+            }
+
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/flow/ClusterDataFlow.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/flow/ClusterDataFlow.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/flow/ClusterDataFlow.java
new file mode 100644
index 0000000..eedb88f
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/flow/ClusterDataFlow.java
@@ -0,0 +1,45 @@
+/*
+ * 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.nifi.cluster.flow;
+
+import org.apache.nifi.cluster.protocol.NodeIdentifier;
+import org.apache.nifi.cluster.protocol.StandardDataFlow;
+
+/**
+ * A dataflow with additional information about the cluster.
+ *
+ * @author unattributed
+ */
+public class ClusterDataFlow {
+
+    private final StandardDataFlow dataFlow;
+
+    private final NodeIdentifier primaryNodeId;
+
+    public ClusterDataFlow(final StandardDataFlow dataFlow, final NodeIdentifier primaryNodeId) {
+        this.dataFlow = dataFlow;
+        this.primaryNodeId = primaryNodeId;
+    }
+
+    public NodeIdentifier getPrimaryNodeId() {
+        return primaryNodeId;
+    }
+
+    public StandardDataFlow getDataFlow() {
+        return dataFlow;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/flow/DaoException.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/flow/DaoException.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/flow/DaoException.java
new file mode 100644
index 0000000..6ff15a7
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/flow/DaoException.java
@@ -0,0 +1,40 @@
+/*
+ * 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.nifi.cluster.flow;
+
+/**
+ * A base exception for data access exceptions.
+ *
+ * @author unattributed
+ */
+public class DaoException extends RuntimeException {
+
+    public DaoException() {
+    }
+
+    public DaoException(String msg) {
+        super(msg);
+    }
+
+    public DaoException(Throwable cause) {
+        super(cause);
+    }
+
+    public DaoException(String msg, Throwable cause) {
+        super(msg, cause);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/flow/DataFlowDao.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/flow/DataFlowDao.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/flow/DataFlowDao.java
new file mode 100644
index 0000000..a273704
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/flow/DataFlowDao.java
@@ -0,0 +1,62 @@
+/*
+ * 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.nifi.cluster.flow;
+
+/**
+ * A data access object for loading and saving the flow managed by the cluster.
+ *
+ * @author unattributed
+ */
+public interface DataFlowDao {
+
+    /**
+     * Loads the cluster's dataflow.
+     *
+     * @return the dataflow or null if no dataflow exists
+     *
+     * @throws DaoException if the dataflow was unable to be loaded
+     */
+    ClusterDataFlow loadDataFlow() throws DaoException;
+
+    /**
+     * Saves the cluster's dataflow.
+     *
+     *
+     * @param dataFlow
+     * @throws DaoException if the dataflow was unable to be saved
+     */
+    void saveDataFlow(ClusterDataFlow dataFlow) throws DaoException;
+
+    /**
+     * Sets the state of the dataflow. If the dataflow does not exist, then an
+     * exception is thrown.
+     *
+     * @param flowState the state of the dataflow
+     *
+     * @throws DaoException if the state was unable to be updated
+     */
+    void setPersistedFlowState(PersistedFlowState flowState) throws DaoException;
+
+    /**
+     * Gets the state of the dataflow.
+     *
+     * @return the state of the dataflow
+     *
+     * @throws DaoException if the state was unable to be retrieved
+     */
+    PersistedFlowState getPersistedFlowState() throws DaoException;
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/flow/DataFlowManagementService.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/flow/DataFlowManagementService.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/flow/DataFlowManagementService.java
new file mode 100644
index 0000000..339d904
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/flow/DataFlowManagementService.java
@@ -0,0 +1,115 @@
+/*
+ * 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.nifi.cluster.flow;
+
+import java.util.Set;
+import org.apache.nifi.cluster.protocol.NodeIdentifier;
+
+/**
+ * A service for managing the cluster's flow. The service will attempt to keep
+ * the cluster's dataflow current while respecting the value of the configured
+ * retrieval delay.
+ *
+ * The eligible retrieval time is reset with the configured delay every time the
+ * flow state is set to STALE. If the state is set to UNKNOWN or CURRENT, then
+ * the flow will not be retrieved.
+ *
+ * Clients must call start() and stop() to initialize and stop the instance.
+ *
+ * @author unattributed
+ */
+public interface DataFlowManagementService {
+
+    /**
+     * Starts the instance. Start may only be called if the instance is not
+     * running.
+     */
+    void start();
+
+    /**
+     * Stops the instance. Stop may only be called if the instance is running.
+     */
+    void stop();
+
+    /**
+     * @return true if the instance is started; false otherwise.
+     */
+    boolean isRunning();
+
+    /**
+     * Loads the dataflow.
+     *
+     * @return the dataflow or null if no dataflow exists
+     */
+    ClusterDataFlow loadDataFlow();
+
+    /**
+     * Updates the dataflow with the given primary node identifier.
+     *
+     * @param nodeId the node identifier
+     *
+     * @throws DaoException if the update failed
+     */
+    void updatePrimaryNode(NodeIdentifier nodeId) throws DaoException;
+
+    /**
+     * Sets the state of the flow.
+     *
+     * @param flowState the state
+     *
+     * @see PersistedFlowState
+     */
+    void setPersistedFlowState(PersistedFlowState flowState);
+
+    /**
+     * @return the state of the flow
+     */
+    PersistedFlowState getPersistedFlowState();
+
+    /**
+     * @return true if the flow is current; false otherwise.
+     */
+    boolean isFlowCurrent();
+
+    /**
+     * Sets the node identifiers to use when attempting to retrieve the flow.
+     *
+     * @param nodeIds the node identifiers
+     */
+    void setNodeIds(Set<NodeIdentifier> nodeIds);
+
+    /**
+     * Returns the set of node identifiers the service is using to retrieve the
+     * flow.
+     *
+     * @return the set of node identifiers the service is using to retrieve the
+     * flow.
+     */
+    Set<NodeIdentifier> getNodeIds();
+
+    /**
+     * @return the retrieval delay in seconds
+     */
+    int getRetrievalDelaySeconds();
+
+    /**
+     * Sets the retrieval delay.
+     *
+     * @param delay the retrieval delay in seconds
+     */
+    void setRetrievalDelay(String delay);
+}


[03/20] incubator-nifi git commit: NIFI-410 pushed RAT exclusions down to the relevant modules and stopped doing broad test resource exclusion - is now specific

Posted by jo...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/node/Node.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/node/Node.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/node/Node.java
new file mode 100644
index 0000000..84565da
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/node/Node.java
@@ -0,0 +1,252 @@
+/*
+ * 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.nifi.cluster.node;
+
+import java.util.concurrent.atomic.AtomicLong;
+
+import org.apache.nifi.cluster.HeartbeatPayload;
+import org.apache.nifi.cluster.protocol.Heartbeat;
+import org.apache.nifi.cluster.protocol.NodeIdentifier;
+import org.apache.nifi.cluster.protocol.ProtocolException;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Represents a connected flow controller. Nodes always have an immutable
+ * identifier and a status. The status may be changed, but never null.
+ *
+ * A Node may be cloned, but the cloning is a shallow copy of the instance.
+ *
+ * This class overrides hashCode and equals and considers two instances to be
+ * equal if they have the equal NodeIdentifiers.
+ *
+ * @author unattributed
+ */
+public class Node implements Cloneable, Comparable<Node> {
+
+    private static final Logger lockLogger = LoggerFactory.getLogger("cluster.lock");
+
+    /**
+     * The semantics of a Node status are as follows:
+     * <ul>
+     * <li>CONNECTED -- a flow controller that is connected to the cluster. A
+     * connecting node transitions to connected after the cluster receives the
+     * flow controller's first heartbeat. A connected node can transition to
+     * disconnecting.</li>
+     * <li>CONNECTING -- a flow controller has issued a connection request to
+     * the cluster, but has not yet sent a heartbeat. A connecting node can
+     * transition to disconnecting or connected. The cluster will not accept any
+     * external requests to change the flow while any node is connecting.</li>
+     * <li>DISCONNECTED -- a flow controller that is not connected to the
+     * cluster. A disconnected node can transition to connecting.</li>
+     * <li>DISCONNECTING -- a flow controller that is in the process of
+     * disconnecting from the cluster. A disconnecting node will always
+     * transition to disconnected.</li>
+     * </ul>
+     */
+    public static enum Status {
+
+        CONNECTED,
+        CONNECTING,
+        DISCONNECTED,
+        DISCONNECTING
+    }
+
+    /**
+     * the node's unique identifier
+     */
+    private final NodeIdentifier nodeId;
+
+    /**
+     * the node statue
+     */
+    private Status status;
+
+    /**
+     * the last heartbeat received by from the node
+     */
+    private Heartbeat lastHeartbeat;
+
+    /**
+     * the payload of the last heartbeat received from the node
+     */
+    private HeartbeatPayload lastHeartbeatPayload;
+
+    /**
+     * the last time the connection for this node was requested
+     */
+    private AtomicLong connectionRequestedTimestamp = new AtomicLong(0L);
+
+    /**
+     * a flag to indicate this node was disconnected because of a lack of
+     * heartbeat
+     */
+    private boolean heartbeatDisconnection;
+
+    public Node(final NodeIdentifier id, final Status status) {
+        if (id == null) {
+            throw new IllegalArgumentException("ID may not be null.");
+        } else if (status == null) {
+            throw new IllegalArgumentException("Status may not be null.");
+        }
+        this.nodeId = id;
+        this.status = status;
+    }
+
+    public NodeIdentifier getNodeId() {
+        return nodeId;
+    }
+
+    /**
+     * Returns the last received heartbeat or null if no heartbeat has been set.
+     *
+     * @return a heartbeat or null
+     */
+    public Heartbeat getHeartbeat() {
+        return lastHeartbeat;
+    }
+
+    public HeartbeatPayload getHeartbeatPayload() {
+        return lastHeartbeatPayload;
+    }
+
+    /**
+     * Sets the last heartbeat received.
+     *
+     * @param heartbeat a heartbeat
+     *
+     * @throws ProtocolException if the heartbeat's payload failed unmarshalling
+     */
+    public void setHeartbeat(final Heartbeat heartbeat) throws ProtocolException {
+        this.lastHeartbeat = heartbeat;
+        if (this.lastHeartbeat == null) {
+            this.lastHeartbeatPayload = null;
+        } else {
+            final byte[] payload = lastHeartbeat.getPayload();
+            if (payload == null || payload.length == 0) {
+                this.lastHeartbeatPayload = null;
+            } else {
+                this.lastHeartbeatPayload = HeartbeatPayload.unmarshal(payload);
+            }
+        }
+    }
+
+    /**
+     * Returns the time of the last received connection request for this node.
+     *
+     * @return the time when the connection request for this node was received.
+     */
+    public long getConnectionRequestedTimestamp() {
+        return connectionRequestedTimestamp.get();
+    }
+
+    /**
+     * Sets the time when the connection request for this node was last
+     * received.
+     *
+     * This method is thread-safe and may be called without obtaining any lock.
+     *
+     * @param connectionRequestedTimestamp
+     */
+    public void setConnectionRequestedTimestamp(long connectionRequestedTimestamp) {
+        this.connectionRequestedTimestamp.set(connectionRequestedTimestamp);
+    }
+
+    /**
+     * Returns true if the node was disconnected due to lack of heartbeat; false
+     * otherwise.
+     *
+     * @return true if the node was disconnected due to lack of heartbeat; false
+     * otherwise.
+     */
+    public boolean isHeartbeatDisconnection() {
+        return heartbeatDisconnection;
+    }
+
+    /**
+     * Sets the status to disconnected and flags the node as being disconnected
+     * by lack of heartbeat.
+     */
+    public void setHeartbeatDisconnection() {
+        setStatus(Status.DISCONNECTED);
+        heartbeatDisconnection = true;
+    }
+
+    /**
+     * @return the status
+     */
+    public Status getStatus() {
+        return status;
+    }
+
+    /**
+     * @param status a status
+     */
+    public void setStatus(final Status status) {
+        if (status == null) {
+            throw new IllegalArgumentException("Status may not be null.");
+        }
+        this.status = status;
+        heartbeatDisconnection = false;
+    }
+
+    @Override
+    public Node clone() {
+        final Node clone = new Node(nodeId, status);
+        clone.lastHeartbeat = lastHeartbeat;
+        clone.lastHeartbeatPayload = lastHeartbeatPayload;
+        clone.heartbeatDisconnection = heartbeatDisconnection;
+        clone.connectionRequestedTimestamp = connectionRequestedTimestamp;
+        return clone;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (obj == null) {
+            return false;
+        }
+        if (getClass() != obj.getClass()) {
+            return false;
+        }
+        final Node other = (Node) obj;
+        if (this.nodeId != other.nodeId && (this.nodeId == null || !this.nodeId.equals(other.nodeId))) {
+            return false;
+        }
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int hash = 7;
+        hash = 53 * hash + (this.nodeId != null ? this.nodeId.hashCode() : 0);
+        return hash;
+    }
+
+    @Override
+    public String toString() {
+        return nodeId.toString();
+    }
+
+    @Override
+    public int compareTo(final Node o) {
+        if (o == null) {
+            return -1;
+        }
+        return getNodeId().getId().compareTo(o.getNodeId().getId());
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/spring/ClusterManagerProtocolServiceLocatorFactoryBean.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/spring/ClusterManagerProtocolServiceLocatorFactoryBean.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/spring/ClusterManagerProtocolServiceLocatorFactoryBean.java
new file mode 100644
index 0000000..e26d196
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/spring/ClusterManagerProtocolServiceLocatorFactoryBean.java
@@ -0,0 +1,116 @@
+/*
+ * 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.nifi.cluster.spring;
+
+import java.net.InetSocketAddress;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.nifi.cluster.protocol.impl.ClusterServiceDiscovery;
+import org.apache.nifi.cluster.protocol.impl.ClusterServiceLocator;
+import org.apache.nifi.io.socket.multicast.DiscoverableService;
+import org.apache.nifi.io.socket.multicast.DiscoverableServiceImpl;
+import org.apache.nifi.util.FormatUtils;
+import org.apache.nifi.util.NiFiProperties;
+
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.DisposableBean;
+import org.springframework.beans.factory.FactoryBean;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+
+/**
+ * Factory bean for creating a singleton ClusterManagerProtocolServiceLocator
+ * instance. If the application is configured to act as the cluster manager,
+ * then null is always returned as the created instance.
+ *
+ * The cluster manager protocol service represents the socket endpoint for
+ * sending internal socket messages to the cluster manager.
+ */
+public class ClusterManagerProtocolServiceLocatorFactoryBean implements FactoryBean, ApplicationContextAware, DisposableBean {
+
+    private ApplicationContext applicationContext;
+
+    private ClusterServiceLocator locator;
+
+    private NiFiProperties properties;
+
+    @Override
+    public Object getObject() throws Exception {
+        /*
+         * If configured for the cluster manager, then the service locator is never used.  
+         */
+        if (properties.isClusterManager()) {
+            return null;
+        } else if (locator == null) {
+
+            if (properties.getClusterProtocolUseMulticast()) {
+
+                // get the service discovery instance
+                final ClusterServiceDiscovery serviceDiscovery = applicationContext.getBean("clusterManagerProtocolServiceDiscovery", ClusterServiceDiscovery.class);
+
+                // create service location configuration
+                final ClusterServiceLocator.AttemptsConfig config = new ClusterServiceLocator.AttemptsConfig();
+                config.setNumAttempts(properties.getClusterProtocolMulticastServiceLocatorAttempts());
+
+                final int delay = (int) FormatUtils.getTimeDuration(properties.getClusterProtocolMulticastServiceLocatorAttemptsDelay(), TimeUnit.SECONDS);
+                config.setTimeBetweenAttempts(delay);
+                config.setTimeBetweenAttempsUnit(TimeUnit.SECONDS);
+
+                locator = new ClusterServiceLocator(serviceDiscovery);
+                locator.setAttemptsConfig(config);
+
+            } else {
+                final String serviceName = applicationContext.getBean("clusterManagerProtocolServiceName", String.class);
+                final InetSocketAddress serviceAddress = properties.getClusterNodeUnicastManagerProtocolAddress();
+                final DiscoverableService service = new DiscoverableServiceImpl(serviceName, serviceAddress);
+                locator = new ClusterServiceLocator(service);
+            }
+
+            // start the locator
+            locator.start();
+
+        }
+        return locator;
+
+    }
+
+    @Override
+    public Class getObjectType() {
+        return ClusterServiceLocator.class;
+    }
+
+    @Override
+    public boolean isSingleton() {
+        return true;
+    }
+
+    @Override
+    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
+        this.applicationContext = applicationContext;
+    }
+
+    @Override
+    public void destroy() throws Exception {
+        if (locator != null && locator.isRunning()) {
+            locator.stop();
+        }
+    }
+
+    public void setProperties(NiFiProperties properties) {
+        this.properties = properties;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/spring/FileBasedClusterNodeFirewallFactoryBean.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/spring/FileBasedClusterNodeFirewallFactoryBean.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/spring/FileBasedClusterNodeFirewallFactoryBean.java
new file mode 100644
index 0000000..ef72298
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/spring/FileBasedClusterNodeFirewallFactoryBean.java
@@ -0,0 +1,58 @@
+/*
+ * 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.nifi.cluster.spring;
+
+import java.io.File;
+import org.apache.nifi.cluster.firewall.impl.FileBasedClusterNodeFirewall;
+import org.apache.nifi.util.NiFiProperties;
+import org.springframework.beans.factory.FactoryBean;
+
+/**
+ * Factory bean for creating a singleton FileBasedClusterNodeFirewall instance.
+ */
+public class FileBasedClusterNodeFirewallFactoryBean implements FactoryBean {
+
+    private FileBasedClusterNodeFirewall firewall;
+
+    private NiFiProperties properties;
+
+    @Override
+    public Object getObject() throws Exception {
+        if (firewall == null) {
+            final File config = properties.getClusterManagerNodeFirewallFile();
+            final File restoreDirectory = properties.getRestoreDirectory();
+            if (config != null) {
+                firewall = new FileBasedClusterNodeFirewall(config, restoreDirectory);
+            }
+        }
+        return firewall;
+    }
+
+    @Override
+    public Class getObjectType() {
+        return FileBasedClusterNodeFirewall.class;
+    }
+
+    @Override
+    public boolean isSingleton() {
+        return true;
+    }
+
+    public void setProperties(NiFiProperties properties) {
+        this.properties = properties;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/spring/WebClusterManagerFactoryBean.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/spring/WebClusterManagerFactoryBean.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/spring/WebClusterManagerFactoryBean.java
new file mode 100644
index 0000000..7169730
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/spring/WebClusterManagerFactoryBean.java
@@ -0,0 +1,139 @@
+/*
+ * 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.nifi.cluster.spring;
+
+import java.nio.file.Paths;
+import org.apache.nifi.admin.service.AuditService;
+import org.apache.nifi.cluster.event.EventManager;
+import org.apache.nifi.cluster.firewall.ClusterNodeFirewall;
+import org.apache.nifi.cluster.flow.DataFlowManagementService;
+import org.apache.nifi.cluster.manager.HttpRequestReplicator;
+import org.apache.nifi.cluster.manager.HttpResponseMapper;
+import org.apache.nifi.cluster.manager.impl.WebClusterManager;
+import org.apache.nifi.cluster.protocol.impl.ClusterManagerProtocolSenderListener;
+import org.apache.nifi.cluster.protocol.impl.ClusterServicesBroadcaster;
+import org.apache.nifi.controller.service.ControllerServiceLoader;
+import org.apache.nifi.encrypt.StringEncryptor;
+import org.apache.nifi.io.socket.multicast.DiscoverableService;
+import org.apache.nifi.io.socket.multicast.DiscoverableServiceImpl;
+import org.apache.nifi.util.NiFiProperties;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.FactoryBean;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+
+/**
+ * Factory bean for creating a singleton WebClusterManager instance. If the
+ * application is not configured to act as the cluster manager, then null is
+ * always returned as the created instance.
+ */
+public class WebClusterManagerFactoryBean implements FactoryBean, ApplicationContextAware {
+
+    private ApplicationContext applicationContext;
+
+    private WebClusterManager clusterManager;
+
+    private NiFiProperties properties;
+
+    private StringEncryptor encryptor;
+
+    @Override
+    public Object getObject() throws Exception {
+        if (properties.isClusterManager() && properties.isNode()) {
+            throw new IllegalStateException("Application may be configured as a cluster manager or a node, but not both.");
+        } else if (!properties.isClusterManager()) {
+            /*
+             * If not configured for the cluster manager, then the cluster manager is never used.  
+             * null is returned so that we don't instantiate a thread pool or other resources. 
+             */
+            return null;
+        } else if (clusterManager == null) {
+
+            // get the service configuration path (fail early)
+            final String serviceConfigurationFile = properties.getProperty(NiFiProperties.SERVICE_CONFIGURATION_FILE);
+            if (serviceConfigurationFile == null) {
+                throw new NullPointerException("The service configuration file has not been specified.");
+            }
+
+            final HttpRequestReplicator requestReplicator = applicationContext.getBean("httpRequestReplicator", HttpRequestReplicator.class);
+            final HttpResponseMapper responseMapper = applicationContext.getBean("httpResponseMapper", HttpResponseMapper.class);
+            final DataFlowManagementService dataFlowService = applicationContext.getBean("dataFlowManagementService", DataFlowManagementService.class);
+            final ClusterManagerProtocolSenderListener senderListener = applicationContext.getBean("clusterManagerProtocolSenderListener", ClusterManagerProtocolSenderListener.class);
+
+            // create the manager
+            clusterManager = new WebClusterManager(
+                    requestReplicator,
+                    responseMapper,
+                    dataFlowService,
+                    senderListener,
+                    properties,
+                    encryptor
+            );
+
+            // set the service broadcaster
+            if (properties.getClusterProtocolUseMulticast()) {
+
+                // create broadcaster
+                final ClusterServicesBroadcaster broadcaster = applicationContext.getBean("clusterServicesBroadcaster", ClusterServicesBroadcaster.class);
+
+                // register the cluster manager protocol service
+                final String clusterManagerProtocolServiceName = applicationContext.getBean("clusterManagerProtocolServiceName", String.class);
+                final DiscoverableService clusterManagerProtocolService = new DiscoverableServiceImpl(clusterManagerProtocolServiceName, properties.getClusterManagerProtocolAddress());
+                broadcaster.addService(clusterManagerProtocolService);
+
+                clusterManager.setServicesBroadcaster(broadcaster);
+            }
+
+            // set the event manager
+            clusterManager.setEventManager(applicationContext.getBean("nodeEventHistoryManager", EventManager.class));
+
+            // set the cluster firewall
+            clusterManager.setClusterFirewall(applicationContext.getBean("clusterFirewall", ClusterNodeFirewall.class));
+
+            // set the audit service
+            clusterManager.setAuditService(applicationContext.getBean("auditService", AuditService.class));
+
+            // load the controller services
+            final ControllerServiceLoader serviceLoader = new ControllerServiceLoader(Paths.get(serviceConfigurationFile));
+            serviceLoader.loadControllerServices(clusterManager);
+        }
+        return clusterManager;
+    }
+
+    @Override
+    public Class getObjectType() {
+        return WebClusterManager.class;
+    }
+
+    @Override
+    public boolean isSingleton() {
+        return true;
+    }
+
+    @Override
+    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
+        this.applicationContext = applicationContext;
+    }
+
+    public void setProperties(NiFiProperties properties) {
+        this.properties = properties;
+    }
+
+    public void setEncryptor(final StringEncryptor encryptor) {
+        this.encryptor = encryptor;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/controller/reporting/ClusteredReportingTaskNode.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/controller/reporting/ClusteredReportingTaskNode.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/controller/reporting/ClusteredReportingTaskNode.java
new file mode 100644
index 0000000..1ed5b30
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/controller/reporting/ClusteredReportingTaskNode.java
@@ -0,0 +1,49 @@
+/*
+ * 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.nifi.controller.reporting;
+
+import org.apache.nifi.cluster.manager.impl.ClusteredReportingContext;
+import org.apache.nifi.controller.ProcessScheduler;
+import org.apache.nifi.controller.ValidationContextFactory;
+import org.apache.nifi.controller.service.ControllerServiceProvider;
+import org.apache.nifi.reporting.BulletinRepository;
+import org.apache.nifi.reporting.EventAccess;
+import org.apache.nifi.reporting.ReportingContext;
+import org.apache.nifi.reporting.ReportingTask;
+
+public class ClusteredReportingTaskNode extends AbstractReportingTaskNode {
+
+    private final EventAccess eventAccess;
+    private final BulletinRepository bulletinRepository;
+    private final ControllerServiceProvider serviceProvider;
+
+    public ClusteredReportingTaskNode(final ReportingTask reportingTask, final String id, final ProcessScheduler scheduler,
+            final EventAccess eventAccess, final BulletinRepository bulletinRepository, final ControllerServiceProvider serviceProvider,
+            final ValidationContextFactory validationContextFactory) {
+        super(reportingTask, id, serviceProvider, scheduler, validationContextFactory);
+
+        this.eventAccess = eventAccess;
+        this.bulletinRepository = bulletinRepository;
+        this.serviceProvider = serviceProvider;
+    }
+
+    @Override
+    public ReportingContext getReportingContext() {
+        return new ClusteredReportingContext(eventAccess, bulletinRepository, getProperties(), serviceProvider);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/resources/nifi-cluster-manager-context.xml
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/resources/nifi-cluster-manager-context.xml b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/resources/nifi-cluster-manager-context.xml
new file mode 100644
index 0000000..68c29bc
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/resources/nifi-cluster-manager-context.xml
@@ -0,0 +1,124 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+<!-- marked as lazy so that clustering beans are not created when applications runs in non-clustered mode -->
+<beans default-lazy-init="true"
+       xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:util="http://www.springframework.org/schema/util"
+       xmlns:context="http://www.springframework.org/schema/context"
+       xmlns:aop="http://www.springframework.org/schema/aop"
+       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
+    http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.1.xsd
+    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
+    http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd">
+
+    <!-- jersey client -->
+    <bean id="jersey-client" class="org.apache.nifi.web.util.WebUtils" factory-method="createClient">
+        <constructor-arg>
+            <bean class="com.sun.jersey.api.client.config.DefaultClientConfig"/>
+        </constructor-arg>
+        <constructor-arg>
+            <bean class="org.apache.nifi.framework.security.util.SslContextFactory" factory-method="createSslContext">
+                <constructor-arg ref="nifiProperties"/>
+            </bean>
+        </constructor-arg>
+    </bean>
+
+    <!-- http request replicator -->
+    <bean id="httpRequestReplicator" class="org.apache.nifi.cluster.manager.impl.HttpRequestReplicatorImpl">
+        <constructor-arg index="0">
+            <bean factory-bean="nifiProperties" factory-method="getClusterManagerNodeApiRequestThreads"/>
+        </constructor-arg>
+        <constructor-arg ref="jersey-client" index="1"/>
+        <constructor-arg index="2">
+            <bean factory-bean="nifiProperties" factory-method="getClusterManagerNodeApiConnectionTimeout"/>
+        </constructor-arg>
+        <constructor-arg index="3">
+            <bean factory-bean="nifiProperties" factory-method="getClusterManagerNodeApiReadTimeout"/>
+        </constructor-arg>
+        <property name="nodeProtocolScheme">
+            <bean factory-bean="nifiProperties" factory-method="getClusterProtocolManagerToNodeApiScheme"/>
+        </property>
+    </bean>
+    
+    <!-- http response mapper -->
+    <bean id="httpResponseMapper" class="org.apache.nifi.cluster.manager.impl.HttpResponseMapperImpl"/>
+
+    <!-- cluster flow DAO -->
+    <bean id="dataFlowDao" class="org.apache.nifi.cluster.flow.impl.DataFlowDaoImpl">
+        <constructor-arg index="0">
+            <bean factory-bean="nifiProperties" factory-method="getFlowConfigurationFileDir"/>
+        </constructor-arg>
+        <constructor-arg index="1">
+            <bean factory-bean="nifiProperties" factory-method="getRestoreDirectory"/>
+        </constructor-arg>
+        <constructor-arg index="2">
+            <bean factory-bean="nifiProperties" factory-method="getAutoResumeState"/>
+        </constructor-arg>
+    </bean>
+    
+    <!-- dataflow management service -->
+    <bean id="dataFlowManagementService" class="org.apache.nifi.cluster.flow.impl.DataFlowManagementServiceImpl">
+        <constructor-arg ref="dataFlowDao"/>
+        <constructor-arg ref="clusterManagerProtocolSender"/>
+        <property name="retrievalDelay">
+            <bean factory-bean="nifiProperties" factory-method="getClusterManagerFlowRetrievalDelay"/>
+        </property>
+    </bean>
+
+    <!-- node event history manager -->
+    <bean id="nodeEventHistoryManager" class="org.apache.nifi.cluster.event.impl.EventManagerImpl">
+        <constructor-arg>
+            <bean factory-bean="nifiProperties" factory-method="getClusterManagerNodeEventHistorySize"/>
+        </constructor-arg>
+    </bean>
+
+    <!-- cluster firewall -->
+    <bean id="clusterFirewall" class="org.apache.nifi.cluster.spring.FileBasedClusterNodeFirewallFactoryBean">
+        <property name="properties" ref="nifiProperties"/>
+    </bean>
+
+    <!-- cluster manager -->
+    <bean id="clusterManager" class="org.apache.nifi.cluster.spring.WebClusterManagerFactoryBean">
+        <property name="properties" ref="nifiProperties"/>
+        <property name="encryptor" ref="stringEncryptor"/>
+    </bean>
+    
+    <!-- discoverable services -->
+    
+    <!-- cluster manager protocol discoverable service -->
+    
+    <!-- service name for communicating with the cluster manager using sockets -->
+    <bean id="clusterManagerProtocolServiceName" class="java.lang.String">
+        <constructor-arg value="cluster-manager-protocol" />
+    </bean>
+    
+    <!-- cluster manager protocol service discovery -->
+    <bean id="clusterManagerProtocolServiceDiscovery" class="org.apache.nifi.cluster.protocol.impl.ClusterServiceDiscovery">
+        <constructor-arg ref="clusterManagerProtocolServiceName" index="0"/>
+        <constructor-arg index="1">
+            <bean factory-bean="nifiProperties" factory-method="getClusterProtocolMulticastAddress"/>
+        </constructor-arg>
+        <constructor-arg ref="protocolMulticastConfiguration" index="2"/>
+        <constructor-arg ref="protocolContext" index="3"/>
+    </bean>
+    
+    <!-- cluster manager protocol service locator -->
+    <bean id="clusterManagerProtocolServiceLocator" class="org.apache.nifi.cluster.spring.ClusterManagerProtocolServiceLocatorFactoryBean">
+        <property name="properties" ref="nifiProperties"/>
+    </bean>
+        
+</beans>

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/event/impl/EventManagerImplTest.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/event/impl/EventManagerImplTest.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/event/impl/EventManagerImplTest.java
new file mode 100644
index 0000000..09ea44b
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/event/impl/EventManagerImplTest.java
@@ -0,0 +1,119 @@
+/*
+ * 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.nifi.cluster.event.impl;
+
+import org.apache.nifi.cluster.event.impl.EventManagerImpl;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import org.apache.nifi.cluster.event.Event;
+import org.apache.nifi.cluster.event.Event.Category;
+import org.apache.nifi.cluster.event.EventManager;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ * @author unattributed
+ */
+public class EventManagerImplTest {
+
+    @Test(expected = IllegalArgumentException.class)
+    public void testNonPositiveHistorySize() {
+        new EventManagerImpl(0);
+    }
+
+    @Test
+    public void testGetEventsUnknownSource() {
+        EventManager manager = new EventManagerImpl(1);
+        assertEquals(Collections.EMPTY_LIST, manager.getEvents("unknown value"));
+    }
+
+    @Test
+    public void testGetEvents() {
+
+        EventManager manager = new EventManagerImpl(2);
+
+        Event e1 = new Event("1", "Event1", Category.INFO, 0);
+        Event e2 = new Event("1", "Event2", Category.INFO, 1);
+
+        manager.addEvent(e1);
+        manager.addEvent(e2);
+
+        List<Event> events = manager.getEvents("1");
+
+        // assert newest to oldest
+        assertEquals(Arrays.asList(e2, e1), events);
+    }
+
+    @Test
+    public void testGetMostRecentEventUnknownSource() {
+        EventManager manager = new EventManagerImpl(1);
+        assertNull(manager.getMostRecentEvent("unknown value"));
+    }
+
+    @Test
+    public void testGetMostRecentEvent() {
+
+        EventManager manager = new EventManagerImpl(2);
+
+        Event e1 = new Event("1", "Event1", Category.INFO, 0);
+        Event e2 = new Event("1", "Event2", Category.INFO, 1);
+
+        manager.addEvent(e1);
+        manager.addEvent(e2);
+
+        // assert newest to oldest
+        assertEquals(e2, manager.getMostRecentEvent("1"));
+    }
+
+    @Test
+    public void testAddEventExceedsHistorySize() {
+
+        EventManager manager = new EventManagerImpl(1);
+
+        Event e1 = new Event("1", "Event1", Category.INFO, 0);
+        Event e2 = new Event("1", "Event2", Category.INFO, 1);
+
+        manager.addEvent(e1);
+        manager.addEvent(e2);
+
+        List<Event> events = manager.getEvents("1");
+
+        // assert oldest evicted
+        assertEquals(Arrays.asList(e2), events);
+
+    }
+
+    @Test
+    public void testClearHistory() {
+
+        EventManager manager = new EventManagerImpl(1);
+
+        Event e1 = new Event("1", "Event1", Category.INFO, 0);
+        Event e2 = new Event("1", "Event2", Category.INFO, 1);
+
+        manager.addEvent(e1);
+        manager.addEvent(e2);
+
+        manager.clearEventHistory("1");
+
+        // assert oldest evicted
+        assertTrue(manager.getEvents("1").isEmpty());
+
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/firewall/impl/FileBasedClusterNodeFirewallTest.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/firewall/impl/FileBasedClusterNodeFirewallTest.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/firewall/impl/FileBasedClusterNodeFirewallTest.java
new file mode 100644
index 0000000..e5db7ca
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/firewall/impl/FileBasedClusterNodeFirewallTest.java
@@ -0,0 +1,98 @@
+/*
+ * 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.nifi.cluster.firewall.impl;
+
+import java.io.File;
+import java.io.IOException;
+import org.apache.nifi.util.file.FileUtils;
+import org.junit.After;
+import org.junit.Before;
+import static org.junit.Assert.*;
+import org.junit.Test;
+
+public class FileBasedClusterNodeFirewallTest {
+
+    private FileBasedClusterNodeFirewall ipsFirewall;
+
+    private FileBasedClusterNodeFirewall acceptAllFirewall;
+
+    private File ipsConfig;
+
+    private File emptyConfig;
+
+    private File restoreDirectory;
+
+    @Before
+    public void setup() throws Exception {
+
+        ipsConfig = new File("src/test/resources/org/apache/nifi/cluster/firewall/impl/ips.txt");
+        emptyConfig = new File("src/test/resources/org/apache/nifi/cluster/firewall/impl/empty.txt");
+
+        restoreDirectory = new File(System.getProperty("java.io.tmpdir") + "/firewall_restore");
+
+        ipsFirewall = new FileBasedClusterNodeFirewall(ipsConfig, restoreDirectory);
+        acceptAllFirewall = new FileBasedClusterNodeFirewall(emptyConfig);
+    }
+
+    @After
+    public void teardown() throws IOException {
+        deleteFile(restoreDirectory);
+    }
+
+    @Test
+    public void testSyncWithRestore() {
+        assertEquals(ipsConfig.length(), new File(restoreDirectory, ipsConfig.getName()).length());
+    }
+
+    @Test
+    public void testIsPermissibleWithExactMatch() {
+        assertTrue(ipsFirewall.isPermissible("2.2.2.2"));
+    }
+
+    @Test
+    public void testIsPermissibleWithSubnetMatch() {
+        assertTrue(ipsFirewall.isPermissible("3.3.3.255"));
+    }
+
+    @Test
+    public void testIsPermissibleWithNoMatch() {
+        assertFalse(ipsFirewall.isPermissible("255.255.255.255"));
+    }
+
+    @Test
+    public void testIsPermissibleWithMalformedData() {
+        assertFalse(ipsFirewall.isPermissible("abc"));
+    }
+
+    @Test
+    public void testIsPermissibleWithEmptyConfig() {
+        assertTrue(acceptAllFirewall.isPermissible("1.1.1.1"));
+    }
+
+    @Test
+    public void testIsPermissibleWithEmptyConfigWithMalformedData() {
+        assertTrue(acceptAllFirewall.isPermissible("abc"));
+    }
+
+    private boolean deleteFile(final File file) {
+        if (file.isDirectory()) {
+            FileUtils.deleteFilesInDir(file, null, null, true, true);
+        }
+        return FileUtils.deleteFile(file, null, 10);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/flow/impl/DataFlowManagementServiceImplTest.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/flow/impl/DataFlowManagementServiceImplTest.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/flow/impl/DataFlowManagementServiceImplTest.java
new file mode 100644
index 0000000..f9ba016
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/flow/impl/DataFlowManagementServiceImplTest.java
@@ -0,0 +1,343 @@
+/*
+ * 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.nifi.cluster.flow.impl;
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.apache.nifi.cluster.flow.DataFlowDao;
+import org.apache.nifi.cluster.flow.PersistedFlowState;
+import org.apache.nifi.cluster.protocol.ClusterManagerProtocolSender;
+import org.apache.nifi.cluster.protocol.NodeIdentifier;
+import org.apache.nifi.cluster.protocol.ProtocolContext;
+import org.apache.nifi.cluster.protocol.ProtocolException;
+import org.apache.nifi.cluster.protocol.ProtocolHandler;
+import org.apache.nifi.cluster.protocol.StandardDataFlow;
+import org.apache.nifi.cluster.protocol.impl.ClusterManagerProtocolSenderImpl;
+import org.apache.nifi.cluster.protocol.impl.SocketProtocolListener;
+import org.apache.nifi.cluster.protocol.jaxb.JaxbProtocolContext;
+import org.apache.nifi.cluster.protocol.jaxb.message.JaxbProtocolUtils;
+import org.apache.nifi.cluster.protocol.message.FlowResponseMessage;
+import org.apache.nifi.cluster.protocol.message.ProtocolMessage;
+import org.apache.nifi.io.socket.ServerSocketConfiguration;
+import org.apache.nifi.io.socket.SocketConfiguration;
+
+import org.apache.commons.io.FileUtils;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.xml.sax.SAXException;
+
+/**
+ * @author unattributed
+ */
+public class DataFlowManagementServiceImplTest {
+
+    private DataFlowManagementServiceImpl service;
+    private File restoreLocation;
+    private File primaryLocation;
+    private DataFlowDao dao;
+    private int apiDummyPort;
+    private int socketPort;
+    private SocketConfiguration socketConfig;
+    private ClusterManagerProtocolSender sender;
+    private ServerSocketConfiguration serverSocketConfig;
+    private SocketProtocolListener listener;
+
+    @Before
+    public void setup() throws IOException {
+
+        primaryLocation = new File(System.getProperty("java.io.tmpdir") + "/primary" + this.getClass().getSimpleName());
+        restoreLocation = new File(System.getProperty("java.io.tmpdir") + "/restore" + this.getClass().getSimpleName());
+
+        FileUtils.deleteDirectory(primaryLocation);
+        FileUtils.deleteDirectory(restoreLocation);
+
+        ProtocolContext protocolContext = new JaxbProtocolContext(JaxbProtocolUtils.JAXB_CONTEXT);
+
+        socketConfig = new SocketConfiguration();
+        socketConfig.setSocketTimeout(1000);
+        serverSocketConfig = new ServerSocketConfiguration();
+
+        dao = new DataFlowDaoImpl(primaryLocation, restoreLocation, false);
+
+        sender = new ClusterManagerProtocolSenderImpl(socketConfig, protocolContext);
+
+        service = new DataFlowManagementServiceImpl(dao, sender);
+        service.start();
+
+        listener = new SocketProtocolListener(1, 0, serverSocketConfig, protocolContext);
+        listener.start();
+
+        apiDummyPort = 7777;
+        socketPort = listener.getPort();
+    }
+
+    @After
+    public void teardown() throws IOException {
+
+        if (service != null && service.isRunning()) {
+            service.stop();
+        }
+
+        if (listener != null && listener.isRunning()) {
+            try {
+                listener.stop();
+            } catch (final Exception ex) {
+                ex.printStackTrace(System.out);
+            }
+        }
+        FileUtils.deleteDirectory(primaryLocation);
+        FileUtils.deleteDirectory(restoreLocation);
+
+    }
+
+    @Test
+    public void testLoadFlowWithNonExistentFlow() throws ParserConfigurationException, SAXException, IOException {
+        verifyFlow();
+    }
+
+    @Test
+    public void testLoadFlowWithNonExistentFlowWhenServiceStopped() throws IOException, SAXException, ParserConfigurationException {
+        service.stop();
+        verifyFlow();
+    }
+
+    private void verifyFlow() throws ParserConfigurationException, SAXException, IOException {
+        final byte[] flowBytes = service.loadDataFlow().getDataFlow().getFlow();
+        final DocumentBuilder docBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+        final Document doc = docBuilder.parse(new ByteArrayInputStream(flowBytes));
+        final Element controller = (Element) doc.getElementsByTagName("flowController").item(0);
+        final Element rootGroup = (Element) controller.getElementsByTagName("rootGroup").item(0);
+        final String rootGroupName = rootGroup.getElementsByTagName("name").item(0).getTextContent();
+        assertEquals("NiFi Flow", rootGroupName);
+    }
+
+    @Test
+    public void testLoadFlowSingleNode() throws Exception {
+        String flowStr = "<rootGroup />";
+        byte[] flowBytes = flowStr.getBytes();
+        listener.addHandler(new FlowRequestProtocolHandler(new StandardDataFlow(flowStr.getBytes("UTF-8"), new byte[0], new byte[0])));
+
+        NodeIdentifier nodeId = new NodeIdentifier("1", "localhost", apiDummyPort, "localhost", socketPort);
+        service.setNodeIds(new HashSet<>(Arrays.asList(nodeId)));
+        service.setPersistedFlowState(PersistedFlowState.STALE);
+
+        assertEquals(PersistedFlowState.STALE, service.getPersistedFlowState());
+
+        // sleep long enough for the flow retriever to run
+        waitForState(PersistedFlowState.CURRENT);
+
+        assertEquals(PersistedFlowState.CURRENT, service.getPersistedFlowState());
+        assertArrayEquals(flowBytes, service.loadDataFlow().getDataFlow().getFlow());
+
+    }
+
+    @Test
+    public void testLoadFlowWithSameNodeIds() throws Exception {
+
+        String flowStr = "<rootGroup />";
+        listener.addHandler(new FlowRequestProtocolHandler(new StandardDataFlow(flowStr.getBytes("UTF-8"), new byte[0], new byte[0])));
+
+        NodeIdentifier nodeId1 = new NodeIdentifier("1", "localhost", apiDummyPort, "localhost", socketPort);
+        NodeIdentifier nodeId2 = new NodeIdentifier("2", "localhost", apiDummyPort, "localhost", socketPort);
+        service.setNodeIds(new HashSet<>(Arrays.asList(nodeId1, nodeId2)));
+        service.setPersistedFlowState(PersistedFlowState.STALE);
+
+        assertEquals(PersistedFlowState.STALE, service.getPersistedFlowState());
+
+        // sleep long enough for the flow retriever to run
+        waitForState(PersistedFlowState.CURRENT);
+
+        // verify that flow is current
+        assertEquals(PersistedFlowState.CURRENT, service.getPersistedFlowState());
+
+        // add same ids in different order
+        service.setNodeIds(new HashSet<>(Arrays.asList(nodeId2, nodeId1)));
+
+        // verify flow is still current
+        assertEquals(PersistedFlowState.CURRENT, service.getPersistedFlowState());
+
+    }
+
+    @Test
+    public void testLoadFlowWithABadNode() throws Exception {
+
+        String flowStr = "<rootGroup />";
+        byte[] flowBytes = flowStr.getBytes();
+        listener.addHandler(new FlowRequestProtocolHandler(new StandardDataFlow(flowStr.getBytes("UTF-8"), new byte[0], new byte[0])));
+
+        NodeIdentifier nodeId1 = new NodeIdentifier("1", "localhost", apiDummyPort, "localhost", socketPort + 1);
+        NodeIdentifier nodeId2 = new NodeIdentifier("2", "localhost", apiDummyPort, "localhost", socketPort);
+        service.setNodeIds(new HashSet<>(Arrays.asList(nodeId1, nodeId2)));
+        service.setPersistedFlowState(PersistedFlowState.STALE);
+
+        assertEquals(PersistedFlowState.STALE, service.getPersistedFlowState());
+
+        // sleep long enough for the flow retriever to run
+        waitForState(PersistedFlowState.CURRENT);
+
+        assertEquals(PersistedFlowState.CURRENT, service.getPersistedFlowState());
+        assertArrayEquals(flowBytes, service.loadDataFlow().getDataFlow().getFlow());
+
+    }
+
+    @Test
+    public void testLoadFlowWithConstantNodeIdChanging() throws Exception {
+        String flowStr = "<rootGroup />";
+        byte[] flowBytes = flowStr.getBytes();
+        listener.addHandler(new FlowRequestProtocolHandler(new StandardDataFlow(flowStr.getBytes("UTF-8"), new byte[0], new byte[0])));
+
+        NodeIdentifier nodeId1 = new NodeIdentifier("1", "localhost", apiDummyPort, "localhost", socketPort + 1);
+        NodeIdentifier nodeId2 = new NodeIdentifier("2", "localhost", apiDummyPort, "localhost", socketPort);
+
+        for (int i = 0; i < 1000; i++) {
+            service.setNodeIds(new HashSet<>(Arrays.asList(nodeId1, nodeId2)));
+            service.setPersistedFlowState(PersistedFlowState.STALE);
+            assertEquals(PersistedFlowState.STALE, service.getPersistedFlowState());
+        }
+
+        // sleep long enough for the flow retriever to run
+        waitForState(PersistedFlowState.CURRENT);
+
+        assertEquals(PersistedFlowState.CURRENT, service.getPersistedFlowState());
+        assertArrayEquals(flowBytes, service.loadDataFlow().getDataFlow().getFlow());
+    }
+
+    @Test
+    public void testLoadFlowWithConstantNodeIdChangingWithRetrievalDelay() throws Exception {
+
+        String flowStr = "<rootGroup />";
+        listener.addHandler(new FlowRequestProtocolHandler(new StandardDataFlow(flowStr.getBytes("UTF-8"), new byte[0], new byte[0])));
+
+        NodeIdentifier nodeId1 = new NodeIdentifier("1", "localhost", apiDummyPort, "localhost", socketPort + 1);
+        NodeIdentifier nodeId2 = new NodeIdentifier("2", "localhost", apiDummyPort, "localhost", socketPort);
+
+        service.setRetrievalDelay("5 sec");
+        for (int i = 0; i < 1000; i++) {
+            service.setNodeIds(new HashSet<>(Arrays.asList(nodeId1, nodeId2)));
+            service.setPersistedFlowState(PersistedFlowState.STALE);
+            assertEquals(PersistedFlowState.STALE, service.getPersistedFlowState());
+        }
+
+        // sleep long enough for the flow retriever to run
+        waitForState(PersistedFlowState.STALE);
+
+        assertEquals(PersistedFlowState.STALE, service.getPersistedFlowState());
+
+    }
+
+    @Test
+    public void testStopRequestedWhileRetrieving() throws Exception {
+
+        String flowStr = "<rootGroup />";
+        listener.addHandler(new FlowRequestProtocolHandler(new StandardDataFlow(flowStr.getBytes("UTF-8"), new byte[0], new byte[0])));
+        Set<NodeIdentifier> nodeIds = new HashSet<>();
+        for (int i = 0; i < 1000; i++) {
+            nodeIds.add(new NodeIdentifier("1", "localhost", apiDummyPort, "localhost", socketPort + 1));
+        }
+        nodeIds.add(new NodeIdentifier("1", "localhost", apiDummyPort, "localhost", socketPort));
+
+        long lastRetrievalTime = service.getLastRetrievalTime();
+
+        service.setNodeIds(nodeIds);
+        service.setPersistedFlowState(PersistedFlowState.STALE);
+        assertEquals(PersistedFlowState.STALE, service.getPersistedFlowState());
+
+        // sleep long enough for the flow retriever to run
+        waitForState(PersistedFlowState.STALE);
+
+        service.stop();
+
+        service.setPersistedFlowState(PersistedFlowState.STALE);
+        assertEquals(PersistedFlowState.STALE, service.getPersistedFlowState());
+
+        assertEquals(lastRetrievalTime, service.getLastRetrievalTime());
+
+    }
+
+    @Test
+    public void testLoadFlowUnknownState() throws Exception {
+
+        String flowStr = "<rootGroup />";
+        byte[] flowBytes = flowStr.getBytes();
+        listener.addHandler(new FlowRequestProtocolHandler(new StandardDataFlow(flowStr.getBytes("UTF-8"), new byte[0], new byte[0])));
+        NodeIdentifier nodeId = new NodeIdentifier("1", "localhost", apiDummyPort, "localhost", socketPort);
+
+        service.setNodeIds(new HashSet<>(Arrays.asList(nodeId)));
+        service.setPersistedFlowState(PersistedFlowState.STALE);
+        assertEquals(PersistedFlowState.STALE, service.getPersistedFlowState());
+
+        service.setPersistedFlowState(PersistedFlowState.UNKNOWN);
+
+        assertEquals(PersistedFlowState.UNKNOWN, service.getPersistedFlowState());
+
+        service.setPersistedFlowState(PersistedFlowState.STALE);
+        assertEquals(PersistedFlowState.STALE, service.getPersistedFlowState());
+
+        // sleep long enough for the flow retriever to run
+        waitForState(PersistedFlowState.CURRENT);
+
+        assertArrayEquals(flowBytes, service.loadDataFlow().getDataFlow().getFlow());
+
+    }
+
+    private class FlowRequestProtocolHandler implements ProtocolHandler {
+
+        private StandardDataFlow dataFlow;
+
+        public FlowRequestProtocolHandler(final StandardDataFlow dataFlow) {
+            this.dataFlow = dataFlow;
+        }
+
+        @Override
+        public boolean canHandle(ProtocolMessage msg) {
+            return true;
+        }
+
+        @Override
+        public ProtocolMessage handle(ProtocolMessage msg) throws ProtocolException {
+            FlowResponseMessage response = new FlowResponseMessage();
+            response.setDataFlow(dataFlow);
+            return response;
+        }
+
+    }
+
+    private void waitForState(PersistedFlowState state) throws InterruptedException {
+        for (int i = 0; i < 30; i++) {
+            if (service.getPersistedFlowState() == state) {
+                break;
+            } else {
+                Thread.sleep(1000);
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/manager/impl/HttpRequestReplicatorImplTest.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/manager/impl/HttpRequestReplicatorImplTest.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/manager/impl/HttpRequestReplicatorImplTest.java
new file mode 100644
index 0000000..0c65aba
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/manager/impl/HttpRequestReplicatorImplTest.java
@@ -0,0 +1,368 @@
+/*
+ * 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.nifi.cluster.manager.impl;
+
+import org.apache.nifi.cluster.manager.impl.HttpRequestReplicatorImpl;
+import javax.ws.rs.core.Response;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.ws.rs.HttpMethod;
+import javax.ws.rs.core.MultivaluedMap;
+import java.net.URISyntaxException;
+import java.util.Arrays;
+import java.util.Iterator;
+import javax.ws.rs.core.StreamingOutput;
+import org.apache.nifi.cluster.manager.testutils.HttpResponse;
+import org.apache.nifi.cluster.manager.testutils.HttpServer;
+import com.sun.jersey.api.client.Client;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.net.URI;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import javax.ws.rs.core.Response.Status;
+import org.apache.nifi.cluster.manager.NodeResponse;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.apache.nifi.cluster.manager.testutils.HttpResponseAction;
+import org.apache.nifi.cluster.protocol.NodeIdentifier;
+import static org.junit.Assert.*;
+
+/**
+ * @author unattributed
+ */
+public class HttpRequestReplicatorImplTest {
+
+    private Client client;
+    private HttpRequestReplicatorImpl replicator;
+    private int executorThreadCount;
+    private int serverThreadCount;
+    private int serverPort;
+    private HttpServer server;
+    private Map<String, List<String>> expectedRequestParameters;
+    private Map<String, String> expectedRequestHeaders;
+    private Map<String, String> expectedResponseHeaders;
+    private Object expectedEntity;
+    private String expectedBody;
+    private URI prototypeUri;
+
+    @Before
+    public void setUp() throws IOException, URISyntaxException {
+
+        executorThreadCount = 5;
+        serverThreadCount = 3;
+
+        client = Client.create();
+
+        replicator = new HttpRequestReplicatorImpl(executorThreadCount, client, "1 sec", "1 sec");
+        replicator.start();
+
+        expectedRequestHeaders = new HashMap<>();
+        expectedRequestHeaders.put("header1", "header value1");
+        expectedRequestHeaders.put("header2", "header value2");
+
+        expectedRequestParameters = new HashMap<>();
+        expectedRequestParameters.put("param1", Arrays.asList("p value1"));
+        expectedRequestParameters.put("param2", Arrays.asList("p value2"));
+
+        expectedResponseHeaders = new HashMap<>();
+        expectedResponseHeaders.put("header1", "header value1");
+        expectedResponseHeaders.put("header2", "header value2");
+
+        expectedEntity = new Entity();
+
+        expectedBody = "some text";
+
+        prototypeUri = new URI("http://prototype.host/path/to/resource");
+
+        server = new HttpServer(serverThreadCount, 0);
+        server.start();
+        serverPort = server.getPort();
+    }
+
+    @After
+    public void teardown() {
+        if (server.isRunning()) {
+            server.stop();
+        }
+        if (replicator.isRunning()) {
+            replicator.stop();
+        }
+    }
+
+    @Test
+    public void testReplicateGetLessNodesThanReplicatorThreads() throws Throwable {
+        testReplicateXXX(executorThreadCount - 1, HttpMethod.GET);
+    }
+
+    @Test
+    public void testReplicateGetMoreNodesThanReplicatorThreads() throws Throwable {
+        testReplicateXXX(executorThreadCount + 1, HttpMethod.GET);
+    }
+
+    @Test
+    public void testReplicateGetWithUnresponsiveNode() throws Throwable {
+
+        // nodes
+        Set<NodeIdentifier> nodeIds = createNodes(2, "localhost", serverPort);
+
+        // response
+        HttpResponse expectedResponse = new HttpResponse(Status.OK, expectedBody);
+
+        // first response normal, second response slow
+        server.addResponseAction(new HttpResponseAction(expectedResponse));
+        server.addResponseAction(new HttpResponseAction(expectedResponse, 3500));
+
+        Set<NodeResponse> responses = replicator.replicate(
+                nodeIds,
+                HttpMethod.GET,
+                prototypeUri,
+                expectedRequestParameters,
+                expectedRequestHeaders);
+
+        assertEquals(nodeIds.size(), responses.size());
+
+        Iterator<NodeResponse> nodeResponseItr = responses.iterator();
+
+        NodeResponse firstResponse = nodeResponseItr.next();
+        NodeResponse secondResponse = nodeResponseItr.next();
+        NodeResponse goodResponse;
+        NodeResponse badResponse;
+        if (firstResponse.hasThrowable()) {
+            goodResponse = secondResponse;
+            badResponse = firstResponse;
+        } else {
+            goodResponse = firstResponse;
+            badResponse = secondResponse;
+        }
+
+        // good response
+        // check status
+        assertEquals(Status.OK.getStatusCode(), goodResponse.getStatus());
+
+        // check entity stream
+        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        ((StreamingOutput) goodResponse.getResponse().getEntity()).write(baos);
+        assertEquals("some text", new String(baos.toByteArray()));
+
+        // bad response
+        assertTrue(badResponse.hasThrowable());
+        assertEquals(Status.INTERNAL_SERVER_ERROR.getStatusCode(), badResponse.getStatus());
+
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    public void testReplicateGetWithEntity() throws Throwable {
+        testReplicateXXXEntity(HttpMethod.GET);
+    }
+
+    @Test
+    public void testReplicatePost() throws Throwable {
+        testReplicateXXX(HttpMethod.POST);
+    }
+
+    @Test
+    public void testReplicatePostWithEntity() throws Throwable {
+        testReplicateXXXEntity(HttpMethod.POST);
+    }
+
+    @Test
+    public void testReplicatePut() throws Throwable {
+        testReplicateXXX(HttpMethod.PUT);
+    }
+
+    @Test
+    public void testReplicatePutWithEntity() throws Throwable {
+        testReplicateXXXEntity(HttpMethod.PUT);
+    }
+
+    @Test
+    public void testReplicateDelete() throws Throwable {
+        testReplicateXXX(HttpMethod.DELETE);
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    public void testReplicateDeleteWithEntity() throws Throwable {
+        testReplicateXXXEntity(HttpMethod.DELETE);
+    }
+
+    @Test
+    public void testReplicateHead() throws Throwable {
+        testReplicateXXX(HttpMethod.HEAD);
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    public void testReplicateHeadWithEntity() throws Throwable {
+        testReplicateXXXEntity(HttpMethod.HEAD);
+    }
+
+    @Test
+    public void testReplicateOptions() throws Throwable {
+        testReplicateXXX(HttpMethod.OPTIONS);
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    public void testReplicateOptionsWithEntity() throws Throwable {
+        testReplicateXXXEntity(HttpMethod.OPTIONS);
+    }
+
+    private void testReplicateXXX(final String method) throws Throwable {
+        testReplicateXXX(executorThreadCount, method);
+    }
+
+    private void testReplicateXXX(final int numNodes, final String method) throws Throwable {
+
+        // nodes
+        Set<NodeIdentifier> nodeIds = createNodes(numNodes, "localhost", serverPort);
+
+        // set up responses
+        for (int i = 0; i < nodeIds.size(); i++) {
+            HttpResponse response = new HttpResponse(Status.OK, expectedBody);
+            response.addHeaders(expectedResponseHeaders);
+            server.addResponseAction(new HttpResponseAction(response));
+        }
+
+        // setup request parameters
+        server.addCheckedParameters(expectedRequestParameters);
+
+        // request headers
+        server.addCheckedHeaders(expectedRequestHeaders);
+
+        Set<NodeResponse> responses = replicator.replicate(
+                nodeIds,
+                method,
+                prototypeUri,
+                expectedRequestParameters,
+                expectedRequestHeaders);
+
+        Set<NodeIdentifier> returnedNodeIds = new HashSet<>();
+        for (NodeResponse response : responses) {
+
+            // check if we received an exception
+            if (response.hasThrowable()) {
+                throw response.getThrowable();
+            }
+
+            // gather ids to verify later
+            returnedNodeIds.add(response.getNodeId());
+
+            // check status
+            assertEquals(Status.OK.getStatusCode(), response.getStatus());
+
+            Response serverResponse = response.getResponse();
+
+            // check response headers are copied
+            assertTrue(containsHeaders(expectedResponseHeaders, serverResponse.getMetadata()));
+
+            // check entity stream
+            if (HttpMethod.HEAD.equalsIgnoreCase(method)) {
+                assertNull(serverResponse.getEntity());
+            } else {
+                assertTrue(isEquals((StreamingOutput) serverResponse.getEntity(), expectedBody));
+            }
+
+        }
+
+        // check node Ids
+        assertEquals(nodeIds, returnedNodeIds);
+    }
+
+    private void testReplicateXXXEntity(final String method) throws Throwable {
+        testReplicateXXXEntity(executorThreadCount, method);
+    }
+
+    private void testReplicateXXXEntity(final int numNodes, final String method) throws Throwable {
+
+        // nodes
+        Set<NodeIdentifier> nodeIds = createNodes(numNodes, "localhost", serverPort);
+
+        // set up responses
+        for (int i = 0; i < nodeIds.size(); i++) {
+            HttpResponse response = new HttpResponse(Status.OK, expectedBody);
+            response.addHeaders(expectedResponseHeaders);
+            server.addResponseAction(new HttpResponseAction(response));
+        }
+
+        // headers
+        expectedRequestHeaders.put("Content-Type", "application/xml");
+
+        Set<NodeResponse> responses = replicator.replicate(
+                nodeIds,
+                method,
+                prototypeUri,
+                expectedEntity,
+                expectedRequestHeaders);
+
+        Set<NodeIdentifier> returnedNodeIds = new HashSet<>();
+        for (NodeResponse response : responses) {
+
+            // check if we received an exception
+            if (response.hasThrowable()) {
+                throw response.getThrowable();
+            }
+
+            // gather ids to verify later
+            returnedNodeIds.add(response.getNodeId());
+
+            // check status
+            assertEquals(Status.OK.getStatusCode(), response.getStatus());
+
+            Response serverResponse = response.getResponse();
+
+            // check response headers are copied
+            assertTrue(containsHeaders(expectedResponseHeaders, serverResponse.getMetadata()));
+
+            // check entity stream
+            assertTrue(isEquals((StreamingOutput) serverResponse.getEntity(), expectedBody));
+
+        }
+
+        // check node Ids
+        assertEquals(nodeIds, returnedNodeIds);
+    }
+
+    private Set<NodeIdentifier> createNodes(int num, String host, int apiPort) {
+        Set<NodeIdentifier> result = new HashSet<>();
+        for (int i = 0; i < num; i++) {
+            result.add(new NodeIdentifier(String.valueOf(i), host, apiPort, host, 1));
+        }
+        return result;
+    }
+
+    private boolean isEquals(StreamingOutput so, String expectedText) throws IOException {
+        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        so.write(baos);
+        return expectedText.equals(new String(baos.toByteArray()));
+    }
+
+    private boolean containsHeaders(Map<String, String> expectedHeaders, MultivaluedMap<String, Object> metadata) {
+        for (Map.Entry<String, String> expectedEntry : expectedHeaders.entrySet()) {
+            if (expectedEntry.getValue().equals(metadata.getFirst(expectedEntry.getKey())) == false) {
+                return false;
+            }
+        }
+        return true;
+    }
+
+}
+
+@XmlRootElement
+class Entity {
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/manager/impl/HttpResponseMapperImplTest.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/manager/impl/HttpResponseMapperImplTest.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/manager/impl/HttpResponseMapperImplTest.java
new file mode 100644
index 0000000..d45a4d1
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/manager/impl/HttpResponseMapperImplTest.java
@@ -0,0 +1,126 @@
+/*
+ * 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.nifi.cluster.manager.impl;
+
+import org.apache.nifi.cluster.manager.impl.HttpResponseMapperImpl;
+import com.sun.jersey.api.client.ClientResponse;
+import com.sun.jersey.core.util.MultivaluedMapImpl;
+import java.io.ByteArrayInputStream;
+import java.util.Map;
+import java.util.HashSet;
+import java.util.Set;
+import java.net.URI;
+import java.net.URISyntaxException;
+import org.apache.nifi.cluster.manager.NodeResponse;
+import org.apache.nifi.cluster.node.Node;
+import org.apache.nifi.cluster.node.Node.Status;
+import org.apache.nifi.cluster.protocol.NodeIdentifier;
+import org.junit.Before;
+import org.junit.Test;
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.*;
+
+/**
+ * @author unattributed
+ */
+public class HttpResponseMapperImplTest {
+
+    private HttpResponseMapperImpl mapper;
+
+    private URI dummyUri;
+
+    @Before
+    public void setup() throws URISyntaxException {
+        mapper = new HttpResponseMapperImpl();
+        dummyUri = new URI("http://dummy.com");
+    }
+
+    @Test
+    public void testToNodeStatusWithNo2xxResponses() {
+
+        Set<NodeResponse> nodeResponses = new HashSet<>();
+        nodeResponses.add(createNodeResourceResponse("1", 400));
+        nodeResponses.add(createNodeResourceResponse("2", 100));
+        nodeResponses.add(createNodeResourceResponse("3", 300));
+        nodeResponses.add(createNodeResourceResponse("4", 500));
+
+        Map<NodeResponse, Status> map = mapper.map(dummyUri, nodeResponses);
+
+        // since no 2xx responses, any 5xx is disconnected
+        for (Map.Entry<NodeResponse, Status> entry : map.entrySet()) {
+            NodeResponse response = entry.getKey();
+            Status status = entry.getValue();
+            switch (response.getNodeId().getId()) {
+                case "1":
+                    assertTrue(status == Node.Status.CONNECTED);
+                    break;
+                case "2":
+                    assertTrue(status == Node.Status.CONNECTED);
+                    break;
+                case "3":
+                    assertTrue(status == Node.Status.CONNECTED);
+                    break;
+                case "4":
+                    assertTrue(status == Node.Status.DISCONNECTED);
+                    break;
+            }
+        }
+    }
+
+    @Test
+    public void testToNodeStatusWith2xxResponses() {
+
+        Set<NodeResponse> nodeResponses = new HashSet<>();
+        nodeResponses.add(createNodeResourceResponse("1", 200));
+        nodeResponses.add(createNodeResourceResponse("2", 100));
+        nodeResponses.add(createNodeResourceResponse("3", 300));
+        nodeResponses.add(createNodeResourceResponse("4", 500));
+
+        Map<NodeResponse, Status> map = mapper.map(dummyUri, nodeResponses);
+
+        // since there were 2xx responses, any non-2xx is disconnected
+        for (Map.Entry<NodeResponse, Status> entry : map.entrySet()) {
+            NodeResponse response = entry.getKey();
+            Status status = entry.getValue();
+            switch (response.getNodeId().getId()) {
+                case "1":
+                    assertTrue(status == Node.Status.CONNECTED);
+                    break;
+                case "2":
+                    assertTrue(status == Node.Status.DISCONNECTED);
+                    break;
+                case "3":
+                    assertTrue(status == Node.Status.DISCONNECTED);
+                    break;
+                case "4":
+                    assertTrue(status == Node.Status.DISCONNECTED);
+                    break;
+            }
+        }
+    }
+
+    private NodeResponse createNodeResourceResponse(String nodeId, int statusCode) {
+
+        ClientResponse clientResponse = mock(ClientResponse.class);
+        when(clientResponse.getStatus()).thenReturn(statusCode);
+        when(clientResponse.getHeaders()).thenReturn(new MultivaluedMapImpl());
+        when(clientResponse.getEntityInputStream()).thenReturn(new ByteArrayInputStream(new byte[0]));
+
+        NodeIdentifier nodeIdentifier = new NodeIdentifier(nodeId, "localhost", 1, "localhost", 1);
+        return new NodeResponse(nodeIdentifier, "GET", dummyUri, clientResponse, 1L, "111");
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/manager/impl/TestWebClusterManager.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/manager/impl/TestWebClusterManager.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/manager/impl/TestWebClusterManager.java
new file mode 100644
index 0000000..13a192f
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/manager/impl/TestWebClusterManager.java
@@ -0,0 +1,54 @@
+/*
+ * 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.nifi.cluster.manager.impl;
+
+import org.apache.nifi.cluster.manager.impl.WebClusterManager;
+
+import static org.junit.Assert.assertEquals;
+
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Locale;
+
+import org.junit.Test;
+
+public class TestWebClusterManager {
+
+    @Test
+    public void testNormalizedStatusSnapshotDate() throws ParseException {
+        final DateFormat df = new SimpleDateFormat("yyyy/MM/dd HH:mm:SS.SSS", Locale.US);
+        final Date date1 = df.parse("2014/01/01 00:00:00.000");
+        final Date date2 = df.parse("2014/01/01 00:04:59.999");
+        final Date date3 = df.parse("2014/01/01 00:05:00.000");
+        final Date date4 = df.parse("2014/01/01 00:05:00.001");
+
+        final Date normalized1 = WebClusterManager.normalizeStatusSnapshotDate(date1, 300000);
+        assertEquals(date1, normalized1);
+
+        final Date normalized2 = WebClusterManager.normalizeStatusSnapshotDate(date2, 300000);
+        assertEquals(date1, normalized2);
+
+        final Date normalized3 = WebClusterManager.normalizeStatusSnapshotDate(date3, 300000);
+        assertEquals(date3, normalized3);
+
+        final Date normalized4 = WebClusterManager.normalizeStatusSnapshotDate(date4, 300000);
+        assertEquals(date3, normalized4);
+    }
+
+}


[18/20] incubator-nifi git commit: NIFI-410 pushed RAT exclusions down to the relevant modules and stopped doing broad test resource exclusion - is now specific

Posted by jo...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/AdaptedHeartbeat.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/AdaptedHeartbeat.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/AdaptedHeartbeat.java
deleted file mode 100644
index 5b9d9b7..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/AdaptedHeartbeat.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * 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.nifi.cluster.protocol.jaxb.message;
-
-import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
-import org.apache.nifi.cluster.protocol.NodeIdentifier;
-
-/**
- * @author unattributed
- */
-public class AdaptedHeartbeat {
-    
-    private NodeIdentifier nodeIdentifier;
-    private byte[] payload;
-    private boolean primary;
-    private boolean connected;
-    
-    public AdaptedHeartbeat() {}
-
-    @XmlJavaTypeAdapter(NodeIdentifierAdapter.class)
-    public NodeIdentifier getNodeIdentifier() {
-        return nodeIdentifier;
-    }
-
-    public void setNodeIdentifier(NodeIdentifier nodeIdentifier) {
-        this.nodeIdentifier = nodeIdentifier;
-    }
-    
-    public boolean isPrimary() {
-        return primary;
-    }
-
-    public void setPrimary(boolean primary) {
-        this.primary = primary;
-    }
-
-    public boolean isConnected() {
-        return connected;
-    }
-    
-    public void setConnected(boolean connected) {
-        this.connected = connected;
-    }
-    
-    public byte[] getPayload() {
-        return payload;
-    }
-
-    public void setPayload(byte[] payload) {
-        this.payload = payload;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/AdaptedNodeBulletins.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/AdaptedNodeBulletins.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/AdaptedNodeBulletins.java
deleted file mode 100644
index 98e2438..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/AdaptedNodeBulletins.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * 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.nifi.cluster.protocol.jaxb.message;
-
-import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
-import org.apache.nifi.cluster.protocol.NodeIdentifier;
-
-/**
- * @author unattributed
- */
-public class AdaptedNodeBulletins {
-    
-    private NodeIdentifier nodeIdentifier;
-    
-    private byte[] payload;
-    
-    public AdaptedNodeBulletins() {}
-
-    @XmlJavaTypeAdapter(NodeIdentifierAdapter.class)
-    public NodeIdentifier getNodeIdentifier() {
-        return nodeIdentifier;
-    }
-
-    public void setNodeIdentifier(NodeIdentifier nodeIdentifier) {
-        this.nodeIdentifier = nodeIdentifier;
-    }
-    
-    public byte[] getPayload() {
-        return payload;
-    }
-
-    public void setPayload(byte[] payload) {
-        this.payload = payload;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/AdaptedNodeIdentifier.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/AdaptedNodeIdentifier.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/AdaptedNodeIdentifier.java
deleted file mode 100644
index 8134ea3..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/AdaptedNodeIdentifier.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * 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.nifi.cluster.protocol.jaxb.message;
-
-/**
- * @author unattributed
- */
-public class AdaptedNodeIdentifier {
-    
-    private String id;
-    
-    private String apiAddress;
-
-    private int apiPort;    
-
-    private String socketAddress;
-    
-    private int socketPort;
-    
-    public AdaptedNodeIdentifier() {}
-
-    public String getApiAddress() {
-        return apiAddress;
-    }
-
-    public void setApiAddress(String apiAddress) {
-        this.apiAddress = apiAddress;
-    }
-
-    public int getApiPort() {
-        return apiPort;
-    }
-
-    public void setApiPort(int apiPort) {
-        this.apiPort = apiPort;
-    }
-
-    public String getId() {
-        return id;
-    }
-
-    public void setId(String id) {
-        this.id = id;
-    }
-
-    public String getSocketAddress() {
-        return socketAddress;
-    }
-
-    public void setSocketAddress(String socketAddress) {
-        this.socketAddress = socketAddress;
-    }
-
-    public int getSocketPort() {
-        return socketPort;
-    }
-
-    public void setSocketPort(int socketPort) {
-        this.socketPort = socketPort;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/ConnectionRequestAdapter.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/ConnectionRequestAdapter.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/ConnectionRequestAdapter.java
deleted file mode 100644
index 1f91cf1..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/ConnectionRequestAdapter.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * 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.nifi.cluster.protocol.jaxb.message;
-
-import javax.xml.bind.annotation.adapters.XmlAdapter;
-import org.apache.nifi.cluster.protocol.ConnectionRequest;
-
-/**
- * @author unattributed
- */
-public class ConnectionRequestAdapter extends XmlAdapter<AdaptedConnectionRequest, ConnectionRequest> {
-
-    @Override
-    public AdaptedConnectionRequest marshal(final ConnectionRequest cr) {
-        final AdaptedConnectionRequest aCr = new AdaptedConnectionRequest();
-        if(cr != null) {
-            aCr.setNodeIdentifier(cr.getProposedNodeIdentifier());
-        }
-        return aCr;
-    }
-
-    @Override
-    public ConnectionRequest unmarshal(final AdaptedConnectionRequest aCr) {
-        return new ConnectionRequest(aCr.getNodeIdentifier());
-    }
- 
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/ConnectionResponseAdapter.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/ConnectionResponseAdapter.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/ConnectionResponseAdapter.java
deleted file mode 100644
index 143bab0..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/ConnectionResponseAdapter.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * 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.nifi.cluster.protocol.jaxb.message;
-
-import javax.xml.bind.annotation.adapters.XmlAdapter;
-import org.apache.nifi.cluster.protocol.ConnectionResponse;
-
-/**
- * @author unattributed
- */
-public class ConnectionResponseAdapter extends XmlAdapter<AdaptedConnectionResponse, ConnectionResponse> {
-
-    @Override
-    public AdaptedConnectionResponse marshal(final ConnectionResponse cr) {
-        final AdaptedConnectionResponse aCr = new AdaptedConnectionResponse();
-        if(cr != null) {
-            aCr.setDataFlow(cr.getDataFlow());
-            aCr.setNodeIdentifier(cr.getNodeIdentifier());
-            aCr.setTryLaterSeconds(cr.getTryLaterSeconds());
-            aCr.setBlockedByFirewall(cr.isBlockedByFirewall());
-            aCr.setPrimary(cr.isPrimary());
-            aCr.setManagerRemoteInputPort(cr.getManagerRemoteInputPort());
-            aCr.setManagerRemoteCommsSecure(cr.isManagerRemoteCommsSecure());
-            aCr.setInstanceId(cr.getInstanceId());
-        }
-        return aCr;
-    }
-
-    @Override
-    public ConnectionResponse unmarshal(final AdaptedConnectionResponse aCr) {
-        if(aCr.shouldTryLater()) {
-            return new ConnectionResponse(aCr.getTryLaterSeconds());
-        } else if(aCr.isBlockedByFirewall()) {
-            return ConnectionResponse.createBlockedByFirewallResponse();
-        } else {
-            return new ConnectionResponse(aCr.getNodeIdentifier(), aCr.getDataFlow(), aCr.isPrimary(), 
-                aCr.getManagerRemoteInputPort(), aCr.isManagerRemoteCommsSecure(), aCr.getInstanceId());
-        }
-    }
- 
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/DataFlowAdapter.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/DataFlowAdapter.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/DataFlowAdapter.java
deleted file mode 100644
index 8d9467f..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/DataFlowAdapter.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * 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.nifi.cluster.protocol.jaxb.message;
-
-import javax.xml.bind.annotation.adapters.XmlAdapter;
-
-import org.apache.nifi.cluster.protocol.StandardDataFlow;
-
-/**
- * @author unattributed
- */
-public class DataFlowAdapter extends XmlAdapter<AdaptedDataFlow, StandardDataFlow> {
-
-    @Override
-    public AdaptedDataFlow marshal(final StandardDataFlow df) {
-        
-        final AdaptedDataFlow aDf = new AdaptedDataFlow();
-        
-        if(df != null) {
-            aDf.setFlow(df.getFlow());
-            aDf.setTemplates(df.getTemplates());
-            aDf.setSnippets(df.getSnippets());
-            aDf.setAutoStartProcessors(df.isAutoStartProcessors());
-        }
-        
-        return aDf;
-    }
-
-    @Override
-    public StandardDataFlow unmarshal(final AdaptedDataFlow aDf) {
-        final StandardDataFlow dataFlow = new StandardDataFlow(aDf.getFlow(), aDf.getTemplates(), aDf.getSnippets());
-        dataFlow.setAutoStartProcessors(aDf.isAutoStartProcessors());
-        return dataFlow;
-    }
- 
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/HeartbeatAdapter.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/HeartbeatAdapter.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/HeartbeatAdapter.java
deleted file mode 100644
index 0e073b6..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/HeartbeatAdapter.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * 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.nifi.cluster.protocol.jaxb.message;
-
-import javax.xml.bind.annotation.adapters.XmlAdapter;
-import org.apache.nifi.cluster.protocol.Heartbeat;
-
-/**
- * @author unattributed
- */
-public class HeartbeatAdapter extends XmlAdapter<AdaptedHeartbeat, Heartbeat> {
-
-    @Override
-    public AdaptedHeartbeat marshal(final Heartbeat hb) {
-        
-        final AdaptedHeartbeat aHb = new AdaptedHeartbeat();
-        
-        if(hb != null) {
-            // set node identifier
-            aHb.setNodeIdentifier(hb.getNodeIdentifier());
-
-            // set payload
-            aHb.setPayload(hb.getPayload());
-            
-            // set leader flag
-            aHb.setPrimary(hb.isPrimary());
-            
-            // set connected flag
-            aHb.setConnected(hb.isConnected());
-        }
-        
-        return aHb;
-    }
-
-    @Override
-    public Heartbeat unmarshal(final AdaptedHeartbeat aHb) {
-        return new Heartbeat(aHb.getNodeIdentifier(), aHb.isPrimary(), aHb.isConnected(), aHb.getPayload());
-    }
- 
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/JaxbProtocolUtils.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/JaxbProtocolUtils.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/JaxbProtocolUtils.java
deleted file mode 100644
index c3a57f5..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/JaxbProtocolUtils.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * 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.nifi.cluster.protocol.jaxb.message;
-
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBException;
-
-/**
- * @author unattributed
- */
-public final class JaxbProtocolUtils {
-    
-    public static final String JAXB_CONTEXT_PATH = ObjectFactory.class.getPackage().getName();
-
-    public static final JAXBContext JAXB_CONTEXT = initializeJaxbContext();
-    
-    /**
-     * Load the JAXBContext version.
-     */
-    private static JAXBContext initializeJaxbContext() {
-        try {
-            return JAXBContext.newInstance(JAXB_CONTEXT_PATH);
-        } catch (JAXBException e) {
-            throw new RuntimeException("Unable to create JAXBContext.", e);
-        }
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/NodeBulletinsAdapter.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/NodeBulletinsAdapter.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/NodeBulletinsAdapter.java
deleted file mode 100644
index 1ae41f7..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/NodeBulletinsAdapter.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * 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.nifi.cluster.protocol.jaxb.message;
-
-import javax.xml.bind.annotation.adapters.XmlAdapter;
-import org.apache.nifi.cluster.protocol.NodeBulletins;
-
-/**
- * @author unattributed
- */
-public class NodeBulletinsAdapter extends XmlAdapter<AdaptedNodeBulletins, NodeBulletins> {
-
-    @Override
-    public AdaptedNodeBulletins marshal(final NodeBulletins hb) {
-        
-        final AdaptedNodeBulletins adaptedBulletins = new AdaptedNodeBulletins();
-        
-        if(hb != null) {
-            // set node identifier
-            adaptedBulletins.setNodeIdentifier(hb.getNodeIdentifier());
-
-            // set payload
-            adaptedBulletins.setPayload(hb.getPayload());
-        }
-        
-        return adaptedBulletins;
-    }
-
-    @Override
-    public NodeBulletins unmarshal(final AdaptedNodeBulletins adaptedBulletins) {
-        return new NodeBulletins(adaptedBulletins.getNodeIdentifier(), adaptedBulletins.getPayload());
-    }
- 
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/NodeIdentifierAdapter.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/NodeIdentifierAdapter.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/NodeIdentifierAdapter.java
deleted file mode 100644
index fe2d8a4..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/NodeIdentifierAdapter.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * 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.nifi.cluster.protocol.jaxb.message;
-
-import javax.xml.bind.annotation.adapters.XmlAdapter;
-import org.apache.nifi.cluster.protocol.NodeIdentifier;
-
-/**
- * @author unattributed
- */
-public class NodeIdentifierAdapter extends XmlAdapter<AdaptedNodeIdentifier, NodeIdentifier> {
-
-    @Override
-    public AdaptedNodeIdentifier marshal(final NodeIdentifier ni) {
-        if(ni == null) {
-            return null;
-        } else {
-            final AdaptedNodeIdentifier aNi = new AdaptedNodeIdentifier();
-            aNi.setId(ni.getId());
-            aNi.setApiAddress(ni.getApiAddress());
-            aNi.setApiPort(ni.getApiPort());
-            aNi.setSocketAddress(ni.getSocketAddress());
-            aNi.setSocketPort(ni.getSocketPort());
-            return aNi;
-        }
-    }
-
-    @Override
-    public NodeIdentifier unmarshal(final AdaptedNodeIdentifier aNi) {
-        if(aNi == null) {
-            return null;
-        } else {
-            return new NodeIdentifier(aNi.getId(), aNi.getApiAddress(), aNi.getApiPort(), aNi.getSocketAddress(), aNi.getSocketPort());
-        }
-    }
- 
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/ObjectFactory.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/ObjectFactory.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/ObjectFactory.java
deleted file mode 100644
index 1613536..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/ObjectFactory.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * 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.nifi.cluster.protocol.jaxb.message;
-
-import javax.xml.bind.annotation.XmlRegistry;
-
-import org.apache.nifi.cluster.protocol.message.ConnectionRequestMessage;
-import org.apache.nifi.cluster.protocol.message.ConnectionResponseMessage;
-import org.apache.nifi.cluster.protocol.message.ControllerStartupFailureMessage;
-import org.apache.nifi.cluster.protocol.message.DisconnectMessage;
-import org.apache.nifi.cluster.protocol.message.FlowRequestMessage;
-import org.apache.nifi.cluster.protocol.message.FlowResponseMessage;
-import org.apache.nifi.cluster.protocol.message.HeartbeatMessage;
-import org.apache.nifi.cluster.protocol.message.MulticastProtocolMessage;
-import org.apache.nifi.cluster.protocol.message.NodeBulletinsMessage;
-import org.apache.nifi.cluster.protocol.message.PingMessage;
-import org.apache.nifi.cluster.protocol.message.PrimaryRoleAssignmentMessage;
-import org.apache.nifi.cluster.protocol.message.ReconnectionFailureMessage;
-import org.apache.nifi.cluster.protocol.message.ReconnectionRequestMessage;
-import org.apache.nifi.cluster.protocol.message.ReconnectionResponseMessage;
-import org.apache.nifi.cluster.protocol.message.ServiceBroadcastMessage;
-
-/**
- * @author unattributed
- */
-@XmlRegistry
-public class ObjectFactory {
-    
-    public ObjectFactory() {}
-    
-    public ReconnectionRequestMessage createReconnectionRequestMessage() {
-        return new ReconnectionRequestMessage();
-    }
-    
-    public ReconnectionFailureMessage createReconnectionFailureMessage() {
-        return new ReconnectionFailureMessage();
-    }
-    
-    public ReconnectionResponseMessage createReconnectionResponseMessage() {
-        return new ReconnectionResponseMessage();
-    }
-    
-    public DisconnectMessage createDisconnectionMessage() {
-        return new DisconnectMessage();
-    }
-    
-    public ConnectionRequestMessage createConnectionRequestMessage() {
-        return new ConnectionRequestMessage();
-    }
-    
-    public ConnectionResponseMessage createConnectionResponseMessage() {
-        return new ConnectionResponseMessage();
-    }
-    
-    public ServiceBroadcastMessage createServiceBroadcastMessage() {
-        return new ServiceBroadcastMessage();
-    }
-    
-    public HeartbeatMessage createHeartbeatMessage() {
-        return new HeartbeatMessage();
-    }
-    
-    public FlowRequestMessage createFlowRequestMessage() {
-        return new FlowRequestMessage();
-    }
-    
-    public FlowResponseMessage createFlowResponseMessage() {
-        return new FlowResponseMessage();
-    }
-    
-    public PingMessage createPingMessage() {
-        return new PingMessage();
-    }
-    
-    public MulticastProtocolMessage createMulticastProtocolMessage() {
-        return new MulticastProtocolMessage();
-    }
-    
-    public ControllerStartupFailureMessage createControllerStartupFailureMessage() {
-        return new ControllerStartupFailureMessage();
-    }
-    
-    public PrimaryRoleAssignmentMessage createPrimaryRoleAssignmentMessage() {
-        return new PrimaryRoleAssignmentMessage();
-    }
-    
-    public NodeBulletinsMessage createBulletinsMessage() {
-        return new NodeBulletinsMessage();
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ConnectionRequestMessage.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ConnectionRequestMessage.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ConnectionRequestMessage.java
deleted file mode 100644
index 344de4e..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ConnectionRequestMessage.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * 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.nifi.cluster.protocol.message;
-
-import javax.xml.bind.annotation.XmlRootElement;
-
-import org.apache.nifi.cluster.protocol.ConnectionRequest;
-
-/**
- * @author unattributed
- */
-@XmlRootElement(name = "connectionRequestMessage")
-public class ConnectionRequestMessage extends ProtocolMessage {
-    
-    private ConnectionRequest connectionRequest;
-    
-    public ConnectionRequestMessage() {}
-    
-    public ConnectionRequest getConnectionRequest() {
-        return connectionRequest;
-    }
-
-    public void setConnectionRequest(ConnectionRequest connectionRequest) {
-        this.connectionRequest = connectionRequest;
-    }
-    
-    @Override
-    public MessageType getType() {
-        return MessageType.CONNECTION_REQUEST;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ConnectionResponseMessage.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ConnectionResponseMessage.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ConnectionResponseMessage.java
deleted file mode 100644
index a262d7a..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ConnectionResponseMessage.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * 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.nifi.cluster.protocol.message;
-
-import javax.xml.bind.annotation.XmlRootElement;
-import org.apache.nifi.cluster.protocol.ConnectionResponse;
-
-/**
- * @author unattributed
- */
-@XmlRootElement(name = "connectionResponseMessage")
-public class ConnectionResponseMessage extends ProtocolMessage {
-    
-    private ConnectionResponse connectionResponse;
-    private String clusterManagerDN;
-    
-    public ConnectionResponseMessage() {}
-
-    public ConnectionResponse getConnectionResponse() {
-        return connectionResponse;
-    }
-
-    public void setConnectionResponse(final ConnectionResponse connectionResponse) {
-        this.connectionResponse = connectionResponse;
-        
-        if ( clusterManagerDN != null ) {
-            this.connectionResponse.setClusterManagerDN(clusterManagerDN);
-        }
-    }
-    
-    public void setClusterManagerDN(final String dn) {
-        if ( connectionResponse != null ) {
-            connectionResponse.setClusterManagerDN(dn);
-        }
-        this.clusterManagerDN = dn;
-    }
-    
-    /**
-     * Returns the DN of the NCM, if it is available or <code>null</code> otherwise.
-     * 
-     * @return
-     */
-    public String getClusterManagerDN() {
-        return clusterManagerDN;
-    }
-
-    @Override
-    public MessageType getType() {
-        return MessageType.CONNECTION_RESPONSE;
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ControllerStartupFailureMessage.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ControllerStartupFailureMessage.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ControllerStartupFailureMessage.java
deleted file mode 100644
index ebc1cae..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ControllerStartupFailureMessage.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * 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.nifi.cluster.protocol.message;
-
-import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
-
-import org.apache.nifi.cluster.protocol.NodeIdentifier;
-import org.apache.nifi.cluster.protocol.jaxb.message.NodeIdentifierAdapter;
-
-/**
- * @author unattributed
- */
-@XmlRootElement(name = "controllerStartupFailureMessage")
-public class ControllerStartupFailureMessage extends ExceptionMessage {
-
-    private NodeIdentifier nodeId;
-    
-    public ControllerStartupFailureMessage() {}
-    
-    @Override
-    public MessageType getType() {
-        return MessageType.CONTROLLER_STARTUP_FAILURE;
-    }
-
-    @XmlJavaTypeAdapter(NodeIdentifierAdapter.class)
-    public NodeIdentifier getNodeId() {
-        return nodeId;
-    }
-
-    public void setNodeId(NodeIdentifier nodeId) {
-        this.nodeId = nodeId;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/DisconnectMessage.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/DisconnectMessage.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/DisconnectMessage.java
deleted file mode 100644
index 8aa7a40..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/DisconnectMessage.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * 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.nifi.cluster.protocol.message;
-
-import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
-import org.apache.nifi.cluster.protocol.NodeIdentifier;
-import org.apache.nifi.cluster.protocol.jaxb.message.NodeIdentifierAdapter;
-
-/**
- * @author unattributed
- */
-@XmlRootElement(name = "disconnectionMessage")
-public class DisconnectMessage extends ProtocolMessage {
-    
-    private NodeIdentifier nodeId;
-    private String explanation;
- 
-    @XmlJavaTypeAdapter(NodeIdentifierAdapter.class)
-    public NodeIdentifier getNodeId() {
-        return nodeId;
-    }
-
-    public void setNodeId(NodeIdentifier nodeId) {
-        this.nodeId = nodeId;
-    }
-
-    public String getExplanation() {
-        return explanation;
-    }
-
-    public void setExplanation(String explanation) {
-        this.explanation = explanation;
-    }
-    
-    @Override
-    public MessageType getType() {
-        return MessageType.DISCONNECTION_REQUEST;
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ExceptionMessage.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ExceptionMessage.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ExceptionMessage.java
deleted file mode 100644
index 99a6dee..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ExceptionMessage.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * 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.nifi.cluster.protocol.message;
-
-import javax.xml.bind.annotation.XmlRootElement;
-
-/**
- * @author unattributed
- */
-@XmlRootElement(name = "exceptionMessage")
-public class ExceptionMessage extends ProtocolMessage {
-    
-    private String exceptionMessage;
-
-    public ExceptionMessage() {}
-
-    public String getExceptionMessage() {
-        return exceptionMessage;
-    }
-
-    public void setExceptionMessage(String exceptionMessage) {
-        this.exceptionMessage = exceptionMessage;
-    }
-    
-    @Override
-    public MessageType getType() {
-        return MessageType.EXCEPTION;
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/FlowRequestMessage.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/FlowRequestMessage.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/FlowRequestMessage.java
deleted file mode 100644
index 4a10538..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/FlowRequestMessage.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * 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.nifi.cluster.protocol.message;
-
-import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
-import org.apache.nifi.cluster.protocol.NodeIdentifier;
-import org.apache.nifi.cluster.protocol.jaxb.message.NodeIdentifierAdapter;
-
-/**
- * @author unattributed
- */
-@XmlRootElement(name = "flowRequestMessage")
-public class FlowRequestMessage extends ProtocolMessage {
-    
-    private NodeIdentifier nodeId;
-
-    @XmlJavaTypeAdapter(NodeIdentifierAdapter.class)
-    public NodeIdentifier getNodeId() {
-        return nodeId;
-    }
-
-    public void setNodeId(NodeIdentifier nodeId) {
-        this.nodeId = nodeId;
-    }
-    
-    @Override
-    public MessageType getType() {
-        return MessageType.FLOW_REQUEST;
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/FlowResponseMessage.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/FlowResponseMessage.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/FlowResponseMessage.java
deleted file mode 100644
index 0d34dae..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/FlowResponseMessage.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * 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.nifi.cluster.protocol.message;
-
-import javax.xml.bind.annotation.XmlRootElement;
-
-import org.apache.nifi.cluster.protocol.StandardDataFlow;
-
-/**
- * @author unattributed
- */
-@XmlRootElement(name = "flowResponseMessage")
-public class FlowResponseMessage extends ProtocolMessage {
-    
-    private StandardDataFlow dataFlow;
-    
-    @Override
-    public MessageType getType() {
-        return MessageType.FLOW_RESPONSE;
-    }
-
-    public StandardDataFlow getDataFlow() {
-        return dataFlow;
-    }
-
-    public void setDataFlow(StandardDataFlow dataFlow) {
-        this.dataFlow = dataFlow;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/HeartbeatMessage.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/HeartbeatMessage.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/HeartbeatMessage.java
deleted file mode 100644
index 0064cb6..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/HeartbeatMessage.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * 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.nifi.cluster.protocol.message;
-
-import org.apache.nifi.cluster.protocol.Heartbeat;
-import javax.xml.bind.annotation.XmlRootElement;
-
-/**
- * @author unattributed
- */
-@XmlRootElement(name = "heartbeatMessage")
-public class HeartbeatMessage extends ProtocolMessage {
-    
-    private Heartbeat heartbeat;
-    
-    @Override
-    public MessageType getType() {
-        return MessageType.HEARTBEAT;
-    }
-
-    public Heartbeat getHeartbeat() {
-        return heartbeat;
-    }
-
-    public void setHeartbeat(Heartbeat heartbeat) {
-        this.heartbeat = heartbeat;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/MulticastProtocolMessage.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/MulticastProtocolMessage.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/MulticastProtocolMessage.java
deleted file mode 100644
index c6d2d44..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/MulticastProtocolMessage.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * 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.nifi.cluster.protocol.message;
-
-import javax.xml.bind.annotation.XmlRootElement;
-
-/**
- * Wraps a protocol message and an identifier for sending the message by way
- * multicast.  The identifier is necessary for the sender to identify a message
- * sent by it.
- * 
- * @author unattributed
- */
-@XmlRootElement(name = "multicastMessage")
-public class MulticastProtocolMessage extends ProtocolMessage {
-    
-    private ProtocolMessage protocolMessage;
-    
-    private String id;
-    
-    public MulticastProtocolMessage() {}
-
-    public MulticastProtocolMessage(final String id, final ProtocolMessage protocolMessage) {
-        this.protocolMessage = protocolMessage;
-        this.id = id;
-    }
-    
-    @Override
-    public MessageType getType() {
-        if(protocolMessage == null) {
-            return null;
-        }
-        return protocolMessage.getType();
-    }
-
-    public String getId() {
-        return id;
-    }
-
-    public void setId(String id) {
-        this.id = id;
-    }
-
-    public ProtocolMessage getProtocolMessage() {
-        return protocolMessage;
-    }
-
-    public void setProtocolMessage(ProtocolMessage protocolMessage) {
-        this.protocolMessage = protocolMessage;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/NodeBulletinsMessage.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/NodeBulletinsMessage.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/NodeBulletinsMessage.java
deleted file mode 100644
index 9237a92..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/NodeBulletinsMessage.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * 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.nifi.cluster.protocol.message;
-
-import org.apache.nifi.cluster.protocol.NodeBulletins;
-import javax.xml.bind.annotation.XmlRootElement;
-
-/**
- * @author unattributed
- */
-@XmlRootElement(name = "nodeBulletinsMessage")
-public class NodeBulletinsMessage extends ProtocolMessage {
-    
-    private NodeBulletins bulletins;
-    
-    @Override
-    public MessageType getType() {
-        return MessageType.BULLETINS;
-    }
-
-    public NodeBulletins getBulletins() {
-        return bulletins;
-    }
-
-    public void setBulletins(NodeBulletins bulletins) {
-        this.bulletins = bulletins;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/PingMessage.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/PingMessage.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/PingMessage.java
deleted file mode 100644
index ee38deb..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/PingMessage.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * 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.nifi.cluster.protocol.message;
-
-import java.util.Date;
-import javax.xml.bind.annotation.XmlRootElement;
-
-/**
- * @author unattributed
- */
-@XmlRootElement(name = "pingMessage")
-public class PingMessage extends ProtocolMessage {
-    
-    private String id;
-    
-    private Date date = new Date();
-
-    public PingMessage() {}
-    
-    public Date getDate() {
-        return date;
-    }
-
-    public void setDate(Date date) {
-        this.date = date;
-    }
-
-    public String getId() {
-        return id;
-    }
-
-    public void setId(String id) {
-        this.id = id;
-    }
-    
-    @Override
-    public MessageType getType() {
-        return MessageType.PING;
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/PrimaryRoleAssignmentMessage.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/PrimaryRoleAssignmentMessage.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/PrimaryRoleAssignmentMessage.java
deleted file mode 100644
index a289abc..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/PrimaryRoleAssignmentMessage.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * 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.nifi.cluster.protocol.message;
-
-import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
-import org.apache.nifi.cluster.protocol.NodeIdentifier;
-import org.apache.nifi.cluster.protocol.jaxb.message.NodeIdentifierAdapter;
-
-/**
- * @author unattributed
- */
-@XmlRootElement(name = "primaryRoleAssignmentMessage")
-public class PrimaryRoleAssignmentMessage extends ProtocolMessage {
-
-    private NodeIdentifier nodeId;
-
-    private boolean primary;
-    
-    @XmlJavaTypeAdapter(NodeIdentifierAdapter.class)
-    public NodeIdentifier getNodeId() {
-        return nodeId;
-    }
-
-    public void setNodeId(NodeIdentifier nodeId) {
-        this.nodeId = nodeId;
-    }
-
-    public boolean isPrimary() {
-        return primary;
-    }
-
-    public void setPrimary(boolean primary) {
-        this.primary = primary;
-    }
-   
-    @Override
-    public MessageType getType() {
-        return MessageType.PRIMARY_ROLE;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ProtocolMessage.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ProtocolMessage.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ProtocolMessage.java
deleted file mode 100644
index 6bf2a13..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ProtocolMessage.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * 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.nifi.cluster.protocol.message;
-
-/**
- * @author unattributed
- */
-public abstract class ProtocolMessage {
-    private volatile String requestorDN;
-    
-    public static enum MessageType {
-        BULLETINS,
-        CONNECTION_REQUEST,
-        CONNECTION_RESPONSE,
-        CONTROLLER_STARTUP_FAILURE,
-        RECONNECTION_FAILURE,
-        DISCONNECTION_REQUEST,
-        EXCEPTION,
-        FLOW_REQUEST,
-        FLOW_RESPONSE,
-        HEARTBEAT,
-        PING,
-        PRIMARY_ROLE,
-        RECONNECTION_REQUEST,
-        RECONNECTION_RESPONSE,
-        SERVICE_BROADCAST,
-    }
-    
-    public abstract MessageType getType();
-    
-    /**
-     * Sets the DN of the entity making the request
-     * @param dn
-     */
-    public void setRequestorDN(final String dn) {
-        this.requestorDN = dn;
-    }
-    
-    /**
-     * Returns the DN of the entity that made the request, if using a secure socket. Otherwise, returns <code>null</code>
-     * @return
-     */
-    public String getRequestorDN() {
-        return requestorDN;
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ReconnectionFailureMessage.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ReconnectionFailureMessage.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ReconnectionFailureMessage.java
deleted file mode 100644
index ba45e28..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ReconnectionFailureMessage.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * 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.nifi.cluster.protocol.message;
-
-import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
-
-import org.apache.nifi.cluster.protocol.NodeIdentifier;
-import org.apache.nifi.cluster.protocol.jaxb.message.NodeIdentifierAdapter;
-
-@XmlRootElement(name = "reconnectionFailureMessage")
-public class ReconnectionFailureMessage extends ExceptionMessage {
-    private NodeIdentifier nodeId;
-    
-    public ReconnectionFailureMessage() {}
-    
-    @Override
-    public MessageType getType() {
-        return MessageType.RECONNECTION_FAILURE;
-    }
-
-    @XmlJavaTypeAdapter(NodeIdentifierAdapter.class)
-    public NodeIdentifier getNodeId() {
-        return nodeId;
-    }
-
-    public void setNodeId(NodeIdentifier nodeId) {
-        this.nodeId = nodeId;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ReconnectionRequestMessage.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ReconnectionRequestMessage.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ReconnectionRequestMessage.java
deleted file mode 100644
index eab3d5d..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ReconnectionRequestMessage.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * 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.nifi.cluster.protocol.message;
-
-import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
-
-import org.apache.nifi.cluster.protocol.NodeIdentifier;
-import org.apache.nifi.cluster.protocol.StandardDataFlow;
-import org.apache.nifi.cluster.protocol.jaxb.message.NodeIdentifierAdapter;
-
-/**
- * @author unattributed
- */
-@XmlRootElement(name = "reconnectionRequestMessage")
-public class ReconnectionRequestMessage extends ProtocolMessage {
-
-    private NodeIdentifier nodeId;
-    private StandardDataFlow dataFlow;
-    private boolean primary;
-    private Integer managerRemoteSiteListeningPort;
-    private Boolean managerRemoteSiteCommsSecure;
-    private String instanceId;
-    
-    public ReconnectionRequestMessage() {}
-
-    @XmlJavaTypeAdapter(NodeIdentifierAdapter.class)
-    public NodeIdentifier getNodeId() {
-        return nodeId;
-    }
-
-    public void setNodeId(NodeIdentifier nodeId) {
-        this.nodeId = nodeId;
-    }
-
-    public StandardDataFlow getDataFlow() {
-        return dataFlow;
-    }
-
-    public void setDataFlow(StandardDataFlow dataFlow) {
-        this.dataFlow = dataFlow;
-    }
-
-    public boolean isPrimary() {
-        return primary;
-    }
-
-    public void setPrimary(boolean primary) {
-        this.primary = primary;
-    }
-    
-    @Override
-    public MessageType getType() {
-        return MessageType.RECONNECTION_REQUEST;
-    }
-    
-    public void setManagerRemoteSiteListeningPort(final Integer listeningPort) {
-        this.managerRemoteSiteListeningPort = listeningPort;
-    }
-    
-    public Integer getManagerRemoteSiteListeningPort() {
-        return managerRemoteSiteListeningPort;
-    }
-    
-    public void setManagerRemoteSiteCommsSecure(final Boolean remoteSiteCommsSecure) {
-        this.managerRemoteSiteCommsSecure = remoteSiteCommsSecure;
-    }
-    
-    public Boolean isManagerRemoteSiteCommsSecure() {
-        return managerRemoteSiteCommsSecure;
-    }
-    
-    public void setInstanceId(final String instanceId) {
-        this.instanceId = instanceId;
-    }
-    
-    public String getInstanceId() {
-        return instanceId;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ReconnectionResponseMessage.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ReconnectionResponseMessage.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ReconnectionResponseMessage.java
deleted file mode 100644
index fd0f921..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ReconnectionResponseMessage.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * 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.nifi.cluster.protocol.message;
-
-import javax.xml.bind.annotation.XmlRootElement;
-
-/**
- * This message is used an "ACK" for a ReconnectionRequestMessage
- */
-@XmlRootElement(name = "reconnectionResponseMessage")
-public class ReconnectionResponseMessage extends ProtocolMessage {
-
-    @Override
-    public MessageType getType() {
-        return MessageType.RECONNECTION_RESPONSE;
-    }
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ServiceBroadcastMessage.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ServiceBroadcastMessage.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ServiceBroadcastMessage.java
deleted file mode 100644
index 92708ba..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ServiceBroadcastMessage.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * 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.nifi.cluster.protocol.message;
-
-import javax.xml.bind.annotation.XmlRootElement;
-
-/**
- * @author unattributed
- */
-@XmlRootElement(name = "serviceBroadcastMessage")
-public class ServiceBroadcastMessage extends ProtocolMessage {
-
-    private String serviceName;
-    
-    private String address;
-    
-    private int port;
-    
-    public ServiceBroadcastMessage() {}
-
-    public String getServiceName() {
-        return serviceName;
-    }
-
-    public void setServiceName(String serviceName) {
-        this.serviceName = serviceName;
-    }
-
-    public String getAddress() {
-        return address;
-    }
-
-    public void setAddress(String address) {
-        this.address = address;
-    }
-
-    public int getPort() {
-        return port;
-    }
-
-    public void setPort(int port) {
-        this.port = port;
-    }
-
-    @Override
-    public MessageType getType() {
-        return MessageType.SERVICE_BROADCAST;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/spring/MulticastConfigurationFactoryBean.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/spring/MulticastConfigurationFactoryBean.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/spring/MulticastConfigurationFactoryBean.java
deleted file mode 100644
index fa201bb..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/spring/MulticastConfigurationFactoryBean.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * 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.nifi.cluster.protocol.spring;
-
-import java.util.concurrent.TimeUnit;
-
-import org.apache.nifi.io.socket.multicast.MulticastConfiguration;
-import org.apache.nifi.util.FormatUtils;
-import org.apache.nifi.util.NiFiProperties;
-import org.springframework.beans.factory.FactoryBean;
-
-/**
- * Factory bean for creating a singleton MulticastConfiguration instance.  
- */
-public class MulticastConfigurationFactoryBean implements FactoryBean {
-    
-    private MulticastConfiguration configuration;
-    private NiFiProperties properties;
-    
-    @Override
-    public Object getObject() throws Exception {
-        if(configuration == null) {
-            configuration = new MulticastConfiguration();
-            
-            final int timeout = (int) FormatUtils.getTimeDuration(properties.getClusterProtocolSocketTimeout(), TimeUnit.MILLISECONDS);
-            configuration.setSocketTimeout(timeout);
-            configuration.setReuseAddress(true);
-        }
-        return configuration;
-
-    }
-
-    @Override
-    public Class getObjectType() {
-        return MulticastConfiguration.class;
-    }
-
-    @Override
-    public boolean isSingleton() {
-        return true;
-    }
-    
-    public void setProperties(NiFiProperties properties) {
-        this.properties = properties;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/spring/ServerSocketConfigurationFactoryBean.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/spring/ServerSocketConfigurationFactoryBean.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/spring/ServerSocketConfigurationFactoryBean.java
deleted file mode 100644
index 5b5816d..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/spring/ServerSocketConfigurationFactoryBean.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * 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.nifi.cluster.protocol.spring;
-
-import java.util.concurrent.TimeUnit;
-
-import org.apache.nifi.io.socket.SSLContextFactory;
-import org.apache.nifi.io.socket.ServerSocketConfiguration;
-import org.apache.nifi.util.FormatUtils;
-import org.apache.nifi.util.NiFiProperties;
-
-import org.springframework.beans.factory.FactoryBean;
-
-/**
- * Factory bean for creating a singleton ServerSocketConfiguration instance.  
- */
-public class ServerSocketConfigurationFactoryBean implements FactoryBean<ServerSocketConfiguration> {
-    private ServerSocketConfiguration configuration;
-    private NiFiProperties properties;
-    
-    @Override
-    public ServerSocketConfiguration getObject() throws Exception {
-        if(configuration == null) {
-            configuration = new ServerSocketConfiguration();
-            configuration.setNeedClientAuth(properties.getNeedClientAuth());
-            
-            final int timeout = (int) FormatUtils.getTimeDuration(properties.getClusterProtocolSocketTimeout(), TimeUnit.MILLISECONDS);
-            configuration.setSocketTimeout(timeout);
-            configuration.setReuseAddress(true);
-            if(Boolean.valueOf(properties.getProperty(NiFiProperties.CLUSTER_PROTOCOL_IS_SECURE))) {
-                configuration.setSSLContextFactory(new SSLContextFactory(properties));
-            }
-        }
-        return configuration;
-
-    }
-
-    @Override
-    public Class<ServerSocketConfiguration> getObjectType() {
-        return ServerSocketConfiguration.class;
-    }
-
-    @Override
-    public boolean isSingleton() {
-        return true;
-    }
-    
-    public void setProperties(NiFiProperties properties) {
-        this.properties = properties;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/spring/SocketConfigurationFactoryBean.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/spring/SocketConfigurationFactoryBean.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/spring/SocketConfigurationFactoryBean.java
deleted file mode 100644
index b438e44..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/spring/SocketConfigurationFactoryBean.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * 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.nifi.cluster.protocol.spring;
-
-import java.util.concurrent.TimeUnit;
-
-import org.apache.nifi.io.socket.SSLContextFactory;
-import org.apache.nifi.io.socket.SocketConfiguration;
-import org.apache.nifi.util.FormatUtils;
-import org.apache.nifi.util.NiFiProperties;
-
-import org.springframework.beans.factory.FactoryBean;
-
-/**
- * Factory bean for creating a singleton SocketConfiguration instance.  
- */
-public class SocketConfigurationFactoryBean implements FactoryBean<SocketConfiguration> {
-    
-    private SocketConfiguration configuration;
-    
-    private NiFiProperties properties;
-    
-    @Override
-    public SocketConfiguration getObject() throws Exception {
-        if(configuration == null) {
-            configuration = new SocketConfiguration();
-            
-            final int timeout = (int) FormatUtils.getTimeDuration(properties.getClusterProtocolSocketTimeout(), TimeUnit.MILLISECONDS);
-            configuration.setSocketTimeout(timeout);
-            configuration.setReuseAddress(true);
-            if(Boolean.valueOf(properties.getProperty(NiFiProperties.CLUSTER_PROTOCOL_IS_SECURE))) {
-                configuration.setSSLContextFactory(new SSLContextFactory(properties));
-            }
-        }
-        return configuration;
-
-    }
-
-    @Override
-    public Class<SocketConfiguration> getObjectType() {
-        return SocketConfiguration.class;
-    }
-
-    @Override
-    public boolean isSingleton() {
-        return true;
-    }
-    
-    public void setProperties(NiFiProperties properties) {
-        this.properties = properties;
-    }
-}


[16/20] incubator-nifi git commit: NIFI-410 pushed RAT exclusions down to the relevant modules and stopped doing broad test resource exclusion - is now specific

Posted by jo...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/event/EventManager.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/event/EventManager.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/event/EventManager.java
deleted file mode 100644
index f9dfb00..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/event/EventManager.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * 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.nifi.cluster.event;
-
-import java.util.List;
-
-/**
- * Manages an ordered list of events. The event history size dictates the total
- * number of events to manage for a given source at a given time. When the size
- * is exceeded, the oldest event for that source is evicted.
- *
- * @author unattributed
- */
-public interface EventManager {
-
-    /**
-     * Adds an event to the manager.
-     *
-     * @param event an Event
-     */
-    void addEvent(Event event);
-
-    /**
-     * Returns a list of events for a given source sorted by the event's
-     * timestamp where the most recent event is first in the list.
-     *
-     * @param eventSource the source
-     *
-     * @return the list of events
-     */
-    List<Event> getEvents(String eventSource);
-
-    /*
-     * Returns the most recent event for the source.  If no events exist, then
-     * null is returned.
-     */
-    Event getMostRecentEvent(String eventSource);
-
-    /*
-     * Clears all events for the given source.
-     */
-    void clearEventHistory(String eventSource);
-
-    /**
-     * Returns the history size.
-     *
-     * @return the history size
-     */
-    int getEventHistorySize();
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/event/impl/EventManagerImpl.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/event/impl/EventManagerImpl.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/event/impl/EventManagerImpl.java
deleted file mode 100644
index 7fadc78..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/event/impl/EventManagerImpl.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * 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.nifi.cluster.event.impl;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.PriorityQueue;
-import java.util.Queue;
-import org.apache.nifi.cluster.event.Event;
-import org.apache.nifi.cluster.event.EventManager;
-
-/**
- * Implements the EventManager.
- *
- * @author unattributed
- */
-public class EventManagerImpl implements EventManager {
-
-    /**
-     * associates the source ID with an ordered queue of events, ordered by most
-     * recent event
-     */
-    private final Map<String, Queue<Event>> eventsMap = new HashMap<>();
-
-    /**
-     * the number of events to maintain for a given source
-     */
-    private final int eventHistorySize;
-
-    /**
-     * Creates an instance.
-     *
-     * @param eventHistorySize the number of events to manage for a given
-     * source. Value must be positive.
-     */
-    public EventManagerImpl(final int eventHistorySize) {
-        if (eventHistorySize <= 0) {
-            throw new IllegalArgumentException("Event history size must be positive: " + eventHistorySize);
-        }
-        this.eventHistorySize = eventHistorySize;
-    }
-
-    @Override
-    public void addEvent(final Event event) {
-
-        if (event == null) {
-            throw new IllegalArgumentException("Event may not be null.");
-        }
-
-        Queue<Event> events = eventsMap.get(event.getSource());
-        if (events == null) {
-            // no events from this source, so add a new queue to the map
-            events = new PriorityQueue<>(eventHistorySize, createEventComparator());
-            eventsMap.put(event.getSource(), events);
-        }
-
-        // add event
-        events.add(event);
-
-        // if we exceeded the history size, then evict the oldest event
-        if (events.size() > eventHistorySize) {
-            removeOldestEvent(events);
-        }
-
-    }
-
-    @Override
-    public List<Event> getEvents(final String eventSource) {
-        final Queue<Event> events = eventsMap.get(eventSource);
-        if (events == null) {
-            return Collections.EMPTY_LIST;
-        } else {
-            return Collections.unmodifiableList(new ArrayList<>(events));
-        }
-    }
-
-    @Override
-    public int getEventHistorySize() {
-        return eventHistorySize;
-    }
-
-    @Override
-    public Event getMostRecentEvent(final String eventSource) {
-        final Queue<Event> events = eventsMap.get(eventSource);
-        if (events == null) {
-            return null;
-        } else {
-            return events.peek();
-        }
-    }
-
-    @Override
-    public void clearEventHistory(final String eventSource) {
-        eventsMap.remove(eventSource);
-    }
-
-    private Comparator createEventComparator() {
-        return new Comparator<Event>() {
-            @Override
-            public int compare(final Event o1, final Event o2) {
-                // orders events by most recent first
-                return (int) (o2.getTimestamp() - o1.getTimestamp());
-            }
-        };
-    }
-
-    private void removeOldestEvent(final Collection<Event> events) {
-
-        if (events.isEmpty()) {
-            return;
-        }
-
-        Event oldestEvent = null;
-        for (final Event event : events) {
-            if (oldestEvent == null || oldestEvent.getTimestamp() > event.getTimestamp()) {
-                oldestEvent = event;
-            }
-        }
-
-        events.remove(oldestEvent);
-
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/firewall/ClusterNodeFirewall.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/firewall/ClusterNodeFirewall.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/firewall/ClusterNodeFirewall.java
deleted file mode 100644
index 2e3d278..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/firewall/ClusterNodeFirewall.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * 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.nifi.cluster.firewall;
-
-/**
- * Defines the interface for restricting external client connections to a set of
- * hosts or IPs.
- */
-public interface ClusterNodeFirewall {
-
-    /**
-     * Returns true if the given host or IP is permissible through the firewall;
-     * false otherwise.
-     *
-     * If an IP is given, then it must be formatted in dotted decimal notation.
-     * @param hostOrIp
-     * @return 
-     */
-    boolean isPermissible(String hostOrIp);
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/firewall/impl/FileBasedClusterNodeFirewall.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/firewall/impl/FileBasedClusterNodeFirewall.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/firewall/impl/FileBasedClusterNodeFirewall.java
deleted file mode 100644
index 916ec14..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/firewall/impl/FileBasedClusterNodeFirewall.java
+++ /dev/null
@@ -1,207 +0,0 @@
-/*
- * 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.nifi.cluster.firewall.impl;
-
-import java.io.*;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.util.*;
-import org.apache.commons.net.util.SubnetUtils;
-import org.apache.nifi.cluster.firewall.ClusterNodeFirewall;
-import org.apache.nifi.util.file.FileUtils;
-import org.apache.nifi.logging.NiFiLog;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * A file-based implementation of the ClusterFirewall interface. The class is
- * configured with a file. If the file is empty, then everything is permissible.
- * Otherwise, the file should contain hostnames or IPs formatted as dotted
- * decimals with an optional CIDR suffix. Each entry must be separated by a
- * newline. An example configuration is given below:
- *
- * <code>
- * # hash character is a comment delimiter
- * 1.2.3.4         # exact IP
- * some.host.name  # a host name
- * 4.5.6.7/8       # range of CIDR IPs
- * 9.10.11.12/13   # a smaller range of CIDR IPs
- * </code>
- *
- * This class allows for synchronization with an optionally configured restore
- * directory. If configured, then at startup, if the either the config file or
- * the restore directory's copy is missing, then the configuration file will be
- * copied to the appropriate location. If both restore directory contains a copy
- * that is different in content to configuration file, then an exception is
- * thrown at construction time.
- */
-public class FileBasedClusterNodeFirewall implements ClusterNodeFirewall {
-
-    private final File config;
-
-    private final File restoreDirectory;
-
-    private final Collection<SubnetUtils.SubnetInfo> subnetInfos = new ArrayList<>();
-
-    private static final Logger logger = new NiFiLog(LoggerFactory.getLogger(FileBasedClusterNodeFirewall.class));
-
-    public FileBasedClusterNodeFirewall(final File config) throws IOException {
-        this(config, null);
-    }
-
-    public FileBasedClusterNodeFirewall(final File config, final File restoreDirectory) throws IOException {
-
-        if (config == null) {
-            throw new IllegalArgumentException("Firewall configuration file may not be null.");
-        }
-
-        this.config = config;
-        this.restoreDirectory = restoreDirectory;
-
-        if (restoreDirectory != null) {
-            // synchronize with restore directory
-            try {
-                syncWithRestoreDirectory();
-            } catch (final IOException ioe) {
-                throw new RuntimeException(ioe);
-            }
-        }
-
-        if (!config.exists() && !config.createNewFile()) {
-            throw new IOException("Firewall configuration file did not exist and could not be created: " + config.getAbsolutePath());
-        }
-
-        logger.info("Loading cluster firewall configuration.");
-        parseConfig(config);
-        logger.info("Cluster firewall configuration loaded.");
-    }
-
-    @Override
-    public boolean isPermissible(final String hostOrIp) {
-        try {
-
-            // if no rules, then permit everything
-            if (subnetInfos.isEmpty()) {
-                return true;
-            }
-
-            final String ip;
-            try {
-                ip = InetAddress.getByName(hostOrIp).getHostAddress();
-            } catch (final UnknownHostException uhe) {
-                logger.warn("Blocking unknown host: " + hostOrIp, uhe);
-                return false;
-            }
-
-            // check each subnet to see if IP is in range
-            for (final SubnetUtils.SubnetInfo subnetInfo : subnetInfos) {
-                if (subnetInfo.isInRange(ip)) {
-                    return true;
-                }
-            }
-
-            // no match
-            return false;
-
-        } catch (final IllegalArgumentException iae) {
-            return false;
-        }
-    }
-
-    private void syncWithRestoreDirectory() throws IOException {
-
-        // sanity check that restore directory is a directory, creating it if necessary
-        FileUtils.ensureDirectoryExistAndCanAccess(restoreDirectory);
-
-        // check that restore directory is not the same as the primary directory
-        if (config.getParentFile().getAbsolutePath().equals(restoreDirectory.getAbsolutePath())) {
-            throw new IllegalStateException(
-                    String.format("Cluster firewall configuration file '%s' cannot be in the restore directory '%s' ",
-                            config.getAbsolutePath(), restoreDirectory.getAbsolutePath()));
-        }
-
-        // the restore copy will have same file name, but reside in a different directory
-        final File restoreFile = new File(restoreDirectory, config.getName());
-
-        // sync the primary copy with the restore copy
-        FileUtils.syncWithRestore(config, restoreFile, logger);
-
-    }
-
-    private void parseConfig(final File config) throws IOException {
-
-        // clear old information
-        subnetInfos.clear();
-        try (BufferedReader br = new BufferedReader(new FileReader(config))) {
-
-            String ipOrHostLine;
-            String ipCidr;
-            int totalIpsAdded = 0;
-            while ((ipOrHostLine = br.readLine()) != null) {
-
-                // cleanup whitespace
-                ipOrHostLine = ipOrHostLine.trim();
-
-                if (ipOrHostLine.isEmpty() || ipOrHostLine.startsWith("#")) {
-                    // skip empty lines or comments
-                    continue;
-                } else if (ipOrHostLine.contains("#")) {
-                    // parse out comments in IP containing lines
-                    ipOrHostLine = ipOrHostLine.substring(0, ipOrHostLine.indexOf("#")).trim();
-                }
-
-                // if given a complete IP, then covert to CIDR
-                if (ipOrHostLine.contains("/")) {
-                    ipCidr = ipOrHostLine;
-                } else if (ipOrHostLine.contains("\\")) {
-                    logger.warn("CIDR IP notation uses forward slashes '/'.  Replacing backslash '\\' with forward slash'/' for '" + ipOrHostLine + "'");
-                    ipCidr = ipOrHostLine.replace("\\", "/");
-                } else {
-                    try {
-                        ipCidr = InetAddress.getByName(ipOrHostLine).getHostAddress();
-                        if (!ipOrHostLine.equals(ipCidr)) {
-                            logger.debug(String.format("Resolved host '%s' to ip '%s'", ipOrHostLine, ipCidr));
-                        }
-                        ipCidr += "/32";
-                        logger.debug("Adding CIDR to exact IP: " + ipCidr);
-                    } catch (final UnknownHostException uhe) {
-                        logger.warn("Firewall is skipping unknown host address: " + ipOrHostLine);
-                        continue;
-                    }
-                }
-
-                try {
-                    logger.debug("Adding CIDR IP to firewall: " + ipCidr);
-                    final SubnetUtils subnetUtils = new SubnetUtils(ipCidr);
-                    subnetUtils.setInclusiveHostCount(true);
-                    subnetInfos.add(subnetUtils.getInfo());
-                    totalIpsAdded++;
-                } catch (final IllegalArgumentException iae) {
-                    logger.warn("Firewall is skipping invalid CIDR address: " + ipOrHostLine);
-                }
-
-            }
-
-            if (totalIpsAdded == 0) {
-                logger.info("No IPs added to firewall.  Firewall will accept all requests.");
-            } else {
-                logger.info(String.format("Added %d IP(s) to firewall.  Only requests originating from the configured IPs will be accepted.", totalIpsAdded));
-            }
-
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/flow/ClusterDataFlow.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/flow/ClusterDataFlow.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/flow/ClusterDataFlow.java
deleted file mode 100644
index eedb88f..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/flow/ClusterDataFlow.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * 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.nifi.cluster.flow;
-
-import org.apache.nifi.cluster.protocol.NodeIdentifier;
-import org.apache.nifi.cluster.protocol.StandardDataFlow;
-
-/**
- * A dataflow with additional information about the cluster.
- *
- * @author unattributed
- */
-public class ClusterDataFlow {
-
-    private final StandardDataFlow dataFlow;
-
-    private final NodeIdentifier primaryNodeId;
-
-    public ClusterDataFlow(final StandardDataFlow dataFlow, final NodeIdentifier primaryNodeId) {
-        this.dataFlow = dataFlow;
-        this.primaryNodeId = primaryNodeId;
-    }
-
-    public NodeIdentifier getPrimaryNodeId() {
-        return primaryNodeId;
-    }
-
-    public StandardDataFlow getDataFlow() {
-        return dataFlow;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/flow/DaoException.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/flow/DaoException.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/flow/DaoException.java
deleted file mode 100644
index 6ff15a7..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/flow/DaoException.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * 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.nifi.cluster.flow;
-
-/**
- * A base exception for data access exceptions.
- *
- * @author unattributed
- */
-public class DaoException extends RuntimeException {
-
-    public DaoException() {
-    }
-
-    public DaoException(String msg) {
-        super(msg);
-    }
-
-    public DaoException(Throwable cause) {
-        super(cause);
-    }
-
-    public DaoException(String msg, Throwable cause) {
-        super(msg, cause);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/flow/DataFlowDao.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/flow/DataFlowDao.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/flow/DataFlowDao.java
deleted file mode 100644
index a273704..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/flow/DataFlowDao.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * 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.nifi.cluster.flow;
-
-/**
- * A data access object for loading and saving the flow managed by the cluster.
- *
- * @author unattributed
- */
-public interface DataFlowDao {
-
-    /**
-     * Loads the cluster's dataflow.
-     *
-     * @return the dataflow or null if no dataflow exists
-     *
-     * @throws DaoException if the dataflow was unable to be loaded
-     */
-    ClusterDataFlow loadDataFlow() throws DaoException;
-
-    /**
-     * Saves the cluster's dataflow.
-     *
-     *
-     * @param dataFlow
-     * @throws DaoException if the dataflow was unable to be saved
-     */
-    void saveDataFlow(ClusterDataFlow dataFlow) throws DaoException;
-
-    /**
-     * Sets the state of the dataflow. If the dataflow does not exist, then an
-     * exception is thrown.
-     *
-     * @param flowState the state of the dataflow
-     *
-     * @throws DaoException if the state was unable to be updated
-     */
-    void setPersistedFlowState(PersistedFlowState flowState) throws DaoException;
-
-    /**
-     * Gets the state of the dataflow.
-     *
-     * @return the state of the dataflow
-     *
-     * @throws DaoException if the state was unable to be retrieved
-     */
-    PersistedFlowState getPersistedFlowState() throws DaoException;
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/flow/DataFlowManagementService.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/flow/DataFlowManagementService.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/flow/DataFlowManagementService.java
deleted file mode 100644
index 339d904..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/flow/DataFlowManagementService.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * 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.nifi.cluster.flow;
-
-import java.util.Set;
-import org.apache.nifi.cluster.protocol.NodeIdentifier;
-
-/**
- * A service for managing the cluster's flow. The service will attempt to keep
- * the cluster's dataflow current while respecting the value of the configured
- * retrieval delay.
- *
- * The eligible retrieval time is reset with the configured delay every time the
- * flow state is set to STALE. If the state is set to UNKNOWN or CURRENT, then
- * the flow will not be retrieved.
- *
- * Clients must call start() and stop() to initialize and stop the instance.
- *
- * @author unattributed
- */
-public interface DataFlowManagementService {
-
-    /**
-     * Starts the instance. Start may only be called if the instance is not
-     * running.
-     */
-    void start();
-
-    /**
-     * Stops the instance. Stop may only be called if the instance is running.
-     */
-    void stop();
-
-    /**
-     * @return true if the instance is started; false otherwise.
-     */
-    boolean isRunning();
-
-    /**
-     * Loads the dataflow.
-     *
-     * @return the dataflow or null if no dataflow exists
-     */
-    ClusterDataFlow loadDataFlow();
-
-    /**
-     * Updates the dataflow with the given primary node identifier.
-     *
-     * @param nodeId the node identifier
-     *
-     * @throws DaoException if the update failed
-     */
-    void updatePrimaryNode(NodeIdentifier nodeId) throws DaoException;
-
-    /**
-     * Sets the state of the flow.
-     *
-     * @param flowState the state
-     *
-     * @see PersistedFlowState
-     */
-    void setPersistedFlowState(PersistedFlowState flowState);
-
-    /**
-     * @return the state of the flow
-     */
-    PersistedFlowState getPersistedFlowState();
-
-    /**
-     * @return true if the flow is current; false otherwise.
-     */
-    boolean isFlowCurrent();
-
-    /**
-     * Sets the node identifiers to use when attempting to retrieve the flow.
-     *
-     * @param nodeIds the node identifiers
-     */
-    void setNodeIds(Set<NodeIdentifier> nodeIds);
-
-    /**
-     * Returns the set of node identifiers the service is using to retrieve the
-     * flow.
-     *
-     * @return the set of node identifiers the service is using to retrieve the
-     * flow.
-     */
-    Set<NodeIdentifier> getNodeIds();
-
-    /**
-     * @return the retrieval delay in seconds
-     */
-    int getRetrievalDelaySeconds();
-
-    /**
-     * Sets the retrieval delay.
-     *
-     * @param delay the retrieval delay in seconds
-     */
-    void setRetrievalDelay(String delay);
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/flow/PersistedFlowState.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/flow/PersistedFlowState.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/flow/PersistedFlowState.java
deleted file mode 100644
index b3afc6e..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/flow/PersistedFlowState.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * 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.nifi.cluster.flow;
-
-/**
- * Represents the various state of a flow managed by the cluster.
- *
- * The semantics of the values are:
- * <ul>
- * <li> CURRENT - the flow is current </li>
- * <li> STALE - the flow is not current, but is eligible to be updated. </li>
- * <li> UNKNOWN - the flow is not current and is not eligible to be updated.
- * </li>
- * </ul>
- *
- * @author unattributed
- */
-public enum PersistedFlowState {
-
-    CURRENT,
-    STALE,
-    UNKNOWN
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/flow/StaleFlowException.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/flow/StaleFlowException.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/flow/StaleFlowException.java
deleted file mode 100644
index ce5a08b..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/flow/StaleFlowException.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * 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.nifi.cluster.flow;
-
-/**
- * Represents the exceptional case when a caller is requesting the current flow,
- * but a current flow is not available.
- *
- * @author unattributed
- */
-public class StaleFlowException extends RuntimeException {
-
-    public StaleFlowException(String message, Throwable cause) {
-        super(message, cause);
-    }
-
-    public StaleFlowException(String message) {
-        super(message);
-    }
-
-    public StaleFlowException(Throwable cause) {
-        super(cause);
-    }
-
-    public StaleFlowException() {
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/flow/impl/DataFlowDaoImpl.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/flow/impl/DataFlowDaoImpl.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/flow/impl/DataFlowDaoImpl.java
deleted file mode 100644
index 72b594a..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/flow/impl/DataFlowDaoImpl.java
+++ /dev/null
@@ -1,600 +0,0 @@
-/*
- * 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.nifi.cluster.flow.impl;
-
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.FilenameFilter;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-import java.util.Arrays;
-import java.util.UUID;
-
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Marshaller;
-import javax.xml.bind.Unmarshaller;
-import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-
-import org.apache.commons.compress.archivers.ArchiveEntry;
-import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
-import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
-import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream;
-import org.apache.nifi.cluster.flow.ClusterDataFlow;
-import org.apache.nifi.cluster.flow.DaoException;
-import org.apache.nifi.cluster.flow.DataFlowDao;
-import org.apache.nifi.cluster.flow.PersistedFlowState;
-import org.apache.nifi.cluster.protocol.DataFlow;
-import org.apache.nifi.cluster.protocol.NodeIdentifier;
-import org.apache.nifi.cluster.protocol.StandardDataFlow;
-import org.apache.nifi.cluster.protocol.jaxb.message.NodeIdentifierAdapter;
-import org.apache.nifi.logging.NiFiLog;
-import org.apache.nifi.stream.io.BufferedInputStream;
-import org.apache.nifi.stream.io.BufferedOutputStream;
-import org.apache.nifi.stream.io.ByteArrayInputStream;
-import org.apache.nifi.stream.io.StreamUtils;
-import org.apache.nifi.util.file.FileUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-/**
- * Implements the FlowDao interface. The implementation tracks the state of the
- * dataflow by annotating the filename of the flow state file. Specifically, the
- * implementation correlates PersistedFlowState states to filename extensions.
- * The correlation is as follows:
- * <ul>
- * <li> CURRENT maps to flow.xml </li>
- * <li> STALE maps to flow.xml.stale </li>
- * <li> UNKNOWN maps to flow.xml.unknown </li>
- * </ul>
- * Whenever the flow state changes, the flow state file's name is updated to
- * denote its state.
- *
- * The implementation also provides for a restore directory that may be
- * configured for higher availability. At instance creation, if the primary or
- * restore directories have multiple flow state files, an exception is thrown.
- * If the primary directory has a current flow state file, but the restore
- * directory does not, then the primary flow state file is copied to the restore
- * directory. If the restore directory has a current flow state file, but the
- * primary directory does not, then the restore flow state file is copied to the
- * primary directory. If both the primary and restore directories have a current
- * flow state file and the files are different, then an exception is thrown.
- *
- * When the flow state file is saved, it is always saved first to the restore
- * directory followed by a save to the primary directory. When the flow state
- * file is loaded, a check is made to verify that the primary and restore flow
- * state files are both current. If either is not current, then an exception is
- * thrown. The primary flow state file is always read when the load method is
- * called.
- *
- * @author unattributed
- */
-public class DataFlowDaoImpl implements DataFlowDao {
-
-    private final File primaryDirectory;
-    private final File restoreDirectory;
-    private final boolean autoStart;
-    private final String generatedRootGroupId = UUID.randomUUID().toString();
-
-    public static final String STALE_EXT = ".stale";
-    public static final String UNKNOWN_EXT = ".unknown";
-    public static final String FLOW_PACKAGE = "flow.tar";
-    public static final String FLOW_XML_FILENAME = "flow.xml";
-    public static final String TEMPLATES_FILENAME = "templates.xml";
-    public static final String SNIPPETS_FILENAME = "snippets.xml";
-    public static final String CLUSTER_INFO_FILENAME = "cluster-info.xml";
-
-    private static final Logger logger = new NiFiLog(LoggerFactory.getLogger(DataFlowDaoImpl.class));
-
-    public DataFlowDaoImpl(final File primaryDirectory) throws DaoException {
-        this(primaryDirectory, null, false);
-    }
-
-    public DataFlowDaoImpl(final File primaryDirectory, final File restoreDirectory, final boolean autoStart) throws DaoException {
-
-        // sanity check that primary directory is a directory, creating it if necessary
-        if (primaryDirectory == null) {
-            throw new IllegalArgumentException("Primary directory may not be null.");
-        } else if (!primaryDirectory.exists()) {
-            if (!primaryDirectory.mkdir()) {
-                throw new DaoException(String.format("Failed to create primary directory '%s'", primaryDirectory.getAbsolutePath()));
-            }
-        } else if (!primaryDirectory.isDirectory()) {
-            throw new IllegalArgumentException("Primary directory must be a directory.");
-        }
-
-        this.autoStart = autoStart;
-
-        try {
-            this.primaryDirectory = primaryDirectory;
-            this.restoreDirectory = restoreDirectory;
-
-            if (restoreDirectory == null) {
-                // check that we have exactly one current flow state file
-                ensureSingleCurrentStateFile(primaryDirectory);
-            } else {
-
-                // check that restore directory is a directory, creating it if necessary
-                FileUtils.ensureDirectoryExistAndCanAccess(restoreDirectory);
-
-                // check that restore directory is not the same as the primary directory
-                if (primaryDirectory.getAbsolutePath().equals(restoreDirectory.getAbsolutePath())) {
-                    throw new IllegalArgumentException(String.format("Primary directory '%s' is the same as restore directory '%s' ",
-                            primaryDirectory.getAbsolutePath(), restoreDirectory.getAbsolutePath()));
-                }
-
-                final File[] primaryFlowStateFiles = getFlowStateFiles(primaryDirectory);
-                final File[] restoreFlowStateFiles = getFlowStateFiles(restoreDirectory);
-
-                // if more than one state file in either primary or restore, then throw exception
-                if (primaryFlowStateFiles.length > 1) {
-                    throw new IllegalStateException(String.format("Found multiple dataflow state files in primary directory '%s'", primaryDirectory));
-                } else if (restoreFlowStateFiles.length > 1) {
-                    throw new IllegalStateException(String.format("Found multiple dataflow state files in restore directory '%s'", restoreDirectory));
-                }
-
-                // check that the single primary state file we found is current or create a new one
-                final File primaryFlowStateFile = ensureSingleCurrentStateFile(primaryDirectory);
-
-                // check that the single restore state file we found is current or create a new one
-                final File restoreFlowStateFile = ensureSingleCurrentStateFile(restoreDirectory);
-
-                // if there was a difference in flow state file directories, then copy the appropriate files
-                if (restoreFlowStateFiles.length == 0 && primaryFlowStateFiles.length != 0) {
-                    // copy primary state file to restore
-                    FileUtils.copyFile(primaryFlowStateFile, restoreFlowStateFile, false, false, logger);
-                } else if (primaryFlowStateFiles.length == 0 && restoreFlowStateFiles.length != 0) {
-                    // copy restore state file to primary
-                    FileUtils.copyFile(restoreFlowStateFile, primaryFlowStateFile, false, false, logger);
-                } else {
-                    // sync the primary copy with the restore copy
-                    syncWithRestore(primaryFlowStateFile, restoreFlowStateFile);
-                }
-
-            }
-        } catch (final IOException | IllegalArgumentException | IllegalStateException | JAXBException ex) {
-            throw new DaoException(ex);
-        }
-    }
-    
-    
-    private void syncWithRestore(final File primaryFile, final File restoreFile) throws IOException {
-        try (final FileInputStream primaryFis = new FileInputStream(primaryFile);
-             final TarArchiveInputStream primaryIn = new TarArchiveInputStream(primaryFis);
-             final FileInputStream restoreFis = new FileInputStream(restoreFile);
-             final TarArchiveInputStream restoreIn = new TarArchiveInputStream(restoreFis)) {
-            
-            final ArchiveEntry primaryEntry = primaryIn.getNextEntry();
-            final ArchiveEntry restoreEntry = restoreIn.getNextEntry();
-
-            if ( primaryEntry == null && restoreEntry == null ) {
-                return;
-            }
-
-            if ( (primaryEntry == null && restoreEntry != null) || (primaryEntry != null && restoreEntry == null) ) {
-                throw new IllegalStateException(String.format("Primary file '%s' is different than restore file '%s'",
-                        primaryFile.getAbsoluteFile(), restoreFile.getAbsolutePath()));
-            }
-            
-            final byte[] primaryMd5 = calculateMd5(primaryIn);
-            final byte[] restoreMd5 = calculateMd5(restoreIn);
-            
-            if ( !Arrays.equals(primaryMd5, restoreMd5) ) {
-                throw new IllegalStateException(String.format("Primary file '%s' is different than restore file '%s'",
-                        primaryFile.getAbsoluteFile(), restoreFile.getAbsolutePath()));
-            }
-        }
-    }
-    
-    private byte[] calculateMd5(final InputStream in) throws IOException {
-        final MessageDigest digest;
-        try {
-            digest = MessageDigest.getInstance("MD5");
-        } catch (final NoSuchAlgorithmException nsae) {
-            throw new IOException(nsae);
-        }
-        
-        int len;
-        final byte[] buffer = new byte[8192];
-        while ((len = in.read(buffer)) > -1) {
-            if (len > 0) {
-                digest.update(buffer, 0, len);
-            }
-        }
-        return digest.digest();
-    }
-
-    @Override
-    public ClusterDataFlow loadDataFlow() throws DaoException {
-        try {
-            return parseDataFlow(getExistingFlowStateFile(primaryDirectory));
-        } catch (final IOException | JAXBException ex) {
-            throw new DaoException(ex);
-        }
-    }
-
-    @Override
-    public void saveDataFlow(final ClusterDataFlow dataFlow) throws DaoException {
-        try {
-
-            final File primaryStateFile = getFlowStateFile(primaryDirectory);
-
-            // write to restore before writing to primary in case primary experiences problems
-            if (restoreDirectory != null) {
-                final File restoreStateFile = getFlowStateFile(restoreDirectory);
-                if (restoreStateFile == null) {
-                    if (primaryStateFile == null) {
-                        writeDataFlow(createNewFlowStateFile(restoreDirectory), dataFlow);
-                    } else {
-                        throw new DaoException(String.format("Unable to save dataflow because dataflow state file in primary directory '%s' exists, but it does not exist in the restore directory '%s'",
-                                primaryDirectory.getAbsolutePath(), restoreDirectory.getAbsolutePath()));
-                    }
-                } else {
-                    if (primaryStateFile == null) {
-                        throw new DaoException(String.format("Unable to save dataflow because dataflow state file in restore directory '%s' exists, but it does not exist in the primary directory '%s'",
-                                restoreDirectory.getAbsolutePath(), primaryDirectory.getAbsolutePath()));
-                    } else {
-                        final PersistedFlowState primaryFlowState = getPersistedFlowState(primaryStateFile);
-                        final PersistedFlowState restoreFlowState = getPersistedFlowState(restoreStateFile);
-                        if (primaryFlowState == restoreFlowState) {
-                            writeDataFlow(restoreStateFile, dataFlow);
-                        } else {
-                            throw new DaoException(String.format("Unable to save dataflow because state file in primary directory '%s' has state '%s', but the state file in the restore directory '%s' has state '%s'",
-                                    primaryDirectory.getAbsolutePath(), primaryFlowState, restoreDirectory.getAbsolutePath(), restoreFlowState));
-                        }
-                    }
-                }
-            }
-
-            // write dataflow to primary 
-            if (primaryStateFile == null) {
-                writeDataFlow(createNewFlowStateFile(primaryDirectory), dataFlow);
-            } else {
-                writeDataFlow(primaryStateFile, dataFlow);
-            }
-
-        } catch (final IOException | JAXBException ex) {
-            throw new DaoException(ex);
-        }
-    }
-
-    @Override
-    public PersistedFlowState getPersistedFlowState() {
-        // trust restore over primary if configured for restore
-        if (restoreDirectory == null) {
-            return getPersistedFlowState(getExistingFlowStateFile(primaryDirectory));
-        } else {
-            return getPersistedFlowState(getExistingFlowStateFile(restoreDirectory));
-        }
-    }
-
-    @Override
-    public void setPersistedFlowState(final PersistedFlowState flowState) throws DaoException {
-        // rename restore before primary if configured for restore
-        if (restoreDirectory != null) {
-            renameFlowStateFile(getExistingFlowStateFile(restoreDirectory), flowState);
-        }
-        renameFlowStateFile(getExistingFlowStateFile(primaryDirectory), flowState);
-    }
-
-    private File ensureSingleCurrentStateFile(final File dir) throws IOException, JAXBException {
-
-        // ensure that we have at most one state file and if we have one, it is current
-        final File[] directoryFlowStateFiles = getFlowStateFiles(dir);
-        if (directoryFlowStateFiles.length > 1) {
-            throw new DaoException(String.format("Found multiple dataflow state files in directory '%s'", dir));
-        } else if (directoryFlowStateFiles.length == 0) {
-            // create a new file if none exist
-            return createNewFlowStateFile(dir);
-        } else {
-            // check that the single flow state file is current
-            final PersistedFlowState flowState = getPersistedFlowState(directoryFlowStateFiles[0]);
-            if (PersistedFlowState.CURRENT == flowState) {
-                return directoryFlowStateFiles[0];
-            } else {
-                throw new DaoException(String.format("Dataflow state file '%s' must be current.", directoryFlowStateFiles[0].getAbsolutePath()));
-            }
-        }
-
-    }
-
-    private PersistedFlowState getPersistedFlowState(final File file) {
-        final String path = file.getAbsolutePath();
-        if (path.endsWith(STALE_EXT)) {
-            return PersistedFlowState.STALE;
-        } else if (path.endsWith(UNKNOWN_EXT)) {
-            return PersistedFlowState.UNKNOWN;
-        } else {
-            return PersistedFlowState.CURRENT;
-        }
-    }
-
-    private File getFlowStateFile(final File dir) {
-        final File[] files = getFlowStateFiles(dir);
-        if (files.length > 1) {
-            throw new IllegalStateException(String.format("Expected at most one dataflow state file, but found %s files.", files.length));
-        } else if (files.length == 0) {
-            return null;
-        } else {
-            return files[0];
-        }
-    }
-
-    private File getExistingFlowStateFile(final File dir) {
-        final File file = getFlowStateFile(dir);
-        if (file == null) {
-            throw new IllegalStateException(String.format("Expected a dataflow state file, but none existed in directory '%s'", dir.getAbsolutePath()));
-        }
-        return file;
-    }
-
-    private File[] getFlowStateFiles(final File dir) {
-        final File[] files = dir.listFiles(new FilenameFilter() {
-            @Override
-            public boolean accept(File dir, String name) {
-                return (name.equals(FLOW_PACKAGE) || name.endsWith(STALE_EXT) || name.endsWith(UNKNOWN_EXT));
-            }
-        });
-
-        if (files == null) {
-            return new File[0];
-        } else {
-            return files;
-        }
-    }
-
-    private File removeStateFileExtension(final File file) {
-
-        final String path = file.getAbsolutePath();
-        final int stateFileExtIndex;
-        if (path.endsWith(STALE_EXT)) {
-            stateFileExtIndex = path.lastIndexOf(STALE_EXT);
-        } else if (path.endsWith(UNKNOWN_EXT)) {
-            stateFileExtIndex = path.lastIndexOf(UNKNOWN_EXT);
-        } else {
-            stateFileExtIndex = path.length();
-        }
-
-        return new File(path.substring(0, stateFileExtIndex));
-    }
-
-    private File addStateFileExtension(final File file, final PersistedFlowState state) {
-        switch (state) {
-            case CURRENT: {
-                return file;
-            }
-            case STALE: {
-                return new File(file.getAbsolutePath() + STALE_EXT);
-            }
-            case UNKNOWN: {
-                return new File(file.getAbsolutePath() + UNKNOWN_EXT);
-            }
-            default: {
-                throw new RuntimeException("Unsupported PersistedFlowState Enum value: " + state);
-            }
-        }
-    }
-
-    private File createNewFlowStateFile(final File dir) throws IOException, JAXBException {
-        final File stateFile = new File(dir, FLOW_PACKAGE);
-        stateFile.createNewFile();
-
-        final byte[] flowBytes = getEmptyFlowBytes();
-        final byte[] templateBytes = new byte[0];
-        final byte[] snippetBytes = new byte[0];
-        final DataFlow dataFlow = new StandardDataFlow(flowBytes, templateBytes, snippetBytes);
-
-        final ClusterMetadata clusterMetadata = new ClusterMetadata();
-        writeDataFlow(stateFile, dataFlow, clusterMetadata);
-
-        return stateFile;
-    }
-
-    private byte[] getEmptyFlowBytes() throws IOException {
-        try {
-            final DocumentBuilder docBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
-            final Document document = docBuilder.newDocument();
-
-            final Element controller = document.createElement("flowController");
-            document.appendChild(controller);
-
-            controller.appendChild(createTextElement(document, "maxThreadCount", "15"));
-
-            final Element rootGroup = document.createElement("rootGroup");
-            rootGroup.appendChild(createTextElement(document, "id", generatedRootGroupId));
-            rootGroup.appendChild(createTextElement(document, "name", "NiFi Flow"));
-
-            // create the position element
-            final Element positionElement = createTextElement(document, "position", "");
-            positionElement.setAttribute("x", "0.0");
-            positionElement.setAttribute("y", "0.0");
-            rootGroup.appendChild(positionElement);
-
-            rootGroup.appendChild(createTextElement(document, "comment", ""));
-            controller.appendChild(rootGroup);
-
-            final Transformer transformer = TransformerFactory.newInstance().newTransformer();
-            transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
-            transformer.setOutputProperty(OutputKeys.INDENT, "yes");
-
-            final DOMSource source = new DOMSource(document);
-            final ByteArrayOutputStream baos = new ByteArrayOutputStream();
-            final StreamResult result = new StreamResult(baos);
-            transformer.transform(source, result);
-
-            return baos.toByteArray();
-        } catch (final Exception e) {
-            throw new IOException(e);
-        }
-    }
-
-    private Element createTextElement(final Document document, final String elementName, final String value) {
-        final Element element = document.createElement(elementName);
-        element.setTextContent(value);
-        return element;
-    }
-
-    private void renameFlowStateFile(final File flowStateFile, final PersistedFlowState newState) throws DaoException {
-        final PersistedFlowState existingState = getPersistedFlowState(flowStateFile);
-        if (existingState != newState) {
-            final File newFlowStateFile = addStateFileExtension(removeStateFileExtension(flowStateFile), newState);
-            if (flowStateFile.renameTo(newFlowStateFile) == false) {
-                throw new DaoException(
-                        String.format("Failed to rename flow state file '%s' to new name '%s'", flowStateFile.getAbsolutePath(), newFlowStateFile.getAbsolutePath()));
-            }
-        }
-    }
-
-    private ClusterDataFlow parseDataFlow(final File file) throws IOException, JAXBException, DaoException {
-        byte[] flowBytes = new byte[0];
-        byte[] templateBytes = new byte[0];
-        byte[] snippetBytes = new byte[0];
-        byte[] clusterInfoBytes = new byte[0];
-
-        try (final InputStream inStream = new FileInputStream(file);
-                final TarArchiveInputStream tarIn = new TarArchiveInputStream(new BufferedInputStream(inStream))) {
-            TarArchiveEntry tarEntry;
-            while ((tarEntry = tarIn.getNextTarEntry()) != null) {
-                switch (tarEntry.getName()) {
-                    case FLOW_XML_FILENAME:
-                        flowBytes = new byte[(int) tarEntry.getSize()];
-                        StreamUtils.fillBuffer(tarIn, flowBytes, true);
-                        break;
-                    case TEMPLATES_FILENAME:
-                        templateBytes = new byte[(int) tarEntry.getSize()];
-                        StreamUtils.fillBuffer(tarIn, templateBytes, true);
-                        break;
-                    case SNIPPETS_FILENAME:
-                        snippetBytes = new byte[(int) tarEntry.getSize()];
-                        StreamUtils.fillBuffer(tarIn, snippetBytes, true);
-                        break;
-                    case CLUSTER_INFO_FILENAME:
-                        clusterInfoBytes = new byte[(int) tarEntry.getSize()];
-                        StreamUtils.fillBuffer(tarIn, clusterInfoBytes, true);
-                        break;
-                    default:
-                        throw new DaoException("Found Unexpected file in dataflow configuration: " + tarEntry.getName());
-                }
-            }
-        }
-
-        final ClusterMetadata clusterMetadata;
-        if (clusterInfoBytes.length == 0) {
-            clusterMetadata = null;
-        } else {
-            final Unmarshaller clusterMetadataUnmarshaller = ClusterMetadata.jaxbCtx.createUnmarshaller();
-            clusterMetadata = (ClusterMetadata) clusterMetadataUnmarshaller.unmarshal(new ByteArrayInputStream(clusterInfoBytes));
-        }
-
-        final StandardDataFlow dataFlow = new StandardDataFlow(flowBytes, templateBytes, snippetBytes);
-        dataFlow.setAutoStartProcessors(autoStart);
-
-        return new ClusterDataFlow(dataFlow, (clusterMetadata == null) ? null : clusterMetadata.getPrimaryNodeId());
-    }
-
-    private void writeDataFlow(final File file, final ClusterDataFlow clusterDataFlow) throws IOException, JAXBException {
-
-        // get the data flow
-        DataFlow dataFlow = clusterDataFlow.getDataFlow();
-
-        // if no dataflow, then write a new dataflow
-        if (dataFlow == null) {
-            dataFlow = new StandardDataFlow(new byte[0], new byte[0], new byte[0]);
-        }
-
-        // setup the cluster metadata
-        final ClusterMetadata clusterMetadata = new ClusterMetadata();
-        clusterMetadata.setPrimaryNodeId(clusterDataFlow.getPrimaryNodeId());
-
-        // write to disk
-        writeDataFlow(file, dataFlow, clusterMetadata);
-    }
-
-    private void writeTarEntry(final TarArchiveOutputStream tarOut, final String filename, final byte[] bytes) throws IOException {
-        final TarArchiveEntry flowEntry = new TarArchiveEntry(filename);
-        flowEntry.setSize(bytes.length);
-        tarOut.putArchiveEntry(flowEntry);
-        tarOut.write(bytes);
-        tarOut.closeArchiveEntry();
-    }
-
-    private void writeDataFlow(final File file, final DataFlow dataFlow, final ClusterMetadata clusterMetadata) throws IOException, JAXBException {
-
-        try (final OutputStream fos = new FileOutputStream(file);
-                final TarArchiveOutputStream tarOut = new TarArchiveOutputStream(new BufferedOutputStream(fos))) {
-
-            writeTarEntry(tarOut, FLOW_XML_FILENAME, dataFlow.getFlow());
-            writeTarEntry(tarOut, TEMPLATES_FILENAME, dataFlow.getTemplates());
-            writeTarEntry(tarOut, SNIPPETS_FILENAME, dataFlow.getSnippets());
-
-            final ByteArrayOutputStream baos = new ByteArrayOutputStream(256);
-            writeClusterMetadata(clusterMetadata, baos);
-            final byte[] clusterInfoBytes = baos.toByteArray();
-
-            writeTarEntry(tarOut, CLUSTER_INFO_FILENAME, clusterInfoBytes);
-        }
-    }
-
-    private void writeClusterMetadata(final ClusterMetadata clusterMetadata, final OutputStream os) throws IOException, JAXBException {
-        // write cluster metadata to output stream
-        final Marshaller marshaller = ClusterMetadata.jaxbCtx.createMarshaller();
-        marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
-        marshaller.setProperty(Marshaller.JAXB_FRAGMENT, true);
-        marshaller.setProperty(Marshaller.JAXB_ENCODING, "UTF-8");
-        marshaller.marshal(clusterMetadata, os);
-    }
-
-    @XmlRootElement(name = "clusterMetadata")
-    private static class ClusterMetadata {
-
-        private NodeIdentifier primaryNodeId;
-
-        private static final JAXBContext jaxbCtx;
-
-        static {
-            try {
-                jaxbCtx = JAXBContext.newInstance(ClusterMetadata.class);
-            } catch (final JAXBException je) {
-                throw new RuntimeException(je);
-            }
-        }
-
-        @XmlJavaTypeAdapter(NodeIdentifierAdapter.class)
-        public NodeIdentifier getPrimaryNodeId() {
-            return primaryNodeId;
-        }
-
-        public void setPrimaryNodeId(final NodeIdentifier primaryNodeId) {
-            this.primaryNodeId = primaryNodeId;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/flow/impl/DataFlowManagementServiceImpl.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/flow/impl/DataFlowManagementServiceImpl.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/flow/impl/DataFlowManagementServiceImpl.java
deleted file mode 100644
index e135af3..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/flow/impl/DataFlowManagementServiceImpl.java
+++ /dev/null
@@ -1,356 +0,0 @@
-/*
- * 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.nifi.cluster.flow.impl;
-
-import java.util.Collections;
-import java.util.Date;
-import java.util.Set;
-import java.util.Timer;
-import java.util.TimerTask;
-import java.util.concurrent.CopyOnWriteArraySet;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.concurrent.atomic.AtomicLong;
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReentrantLock;
-
-import org.apache.nifi.cluster.flow.ClusterDataFlow;
-import org.apache.nifi.cluster.flow.DaoException;
-import org.apache.nifi.cluster.flow.DataFlowDao;
-import org.apache.nifi.cluster.flow.DataFlowManagementService;
-import org.apache.nifi.cluster.flow.PersistedFlowState;
-import org.apache.nifi.cluster.protocol.ClusterManagerProtocolSender;
-import org.apache.nifi.cluster.protocol.NodeIdentifier;
-import org.apache.nifi.cluster.protocol.StandardDataFlow;
-import org.apache.nifi.cluster.protocol.message.FlowRequestMessage;
-import org.apache.nifi.cluster.protocol.message.FlowResponseMessage;
-import org.apache.nifi.logging.NiFiLog;
-import org.apache.nifi.util.FormatUtils;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Implements FlowManagementService interface. The service tries to keep the
- * cluster's flow current with regards to the available nodes.
- *
- * The instance may be configured with a retrieval delay, which will reduce the
- * number of retrievals performed by the service at the expense of increasing
- * the chances that the service will not be able to provide a current flow to
- * the caller.
- *
- * By default, the service will try to update the flow as quickly as possible.
- * Configuring a delay enables a less aggressive retrieval strategy.
- * Specifically, the eligible retrieval time is reset every time the flow state
- * is set to STALE. If the state is set to UNKNOWN or CURRENT, then the flow
- * will not be retrieved.
- *
- * @author unattributed
- */
-public class DataFlowManagementServiceImpl implements DataFlowManagementService {
-
-    /*
-     * Developer Note: 
-     * 
-     * This class maintains an ExecutorService and a Runnable.
-     * Although the class is not externally threadsafe, its internals are protected to
-     * accommodate multithread access between the ExecutorServer and the Runnable.
-     * 
-     */
-    private static final Logger logger = new NiFiLog(LoggerFactory.getLogger(DataFlowManagementServiceImpl.class));
-
-    private final DataFlowDao flowDao;
-
-    private final ClusterManagerProtocolSender sender;
-
-    private final Set<NodeIdentifier> nodeIds = new CopyOnWriteArraySet<>();
-
-    private final AtomicBoolean stopRequested = new AtomicBoolean(false);
-
-    private final AtomicLong lastRetrievalTime = new AtomicLong(-1);
-
-    private Timer flowRetriever;
-
-    private long retrievableAfterTime = 0L;
-
-    private AtomicInteger retrievalDelaySeconds = new AtomicInteger(0);
-
-    private final TimingReentrantLock resourceLock = new TimingReentrantLock(new ReentrantLock());
-
-    public DataFlowManagementServiceImpl(final DataFlowDao flowDao, final ClusterManagerProtocolSender sender) {
-        if (flowDao == null) {
-            throw new IllegalArgumentException("Flow DAO may not be null.");
-        } else if (sender == null) {
-            throw new IllegalArgumentException("Cluster Manager Protocol Sender may not be null.");
-        }
-        this.flowDao = flowDao;
-        this.sender = sender;
-    }
-
-    @Override
-    public void start() {
-
-        if (isRunning()) {
-            throw new IllegalArgumentException("Instance is already running.");
-        }
-
-        // reset stop requested
-        stopRequested.set(false);
-
-        // setup flow retreiver timer
-        flowRetriever = new Timer("Flow Management Service", /* is daemon */ true);
-        flowRetriever.schedule(new FlowRetrieverTimerTask(), 0, 500);
-    }
-
-    @Override
-    public boolean isRunning() {
-        return (flowRetriever != null);
-    }
-
-    @Override
-    public void stop() {
-
-        if (isRunning() == false) {
-            throw new IllegalArgumentException("Instance is already stopped.");
-        }
-
-        // record stop request
-        stopRequested.set(true);
-
-        flowRetriever.cancel();
-        flowRetriever = null;
-
-    }
-
-    @Override
-    public ClusterDataFlow loadDataFlow() throws DaoException {
-        resourceLock.lock();
-        try {
-            return flowDao.loadDataFlow();
-        } finally {
-            resourceLock.unlock("loadDataFlow");
-        }
-    }
-
-    @Override
-    public void updatePrimaryNode(final NodeIdentifier nodeId) {
-        resourceLock.lock();
-        try {
-            final ClusterDataFlow existingClusterDataFlow = flowDao.loadDataFlow();
-
-            final StandardDataFlow dataFlow;
-            if (existingClusterDataFlow == null) {
-                dataFlow = null;
-            } else {
-                dataFlow = existingClusterDataFlow.getDataFlow();
-            }
-
-            flowDao.saveDataFlow(new ClusterDataFlow(dataFlow, nodeId));
-        } finally {
-            resourceLock.unlock("updatePrimaryNode");
-        }
-    }
-
-    @Override
-    public PersistedFlowState getPersistedFlowState() {
-        resourceLock.lock();
-        try {
-            return flowDao.getPersistedFlowState();
-        } finally {
-            resourceLock.unlock("getPersistedFlowState");
-        }
-    }
-
-    @Override
-    public boolean isFlowCurrent() {
-        return PersistedFlowState.CURRENT == getPersistedFlowState();
-    }
-
-    @Override
-    public void setPersistedFlowState(final PersistedFlowState flowState) {
-        // lock to ensure state change and retrievable time update are atomic
-        resourceLock.lock();
-        try {
-            flowDao.setPersistedFlowState(flowState);
-            if (PersistedFlowState.STALE == flowState) {
-                retrievableAfterTime = new Date().getTime() + (getRetrievalDelaySeconds() * 1000);
-            } else if (PersistedFlowState.UNKNOWN == flowState || PersistedFlowState.CURRENT == flowState) {
-                retrievableAfterTime = Long.MAX_VALUE;
-            }
-        } finally {
-            resourceLock.unlock("setPersistedFlowState");
-        }
-    }
-
-    @Override
-    public Set<NodeIdentifier> getNodeIds() {
-        return Collections.unmodifiableSet(nodeIds);
-    }
-
-    @Override
-    public void setNodeIds(final Set<NodeIdentifier> nodeIds) {
-
-        if (nodeIds == null) {
-            throw new IllegalArgumentException("Node IDs may not be null.");
-        }
-
-        resourceLock.lock();
-        try {
-
-            if (this.nodeIds.equals(nodeIds)) {
-                return;
-            }
-
-            this.nodeIds.clear();
-            this.nodeIds.addAll(nodeIds);
-
-        } finally {
-            resourceLock.unlock("setNodeIds");
-        }
-
-    }
-
-    @Override
-    public int getRetrievalDelaySeconds() {
-        return retrievalDelaySeconds.get();
-    }
-
-    @Override
-    public void setRetrievalDelay(final String retrievalDelay) {
-        this.retrievalDelaySeconds.set((int) FormatUtils.getTimeDuration(retrievalDelay, TimeUnit.SECONDS));
-    }
-
-    public ClusterManagerProtocolSender getSender() {
-        return sender;
-    }
-
-    public long getLastRetrievalTime() {
-        return lastRetrievalTime.get();
-    }
-
-    /**
-     * A timer task for issuing FlowRequestMessage messages to nodes to retrieve
-     * an updated flow.
-     */
-    private class FlowRetrieverTimerTask extends TimerTask {
-
-        @Override
-        public void run() {
-
-            resourceLock.lock();
-            try {
-                // if flow is current, then we're done
-                if (isFlowCurrent()) {
-                    return;
-                }
-            } catch (final Exception ex) {
-                logger.info("Encountered exception checking if flow is current caused by " + ex, ex);
-            } finally {
-                resourceLock.unlock("FlowRetrieverTimerTask - isFlowCurrent");
-            }
-
-            final FlowRequestMessage request = new FlowRequestMessage();
-            for (final NodeIdentifier nodeId : getNodeIds()) {
-                try {
-                    // setup request
-                    request.setNodeId(nodeId);
-
-                    // record request time
-                    final long requestSentTime = new Date().getTime();
-
-                    resourceLock.lock();
-                    try {
-                        // sanity checks before making request
-                        if (stopRequested.get()) {  // did we receive a stop request
-                            logger.debug("Stopping runnable prematurely because a request to stop was issued.");
-                            return;
-                        } else if (requestSentTime < retrievableAfterTime) {
-                            /*
-                             * Retrievable after time was updated while obtaining
-                             * the lock, so try again later
-                             */
-                            return;
-                        }
-                    } finally {
-                        resourceLock.unlock("FlowRetrieverTimerTask - check stopRequested");
-                    }
-
-                    // send request
-                    final FlowResponseMessage response = sender.requestFlow(request);
-
-                    resourceLock.lock();
-                    try {
-                        // check if the retrieved flow is still valid
-                        if (requestSentTime > retrievableAfterTime) {
-                            logger.info("Saving retrieved flow.");
-
-                            final StandardDataFlow dataFlow = response.getDataFlow();
-                            final ClusterDataFlow existingClusterDataFlow = flowDao.loadDataFlow();
-                            final ClusterDataFlow currentClusterDataFlow;
-                            if (existingClusterDataFlow == null) {
-                                currentClusterDataFlow = new ClusterDataFlow(dataFlow, null);
-                            } else {
-                                currentClusterDataFlow = new ClusterDataFlow(dataFlow, existingClusterDataFlow.getPrimaryNodeId());
-                            }
-                            flowDao.saveDataFlow(currentClusterDataFlow);
-                            flowDao.setPersistedFlowState(PersistedFlowState.CURRENT);
-                            lastRetrievalTime.set(new Date().getTime());
-                        }
-
-                        /*
-                         * Retrievable after time was updated while requesting
-                         * the flow, so try again later.
-                         */
-                    } finally {
-                        resourceLock.unlock("FlowRetrieverTimerTask - saveDataFlow");
-                    }
-
-                } catch (final Throwable t) {
-                    logger.info("Encountered exception retrieving flow from node " + nodeId + " caused by " + t, t);
-                }
-            }
-        }
-    }
-
-    private static class TimingReentrantLock {
-
-        private final Lock lock;
-        private static final Logger logger = LoggerFactory.getLogger("dataFlowManagementService.lock");
-
-        private final ThreadLocal<Long> lockTime = new ThreadLocal<>();
-
-        public TimingReentrantLock(final Lock lock) {
-            this.lock = lock;
-        }
-
-        public void lock() {
-            lock.lock();
-            lockTime.set(System.nanoTime());
-        }
-
-        public void unlock(final String task) {
-            final long nanosLocked = System.nanoTime() - lockTime.get();
-            lock.unlock();
-
-            final long millisLocked = TimeUnit.MILLISECONDS.convert(nanosLocked, TimeUnit.NANOSECONDS);
-            if (millisLocked > 100L) {
-                logger.debug("Lock held for {} milliseconds for task: {}", millisLocked, task);
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/ClusterManager.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/ClusterManager.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/ClusterManager.java
deleted file mode 100644
index 3a1dfb2..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/ClusterManager.java
+++ /dev/null
@@ -1,225 +0,0 @@
-/*
- * 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.nifi.cluster.manager;
-
-import java.util.List;
-import java.util.Set;
-
-import org.apache.nifi.cluster.event.Event;
-import org.apache.nifi.cluster.manager.exception.IllegalNodeDeletionException;
-import org.apache.nifi.cluster.manager.exception.IllegalNodeDisconnectionException;
-import org.apache.nifi.cluster.manager.exception.IllegalNodeReconnectionException;
-import org.apache.nifi.cluster.manager.exception.IneligiblePrimaryNodeException;
-import org.apache.nifi.cluster.manager.exception.NodeDisconnectionException;
-import org.apache.nifi.cluster.manager.exception.PrimaryRoleAssignmentException;
-import org.apache.nifi.cluster.manager.exception.UnknownNodeException;
-import org.apache.nifi.cluster.node.Node;
-import org.apache.nifi.cluster.node.Node.Status;
-import org.apache.nifi.cluster.protocol.ConnectionRequest;
-import org.apache.nifi.cluster.protocol.ConnectionResponse;
-import org.apache.nifi.cluster.protocol.Heartbeat;
-import org.apache.nifi.cluster.protocol.NodeIdentifier;
-import org.apache.nifi.controller.status.ProcessGroupStatus;
-import org.apache.nifi.diagnostics.SystemDiagnostics;
-import org.apache.nifi.remote.cluster.NodeInformant;
-import org.apache.nifi.reporting.BulletinRepository;
-
-/**
- * Defines the interface for a ClusterManager. The cluster manager is a
- * threadsafe centralized manager for a cluster. Members of a cluster are nodes.
- * A member becomes a node by issuing a connection request to the manager. The
- * manager maintains the set of nodes. Nodes may be disconnected, reconnected,
- * and deleted.
- *
- * Nodes are responsible for sending heartbeats to the manager to indicate their
- * liveliness. A manager may disconnect a node if it does not receive a
- * heartbeat within a configurable time period. A cluster manager instance may
- * be configured with how often to monitor received heartbeats
- * (getHeartbeatMonitoringIntervalSeconds()) and the maximum time that may
- * elapse between node heartbeats before disconnecting the node
- * (getMaxHeartbeatGapSeconds()).
- *
- * Since only a single node may execute isolated processors, the cluster manager
- * maintains the notion of a primary node. The primary node is chosen at cluster
- * startup and retains the role until a user requests a different node to be the
- * primary node.
- *
- * @author unattributed
- */
-public interface ClusterManager extends NodeInformant {
-
-    /**
-     * Handles a node's heartbeat.
-     *
-     * @param heartbeat a heartbeat
-     *
-     */
-    void handleHeartbeat(Heartbeat heartbeat);
-
-    /**
-     * @param statuses the statuses of the nodes
-     * @return the set of nodes
-     */
-    Set<Node> getNodes(Status... statuses);
-
-    /**
-     * @param nodeId
-     * @return returns the node with the given identifier or null if node does
-     * not exist
-     */
-    Node getNode(String nodeId);
-
-    /**
-     * @param statuses
-     * @return the set of node identifiers with the given node status
-     */
-    Set<NodeIdentifier> getNodeIds(Status... statuses);
-
-    /**
-     * Deletes the node with the given node identifier. If the given node is the
-     * primary node, then a subsequent request may be made to the manager to set
-     * a new primary node.
-     *
-     * @param nodeId the node identifier
-     * @param userDn the Distinguished Name of the user requesting the node be
-     * deleted from the cluster
-     *
-     * @throws UnknownNodeException if the node does not exist
-     * @throws IllegalNodeDeletionException if the node is not in a disconnected
-     * state
-     */
-    void deleteNode(String nodeId, String userDn) throws UnknownNodeException, IllegalNodeDeletionException;
-
-    /**
-     * Requests a connection to the cluster.
-     *
-     * @param request the request
-     *
-     * @return the response
-     */
-    ConnectionResponse requestConnection(ConnectionRequest request);
-
-    /**
-     * Services reconnection requests for a given node. If the node indicates
-     * reconnection failure, then the node will be set to disconnected.
-     * Otherwise, a reconnection request will be sent to the node, initiating
-     * the connection handshake.
-     *
-     * @param nodeId a node identifier
-     * @param userDn the Distinguished Name of the user requesting the
-     * reconnection
-     *
-     * @throws UnknownNodeException if the node does not exist
-     * @throws IllegalNodeReconnectionException if the node is not disconnected
-     */
-    void requestReconnection(String nodeId, String userDn) throws UnknownNodeException, IllegalNodeReconnectionException;
-
-    /**
-     * Requests the node with the given identifier be disconnected.
-     *
-     * @param nodeId the node identifier
-     * @param userDn the Distinguished Name of the user requesting the
-     * disconnection
-     *
-     * @throws UnknownNodeException if the node does not exist
-     * @throws IllegalNodeDisconnectionException if the node cannot be
-     * disconnected due to the cluster's state (e.g., node is last connected
-     * node or node is primary)
-     * @throws UnknownNodeException if the node does not exist
-     * @throws IllegalNodeDisconnectionException if the node is not disconnected
-     * @throws NodeDisconnectionException if the disconnection failed
-     */
-    void requestDisconnection(String nodeId, String userDn) throws UnknownNodeException, IllegalNodeDisconnectionException, NodeDisconnectionException;
-
-    /**
-     * @return the time in seconds to wait between successive executions of
-     * heartbeat monitoring
-     */
-    int getHeartbeatMonitoringIntervalSeconds();
-
-    /**
-     * @return the maximum time in seconds that is allowed between successive
-     * heartbeats of a node before disconnecting the node
-     */
-    int getMaxHeartbeatGapSeconds();
-
-    /**
-     * Returns a list of node events for the node with the given identifier. The
-     * events will be returned in order of most recent to least recent according
-     * to the creation date of the event.
-     *
-     * @param nodeId the node identifier
-     *
-     * @return the list of events or an empty list if no node exists with the
-     * given identifier
-     */
-    List<Event> getNodeEvents(final String nodeId);
-
-    /**
-     * Revokes the primary role from the current primary node and assigns the
-     * primary role to given given node ID.
-     *
-     * If role revocation fails, then the current primary node is set to
-     * disconnected while retaining the primary role and no role assignment is
-     * performed.
-     *
-     * If role assignment fails, then the given node is set to disconnected and
-     * is given the primary role.
-     *
-     * @param nodeId the node identifier
-     * @param userDn the Distinguished Name of the user requesting that the
-     * Primary Node be assigned
-     *
-     * @throws UnknownNodeException if the node with the given identifier does
-     * not exist
-     * @throws IneligiblePrimaryNodeException if the node with the given
-     * identifier is not eligible to be the primary node
-     * @throws PrimaryRoleAssignmentException if the cluster was unable to
-     * change the primary role to the requested node
-     */
-    void setPrimaryNode(String nodeId, String userDn) throws UnknownNodeException, IneligiblePrimaryNodeException, PrimaryRoleAssignmentException;
-
-    /**
-     * @return the primary node of the cluster or null if no primary node exists
-     */
-    Node getPrimaryNode();
-
-    /**
-     * Returns the bulletin repository.
-     *
-     * @return
-     */
-    BulletinRepository getBulletinRepository();
-
-    /**
-     * Returns a {@link ProcessGroupStatus} that represents the status of all
-     * nodes with the given {@link Status}es for the given ProcessGroup id, or
-     * null if no nodes exist with the given statuses
-     *
-     * @param groupId
-     * @return
-     */
-    ProcessGroupStatus getProcessGroupStatus(String groupId);
-
-    /**
-     * Returns a merged representation of the System Diagnostics for all nodes
-     * in the cluster
-     *
-     * @return
-     */
-    SystemDiagnostics getSystemDiagnostics();
-}


[14/20] incubator-nifi git commit: NIFI-410 pushed RAT exclusions down to the relevant modules and stopped doing broad test resource exclusion - is now specific

Posted by jo...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/impl/HttpRequestReplicatorImpl.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/impl/HttpRequestReplicatorImpl.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/impl/HttpRequestReplicatorImpl.java
deleted file mode 100644
index 81bb7a7..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/impl/HttpRequestReplicatorImpl.java
+++ /dev/null
@@ -1,531 +0,0 @@
-/*
- * 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.nifi.cluster.manager.impl;
-
-import com.sun.jersey.api.client.Client;
-import com.sun.jersey.api.client.ClientResponse;
-import com.sun.jersey.api.client.UniformInterfaceException;
-import com.sun.jersey.api.client.WebResource;
-import com.sun.jersey.api.client.config.ClientConfig;
-import com.sun.jersey.api.client.filter.GZIPContentEncodingFilter;
-import com.sun.jersey.core.util.MultivaluedMapImpl;
-
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.UUID;
-import java.util.concurrent.Callable;
-import java.util.concurrent.CompletionService;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.ExecutorCompletionService;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
-
-import javax.ws.rs.HttpMethod;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.MultivaluedMap;
-
-import org.apache.nifi.cluster.manager.HttpRequestReplicator;
-import org.apache.nifi.cluster.manager.NodeResponse;
-import org.apache.nifi.cluster.manager.exception.UriConstructionException;
-import org.apache.nifi.cluster.protocol.NodeIdentifier;
-import org.apache.nifi.logging.NiFiLog;
-import org.apache.nifi.util.FormatUtils;
-
-import org.apache.commons.lang3.StringUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * An implementation of the <code>HttpRequestReplicator</code> interface. This
- * implementation parallelizes the node HTTP requests using the given
- * <code>ExecutorService</code> instance. Individual requests may have
- * connection and read timeouts set, which may be set during instance
- * construction. Otherwise, the default is not to timeout.
- *
- * If a node protocol scheme is provided during construction, then all requests
- * will be replicated using the given scheme. If null is provided as the scheme
- * (the default), then the requests will be replicated using the scheme of the
- * original URI.
- *
- * Clients must call start() and stop() to initialize and shutdown the instance.
- * The instance must be started before issuing any replication requests.
- *
- * @author unattributed
- */
-public class HttpRequestReplicatorImpl implements HttpRequestReplicator {
-
-    // defaults
-    private static final int DEFAULT_SHUTDOWN_REPLICATOR_SECONDS = 30;
-
-    // logger
-    private static final Logger logger = new NiFiLog(LoggerFactory.getLogger(HttpRequestReplicatorImpl.class));
-
-    // final members
-    private final Client client;            // the client to use for issuing requests
-    private final int numThreads;           // number of threads to use for request replication
-    private final int connectionTimeoutMs;  // connection timeout per node request
-    private final int readTimeoutMs;        // read timeout per node request
-
-    // members
-    private ExecutorService executorService;
-    private int shutdownReplicatorSeconds = DEFAULT_SHUTDOWN_REPLICATOR_SECONDS;
-
-    // guarded by synchronized method access in support of multithreaded replication
-    private String nodeProtocolScheme = null;
-
-    /**
-     * Creates an instance. The connection timeout and read timeout will be
-     * infinite.
-     *
-     * @param numThreads the number of threads to use when parallelizing
-     * requests
-     * @param client a client for making requests
-     */
-    public HttpRequestReplicatorImpl(final int numThreads, final Client client) {
-        this(numThreads, client, "0 sec", "0 sec");
-    }
-
-    /**
-     * Creates an instance.
-     *
-     * @param numThreads the number of threads to use when parallelizing
-     * requests
-     * @param client a client for making requests
-     * @param connectionTimeoutMs the connection timeout specified in
-     * milliseconds
-     * @param readTimeoutMs the read timeout specified in milliseconds
-     */
-    public HttpRequestReplicatorImpl(final int numThreads, final Client client, final String connectionTimeout, final String readTimeout) {
-
-        if (numThreads <= 0) {
-            throw new IllegalArgumentException("The number of threads must be greater than zero.");
-        } else if (client == null) {
-            throw new IllegalArgumentException("Client may not be null.");
-        }
-
-        this.numThreads = numThreads;
-        this.client = client;
-        this.connectionTimeoutMs = (int) FormatUtils.getTimeDuration(connectionTimeout, TimeUnit.MILLISECONDS);
-        this.readTimeoutMs = (int) FormatUtils.getTimeDuration(readTimeout, TimeUnit.MILLISECONDS);
-
-        client.getProperties().put(ClientConfig.PROPERTY_CONNECT_TIMEOUT, connectionTimeoutMs);
-        client.getProperties().put(ClientConfig.PROPERTY_READ_TIMEOUT, readTimeoutMs);
-        client.getProperties().put(ClientConfig.PROPERTY_FOLLOW_REDIRECTS, Boolean.TRUE);
-    }
-
-    @Override
-    public void start() {
-        if (isRunning()) {
-            throw new IllegalStateException("Instance is already started.");
-        }
-        executorService = Executors.newFixedThreadPool(numThreads);
-    }
-
-    @Override
-    public boolean isRunning() {
-        return executorService != null && !executorService.isShutdown();
-    }
-
-    @Override
-    public void stop() {
-
-        if (!isRunning()) {
-            throw new IllegalStateException("Instance is already stopped.");
-        }
-
-        // shutdown executor service
-        try {
-            if (getShutdownReplicatorSeconds() <= 0) {
-                executorService.shutdownNow();
-            } else {
-                executorService.shutdown();
-            }
-            executorService.awaitTermination(getShutdownReplicatorSeconds(), TimeUnit.SECONDS);
-        } catch (final InterruptedException ex) {
-            Thread.currentThread().interrupt();
-        } finally {
-            if (executorService.isTerminated()) {
-                logger.info("HTTP Request Replicator has been terminated successfully.");
-            } else {
-                logger.warn("HTTP Request Replicator has not terminated properly.  There exists an uninterruptable thread that will take an indeterminate amount of time to stop.");
-            }
-        }
-    }
-
-    /**
-     * Sets the protocol scheme to use when issuing requests to nodes.
-     *
-     * @param nodeProtocolScheme the scheme. Valid values are "http", "https",
-     * or null. If null is specified, then the scheme of the originating request
-     * is used when replicating that request.
-     */
-    public synchronized void setNodeProtocolScheme(final String nodeProtocolScheme) {
-        if (StringUtils.isNotBlank(nodeProtocolScheme)) {
-            if (!"http".equalsIgnoreCase(nodeProtocolScheme) && !"https".equalsIgnoreCase(nodeProtocolScheme)) {
-                throw new IllegalArgumentException("Node Protocol Scheme must be either HTTP or HTTPS");
-            }
-        }
-        this.nodeProtocolScheme = nodeProtocolScheme;
-    }
-
-    public synchronized String getNodeProtocolScheme() {
-        return nodeProtocolScheme;
-    }
-
-    private synchronized String getNodeProtocolScheme(final URI uri) {
-        // if we are not configured to use a protocol scheme, then use the uri's scheme
-        if (StringUtils.isBlank(nodeProtocolScheme)) {
-            return uri.getScheme();
-        }
-        return nodeProtocolScheme;
-    }
-
-    public int getConnectionTimeoutMs() {
-        return connectionTimeoutMs;
-    }
-
-    public int getReadTimeoutMs() {
-        return readTimeoutMs;
-    }
-
-    public int getShutdownReplicatorSeconds() {
-        return shutdownReplicatorSeconds;
-    }
-
-    public void setShutdownReplicatorSeconds(int shutdownReplicatorSeconds) {
-        this.shutdownReplicatorSeconds = shutdownReplicatorSeconds;
-    }
-
-    @Override
-    public Set<NodeResponse> replicate(final Set<NodeIdentifier> nodeIds, final String method,
-            final URI uri, final Map<String, List<String>> parameters, final Map<String, String> headers)
-            throws UriConstructionException {
-        if (nodeIds == null) {
-            throw new IllegalArgumentException("Node IDs may not be null.");
-        } else if (method == null) {
-            throw new IllegalArgumentException("HTTP method may not be null.");
-        } else if (uri == null) {
-            throw new IllegalArgumentException("URI may not be null.");
-        } else if (parameters == null) {
-            throw new IllegalArgumentException("Parameters may not be null.");
-        } else if (headers == null) {
-            throw new IllegalArgumentException("HTTP headers map may not be null.");
-        }
-        return replicateHelper(nodeIds, method, getNodeProtocolScheme(uri), uri.getPath(), parameters, /* entity */ null, headers);
-    }
-
-    @Override
-    public Set<NodeResponse> replicate(final Set<NodeIdentifier> nodeIds, final String method, final URI uri,
-            final Object entity, final Map<String, String> headers) throws UriConstructionException {
-        if (nodeIds == null) {
-            throw new IllegalArgumentException("Node IDs may not be null.");
-        } else if (method == null) {
-            throw new IllegalArgumentException("HTTP method may not be null.");
-        } else if (method.equalsIgnoreCase(HttpMethod.DELETE) || method.equalsIgnoreCase(HttpMethod.GET) || method.equalsIgnoreCase(HttpMethod.HEAD) || method.equalsIgnoreCase(HttpMethod.OPTIONS)) {
-            throw new IllegalArgumentException("HTTP (DELETE | GET | HEAD | OPTIONS) requests cannot have a body containing an entity.");
-        } else if (uri == null) {
-            throw new IllegalArgumentException("URI may not be null.");
-        } else if (entity == null) {
-            throw new IllegalArgumentException("Entity may not be null.");
-        } else if (headers == null) {
-            throw new IllegalArgumentException("HTTP headers map may not be null.");
-        }
-        return replicateHelper(nodeIds, method, getNodeProtocolScheme(uri), uri.getPath(), /* parameters */ null, entity, headers);
-    }
-
-    private Set<NodeResponse> replicateHelper(final Set<NodeIdentifier> nodeIds, final String method, final String scheme,
-            final String path, final Map<String, List<String>> parameters, final Object entity, final Map<String, String> headers)
-            throws UriConstructionException {
-
-        if (nodeIds.isEmpty()) {
-            return new HashSet<>(); // return quickly for trivial case
-        }
-
-        final CompletionService<NodeResponse> completionService = new ExecutorCompletionService<>(executorService);
-
-        // keeps track of future requests so that failed requests can be tied back to the failing node
-        final Collection<NodeHttpRequestFutureWrapper> futureNodeHttpRequests = new ArrayList<>();
-
-        // construct the URIs for the nodes
-        final Map<NodeIdentifier, URI> uriMap = new HashMap<>();
-        try {
-            for (final NodeIdentifier nodeId : nodeIds) {
-                final URI nodeUri = new URI(scheme, null, nodeId.getApiAddress(), nodeId.getApiPort(), path, /* query */ null, /* fragment */ null);
-                uriMap.put(nodeId, nodeUri);
-            }
-        } catch (final URISyntaxException use) {
-            throw new UriConstructionException(use);
-        }
-
-        // submit the requests to the nodes
-        final String requestId = UUID.randomUUID().toString();
-        headers.put(WebClusterManager.REQUEST_ID_HEADER, requestId);
-        for (final Map.Entry<NodeIdentifier, URI> entry : uriMap.entrySet()) {
-            final NodeIdentifier nodeId = entry.getKey();
-            final URI nodeUri = entry.getValue();
-            final NodeHttpRequestCallable callable = (entity == null)
-                    ? new NodeHttpRequestCallable(nodeId, method, nodeUri, parameters, headers)
-                    : new NodeHttpRequestCallable(nodeId, method, nodeUri, entity, headers);
-            futureNodeHttpRequests.add(new NodeHttpRequestFutureWrapper(nodeId, method, nodeUri, completionService.submit(callable)));
-        }
-
-        // get the node responses
-        final Set<NodeResponse> result = new HashSet<>();
-        for (int i = 0; i < nodeIds.size(); i++) {
-
-            // keeps track of the original request information in case we receive an exception
-            NodeHttpRequestFutureWrapper futureNodeHttpRequest = null;
-            try {
-
-                // get the future resource response for the node
-                final Future<NodeResponse> futureNodeResourceResponse = completionService.take();
-
-                // find the original request by comparing the submitted future with the future returned by the completion service
-                for (final NodeHttpRequestFutureWrapper futureNodeHttpRequestElem : futureNodeHttpRequests) {
-                    if (futureNodeHttpRequestElem.getFuture() == futureNodeResourceResponse) {
-                        futureNodeHttpRequest = futureNodeHttpRequestElem;
-                    }
-                }
-
-                // try to retrieve the node response and add to result
-                final NodeResponse nodeResponse = futureNodeResourceResponse.get();
-                result.add(nodeResponse);
-
-            } catch (final InterruptedException | ExecutionException ex) {
-
-                logger.warn("Node request for " + futureNodeHttpRequest.getNodeId() + " encountered exception: " + ex, ex);
-
-                // create node response with the thrown exception and add to result
-                final NodeResponse nodeResponse = new NodeResponse(
-                        futureNodeHttpRequest.getNodeId(), futureNodeHttpRequest.getHttpMethod(), futureNodeHttpRequest.getRequestUri(), ex);
-                result.add(nodeResponse);
-
-            }
-        }
-
-        if (logger.isDebugEnabled()) {
-            NodeResponse min = null;
-            NodeResponse max = null;
-            long nanosSum = 0L;
-            int nanosAdded = 0;
-
-            for (final NodeResponse response : result) {
-                final long requestNanos = response.getRequestDuration(TimeUnit.NANOSECONDS);
-                final long minNanos = (min == null) ? -1 : min.getRequestDuration(TimeUnit.NANOSECONDS);
-                final long maxNanos = (max == null) ? -1 : max.getRequestDuration(TimeUnit.NANOSECONDS);
-
-                if (requestNanos < minNanos || minNanos < 0L) {
-                    min = response;
-                }
-
-                if (requestNanos > maxNanos || maxNanos < 0L) {
-                    max = response;
-                }
-
-                if (requestNanos >= 0L) {
-                    nanosSum += requestNanos;
-                    nanosAdded++;
-                }
-            }
-
-            final StringBuilder sb = new StringBuilder();
-            sb.append("Node Responses for ").append(method).append(" ").append(path).append(" (Request ID ").append(requestId).append("):\n");
-            for (final NodeResponse response : result) {
-                sb.append(response).append("\n");
-            }
-
-            final long averageNanos = (nanosAdded == 0) ? -1L : nanosSum / nanosAdded;
-            final long averageMillis = (averageNanos < 0) ? averageNanos : TimeUnit.MILLISECONDS.convert(averageNanos, TimeUnit.NANOSECONDS);
-            logger.debug("For {} {} (Request ID {}), minimum response time = {}, max = {}, average = {} ms",
-                    method, path, requestId, min, max, averageMillis);
-            logger.debug(sb.toString());
-        }
-
-        return result;
-    }
-
-    /**
-     * Wraps a future node response with info from originating request. This
-     * coupling allows for futures that encountered exceptions to be linked back
-     * to the failing node and better reported.
-     */
-    private class NodeHttpRequestFutureWrapper {
-
-        private final NodeIdentifier nodeId;
-
-        private final String httpMethod;
-
-        private final URI requestUri;
-
-        private final Future<NodeResponse> future;
-
-        public NodeHttpRequestFutureWrapper(final NodeIdentifier nodeId, final String httpMethod,
-                final URI requestUri, final Future<NodeResponse> future) {
-            if (nodeId == null) {
-                throw new IllegalArgumentException("Node ID may not be null.");
-            } else if (StringUtils.isBlank(httpMethod)) {
-                throw new IllegalArgumentException("Http method may not be null or empty.");
-            } else if (requestUri == null) {
-                throw new IllegalArgumentException("Request URI may not be null.");
-            } else if (future == null) {
-                throw new IllegalArgumentException("Future may not be null.");
-            }
-            this.nodeId = nodeId;
-            this.httpMethod = httpMethod;
-            this.requestUri = requestUri;
-            this.future = future;
-        }
-
-        public NodeIdentifier getNodeId() {
-            return nodeId;
-        }
-
-        public String getHttpMethod() {
-            return httpMethod;
-        }
-
-        public URI getRequestUri() {
-            return requestUri;
-        }
-
-        public Future<NodeResponse> getFuture() {
-            return future;
-        }
-    }
-
-    /**
-     * A Callable for making an HTTP request to a single node and returning its
-     * response.
-     */
-    private class NodeHttpRequestCallable implements Callable<NodeResponse> {
-
-        private final NodeIdentifier nodeId;
-        private final String method;
-        private final URI uri;
-        private final Object entity;
-        private final Map<String, List<String>> parameters = new HashMap<>();
-        private final Map<String, String> headers = new HashMap<>();
-
-        private NodeHttpRequestCallable(final NodeIdentifier nodeId, final String method,
-                final URI uri, final Object entity, final Map<String, String> headers) {
-            this.nodeId = nodeId;
-            this.method = method;
-            this.uri = uri;
-            this.entity = entity;
-            this.headers.putAll(headers);
-        }
-
-        private NodeHttpRequestCallable(final NodeIdentifier nodeId, final String method,
-                final URI uri, final Map<String, List<String>> parameters, final Map<String, String> headers) {
-            this.nodeId = nodeId;
-            this.method = method;
-            this.uri = uri;
-            this.entity = null;
-            this.parameters.putAll(parameters);
-            this.headers.putAll(headers);
-        }
-
-        @Override
-        public NodeResponse call() {
-
-            try {
-                // create and send the request
-                final WebResource.Builder resourceBuilder = getResourceBuilder();
-                final String requestId = headers.get("x-nifi-request-id");
-
-                final long startNanos = System.nanoTime();
-                final ClientResponse clientResponse;
-                if (HttpMethod.DELETE.equalsIgnoreCase(method)) {
-                    clientResponse = resourceBuilder.delete(ClientResponse.class);
-                } else if (HttpMethod.GET.equalsIgnoreCase(method)) {
-                    clientResponse = resourceBuilder.get(ClientResponse.class);
-                } else if (HttpMethod.HEAD.equalsIgnoreCase(method)) {
-                    clientResponse = resourceBuilder.head();
-                } else if (HttpMethod.OPTIONS.equalsIgnoreCase(method)) {
-                    clientResponse = resourceBuilder.options(ClientResponse.class);
-                } else if (HttpMethod.POST.equalsIgnoreCase(method)) {
-                    clientResponse = resourceBuilder.post(ClientResponse.class);
-                } else if (HttpMethod.PUT.equalsIgnoreCase(method)) {
-                    clientResponse = resourceBuilder.put(ClientResponse.class);
-                } else {
-                    throw new IllegalArgumentException("HTTP Method '" + method + "' not supported for request replication.");
-                }
-
-                // create and return the response
-                return new NodeResponse(nodeId, method, uri, clientResponse, System.nanoTime() - startNanos, requestId);
-
-            } catch (final UniformInterfaceException | IllegalArgumentException t) {
-                return new NodeResponse(nodeId, method, uri, t);
-            }
-
-        }
-
-        private WebResource.Builder getResourceBuilder() {
-
-            // convert parameters to a more convenient data structure
-            final MultivaluedMap<String, String> map = new MultivaluedMapImpl();
-            map.putAll(parameters);
-
-            // create the resource
-            WebResource resource = client.resource(uri);
-
-            if (WebClusterManager.isResponseInterpreted(uri, method)) {
-                resource.addFilter(new GZIPContentEncodingFilter(false));
-            }
-
-            // set the parameters as either query parameters or as request body
-            final WebResource.Builder builder;
-            if (HttpMethod.DELETE.equalsIgnoreCase(method) || HttpMethod.HEAD.equalsIgnoreCase(method) || HttpMethod.GET.equalsIgnoreCase(method) || HttpMethod.OPTIONS.equalsIgnoreCase(method)) {
-                resource = resource.queryParams(map);
-                builder = resource.getRequestBuilder();
-            } else {
-                if (entity == null) {
-                    builder = resource.entity(map);
-                } else {
-                    builder = resource.entity(entity);
-                }
-            }
-
-            // set headers
-            boolean foundContentType = false;
-            for (final Map.Entry<String, String> entry : headers.entrySet()) {
-                builder.header(entry.getKey(), entry.getValue());
-                if (entry.getKey().equalsIgnoreCase("content-type")) {
-                    foundContentType = true;
-                }
-            }
-
-            // set default content type
-            if (!foundContentType) {
-                // set default content type
-                builder.type(MediaType.APPLICATION_FORM_URLENCODED);
-            }
-
-            return builder;
-        }
-
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/impl/HttpResponseMapperImpl.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/impl/HttpResponseMapperImpl.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/impl/HttpResponseMapperImpl.java
deleted file mode 100644
index afade7e..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/impl/HttpResponseMapperImpl.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * 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.nifi.cluster.manager.impl;
-
-import java.net.URI;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-import org.apache.nifi.cluster.manager.HttpResponseMapper;
-import org.apache.nifi.cluster.manager.NodeResponse;
-import org.apache.nifi.cluster.node.Node;
-import org.apache.nifi.cluster.node.Node.Status;
-import org.apache.nifi.logging.NiFiLog;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Determines the status of nodes based on their HTTP response codes.
- *
- * The algorithm is as follows.
- *
- * If any HTTP responses were 2XX, then disconnect non-2XX responses. This is
- * because 2XX may have changed a node's flow.
- *
- * If no 2XX responses were received, then the node's flow has not changed.
- * Instead of disconnecting everything, we only disconnect the nodes with
- * internal errors, i.e., 5XX responses.
- *
- * @author unattributed
- */
-public class HttpResponseMapperImpl implements HttpResponseMapper {
-
-    private static final Logger logger = new NiFiLog(LoggerFactory.getLogger(HttpResponseMapperImpl.class));
-
-    @Override
-    public Map<NodeResponse, Status> map(final URI requestURI, final Set<NodeResponse> nodeResponses) {
-
-        final Map<NodeResponse, Status> result = new HashMap<>();
-
-        // check if any responses were 2XX
-        boolean found2xx = false;
-        for (final NodeResponse nodeResponse : nodeResponses) {
-            if (nodeResponse.is2xx()) {
-                found2xx = true;
-                break;
-            }
-        }
-
-        // determine the status of each node 
-        for (final NodeResponse nodeResponse : nodeResponses) {
-
-            final Node.Status status;
-            if (found2xx) {
-                // disconnect nodes with non-2XX responses
-                status = nodeResponse.is2xx()
-                        ? Node.Status.CONNECTED
-                        : Node.Status.DISCONNECTED;
-            } else {
-                // disconnect nodes with 5XX responses or exception
-                status = nodeResponse.is5xx()
-                        ? Node.Status.DISCONNECTED
-                        : Node.Status.CONNECTED;
-            }
-
-            result.put(nodeResponse, status);
-        }
-
-        return result;
-    }
-
-}


[08/20] incubator-nifi git commit: NIFI-410 pushed RAT exclusions down to the relevant modules and stopped doing broad test resource exclusion - is now specific

Posted by jo...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ConnectionRequestMessage.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ConnectionRequestMessage.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ConnectionRequestMessage.java
new file mode 100644
index 0000000..344de4e
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ConnectionRequestMessage.java
@@ -0,0 +1,46 @@
+/*
+ * 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.nifi.cluster.protocol.message;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.apache.nifi.cluster.protocol.ConnectionRequest;
+
+/**
+ * @author unattributed
+ */
+@XmlRootElement(name = "connectionRequestMessage")
+public class ConnectionRequestMessage extends ProtocolMessage {
+    
+    private ConnectionRequest connectionRequest;
+    
+    public ConnectionRequestMessage() {}
+    
+    public ConnectionRequest getConnectionRequest() {
+        return connectionRequest;
+    }
+
+    public void setConnectionRequest(ConnectionRequest connectionRequest) {
+        this.connectionRequest = connectionRequest;
+    }
+    
+    @Override
+    public MessageType getType() {
+        return MessageType.CONNECTION_REQUEST;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ConnectionResponseMessage.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ConnectionResponseMessage.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ConnectionResponseMessage.java
new file mode 100644
index 0000000..a262d7a
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ConnectionResponseMessage.java
@@ -0,0 +1,66 @@
+/*
+ * 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.nifi.cluster.protocol.message;
+
+import javax.xml.bind.annotation.XmlRootElement;
+import org.apache.nifi.cluster.protocol.ConnectionResponse;
+
+/**
+ * @author unattributed
+ */
+@XmlRootElement(name = "connectionResponseMessage")
+public class ConnectionResponseMessage extends ProtocolMessage {
+    
+    private ConnectionResponse connectionResponse;
+    private String clusterManagerDN;
+    
+    public ConnectionResponseMessage() {}
+
+    public ConnectionResponse getConnectionResponse() {
+        return connectionResponse;
+    }
+
+    public void setConnectionResponse(final ConnectionResponse connectionResponse) {
+        this.connectionResponse = connectionResponse;
+        
+        if ( clusterManagerDN != null ) {
+            this.connectionResponse.setClusterManagerDN(clusterManagerDN);
+        }
+    }
+    
+    public void setClusterManagerDN(final String dn) {
+        if ( connectionResponse != null ) {
+            connectionResponse.setClusterManagerDN(dn);
+        }
+        this.clusterManagerDN = dn;
+    }
+    
+    /**
+     * Returns the DN of the NCM, if it is available or <code>null</code> otherwise.
+     * 
+     * @return
+     */
+    public String getClusterManagerDN() {
+        return clusterManagerDN;
+    }
+
+    @Override
+    public MessageType getType() {
+        return MessageType.CONNECTION_RESPONSE;
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ControllerStartupFailureMessage.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ControllerStartupFailureMessage.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ControllerStartupFailureMessage.java
new file mode 100644
index 0000000..ebc1cae
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ControllerStartupFailureMessage.java
@@ -0,0 +1,49 @@
+/*
+ * 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.nifi.cluster.protocol.message;
+
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+
+import org.apache.nifi.cluster.protocol.NodeIdentifier;
+import org.apache.nifi.cluster.protocol.jaxb.message.NodeIdentifierAdapter;
+
+/**
+ * @author unattributed
+ */
+@XmlRootElement(name = "controllerStartupFailureMessage")
+public class ControllerStartupFailureMessage extends ExceptionMessage {
+
+    private NodeIdentifier nodeId;
+    
+    public ControllerStartupFailureMessage() {}
+    
+    @Override
+    public MessageType getType() {
+        return MessageType.CONTROLLER_STARTUP_FAILURE;
+    }
+
+    @XmlJavaTypeAdapter(NodeIdentifierAdapter.class)
+    public NodeIdentifier getNodeId() {
+        return nodeId;
+    }
+
+    public void setNodeId(NodeIdentifier nodeId) {
+        this.nodeId = nodeId;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/DisconnectMessage.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/DisconnectMessage.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/DisconnectMessage.java
new file mode 100644
index 0000000..8aa7a40
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/DisconnectMessage.java
@@ -0,0 +1,55 @@
+/*
+ * 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.nifi.cluster.protocol.message;
+
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+import org.apache.nifi.cluster.protocol.NodeIdentifier;
+import org.apache.nifi.cluster.protocol.jaxb.message.NodeIdentifierAdapter;
+
+/**
+ * @author unattributed
+ */
+@XmlRootElement(name = "disconnectionMessage")
+public class DisconnectMessage extends ProtocolMessage {
+    
+    private NodeIdentifier nodeId;
+    private String explanation;
+ 
+    @XmlJavaTypeAdapter(NodeIdentifierAdapter.class)
+    public NodeIdentifier getNodeId() {
+        return nodeId;
+    }
+
+    public void setNodeId(NodeIdentifier nodeId) {
+        this.nodeId = nodeId;
+    }
+
+    public String getExplanation() {
+        return explanation;
+    }
+
+    public void setExplanation(String explanation) {
+        this.explanation = explanation;
+    }
+    
+    @Override
+    public MessageType getType() {
+        return MessageType.DISCONNECTION_REQUEST;
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ExceptionMessage.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ExceptionMessage.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ExceptionMessage.java
new file mode 100644
index 0000000..99a6dee
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ExceptionMessage.java
@@ -0,0 +1,44 @@
+/*
+ * 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.nifi.cluster.protocol.message;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ * @author unattributed
+ */
+@XmlRootElement(name = "exceptionMessage")
+public class ExceptionMessage extends ProtocolMessage {
+    
+    private String exceptionMessage;
+
+    public ExceptionMessage() {}
+
+    public String getExceptionMessage() {
+        return exceptionMessage;
+    }
+
+    public void setExceptionMessage(String exceptionMessage) {
+        this.exceptionMessage = exceptionMessage;
+    }
+    
+    @Override
+    public MessageType getType() {
+        return MessageType.EXCEPTION;
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/FlowRequestMessage.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/FlowRequestMessage.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/FlowRequestMessage.java
new file mode 100644
index 0000000..4a10538
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/FlowRequestMessage.java
@@ -0,0 +1,46 @@
+/*
+ * 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.nifi.cluster.protocol.message;
+
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+import org.apache.nifi.cluster.protocol.NodeIdentifier;
+import org.apache.nifi.cluster.protocol.jaxb.message.NodeIdentifierAdapter;
+
+/**
+ * @author unattributed
+ */
+@XmlRootElement(name = "flowRequestMessage")
+public class FlowRequestMessage extends ProtocolMessage {
+    
+    private NodeIdentifier nodeId;
+
+    @XmlJavaTypeAdapter(NodeIdentifierAdapter.class)
+    public NodeIdentifier getNodeId() {
+        return nodeId;
+    }
+
+    public void setNodeId(NodeIdentifier nodeId) {
+        this.nodeId = nodeId;
+    }
+    
+    @Override
+    public MessageType getType() {
+        return MessageType.FLOW_REQUEST;
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/FlowResponseMessage.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/FlowResponseMessage.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/FlowResponseMessage.java
new file mode 100644
index 0000000..0d34dae
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/FlowResponseMessage.java
@@ -0,0 +1,44 @@
+/*
+ * 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.nifi.cluster.protocol.message;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.apache.nifi.cluster.protocol.StandardDataFlow;
+
+/**
+ * @author unattributed
+ */
+@XmlRootElement(name = "flowResponseMessage")
+public class FlowResponseMessage extends ProtocolMessage {
+    
+    private StandardDataFlow dataFlow;
+    
+    @Override
+    public MessageType getType() {
+        return MessageType.FLOW_RESPONSE;
+    }
+
+    public StandardDataFlow getDataFlow() {
+        return dataFlow;
+    }
+
+    public void setDataFlow(StandardDataFlow dataFlow) {
+        this.dataFlow = dataFlow;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/HeartbeatMessage.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/HeartbeatMessage.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/HeartbeatMessage.java
new file mode 100644
index 0000000..0064cb6
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/HeartbeatMessage.java
@@ -0,0 +1,43 @@
+/*
+ * 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.nifi.cluster.protocol.message;
+
+import org.apache.nifi.cluster.protocol.Heartbeat;
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ * @author unattributed
+ */
+@XmlRootElement(name = "heartbeatMessage")
+public class HeartbeatMessage extends ProtocolMessage {
+    
+    private Heartbeat heartbeat;
+    
+    @Override
+    public MessageType getType() {
+        return MessageType.HEARTBEAT;
+    }
+
+    public Heartbeat getHeartbeat() {
+        return heartbeat;
+    }
+
+    public void setHeartbeat(Heartbeat heartbeat) {
+        this.heartbeat = heartbeat;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/MulticastProtocolMessage.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/MulticastProtocolMessage.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/MulticastProtocolMessage.java
new file mode 100644
index 0000000..c6d2d44
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/MulticastProtocolMessage.java
@@ -0,0 +1,66 @@
+/*
+ * 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.nifi.cluster.protocol.message;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ * Wraps a protocol message and an identifier for sending the message by way
+ * multicast.  The identifier is necessary for the sender to identify a message
+ * sent by it.
+ * 
+ * @author unattributed
+ */
+@XmlRootElement(name = "multicastMessage")
+public class MulticastProtocolMessage extends ProtocolMessage {
+    
+    private ProtocolMessage protocolMessage;
+    
+    private String id;
+    
+    public MulticastProtocolMessage() {}
+
+    public MulticastProtocolMessage(final String id, final ProtocolMessage protocolMessage) {
+        this.protocolMessage = protocolMessage;
+        this.id = id;
+    }
+    
+    @Override
+    public MessageType getType() {
+        if(protocolMessage == null) {
+            return null;
+        }
+        return protocolMessage.getType();
+    }
+
+    public String getId() {
+        return id;
+    }
+
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    public ProtocolMessage getProtocolMessage() {
+        return protocolMessage;
+    }
+
+    public void setProtocolMessage(ProtocolMessage protocolMessage) {
+        this.protocolMessage = protocolMessage;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/NodeBulletinsMessage.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/NodeBulletinsMessage.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/NodeBulletinsMessage.java
new file mode 100644
index 0000000..9237a92
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/NodeBulletinsMessage.java
@@ -0,0 +1,43 @@
+/*
+ * 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.nifi.cluster.protocol.message;
+
+import org.apache.nifi.cluster.protocol.NodeBulletins;
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ * @author unattributed
+ */
+@XmlRootElement(name = "nodeBulletinsMessage")
+public class NodeBulletinsMessage extends ProtocolMessage {
+    
+    private NodeBulletins bulletins;
+    
+    @Override
+    public MessageType getType() {
+        return MessageType.BULLETINS;
+    }
+
+    public NodeBulletins getBulletins() {
+        return bulletins;
+    }
+
+    public void setBulletins(NodeBulletins bulletins) {
+        this.bulletins = bulletins;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/PingMessage.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/PingMessage.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/PingMessage.java
new file mode 100644
index 0000000..ee38deb
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/PingMessage.java
@@ -0,0 +1,55 @@
+/*
+ * 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.nifi.cluster.protocol.message;
+
+import java.util.Date;
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ * @author unattributed
+ */
+@XmlRootElement(name = "pingMessage")
+public class PingMessage extends ProtocolMessage {
+    
+    private String id;
+    
+    private Date date = new Date();
+
+    public PingMessage() {}
+    
+    public Date getDate() {
+        return date;
+    }
+
+    public void setDate(Date date) {
+        this.date = date;
+    }
+
+    public String getId() {
+        return id;
+    }
+
+    public void setId(String id) {
+        this.id = id;
+    }
+    
+    @Override
+    public MessageType getType() {
+        return MessageType.PING;
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/PrimaryRoleAssignmentMessage.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/PrimaryRoleAssignmentMessage.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/PrimaryRoleAssignmentMessage.java
new file mode 100644
index 0000000..a289abc
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/PrimaryRoleAssignmentMessage.java
@@ -0,0 +1,56 @@
+/*
+ * 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.nifi.cluster.protocol.message;
+
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+import org.apache.nifi.cluster.protocol.NodeIdentifier;
+import org.apache.nifi.cluster.protocol.jaxb.message.NodeIdentifierAdapter;
+
+/**
+ * @author unattributed
+ */
+@XmlRootElement(name = "primaryRoleAssignmentMessage")
+public class PrimaryRoleAssignmentMessage extends ProtocolMessage {
+
+    private NodeIdentifier nodeId;
+
+    private boolean primary;
+    
+    @XmlJavaTypeAdapter(NodeIdentifierAdapter.class)
+    public NodeIdentifier getNodeId() {
+        return nodeId;
+    }
+
+    public void setNodeId(NodeIdentifier nodeId) {
+        this.nodeId = nodeId;
+    }
+
+    public boolean isPrimary() {
+        return primary;
+    }
+
+    public void setPrimary(boolean primary) {
+        this.primary = primary;
+    }
+   
+    @Override
+    public MessageType getType() {
+        return MessageType.PRIMARY_ROLE;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ProtocolMessage.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ProtocolMessage.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ProtocolMessage.java
new file mode 100644
index 0000000..6bf2a13
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ProtocolMessage.java
@@ -0,0 +1,61 @@
+/*
+ * 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.nifi.cluster.protocol.message;
+
+/**
+ * @author unattributed
+ */
+public abstract class ProtocolMessage {
+    private volatile String requestorDN;
+    
+    public static enum MessageType {
+        BULLETINS,
+        CONNECTION_REQUEST,
+        CONNECTION_RESPONSE,
+        CONTROLLER_STARTUP_FAILURE,
+        RECONNECTION_FAILURE,
+        DISCONNECTION_REQUEST,
+        EXCEPTION,
+        FLOW_REQUEST,
+        FLOW_RESPONSE,
+        HEARTBEAT,
+        PING,
+        PRIMARY_ROLE,
+        RECONNECTION_REQUEST,
+        RECONNECTION_RESPONSE,
+        SERVICE_BROADCAST,
+    }
+    
+    public abstract MessageType getType();
+    
+    /**
+     * Sets the DN of the entity making the request
+     * @param dn
+     */
+    public void setRequestorDN(final String dn) {
+        this.requestorDN = dn;
+    }
+    
+    /**
+     * Returns the DN of the entity that made the request, if using a secure socket. Otherwise, returns <code>null</code>
+     * @return
+     */
+    public String getRequestorDN() {
+        return requestorDN;
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ReconnectionFailureMessage.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ReconnectionFailureMessage.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ReconnectionFailureMessage.java
new file mode 100644
index 0000000..ba45e28
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ReconnectionFailureMessage.java
@@ -0,0 +1,45 @@
+/*
+ * 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.nifi.cluster.protocol.message;
+
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+
+import org.apache.nifi.cluster.protocol.NodeIdentifier;
+import org.apache.nifi.cluster.protocol.jaxb.message.NodeIdentifierAdapter;
+
+@XmlRootElement(name = "reconnectionFailureMessage")
+public class ReconnectionFailureMessage extends ExceptionMessage {
+    private NodeIdentifier nodeId;
+    
+    public ReconnectionFailureMessage() {}
+    
+    @Override
+    public MessageType getType() {
+        return MessageType.RECONNECTION_FAILURE;
+    }
+
+    @XmlJavaTypeAdapter(NodeIdentifierAdapter.class)
+    public NodeIdentifier getNodeId() {
+        return nodeId;
+    }
+
+    public void setNodeId(NodeIdentifier nodeId) {
+        this.nodeId = nodeId;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ReconnectionRequestMessage.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ReconnectionRequestMessage.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ReconnectionRequestMessage.java
new file mode 100644
index 0000000..eab3d5d
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ReconnectionRequestMessage.java
@@ -0,0 +1,94 @@
+/*
+ * 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.nifi.cluster.protocol.message;
+
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+
+import org.apache.nifi.cluster.protocol.NodeIdentifier;
+import org.apache.nifi.cluster.protocol.StandardDataFlow;
+import org.apache.nifi.cluster.protocol.jaxb.message.NodeIdentifierAdapter;
+
+/**
+ * @author unattributed
+ */
+@XmlRootElement(name = "reconnectionRequestMessage")
+public class ReconnectionRequestMessage extends ProtocolMessage {
+
+    private NodeIdentifier nodeId;
+    private StandardDataFlow dataFlow;
+    private boolean primary;
+    private Integer managerRemoteSiteListeningPort;
+    private Boolean managerRemoteSiteCommsSecure;
+    private String instanceId;
+    
+    public ReconnectionRequestMessage() {}
+
+    @XmlJavaTypeAdapter(NodeIdentifierAdapter.class)
+    public NodeIdentifier getNodeId() {
+        return nodeId;
+    }
+
+    public void setNodeId(NodeIdentifier nodeId) {
+        this.nodeId = nodeId;
+    }
+
+    public StandardDataFlow getDataFlow() {
+        return dataFlow;
+    }
+
+    public void setDataFlow(StandardDataFlow dataFlow) {
+        this.dataFlow = dataFlow;
+    }
+
+    public boolean isPrimary() {
+        return primary;
+    }
+
+    public void setPrimary(boolean primary) {
+        this.primary = primary;
+    }
+    
+    @Override
+    public MessageType getType() {
+        return MessageType.RECONNECTION_REQUEST;
+    }
+    
+    public void setManagerRemoteSiteListeningPort(final Integer listeningPort) {
+        this.managerRemoteSiteListeningPort = listeningPort;
+    }
+    
+    public Integer getManagerRemoteSiteListeningPort() {
+        return managerRemoteSiteListeningPort;
+    }
+    
+    public void setManagerRemoteSiteCommsSecure(final Boolean remoteSiteCommsSecure) {
+        this.managerRemoteSiteCommsSecure = remoteSiteCommsSecure;
+    }
+    
+    public Boolean isManagerRemoteSiteCommsSecure() {
+        return managerRemoteSiteCommsSecure;
+    }
+    
+    public void setInstanceId(final String instanceId) {
+        this.instanceId = instanceId;
+    }
+    
+    public String getInstanceId() {
+        return instanceId;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ReconnectionResponseMessage.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ReconnectionResponseMessage.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ReconnectionResponseMessage.java
new file mode 100644
index 0000000..fd0f921
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ReconnectionResponseMessage.java
@@ -0,0 +1,32 @@
+/*
+ * 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.nifi.cluster.protocol.message;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ * This message is used an "ACK" for a ReconnectionRequestMessage
+ */
+@XmlRootElement(name = "reconnectionResponseMessage")
+public class ReconnectionResponseMessage extends ProtocolMessage {
+
+    @Override
+    public MessageType getType() {
+        return MessageType.RECONNECTION_RESPONSE;
+    }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ServiceBroadcastMessage.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ServiceBroadcastMessage.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ServiceBroadcastMessage.java
new file mode 100644
index 0000000..92708ba
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/message/ServiceBroadcastMessage.java
@@ -0,0 +1,64 @@
+/*
+ * 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.nifi.cluster.protocol.message;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ * @author unattributed
+ */
+@XmlRootElement(name = "serviceBroadcastMessage")
+public class ServiceBroadcastMessage extends ProtocolMessage {
+
+    private String serviceName;
+    
+    private String address;
+    
+    private int port;
+    
+    public ServiceBroadcastMessage() {}
+
+    public String getServiceName() {
+        return serviceName;
+    }
+
+    public void setServiceName(String serviceName) {
+        this.serviceName = serviceName;
+    }
+
+    public String getAddress() {
+        return address;
+    }
+
+    public void setAddress(String address) {
+        this.address = address;
+    }
+
+    public int getPort() {
+        return port;
+    }
+
+    public void setPort(int port) {
+        this.port = port;
+    }
+
+    @Override
+    public MessageType getType() {
+        return MessageType.SERVICE_BROADCAST;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/spring/MulticastConfigurationFactoryBean.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/spring/MulticastConfigurationFactoryBean.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/spring/MulticastConfigurationFactoryBean.java
new file mode 100644
index 0000000..fa201bb
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/spring/MulticastConfigurationFactoryBean.java
@@ -0,0 +1,60 @@
+/*
+ * 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.nifi.cluster.protocol.spring;
+
+import java.util.concurrent.TimeUnit;
+
+import org.apache.nifi.io.socket.multicast.MulticastConfiguration;
+import org.apache.nifi.util.FormatUtils;
+import org.apache.nifi.util.NiFiProperties;
+import org.springframework.beans.factory.FactoryBean;
+
+/**
+ * Factory bean for creating a singleton MulticastConfiguration instance.  
+ */
+public class MulticastConfigurationFactoryBean implements FactoryBean {
+    
+    private MulticastConfiguration configuration;
+    private NiFiProperties properties;
+    
+    @Override
+    public Object getObject() throws Exception {
+        if(configuration == null) {
+            configuration = new MulticastConfiguration();
+            
+            final int timeout = (int) FormatUtils.getTimeDuration(properties.getClusterProtocolSocketTimeout(), TimeUnit.MILLISECONDS);
+            configuration.setSocketTimeout(timeout);
+            configuration.setReuseAddress(true);
+        }
+        return configuration;
+
+    }
+
+    @Override
+    public Class getObjectType() {
+        return MulticastConfiguration.class;
+    }
+
+    @Override
+    public boolean isSingleton() {
+        return true;
+    }
+    
+    public void setProperties(NiFiProperties properties) {
+        this.properties = properties;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/spring/ServerSocketConfigurationFactoryBean.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/spring/ServerSocketConfigurationFactoryBean.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/spring/ServerSocketConfigurationFactoryBean.java
new file mode 100644
index 0000000..5b5816d
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/spring/ServerSocketConfigurationFactoryBean.java
@@ -0,0 +1,65 @@
+/*
+ * 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.nifi.cluster.protocol.spring;
+
+import java.util.concurrent.TimeUnit;
+
+import org.apache.nifi.io.socket.SSLContextFactory;
+import org.apache.nifi.io.socket.ServerSocketConfiguration;
+import org.apache.nifi.util.FormatUtils;
+import org.apache.nifi.util.NiFiProperties;
+
+import org.springframework.beans.factory.FactoryBean;
+
+/**
+ * Factory bean for creating a singleton ServerSocketConfiguration instance.  
+ */
+public class ServerSocketConfigurationFactoryBean implements FactoryBean<ServerSocketConfiguration> {
+    private ServerSocketConfiguration configuration;
+    private NiFiProperties properties;
+    
+    @Override
+    public ServerSocketConfiguration getObject() throws Exception {
+        if(configuration == null) {
+            configuration = new ServerSocketConfiguration();
+            configuration.setNeedClientAuth(properties.getNeedClientAuth());
+            
+            final int timeout = (int) FormatUtils.getTimeDuration(properties.getClusterProtocolSocketTimeout(), TimeUnit.MILLISECONDS);
+            configuration.setSocketTimeout(timeout);
+            configuration.setReuseAddress(true);
+            if(Boolean.valueOf(properties.getProperty(NiFiProperties.CLUSTER_PROTOCOL_IS_SECURE))) {
+                configuration.setSSLContextFactory(new SSLContextFactory(properties));
+            }
+        }
+        return configuration;
+
+    }
+
+    @Override
+    public Class<ServerSocketConfiguration> getObjectType() {
+        return ServerSocketConfiguration.class;
+    }
+
+    @Override
+    public boolean isSingleton() {
+        return true;
+    }
+    
+    public void setProperties(NiFiProperties properties) {
+        this.properties = properties;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/spring/SocketConfigurationFactoryBean.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/spring/SocketConfigurationFactoryBean.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/spring/SocketConfigurationFactoryBean.java
new file mode 100644
index 0000000..b438e44
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/spring/SocketConfigurationFactoryBean.java
@@ -0,0 +1,66 @@
+/*
+ * 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.nifi.cluster.protocol.spring;
+
+import java.util.concurrent.TimeUnit;
+
+import org.apache.nifi.io.socket.SSLContextFactory;
+import org.apache.nifi.io.socket.SocketConfiguration;
+import org.apache.nifi.util.FormatUtils;
+import org.apache.nifi.util.NiFiProperties;
+
+import org.springframework.beans.factory.FactoryBean;
+
+/**
+ * Factory bean for creating a singleton SocketConfiguration instance.  
+ */
+public class SocketConfigurationFactoryBean implements FactoryBean<SocketConfiguration> {
+    
+    private SocketConfiguration configuration;
+    
+    private NiFiProperties properties;
+    
+    @Override
+    public SocketConfiguration getObject() throws Exception {
+        if(configuration == null) {
+            configuration = new SocketConfiguration();
+            
+            final int timeout = (int) FormatUtils.getTimeDuration(properties.getClusterProtocolSocketTimeout(), TimeUnit.MILLISECONDS);
+            configuration.setSocketTimeout(timeout);
+            configuration.setReuseAddress(true);
+            if(Boolean.valueOf(properties.getProperty(NiFiProperties.CLUSTER_PROTOCOL_IS_SECURE))) {
+                configuration.setSSLContextFactory(new SSLContextFactory(properties));
+            }
+        }
+        return configuration;
+
+    }
+
+    @Override
+    public Class<SocketConfiguration> getObjectType() {
+        return SocketConfiguration.class;
+    }
+
+    @Override
+    public boolean isSingleton() {
+        return true;
+    }
+    
+    public void setProperties(NiFiProperties properties) {
+        this.properties = properties;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/resources/nifi-cluster-protocol-context.xml
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/resources/nifi-cluster-protocol-context.xml b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/resources/nifi-cluster-protocol-context.xml
new file mode 100644
index 0000000..07ea7a4
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/resources/nifi-cluster-protocol-context.xml
@@ -0,0 +1,110 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+<!-- marked as lazy so that cluster protocol beans are not created when applications runs in standalone mode -->
+<beans default-lazy-init="true"
+       xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:util="http://www.springframework.org/schema/util"
+       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
+        http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.1.xsd">
+
+    <!-- protocol context -->
+    <bean id="protocolContext" class="org.apache.nifi.cluster.protocol.jaxb.JaxbProtocolContext">
+        <constructor-arg>
+            <util:constant static-field="org.apache.nifi.cluster.protocol.jaxb.message.JaxbProtocolUtils.JAXB_CONTEXT"/>
+        </constructor-arg>
+    </bean>
+    
+    <!-- socket configuration -->
+    <bean id="protocolSocketConfiguration" class="org.apache.nifi.cluster.protocol.spring.SocketConfigurationFactoryBean">
+        <property name="properties" ref="nifiProperties"/>
+    </bean>
+    
+    <!-- server socket configuration -->
+    <bean id="protocolServerSocketConfiguration" class="org.apache.nifi.cluster.protocol.spring.ServerSocketConfigurationFactoryBean">
+        <property name="properties" ref="nifiProperties"/>
+    </bean>
+    
+    <!-- multicast configuration -->
+    <bean id="protocolMulticastConfiguration" class="org.apache.nifi.cluster.protocol.spring.MulticastConfigurationFactoryBean">
+        <property name="properties" ref="nifiProperties"/>
+    </bean>
+
+    <!-- cluster manager protocol sender -->
+    <bean id="clusterManagerProtocolSender" class="org.apache.nifi.cluster.protocol.impl.ClusterManagerProtocolSenderImpl">
+        <constructor-arg ref="protocolSocketConfiguration"/>
+        <constructor-arg ref="protocolContext"/>
+        <property name="handshakeTimeout">
+            <bean factory-bean="nifiProperties" factory-method="getClusterProtocolConnectionHandshakeTimeout"/>
+        </property>
+    </bean>
+    
+    <!-- cluster manager protocol listener -->
+    <bean id="clusterManagerProtocolListener" class="org.apache.nifi.cluster.protocol.impl.SocketProtocolListener">
+        <constructor-arg index="0">
+            <bean factory-bean="nifiProperties" factory-method="getClusterManagerProtocolThreads"/>
+        </constructor-arg>
+        <constructor-arg index="1">
+            <bean factory-bean="nifiProperties" factory-method="getClusterManagerProtocolPort"/>
+        </constructor-arg>
+        <constructor-arg ref="protocolServerSocketConfiguration" index="2"/>
+        <constructor-arg ref="protocolContext" index="3"/>
+    </bean>
+    
+    <!-- cluster manager sender/listener -->
+    <bean id="clusterManagerProtocolSenderListener" class="org.apache.nifi.cluster.protocol.impl.ClusterManagerProtocolSenderListener">
+        <constructor-arg ref="clusterManagerProtocolSender"/>
+        <constructor-arg ref="clusterManagerProtocolListener"/>
+    </bean>
+    
+    <!-- node protocol sender -->
+    <bean id="nodeProtocolSender" class="org.apache.nifi.cluster.protocol.impl.NodeProtocolSenderImpl">
+        <constructor-arg ref="clusterManagerProtocolServiceLocator"/>
+        <constructor-arg ref="protocolSocketConfiguration"/>
+        <constructor-arg ref="protocolContext"/>
+    </bean>
+    
+    <!-- node protocol listener -->
+    <bean id="nodeProtocolListener" class="org.apache.nifi.cluster.protocol.impl.SocketProtocolListener">
+        <constructor-arg index="0">
+            <bean factory-bean="nifiProperties" factory-method="getClusterNodeProtocolThreads"/>
+        </constructor-arg>
+        <constructor-arg index="1">
+            <bean factory-bean="nifiProperties" factory-method="getClusterNodeProtocolPort"/>
+        </constructor-arg>
+        <constructor-arg ref="protocolServerSocketConfiguration" index="2"/>
+        <constructor-arg ref="protocolContext" index="3"/>
+    </bean>
+    
+    <!-- node sender/listener -->
+    <bean id="nodeProtocolSenderListener" class="org.apache.nifi.cluster.protocol.impl.NodeProtocolSenderListener">
+        <constructor-arg ref="nodeProtocolSender"/>
+        <constructor-arg ref="nodeProtocolListener"/>
+    </bean>
+    
+    <!-- cluster services broadcaster -->
+    <bean id="clusterServicesBroadcaster" class="org.apache.nifi.cluster.protocol.impl.ClusterServicesBroadcaster">
+        <constructor-arg index="0">
+            <bean factory-bean="nifiProperties" factory-method="getClusterProtocolMulticastAddress"/>
+        </constructor-arg>
+        <constructor-arg ref="protocolMulticastConfiguration" index="1"/>
+        <constructor-arg ref="protocolContext" index="2"/>
+        <constructor-arg index="3">
+            <bean factory-bean="nifiProperties" factory-method="getClusterProtocolMulticastServiceBroadcastDelay"/>
+        </constructor-arg>
+    </bean>
+ 
+</beans>

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/ClusterManagerProtocolSenderImplTest.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/ClusterManagerProtocolSenderImplTest.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/ClusterManagerProtocolSenderImplTest.java
new file mode 100644
index 0000000..59837c1
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/ClusterManagerProtocolSenderImplTest.java
@@ -0,0 +1,134 @@
+/*
+ * 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.nifi.cluster.protocol.impl;
+
+import org.apache.nifi.cluster.protocol.impl.SocketProtocolListener;
+import org.apache.nifi.cluster.protocol.impl.ClusterManagerProtocolSenderImpl;
+import java.io.IOException;
+import java.net.InetAddress;
+import org.apache.nifi.cluster.protocol.NodeIdentifier;
+import org.apache.nifi.cluster.protocol.ProtocolContext;
+import org.apache.nifi.cluster.protocol.ProtocolException;
+import org.apache.nifi.cluster.protocol.ProtocolHandler;
+import org.apache.nifi.cluster.protocol.jaxb.JaxbProtocolContext;
+import org.apache.nifi.cluster.protocol.jaxb.message.JaxbProtocolUtils;
+import org.apache.nifi.cluster.protocol.message.FlowRequestMessage;
+import org.apache.nifi.cluster.protocol.message.FlowResponseMessage;
+import org.apache.nifi.cluster.protocol.message.PingMessage;
+import org.apache.nifi.cluster.protocol.message.ProtocolMessage;
+import org.apache.nifi.io.socket.ServerSocketConfiguration;
+import org.apache.nifi.io.socket.SocketConfiguration;
+import org.junit.After;
+import static org.junit.Assert.*;
+import org.junit.Before;
+import org.junit.Test;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.*;
+import org.mockito.invocation.InvocationOnMock;
+import org.mockito.stubbing.Answer;
+
+/**
+ * @author unattributed
+ */
+public class ClusterManagerProtocolSenderImplTest {
+    
+    private InetAddress address;
+    
+    private int port;
+    
+    private SocketProtocolListener listener;
+    
+    private ClusterManagerProtocolSenderImpl sender;
+    
+    private ProtocolHandler mockHandler;
+    
+    @Before
+    public void setup() throws IOException {
+        
+        address = InetAddress.getLocalHost();
+        ServerSocketConfiguration serverSocketConfiguration = new ServerSocketConfiguration();
+        serverSocketConfiguration.setSocketTimeout(2000);
+
+        mockHandler = mock(ProtocolHandler.class);
+        
+        ProtocolContext protocolContext = new JaxbProtocolContext(JaxbProtocolUtils.JAXB_CONTEXT);
+        
+        listener = new SocketProtocolListener(5, 0, serverSocketConfiguration, protocolContext);
+        listener.addHandler(mockHandler);
+        listener.start();
+        
+        port = listener.getPort();
+        
+        SocketConfiguration socketConfiguration = new SocketConfiguration();
+        sender = new ClusterManagerProtocolSenderImpl(socketConfiguration, protocolContext);
+    }
+    
+    @After
+    public void teardown() throws IOException {
+        if(listener.isRunning()) {
+            listener.stop();
+        }
+    }
+    
+    @Test
+    public void testRequestFlow() throws Exception {
+        
+        when(mockHandler.canHandle(any(ProtocolMessage.class))).thenReturn(Boolean.TRUE);
+        when(mockHandler.handle(any(ProtocolMessage.class))).thenReturn(new FlowResponseMessage());
+        FlowRequestMessage request = new FlowRequestMessage();
+        request.setNodeId(new NodeIdentifier("id", "api-address", 1, address.getHostAddress(), port));
+        FlowResponseMessage response = sender.requestFlow(request);
+        assertNotNull(response);
+    }
+    
+    @Test
+    public void testRequestFlowWithBadResponseMessage() throws Exception {
+        
+        when(mockHandler.canHandle(any(ProtocolMessage.class))).thenReturn(Boolean.TRUE);
+        when(mockHandler.handle(any(ProtocolMessage.class))).thenReturn(new PingMessage());
+        FlowRequestMessage request = new FlowRequestMessage();
+        request.setNodeId(new NodeIdentifier("id", "api-address", 1, address.getHostAddress(), port));
+        try {
+            sender.requestFlow(request);
+            fail("failed to throw exception");
+        } catch(ProtocolException pe) {}
+        
+    }
+    
+    @Test
+    public void testRequestFlowDelayedResponse() throws Exception {
+        
+        final int time = 250;
+        sender.getSocketConfiguration().setSocketTimeout(time);
+        
+        when(mockHandler.canHandle(any(ProtocolMessage.class))).thenReturn(Boolean.TRUE);
+        when(mockHandler.handle(any(ProtocolMessage.class))).thenAnswer(new Answer<FlowResponseMessage>() {
+            @Override
+            public FlowResponseMessage answer(InvocationOnMock invocation) throws Throwable {
+                Thread.sleep(time * 3);
+                return new FlowResponseMessage();
+            }
+        });
+        FlowRequestMessage request = new FlowRequestMessage();
+        request.setNodeId(new NodeIdentifier("id", "api-address", 1, address.getHostAddress(), port));
+        try {
+            sender.requestFlow(request);
+            fail("failed to throw exception");
+        } catch(ProtocolException pe) {}
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/ClusterServiceDiscoveryTest.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/ClusterServiceDiscoveryTest.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/ClusterServiceDiscoveryTest.java
new file mode 100644
index 0000000..e3703e2
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/ClusterServiceDiscoveryTest.java
@@ -0,0 +1,135 @@
+/*
+ * 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.nifi.cluster.protocol.impl;
+
+import org.apache.nifi.cluster.protocol.impl.ClusterServiceDiscovery;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.net.DatagramPacket;
+import java.net.InetSocketAddress;
+import java.net.MulticastSocket;
+import org.apache.nifi.cluster.protocol.ProtocolContext;
+import org.apache.nifi.cluster.protocol.ProtocolMessageMarshaller;
+import org.apache.nifi.cluster.protocol.jaxb.JaxbProtocolContext;
+import org.apache.nifi.cluster.protocol.jaxb.message.JaxbProtocolUtils;
+import org.apache.nifi.cluster.protocol.message.PingMessage;
+import org.apache.nifi.cluster.protocol.message.ProtocolMessage;
+import org.apache.nifi.cluster.protocol.message.ServiceBroadcastMessage;
+import org.apache.nifi.io.socket.multicast.MulticastConfiguration;
+import org.apache.nifi.io.socket.multicast.MulticastUtils;
+import org.junit.After;
+import static org.junit.Assert.*;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ * @author unattributed
+ */
+public class ClusterServiceDiscoveryTest {
+    
+    private ClusterServiceDiscovery discovery;
+    
+    private String serviceName;
+    
+    private MulticastSocket socket;
+    
+    private InetSocketAddress multicastAddress;
+    
+    private MulticastConfiguration configuration;
+    
+    private ProtocolContext protocolContext;
+    
+    @Before
+    public void setup() throws Exception {
+
+        serviceName = "some-service";
+        multicastAddress = new InetSocketAddress("225.1.1.1", 22222);
+        configuration = new MulticastConfiguration();
+        
+        protocolContext = new JaxbProtocolContext(JaxbProtocolUtils.JAXB_CONTEXT);
+        
+        discovery = new ClusterServiceDiscovery(serviceName, multicastAddress, configuration, protocolContext);
+        discovery.start();
+
+        socket = MulticastUtils.createMulticastSocket(multicastAddress.getPort(), configuration);
+    }
+    
+    @After
+    public void teardown() throws IOException {
+        try {
+            if(discovery.isRunning()) {
+                discovery.stop();
+            }
+        } finally {
+            MulticastUtils.closeQuietly(socket);
+        }
+    }
+    
+    @Ignore("Test needs to be fixed.  Requires an active network connection")
+    @Test
+    public void testGetAddressOnStartup() {
+        assertNull(discovery.getService());
+    }   
+            
+    @Ignore("This test has an NPE after ignoring another...perhaps has a bad inter-test dependency")
+    @Test
+    public void testGetAddressAfterBroadcast() throws Exception {
+        
+        ServiceBroadcastMessage msg = new ServiceBroadcastMessage();
+        msg.setServiceName("some-service");
+        msg.setAddress("3.3.3.3");
+        msg.setPort(1234);
+        
+        // marshal message to output stream
+        ProtocolMessageMarshaller marshaller = protocolContext.createMarshaller();
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        marshaller.marshal(msg, baos);
+        byte[] requestPacketBytes = baos.toByteArray();
+        DatagramPacket packet = new DatagramPacket(requestPacketBytes, requestPacketBytes.length, multicastAddress);
+        socket.send(packet);
+        
+        Thread.sleep(250);
+       
+        InetSocketAddress updatedAddress = discovery.getService().getServiceAddress();
+        assertEquals("some-service", discovery.getServiceName());
+        assertEquals("3.3.3.3", updatedAddress.getHostName());
+        assertEquals(1234, updatedAddress.getPort());
+        
+    }
+    
+    @Ignore("Test needs to be fixed.  Requires an active network connection")
+    @Test
+    public void testBadBroadcastMessage() throws Exception {
+        
+        ProtocolMessage msg = new PingMessage();
+        
+        // marshal message to output stream
+        ProtocolMessageMarshaller marshaller = protocolContext.createMarshaller();
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        marshaller.marshal(msg, baos);
+        byte[] requestPacketBytes = baos.toByteArray();
+        DatagramPacket packet = new DatagramPacket(requestPacketBytes, requestPacketBytes.length, multicastAddress);
+        socket.send(packet);
+        
+        Thread.sleep(250);
+       
+        assertNull(discovery.getService());
+        
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/ClusterServiceLocatorTest.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/ClusterServiceLocatorTest.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/ClusterServiceLocatorTest.java
new file mode 100644
index 0000000..b1c156b
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/ClusterServiceLocatorTest.java
@@ -0,0 +1,121 @@
+/*
+ * 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.nifi.cluster.protocol.impl;
+
+import org.apache.nifi.cluster.protocol.impl.ClusterServiceLocator;
+import org.apache.nifi.cluster.protocol.impl.ClusterServiceDiscovery;
+import java.net.InetSocketAddress;
+import java.util.concurrent.TimeUnit;
+import org.apache.nifi.io.socket.multicast.DiscoverableService;
+import org.apache.nifi.io.socket.multicast.DiscoverableServiceImpl;
+import static org.junit.Assert.*;
+import org.junit.Before;
+import org.junit.Test;
+import static org.mockito.Mockito.*;
+import org.mockito.stubbing.OngoingStubbing;
+
+public class ClusterServiceLocatorTest {
+    
+    private ClusterServiceDiscovery mockServiceDiscovery;
+    
+    private int fixedPort;
+    
+    private DiscoverableService fixedService;
+    
+    private ClusterServiceLocator serviceDiscoveryLocator;
+    
+    private ClusterServiceLocator serviceDiscoveryFixedPortLocator;
+    
+    private ClusterServiceLocator fixedServiceLocator;
+    
+    @Before
+    public void setup() throws Exception {
+        
+        fixedPort = 1;
+        mockServiceDiscovery = mock(ClusterServiceDiscovery.class);
+        fixedService = new DiscoverableServiceImpl("some-service", InetSocketAddress.createUnresolved("some-host", 20));
+        
+        serviceDiscoveryLocator = new ClusterServiceLocator(mockServiceDiscovery);
+        serviceDiscoveryFixedPortLocator = new ClusterServiceLocator(mockServiceDiscovery, fixedPort);
+        fixedServiceLocator = new ClusterServiceLocator(fixedService);
+        
+    }
+    
+    @Test
+    public void getServiceWhenServiceDiscoveryNotStarted() {
+        assertNull(serviceDiscoveryLocator.getService());
+    }
+    
+    @Test
+    public void getServiceWhenServiceDiscoveryFixedPortNotStarted() {
+        assertNull(serviceDiscoveryLocator.getService());
+    }
+    
+    @Test
+    public void getServiceWhenFixedServiceNotStarted() {
+        assertEquals(fixedService, fixedServiceLocator.getService());
+    }
+    
+    @Test
+    public void getServiceNotOnFirstAttempt() {
+                
+        ClusterServiceLocator.AttemptsConfig config = new ClusterServiceLocator.AttemptsConfig();
+        config.setNumAttempts(2);
+        config.setTimeBetweenAttempsUnit(TimeUnit.SECONDS);
+        config.setTimeBetweenAttempts(1);
+        
+        serviceDiscoveryLocator.setAttemptsConfig(config);
+        
+        OngoingStubbing<DiscoverableService> stubbing = null;
+        for(int i = 0; i < config.getNumAttempts() - 1; i++) {
+            if(stubbing == null) {
+                stubbing = when(mockServiceDiscovery.getService()).thenReturn(null);
+            } else {
+                stubbing.thenReturn(null);
+            }
+        }
+        stubbing.thenReturn(fixedService);
+        
+        assertEquals(fixedService, serviceDiscoveryLocator.getService());
+        
+    }
+    
+    @Test
+    public void getServiceNotOnFirstAttemptWithFixedPort() {
+        
+        ClusterServiceLocator.AttemptsConfig config = new ClusterServiceLocator.AttemptsConfig();
+        config.setNumAttempts(2);
+        config.setTimeBetweenAttempsUnit(TimeUnit.SECONDS);
+        config.setTimeBetweenAttempts(1);
+        
+        serviceDiscoveryFixedPortLocator.setAttemptsConfig(config);
+        
+        OngoingStubbing<DiscoverableService> stubbing = null;
+        for(int i = 0; i < config.getNumAttempts() - 1; i++) {
+            if(stubbing == null) {
+                stubbing = when(mockServiceDiscovery.getService()).thenReturn(null);
+            } else {
+                stubbing.thenReturn(null);
+            }
+        }
+        stubbing.thenReturn(fixedService);
+        
+        InetSocketAddress resultAddress = InetSocketAddress.createUnresolved(fixedService.getServiceAddress().getHostName(), fixedPort);
+        DiscoverableService resultService = new DiscoverableServiceImpl(fixedService.getServiceName(), resultAddress);
+        assertEquals(resultService, serviceDiscoveryFixedPortLocator.getService());
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/ClusterServicesBroadcasterTest.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/ClusterServicesBroadcasterTest.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/ClusterServicesBroadcasterTest.java
new file mode 100644
index 0000000..ec1f26d
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/test/java/org/apache/nifi/cluster/protocol/impl/ClusterServicesBroadcasterTest.java
@@ -0,0 +1,133 @@
+/*
+ * 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.nifi.cluster.protocol.impl;
+
+import org.apache.nifi.cluster.protocol.impl.ClusterServicesBroadcaster;
+import org.apache.nifi.cluster.protocol.impl.MulticastProtocolListener;
+import java.net.InetSocketAddress;
+import org.apache.nifi.cluster.protocol.ProtocolContext;
+import org.apache.nifi.cluster.protocol.ProtocolException;
+import org.apache.nifi.cluster.protocol.ProtocolHandler;
+import org.apache.nifi.cluster.protocol.jaxb.JaxbProtocolContext;
+import org.apache.nifi.cluster.protocol.jaxb.message.JaxbProtocolUtils;
+import org.apache.nifi.cluster.protocol.message.ProtocolMessage;
+import org.apache.nifi.cluster.protocol.message.ServiceBroadcastMessage;
+import org.apache.nifi.io.socket.multicast.DiscoverableService;
+import org.apache.nifi.io.socket.multicast.DiscoverableServiceImpl;
+import org.apache.nifi.io.socket.multicast.MulticastConfiguration;
+import org.junit.After;
+import static org.junit.Assert.*;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ * @author unattributed
+ */
+public class ClusterServicesBroadcasterTest {
+    
+    private ClusterServicesBroadcaster broadcaster;
+    
+    private MulticastProtocolListener listener;
+    
+    private DummyProtocolHandler handler;
+    
+    private InetSocketAddress multicastAddress;
+    
+    private DiscoverableService broadcastedService;
+
+    private ProtocolContext protocolContext;
+    
+    private MulticastConfiguration configuration;
+    
+    @Before
+    public void setup() throws Exception {
+
+        broadcastedService = new DiscoverableServiceImpl("some-service", new InetSocketAddress("localhost", 11111));
+        
+        multicastAddress = new InetSocketAddress("225.1.1.1", 22222);
+        
+        configuration = new MulticastConfiguration();
+        
+        protocolContext = new JaxbProtocolContext(JaxbProtocolUtils.JAXB_CONTEXT);
+        
+        broadcaster = new ClusterServicesBroadcaster(multicastAddress, configuration, protocolContext, "500 ms");
+        broadcaster.addService(broadcastedService);
+        
+        handler = new DummyProtocolHandler();
+        listener = new MulticastProtocolListener(5, multicastAddress, configuration, protocolContext);
+        listener.addHandler(handler);
+    }
+    
+    @After
+    public void teardown() {
+        
+        if(broadcaster.isRunning()) {
+            broadcaster.stop();
+        }
+        
+        try {
+            if(listener.isRunning()) {
+                listener.stop();
+            }
+        } catch(Exception ex) {
+            ex.printStackTrace(System.out);
+        }
+        
+    }
+    
+    @Ignore("fails needs to be fixed")
+    @Test
+    public void testBroadcastReceived() throws Exception {
+        
+        broadcaster.start();
+        listener.start();
+        
+        Thread.sleep(1000);
+        
+        listener.stop();
+        
+        assertNotNull(handler.getProtocolMessage());
+        assertEquals(ProtocolMessage.MessageType.SERVICE_BROADCAST, handler.getProtocolMessage().getType());
+        final ServiceBroadcastMessage msg = (ServiceBroadcastMessage) handler.getProtocolMessage();
+        assertEquals(broadcastedService.getServiceName(), msg.getServiceName());
+        assertEquals(broadcastedService.getServiceAddress().getHostName(), msg.getAddress());
+        assertEquals(broadcastedService.getServiceAddress().getPort(), msg.getPort());
+    }
+    
+    private class DummyProtocolHandler implements ProtocolHandler {
+
+        private ProtocolMessage protocolMessage;
+        
+        @Override
+        public boolean canHandle(ProtocolMessage msg) {
+            return true;
+        }
+
+        @Override
+        public ProtocolMessage handle(ProtocolMessage msg) throws ProtocolException {
+            this.protocolMessage = msg;
+            return null;
+        }
+        
+        public ProtocolMessage getProtocolMessage() {
+            return protocolMessage;
+        }
+        
+    }
+    
+}


[10/20] incubator-nifi git commit: NIFI-410 pushed RAT exclusions down to the relevant modules and stopped doing broad test resource exclusion - is now specific

Posted by jo...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ConnectionResponse.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ConnectionResponse.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ConnectionResponse.java
new file mode 100644
index 0000000..7a5ff2b
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ConnectionResponse.java
@@ -0,0 +1,141 @@
+/*
+ * 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.nifi.cluster.protocol;
+
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+
+import org.apache.nifi.cluster.protocol.jaxb.message.ConnectionResponseAdapter;
+
+/**
+ * The cluster manager's response to a node's connection request.  If the manager
+ * has a current copy of the data flow, then it is returned with a node identifier
+ * to the node.  Otherwise, the manager will provide a "try again in X seconds" 
+ * response to the node in hopes that a current data flow will be available upon
+ * subsequent requests.
+ * 
+ * @author unattributed
+ */
+@XmlJavaTypeAdapter(ConnectionResponseAdapter.class)
+public class ConnectionResponse {
+
+    private final boolean blockedByFirewall;
+    private final int tryLaterSeconds;
+    private final NodeIdentifier nodeIdentifier;
+    private final StandardDataFlow dataFlow;
+    private final boolean primary;
+    private final Integer managerRemoteInputPort;
+    private final Boolean managerRemoteCommsSecure;
+    private final String instanceId;
+    
+    private volatile String clusterManagerDN;
+    
+    public ConnectionResponse(final NodeIdentifier nodeIdentifier, final StandardDataFlow dataFlow, final boolean primary, 
+        final Integer managerRemoteInputPort, final Boolean managerRemoteCommsSecure, final String instanceId) {
+        if(nodeIdentifier == null) {
+            throw new IllegalArgumentException("Node identifier may not be empty or null.");
+        } else if(dataFlow == null) {
+            throw new IllegalArgumentException("DataFlow may not be null.");
+        }
+        this.nodeIdentifier = nodeIdentifier;
+        this.dataFlow = dataFlow;
+        this.tryLaterSeconds = 0;
+        this.blockedByFirewall = false;
+        this.primary = primary;
+        this.managerRemoteInputPort = managerRemoteInputPort;
+        this.managerRemoteCommsSecure = managerRemoteCommsSecure;
+        this.instanceId = instanceId;
+    }
+    
+    public ConnectionResponse(final int tryLaterSeconds) {
+        if(tryLaterSeconds <= 0) {
+            throw new IllegalArgumentException("Try-Later seconds may not be nonnegative: " + tryLaterSeconds);
+        }
+        this.dataFlow = null;
+        this.nodeIdentifier = null;
+        this.tryLaterSeconds = tryLaterSeconds;
+        this.blockedByFirewall = false;
+        this.primary = false;
+        this.managerRemoteInputPort = null;
+        this.managerRemoteCommsSecure = null;
+        this.instanceId = null;
+    }
+
+    private ConnectionResponse() {
+        this.dataFlow = null;
+        this.nodeIdentifier = null;
+        this.tryLaterSeconds = 0;
+        this.blockedByFirewall = true;
+        this.primary = false;
+        this.managerRemoteInputPort = null;
+        this.managerRemoteCommsSecure = null;
+        this.instanceId = null;
+    }
+    
+    public static ConnectionResponse createBlockedByFirewallResponse() {
+        return new ConnectionResponse();
+    }
+    
+    public boolean isPrimary() {
+        return primary;
+    }
+    
+    public boolean shouldTryLater() {
+        return tryLaterSeconds > 0;
+    }
+    
+    public boolean isBlockedByFirewall() {
+        return blockedByFirewall;
+    }
+
+    public int getTryLaterSeconds() {
+        return tryLaterSeconds;
+    }
+    
+    public StandardDataFlow getDataFlow() {
+        return dataFlow;
+    }
+    
+    public NodeIdentifier getNodeIdentifier() {
+        return nodeIdentifier;
+    }
+
+    public Integer getManagerRemoteInputPort() {
+        return managerRemoteInputPort;
+    }
+    
+    public Boolean isManagerRemoteCommsSecure() {
+        return managerRemoteCommsSecure;
+    }
+    
+    public String getInstanceId() {
+        return instanceId;
+    }
+    
+    public void setClusterManagerDN(final String dn) {
+        this.clusterManagerDN = dn;
+    }
+    
+    /**
+     * Returns the DN of the NCM, if it is available or <code>null</code> otherwise.
+     * 
+     * @return
+     */
+    public String getClusterManagerDN() {
+        return clusterManagerDN;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/Heartbeat.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/Heartbeat.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/Heartbeat.java
new file mode 100644
index 0000000..67324a1
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/Heartbeat.java
@@ -0,0 +1,68 @@
+/*
+ * 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.nifi.cluster.protocol;
+
+import java.util.Date;
+import javax.xml.bind.annotation.XmlTransient;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+import org.apache.nifi.cluster.protocol.jaxb.message.HeartbeatAdapter;
+
+/**
+ * A heartbeat for indicating the status of a node to the cluster.
+ * @author unattributed
+ */
+@XmlJavaTypeAdapter(HeartbeatAdapter.class)
+public class Heartbeat {
+    
+    private final NodeIdentifier nodeIdentifier;
+    private final boolean primary;
+    private final boolean connected;
+    private final long createdTimestamp;
+    private final byte[] payload;
+    
+    public Heartbeat(final NodeIdentifier nodeIdentifier, final boolean primary, final boolean connected, final byte[] payload) {
+        if(nodeIdentifier == null) {
+            throw new IllegalArgumentException("Node Identifier may not be null.");
+        } 
+        this.nodeIdentifier = nodeIdentifier;
+        this.primary = primary;
+        this.connected = connected;
+        this.payload = payload;
+        this.createdTimestamp = new Date().getTime();
+    }
+    
+    public NodeIdentifier getNodeIdentifier() {
+        return nodeIdentifier;
+    }
+    
+    public byte[] getPayload() {
+        return payload;
+    }
+    
+    public boolean isPrimary() {
+        return primary;
+    }
+    
+    public boolean isConnected() {
+        return connected;
+    }
+    
+    @XmlTransient
+    public long getCreatedTimestamp() {
+        return createdTimestamp;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/NodeBulletins.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/NodeBulletins.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/NodeBulletins.java
new file mode 100644
index 0000000..a120524
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/NodeBulletins.java
@@ -0,0 +1,44 @@
+/*
+ * 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.nifi.cluster.protocol;
+
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+import org.apache.nifi.cluster.protocol.jaxb.message.NodeBulletinsAdapter;
+
+/**
+ *
+ */
+@XmlJavaTypeAdapter(NodeBulletinsAdapter.class)
+public class NodeBulletins {
+
+    private final NodeIdentifier nodeIdentifier;
+    private final byte[] payload;
+
+    public NodeBulletins(NodeIdentifier nodeIdentifier, byte[] payload) {
+        this.nodeIdentifier = nodeIdentifier;
+        this.payload = payload;
+    }
+
+    public NodeIdentifier getNodeIdentifier() {
+        return nodeIdentifier;
+    }
+
+    public byte[] getPayload() {
+        return payload;
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/NodeIdentifier.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/NodeIdentifier.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/NodeIdentifier.java
new file mode 100644
index 0000000..1893186
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/NodeIdentifier.java
@@ -0,0 +1,172 @@
+/*
+ * 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.nifi.cluster.protocol;
+
+import org.apache.commons.lang3.StringUtils;
+
+/**
+ * A node identifier denoting the coordinates of a flow controller that is connected 
+ * to a cluster.  Nodes provide an external public API interface and an internal private
+ * interface for communicating with the cluster.
+ * 
+ * The external API interface and internal protocol each require an IP or hostname 
+ * as well as a port for communicating. 
+ * 
+ * This class overrides hashCode and equals and considers two instances to be
+ * equal if they have the equal IDs.
+ * 
+ * @author unattributed
+ * @Immutable
+ * @Threadsafe
+ */
+public class NodeIdentifier {
+ 
+    /** the unique identifier for the node */
+    private final String id;
+    
+    /** the IP or hostname to use for sending requests to the node's external interface */
+    private final String apiAddress;
+    
+    /** the port to use use for sending requests to the node's external interface */
+    private final int apiPort;    
+    
+    /** the IP or hostname to use for sending requests to the node's internal interface */
+    private final String socketAddress;
+    
+    /** the port to use use for sending requests to the node's internal interface */
+    private final int socketPort;
+    
+    private final String nodeDn;
+
+    public NodeIdentifier(final String id, final String apiAddress, final int apiPort, final String socketAddress, final int socketPort) {
+        this(id, apiAddress, apiPort, socketAddress, socketPort, null);
+    }
+    
+    public NodeIdentifier(final String id, final String apiAddress, final int apiPort, final String socketAddress, final int socketPort, final String dn) {
+        
+        if(StringUtils.isBlank(id)) {
+            throw new IllegalArgumentException("Node ID may not be empty or null.");
+        } else if(StringUtils.isBlank(apiAddress)) {
+            throw new IllegalArgumentException("Node API address may not be empty or null.");
+        } else if(StringUtils.isBlank(socketAddress)) {
+            throw new IllegalArgumentException("Node socket address may not be empty or null.");
+        } 
+        
+        validatePort(apiPort);
+        validatePort(socketPort);
+        
+        this.id = id;
+        this.apiAddress = apiAddress;
+        this.apiPort = apiPort;
+        this.socketAddress = socketAddress;
+        this.socketPort = socketPort;
+        this.nodeDn = dn;
+    }
+
+    public String getId() {
+        return id;
+    }
+    
+    public String getDN() {
+        return nodeDn;
+    }
+    
+    public String getApiAddress() {
+        return apiAddress;
+    }
+
+    public int getApiPort() {
+        return apiPort;
+    }
+
+    public String getSocketAddress() {
+        return socketAddress;
+    }
+    
+    public int getSocketPort() {
+        return socketPort;
+    }
+    
+    private void validatePort(final int port) {
+        if(port < 1 || port > 65535) {
+            throw new IllegalArgumentException("Port must be inclusively in the range [1, 65535].  Port given: " + port);
+        }   
+    }
+    
+    /**
+     * Compares the id of two node identifiers for equality.
+     * 
+     * @param obj a node identifier
+     * 
+     * @return true if the id is equal; false otherwise
+     */
+    @Override
+    public boolean equals(Object obj) {
+        if (obj == null) {
+            return false;
+        }
+        if (getClass() != obj.getClass()) {
+            return false;
+        }
+        final NodeIdentifier other = (NodeIdentifier) obj;
+        if ((this.id == null) ? (other.id != null) : !this.id.equals(other.id)) {
+            return false;
+        }
+        return true;
+    }
+
+    /**
+     * Compares API address/port and socket address/port for equality.  The 
+     * id is not used for comparison.
+     * 
+     * @param other a node identifier
+     * 
+     * @return true if API address/port and socket address/port are equal; false
+     * otherwise
+     */
+    public boolean logicallyEquals(final NodeIdentifier other) {
+        if(other == null) {
+            return false;
+        }
+        if ((this.apiAddress == null) ? (other.apiAddress != null) : !this.apiAddress.equals(other.apiAddress)) {
+            return false;
+        }
+        if(this.apiPort != other.apiPort) {
+            return false;
+        }
+        if ((this.socketAddress == null) ? (other.socketAddress != null) : !this.socketAddress.equals(other.socketAddress)) {
+            return false;
+        }
+        if(this.socketPort != other.socketPort) {
+            return false;
+        }
+        return true;
+    }
+    
+    @Override
+    public int hashCode() {
+        int hash = 7;
+        hash = 31 * hash + (this.id != null ? this.id.hashCode() : 0);
+        return hash;
+    }
+
+    @Override
+    public String toString() {
+        return "[" + "id=" + id + ", apiAddress=" + apiAddress + ", apiPort=" + apiPort + ", socketAddress=" + socketAddress + ", socketPort=" + socketPort + ']';
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/NodeProtocolSender.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/NodeProtocolSender.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/NodeProtocolSender.java
new file mode 100644
index 0000000..1edcb91
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/NodeProtocolSender.java
@@ -0,0 +1,73 @@
+/*
+ * 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.nifi.cluster.protocol;
+
+import org.apache.nifi.cluster.protocol.message.ConnectionRequestMessage;
+import org.apache.nifi.cluster.protocol.message.ConnectionResponseMessage;
+import org.apache.nifi.cluster.protocol.message.ControllerStartupFailureMessage;
+import org.apache.nifi.cluster.protocol.message.HeartbeatMessage;
+import org.apache.nifi.cluster.protocol.message.NodeBulletinsMessage;
+import org.apache.nifi.cluster.protocol.message.ReconnectionFailureMessage;
+
+/**
+ * An interface for sending protocol messages from a node to the cluster manager.
+ * @author unattributed
+ */
+public interface NodeProtocolSender {
+    
+    /**
+     * Sends a "connection request" message to the cluster manager.
+     * @param msg a message
+     * @return the response
+     * @throws UnknownServiceAddressException if the cluster manager's address is not known
+     * @throws ProtocolException if communication failed
+     */
+    ConnectionResponseMessage requestConnection(ConnectionRequestMessage msg) throws ProtocolException, UnknownServiceAddressException;
+    
+    /**
+     * Sends a "heartbeat" message to the cluster manager.
+     * @param msg a message
+     * @throws UnknownServiceAddressException if the cluster manager's address is not known
+     * @throws ProtocolException if communication failed
+     */
+    void heartbeat(HeartbeatMessage msg) throws ProtocolException, UnknownServiceAddressException;
+    
+    /**
+     * Sends a bulletins message to the cluster manager.
+     * @param msg
+     * @throws ProtocolException
+     * @throws UnknownServiceAddressException 
+     */
+    void sendBulletins(NodeBulletinsMessage msg) throws ProtocolException, UnknownServiceAddressException;
+    
+    /**
+     * Sends a failure notification if the controller was unable start.
+     * @param msg a message
+     * @throws UnknownServiceAddressException if the cluster manager's address is not known
+     * @throws ProtocolException if communication failed
+     */
+    void notifyControllerStartupFailure(ControllerStartupFailureMessage msg) throws ProtocolException, UnknownServiceAddressException;
+    
+    /**
+     * Sends a failure notification if the node was unable to reconnect to the cluster
+     * @param msg a message
+     * @throws UnknownServiceAddressException if the cluster manager's address is not known
+     * @throws ProtocolException if communication failed
+     */
+    void notifyReconnectionFailure(ReconnectionFailureMessage msg) throws ProtocolException, UnknownServiceAddressException;
+    
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ProtocolContext.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ProtocolContext.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ProtocolContext.java
new file mode 100644
index 0000000..b614e76
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ProtocolContext.java
@@ -0,0 +1,39 @@
+/*
+ * 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.nifi.cluster.protocol;
+
+/**
+ * The context for communicating using the internal cluster protocol. 
+ * 
+ * @param <T> The type of protocol message.
+ * 
+ * @author unattributed
+ */
+public interface ProtocolContext<T> {
+ 
+    /**
+     * Creates a marshaller for serializing protocol messages.
+     * @return a marshaller
+     */
+    ProtocolMessageMarshaller<T> createMarshaller();
+    
+    /**
+     * Creates an unmarshaller for deserializing protocol messages.
+     * @return a unmarshaller
+     */
+    ProtocolMessageUnmarshaller<T> createUnmarshaller();
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ProtocolException.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ProtocolException.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ProtocolException.java
new file mode 100644
index 0000000..f11ad84
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ProtocolException.java
@@ -0,0 +1,40 @@
+/*
+ * 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.nifi.cluster.protocol;
+
+/**
+ * The base exception for problems encountered while communicating within the
+ * cluster.
+ * @author unattributed
+ */
+public class ProtocolException extends RuntimeException {
+    
+    public ProtocolException() {
+    }
+    
+    public ProtocolException(String msg) {
+        super(msg);
+    }
+    
+    public ProtocolException(Throwable cause) {
+        super(cause);
+    }
+    
+    public ProtocolException(String msg, Throwable cause) {
+        super(msg, cause);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ProtocolHandler.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ProtocolHandler.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ProtocolHandler.java
new file mode 100644
index 0000000..6de87db
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ProtocolHandler.java
@@ -0,0 +1,44 @@
+/*
+ * 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.nifi.cluster.protocol;
+
+import org.apache.nifi.cluster.protocol.message.ProtocolMessage;
+
+/**
+ * A handler for processing protocol messages.
+ * @author unattributed
+ */
+public interface ProtocolHandler {
+    
+    /**
+     * Handles the given protocol message or throws an exception if it cannot
+     * handle the message.  If no response is needed by the protocol, then null
+     * should be returned.
+     * 
+     * @param msg a message
+     * @return a response or null, if no response is necessary
+     * 
+     * @throws ProtocolException if the message could not be processed
+     */
+    ProtocolMessage handle(ProtocolMessage msg) throws ProtocolException;
+    
+    /**
+     * @param msg
+     * @return true if the handler can process the given message; false otherwise
+     */
+    boolean canHandle(ProtocolMessage msg);
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ProtocolListener.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ProtocolListener.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ProtocolListener.java
new file mode 100644
index 0000000..32f0f5d
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ProtocolListener.java
@@ -0,0 +1,72 @@
+/*
+ * 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.nifi.cluster.protocol;
+
+import java.io.IOException;
+import java.util.Collection;
+
+import org.apache.nifi.reporting.BulletinRepository;
+
+/**
+ * Defines the interface for a listener to process protocol messages.
+ * @author unattributed
+ */
+public interface ProtocolListener {
+    
+    /**
+     * Starts the instance for listening for messages.  Start may only be called
+     * if the instance is not running.
+     * @throws java.io.IOException
+     */
+    void start() throws IOException;
+    
+    /**
+     * Stops the instance from listening for messages.  Stop may only be called
+     * if the instance is running.
+     * @throws java.io.IOException
+     */
+    void stop() throws IOException;
+    
+    /**
+     * @return true if the instance is started; false otherwise.
+     */
+    boolean isRunning();
+    
+    /**
+     * @return the handlers registered with the listener
+     */
+    Collection<ProtocolHandler> getHandlers();
+    
+    /**
+     * Registers a handler with the listener.
+     * @param handler a handler
+     */
+    void addHandler(ProtocolHandler handler);
+    
+    /**
+     * Sets the BulletinRepository that can be used to report bulletins
+     * @param bulletinRepository
+     */
+    void setBulletinRepository(BulletinRepository bulletinRepository);
+    
+    /**
+     * Unregisters the handler with the listener.
+     * @param handler a handler
+     * @return true if the handler was removed; false otherwise
+     */
+    boolean removeHandler(ProtocolHandler handler);
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ProtocolMessageMarshaller.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ProtocolMessageMarshaller.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ProtocolMessageMarshaller.java
new file mode 100644
index 0000000..bb436e0
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ProtocolMessageMarshaller.java
@@ -0,0 +1,38 @@
+/*
+ * 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.nifi.cluster.protocol;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+/**
+ * Defines a marshaller for serializing protocol messages.
+ * 
+ * @param <T> The type of protocol message.
+ * 
+ * @author unattributed
+ */
+public interface ProtocolMessageMarshaller<T> {
+    
+    /**
+     * Serializes the given message to the given output stream.
+     * @param msg a message
+     * @param os an output stream
+     * @throws IOException if the message could not be serialized to the stream
+     */
+    void marshal(T msg, OutputStream os) throws IOException;
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ProtocolMessageUnmarshaller.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ProtocolMessageUnmarshaller.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ProtocolMessageUnmarshaller.java
new file mode 100644
index 0000000..c690e7b
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ProtocolMessageUnmarshaller.java
@@ -0,0 +1,38 @@
+/*
+ * 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.nifi.cluster.protocol;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * Defines an unmarshaller for deserializing protocol messages.
+ * 
+ * @param <T> The type of protocol message.
+ * 
+ * @author unattributed
+ */
+public interface ProtocolMessageUnmarshaller<T> {
+    
+    /**
+     * Deserializes a message on the given input stream.
+     * @param is an input stream
+     * @return 
+     * @throws IOException if the message could not be deserialized from the stream
+     */
+    T unmarshal(InputStream is) throws IOException;
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/StandardDataFlow.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/StandardDataFlow.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/StandardDataFlow.java
new file mode 100644
index 0000000..c2d16fc
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/StandardDataFlow.java
@@ -0,0 +1,105 @@
+/*
+ * 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.nifi.cluster.protocol;
+
+import org.apache.nifi.cluster.protocol.DataFlow;
+import java.io.Serializable;
+import java.util.Arrays;
+
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+
+import org.apache.nifi.cluster.protocol.jaxb.message.DataFlowAdapter;
+
+/**
+ * Represents a dataflow, which includes the raw bytes of the flow.xml and 
+ * whether processors should be started automatically at application startup.
+ */
+@XmlJavaTypeAdapter(DataFlowAdapter.class)
+public class StandardDataFlow implements Serializable, DataFlow {
+    
+    private final byte[] flow;
+    private final byte[] templateBytes;
+    private final byte[] snippetBytes;
+
+    private boolean autoStartProcessors;
+    
+    /**
+     * Constructs an instance.  
+     * 
+     * @param flow a valid flow as bytes, which cannot be null
+     * @param templateBytes an XML representation of templates
+     * @param snippetBytes an XML representation of snippets
+     * 
+     * @throws NullPointerException if any argument is null
+     */
+    public StandardDataFlow(final byte[] flow, final byte[] templateBytes, final byte[] snippetBytes) {
+        this.flow = flow;
+        this.templateBytes = templateBytes;
+        this.snippetBytes = snippetBytes;
+    }
+    
+    public StandardDataFlow(final DataFlow toCopy) {
+        this.flow = copy(toCopy.getFlow());
+        this.templateBytes = copy(toCopy.getTemplates());
+        this.snippetBytes = copy(toCopy.getSnippets());
+        this.autoStartProcessors = toCopy.isAutoStartProcessors();
+    }
+    
+    private static byte[] copy(final byte[] bytes) {
+        return bytes == null ? null : Arrays.copyOf(bytes, bytes.length);
+    }
+    
+    /**
+     * @return the raw byte array of the flow 
+     */
+    public byte[] getFlow() {
+        return flow;
+    }
+
+    /**
+     * @return the raw byte array of the templates
+     */
+    public byte[] getTemplates() {
+        return templateBytes;
+    }
+    
+    /**
+     * @return the raw byte array of the snippets
+     */
+    public byte[] getSnippets() {
+        return snippetBytes;
+    }
+    
+    /**
+     * @return true if processors should be automatically started at application 
+     * startup; false otherwise 
+     */
+    public boolean isAutoStartProcessors() {
+        return autoStartProcessors;
+    }
+    
+    /**
+     * 
+     * Sets the flag to automatically start processors at application startup.
+     * 
+     * @param autoStartProcessors true if processors should be automatically
+     * started at application startup; false otherwise
+     */
+    public void setAutoStartProcessors(final boolean autoStartProcessors) {
+        this.autoStartProcessors = autoStartProcessors;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/UnknownServiceAddressException.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/UnknownServiceAddressException.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/UnknownServiceAddressException.java
new file mode 100644
index 0000000..41c74eb
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/UnknownServiceAddressException.java
@@ -0,0 +1,39 @@
+/*
+ * 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.nifi.cluster.protocol;
+
+/**
+ * Represents the exceptional case when a service's address is not known.
+ * @author unattributed
+ */
+public class UnknownServiceAddressException extends RuntimeException {
+    
+    public UnknownServiceAddressException() {
+    }
+    
+    public UnknownServiceAddressException(String msg) {
+        super(msg);
+    }
+    
+    public UnknownServiceAddressException(Throwable cause) {
+        super(cause);
+    }
+    
+    public UnknownServiceAddressException(String msg, Throwable cause) {
+        super(msg, cause);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/ClusterManagerProtocolSenderImpl.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/ClusterManagerProtocolSenderImpl.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/ClusterManagerProtocolSenderImpl.java
new file mode 100644
index 0000000..ceb3fcb
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/ClusterManagerProtocolSenderImpl.java
@@ -0,0 +1,245 @@
+/*
+ * 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.nifi.cluster.protocol.impl;
+
+import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.net.Socket;
+import java.net.SocketException;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.nifi.cluster.protocol.ClusterManagerProtocolSender;
+import org.apache.nifi.cluster.protocol.NodeIdentifier;
+import org.apache.nifi.cluster.protocol.ProtocolContext;
+import org.apache.nifi.cluster.protocol.ProtocolException;
+import org.apache.nifi.cluster.protocol.ProtocolMessageMarshaller;
+import org.apache.nifi.cluster.protocol.ProtocolMessageUnmarshaller;
+import org.apache.nifi.cluster.protocol.message.DisconnectMessage;
+import org.apache.nifi.cluster.protocol.message.FlowRequestMessage;
+import org.apache.nifi.cluster.protocol.message.FlowResponseMessage;
+import org.apache.nifi.cluster.protocol.message.PrimaryRoleAssignmentMessage;
+import org.apache.nifi.cluster.protocol.message.ProtocolMessage;
+import org.apache.nifi.cluster.protocol.message.ProtocolMessage.MessageType;
+import org.apache.nifi.cluster.protocol.message.ReconnectionRequestMessage;
+import org.apache.nifi.cluster.protocol.message.ReconnectionResponseMessage;
+import org.apache.nifi.io.socket.SocketConfiguration;
+import org.apache.nifi.io.socket.SocketUtils;
+import org.apache.nifi.reporting.BulletinRepository;
+import org.apache.nifi.util.FormatUtils;
+
+/**
+ * A protocol sender for sending protocol messages from the cluster manager to
+ * nodes.  
+ * 
+ * Connection-type requests (e.g., reconnection, disconnection) by nature of 
+ * starting/stopping flow controllers take longer than other types of protocol 
+ * messages.  Therefore, a handshake timeout may be specified to lengthen the 
+ * allowable time for communication with the node.
+ * 
+ * @author unattributed
+ */
+public class ClusterManagerProtocolSenderImpl implements ClusterManagerProtocolSender {
+
+    
+    private final ProtocolContext<ProtocolMessage> protocolContext;
+    private final SocketConfiguration socketConfiguration;
+    private int handshakeTimeoutSeconds;
+    private volatile BulletinRepository bulletinRepository;
+
+    public ClusterManagerProtocolSenderImpl(final SocketConfiguration socketConfiguration, final ProtocolContext<ProtocolMessage> protocolContext) {
+        if(socketConfiguration == null) {
+            throw new IllegalArgumentException("Socket configuration may not be null.");
+        } else if(protocolContext == null) {
+            throw new IllegalArgumentException("Protocol Context may not be null.");
+        }
+        this.socketConfiguration = socketConfiguration;
+        this.protocolContext = protocolContext;
+        this.handshakeTimeoutSeconds = -1;  // less than zero denotes variable not configured
+    }
+    
+    @Override
+    public void setBulletinRepository(final BulletinRepository bulletinRepository) {
+        this.bulletinRepository = bulletinRepository;
+    }
+
+    /**
+     * Requests the data flow from a node.
+     * @param msg a message
+     * @return the message response
+     * @throws @throws ProtocolException if the message failed to be sent or the response was malformed
+     */
+    @Override
+    public FlowResponseMessage requestFlow(final FlowRequestMessage msg) throws ProtocolException {
+        Socket socket = null;
+        try {
+        	socket = createSocket(msg.getNodeId(), false);
+            
+            try {
+                // marshal message to output stream
+                final ProtocolMessageMarshaller<ProtocolMessage> marshaller = protocolContext.createMarshaller();
+                marshaller.marshal(msg, socket.getOutputStream());
+            } catch(final IOException ioe) {
+                throw new ProtocolException("Failed marshalling '" + msg.getType() + "' protocol message due to: " + ioe, ioe);
+            }
+            
+            final ProtocolMessage response;
+            try {
+                // unmarshall response and return
+                final ProtocolMessageUnmarshaller<ProtocolMessage> unmarshaller = protocolContext.createUnmarshaller();
+                response = unmarshaller.unmarshal(socket.getInputStream());
+            } catch(final IOException ioe) {
+                throw new ProtocolException("Failed unmarshalling '" + MessageType.FLOW_RESPONSE + "' protocol message due to: " + ioe, ioe);
+            } 
+            
+            if(MessageType.FLOW_RESPONSE == response.getType()) {
+                return (FlowResponseMessage) response;
+            } else {
+                throw new ProtocolException("Expected message type '" + MessageType.FLOW_RESPONSE + "' but found '" + response.getType() + "'");
+            }
+            
+        } finally {
+            SocketUtils.closeQuietly(socket);
+        }
+    }
+
+    /**
+     * Requests a node to reconnect to the cluster.  The configured value for
+     * handshake timeout is applied to the socket before making the request.
+     * @param msg a message
+     * @return the response
+     * @throws ProtocolException if the message failed to be sent or the response was malformed
+     */
+    @Override
+    public ReconnectionResponseMessage requestReconnection(final ReconnectionRequestMessage msg) throws ProtocolException {
+        Socket socket = null;
+        try {
+        	socket = createSocket(msg.getNodeId(), true);
+
+            // marshal message to output stream
+            try {
+                final ProtocolMessageMarshaller<ProtocolMessage> marshaller = protocolContext.createMarshaller();
+                marshaller.marshal(msg, socket.getOutputStream());
+            } catch(final IOException ioe) {
+                throw new ProtocolException("Failed marshalling '" + msg.getType() + "' protocol message due to: " + ioe, ioe);
+            }
+            
+            
+            final ProtocolMessage response;
+            try {
+                // unmarshall response and return
+                final ProtocolMessageUnmarshaller<ProtocolMessage> unmarshaller = protocolContext.createUnmarshaller();
+                response = unmarshaller.unmarshal(socket.getInputStream());
+            } catch(final IOException ioe) {
+                throw new ProtocolException("Failed unmarshalling '" + MessageType.RECONNECTION_RESPONSE + "' protocol message due to: " + ioe, ioe);
+            } 
+            
+            if(MessageType.RECONNECTION_RESPONSE == response.getType()) {
+                return (ReconnectionResponseMessage) response;
+            } else {
+                throw new ProtocolException("Expected message type '" + MessageType.FLOW_RESPONSE + "' but found '" + response.getType() + "'");
+            }
+        } finally {
+            SocketUtils.closeQuietly(socket);
+        }
+    }
+    
+    /**
+     * Requests a node to disconnect from the cluster.  The configured value for
+     * handshake timeout is applied to the socket before making the request.
+     * @param msg a message
+     * @throws ProtocolException if the message failed to be sent
+     */
+    @Override
+    public void disconnect(final DisconnectMessage msg) throws ProtocolException {
+        Socket socket = null;
+        try {
+        	socket = createSocket(msg.getNodeId(), true);
+
+            // marshal message to output stream
+            try {
+                final ProtocolMessageMarshaller<ProtocolMessage> marshaller = protocolContext.createMarshaller();
+                marshaller.marshal(msg, socket.getOutputStream());
+            } catch(final IOException ioe) {
+                throw new ProtocolException("Failed marshalling '" + msg.getType() + "' protocol message due to: " + ioe, ioe);
+            }
+        } finally {
+            SocketUtils.closeQuietly(socket);
+        }
+    }
+
+    /**
+     * Assigns the primary role to a node.
+     * 
+     * @param msg a message
+     * 
+     * @throws ProtocolException if the message failed to be sent
+     */
+    @Override
+    public void assignPrimaryRole(final PrimaryRoleAssignmentMessage msg) throws ProtocolException {
+        Socket socket = null;
+        try {
+        	socket = createSocket(msg.getNodeId(), true);
+
+            try {
+                // marshal message to output stream
+                final ProtocolMessageMarshaller<ProtocolMessage> marshaller = protocolContext.createMarshaller();
+                marshaller.marshal(msg, socket.getOutputStream());
+            } catch(final IOException ioe) {
+                throw new ProtocolException("Failed marshalling '" + msg.getType() + "' protocol message due to: " + ioe, ioe);
+            }
+        } finally {
+            SocketUtils.closeQuietly(socket);
+        }
+    }
+    
+    
+    private void setConnectionHandshakeTimeoutOnSocket(final Socket socket) throws SocketException {
+        // update socket timeout, if handshake timeout was set; otherwise use socket's current timeout
+        if(handshakeTimeoutSeconds >= 0) {
+            socket.setSoTimeout(handshakeTimeoutSeconds * 1000);
+        }   
+    }
+    
+    public SocketConfiguration getSocketConfiguration() {
+        return socketConfiguration;
+    }
+
+    public int getHandshakeTimeoutSeconds() {
+        return handshakeTimeoutSeconds;
+    }
+
+    public void setHandshakeTimeout(final String handshakeTimeout) {
+        this.handshakeTimeoutSeconds = (int) FormatUtils.getTimeDuration(handshakeTimeout, TimeUnit.SECONDS);
+    }
+
+    private Socket createSocket(final NodeIdentifier nodeId, final boolean applyHandshakeTimeout) {
+    	return createSocket(nodeId.getSocketAddress(), nodeId.getSocketPort(), applyHandshakeTimeout);
+    }
+    
+    private Socket createSocket(final String host, final int port, final boolean applyHandshakeTimeout) {
+    	try {
+            // create a socket
+            final Socket socket = SocketUtils.createSocket(InetSocketAddress.createUnresolved(host, port), socketConfiguration);
+            if ( applyHandshakeTimeout ) {
+            	setConnectionHandshakeTimeoutOnSocket(socket);
+            }
+            return socket;
+        } catch(final IOException ioe) {
+            throw new ProtocolException("Failed to create socket due to: " + ioe, ioe);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/ClusterManagerProtocolSenderListener.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/ClusterManagerProtocolSenderListener.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/ClusterManagerProtocolSenderListener.java
new file mode 100644
index 0000000..933e5fa
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/ClusterManagerProtocolSenderListener.java
@@ -0,0 +1,118 @@
+/*
+ * 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.nifi.cluster.protocol.impl;
+
+import java.io.IOException;
+import java.util.Collection;
+
+import org.apache.nifi.cluster.protocol.ClusterManagerProtocolSender;
+import org.apache.nifi.cluster.protocol.ProtocolException;
+import org.apache.nifi.cluster.protocol.ProtocolHandler;
+import org.apache.nifi.cluster.protocol.ProtocolListener;
+import org.apache.nifi.cluster.protocol.message.DisconnectMessage;
+import org.apache.nifi.cluster.protocol.message.FlowRequestMessage;
+import org.apache.nifi.cluster.protocol.message.FlowResponseMessage;
+import org.apache.nifi.cluster.protocol.message.PrimaryRoleAssignmentMessage;
+import org.apache.nifi.cluster.protocol.message.ReconnectionRequestMessage;
+import org.apache.nifi.cluster.protocol.message.ReconnectionResponseMessage;
+import org.apache.nifi.reporting.BulletinRepository;
+
+/**
+ * A wrapper class for consolidating a protocol sender and listener for the cluster
+ * manager.
+ * 
+ * @author unattributed
+ */
+public class ClusterManagerProtocolSenderListener implements ClusterManagerProtocolSender, ProtocolListener {
+    
+    private final ClusterManagerProtocolSender sender;
+    
+    private final ProtocolListener listener;
+    
+    public ClusterManagerProtocolSenderListener(final ClusterManagerProtocolSender sender, final ProtocolListener listener) {
+        if(sender == null) {
+            throw new IllegalArgumentException("ClusterManagerProtocolSender may not be null.");
+        } else if(listener == null) {
+            throw new IllegalArgumentException("ProtocolListener may not be null.");
+        }
+        this.sender = sender;
+        this.listener = listener;
+    }
+
+    @Override
+    public void stop() throws IOException {
+        if(!isRunning()) {
+            throw new IllegalStateException("Instance is already stopped.");
+        }
+        listener.stop();
+    }
+
+    @Override
+    public void start() throws IOException {
+        if(isRunning()) {
+            throw new IllegalStateException("Instance is already started.");
+        }
+        listener.start();
+    }
+
+    @Override
+    public boolean isRunning() {
+        return listener.isRunning();
+    }
+
+    @Override
+    public boolean removeHandler(final ProtocolHandler handler) {
+        return listener.removeHandler(handler);
+    }
+
+    @Override
+    public Collection<ProtocolHandler> getHandlers() {
+        return listener.getHandlers();
+    }
+
+    @Override
+    public void addHandler(final ProtocolHandler handler) {
+        listener.addHandler(handler);
+    }
+    
+    @Override
+    public void setBulletinRepository(final BulletinRepository bulletinRepository) {
+        listener.setBulletinRepository(bulletinRepository);
+        sender.setBulletinRepository(bulletinRepository);
+    }
+    
+    @Override
+    public FlowResponseMessage requestFlow(final FlowRequestMessage msg) throws ProtocolException {
+        return sender.requestFlow(msg);
+    }
+
+    @Override
+    public ReconnectionResponseMessage requestReconnection(final ReconnectionRequestMessage msg) throws ProtocolException {
+        return sender.requestReconnection(msg);
+    }
+
+    @Override
+    public void disconnect(DisconnectMessage msg) throws ProtocolException {
+        sender.disconnect(msg);
+    }
+    
+    @Override
+    public void assignPrimaryRole(PrimaryRoleAssignmentMessage msg) throws ProtocolException {
+        sender.assignPrimaryRole(msg);
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/ClusterServiceDiscovery.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/ClusterServiceDiscovery.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/ClusterServiceDiscovery.java
new file mode 100644
index 0000000..24e51e0
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/ClusterServiceDiscovery.java
@@ -0,0 +1,181 @@
+/*
+ * 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.nifi.cluster.protocol.impl;
+
+import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.util.Collection;
+import java.util.Collections;
+import org.apache.nifi.io.socket.multicast.DiscoverableService;
+import org.apache.nifi.io.socket.multicast.DiscoverableServiceImpl;
+import org.apache.nifi.io.socket.multicast.MulticastConfiguration;
+import org.apache.nifi.io.socket.multicast.MulticastServiceDiscovery;
+import org.apache.nifi.reporting.BulletinRepository;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.nifi.cluster.protocol.ProtocolContext;
+import org.apache.nifi.cluster.protocol.ProtocolException;
+import org.apache.nifi.cluster.protocol.ProtocolHandler;
+import org.apache.nifi.cluster.protocol.ProtocolListener;
+import org.apache.nifi.cluster.protocol.message.ProtocolMessage;
+import org.apache.nifi.cluster.protocol.message.ProtocolMessage.MessageType;
+import org.apache.nifi.cluster.protocol.message.ServiceBroadcastMessage;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * An implementation for discovering services by way of "service broadcast" type
+ * protocol messages over multicast.
+ *
+ * The client caller is responsible for starting and stopping the service
+ * discovery. The instance must be stopped before termination of the JVM to
+ * ensure proper resource clean-up.
+ *
+ * @author unattributed
+ */
+public class ClusterServiceDiscovery implements MulticastServiceDiscovery, ProtocolListener {
+
+    private static final Logger logger = LoggerFactory.getLogger(ClusterServiceDiscovery.class);
+    private final String serviceName;
+    private final MulticastConfiguration multicastConfiguration;
+    private final MulticastProtocolListener listener;
+    private volatile BulletinRepository bulletinRepository;
+
+    /*
+     * guarded by this
+     */
+    private DiscoverableService service;
+
+    
+    public ClusterServiceDiscovery(final String serviceName, final InetSocketAddress multicastAddress,
+            final MulticastConfiguration multicastConfiguration, final ProtocolContext<ProtocolMessage> protocolContext) {
+
+        if (StringUtils.isBlank(serviceName)) {
+            throw new IllegalArgumentException("Service name may not be null or empty.");
+        } else if (multicastAddress == null) {
+            throw new IllegalArgumentException("Multicast address may not be null.");
+        } else if (multicastAddress.getAddress().isMulticastAddress() == false) {
+            throw new IllegalArgumentException("Multicast group must be a Class D address.");
+        } else if (protocolContext == null) {
+            throw new IllegalArgumentException("Protocol Context may not be null.");
+        } else if (multicastConfiguration == null) {
+            throw new IllegalArgumentException("Multicast configuration may not be null.");
+        }
+
+        this.serviceName = serviceName;
+        this.multicastConfiguration = multicastConfiguration;
+        this.listener = new MulticastProtocolListener(1, multicastAddress, multicastConfiguration, protocolContext);
+        listener.addHandler(new ClusterManagerServiceBroadcastHandler());
+    }
+
+    @Override
+    public void setBulletinRepository(final BulletinRepository bulletinRepository) {
+        this.bulletinRepository = bulletinRepository;
+    }
+
+    @Override
+    public synchronized DiscoverableService getService() {
+        return service;
+    }
+
+    @Override
+    public InetSocketAddress getMulticastAddress() {
+        return listener.getMulticastAddress();
+    }
+
+    @Override
+    public Collection<ProtocolHandler> getHandlers() {
+        return Collections.unmodifiableCollection(listener.getHandlers());
+    }
+
+    @Override
+    public void addHandler(ProtocolHandler handler) {
+        listener.addHandler(handler);
+    }
+
+    @Override
+    public boolean removeHandler(ProtocolHandler handler) {
+        return listener.removeHandler(handler);
+    }
+
+    @Override
+    public boolean isRunning() {
+        return listener.isRunning();
+    }
+
+    @Override
+    public void start() throws IOException {
+        if (isRunning()) {
+            throw new IllegalStateException("Instance is already running.");
+        }
+        listener.start();
+    }
+
+    @Override
+    public void stop() throws IOException {
+        if (isRunning() == false) {
+            throw new IllegalStateException("Instance is already stopped.");
+        }
+        listener.stop();
+    }
+
+    public String getServiceName() {
+        return serviceName;
+    }
+
+    public MulticastConfiguration getMulticastConfiguration() {
+        return multicastConfiguration;
+    }
+
+    private class ClusterManagerServiceBroadcastHandler implements ProtocolHandler {
+
+        @Override
+        public boolean canHandle(final ProtocolMessage msg) {
+            return MessageType.SERVICE_BROADCAST == msg.getType();
+        }
+
+        @Override
+        public ProtocolMessage handle(final ProtocolMessage msg) throws ProtocolException {
+            synchronized (ClusterServiceDiscovery.this) {
+                if (canHandle(msg) == false) {
+                    throw new ProtocolException("Handler cannot handle message type: " + msg.getType());
+                } else {
+                    final ServiceBroadcastMessage broadcastMsg = (ServiceBroadcastMessage) msg;
+                    if (serviceName.equals(broadcastMsg.getServiceName())) {
+                        final DiscoverableService oldService = service;
+                        if (oldService == null
+                                || broadcastMsg.getAddress().equalsIgnoreCase(oldService.getServiceAddress().getHostName()) == false
+                                || broadcastMsg.getPort() != oldService.getServiceAddress().getPort()) {
+                            service = new DiscoverableServiceImpl(serviceName, InetSocketAddress.createUnresolved(broadcastMsg.getAddress(), broadcastMsg.getPort()));
+                            final InetSocketAddress oldServiceAddress = (oldService == null) ? null : oldService.getServiceAddress();
+                            logger.info(String.format("Updating cluster service address for '%s' from '%s' to '%s'", serviceName, prettyPrint(oldServiceAddress), prettyPrint(service.getServiceAddress())));
+                        }
+                    }
+                    return null;
+                }
+            }
+        }
+    }
+
+    private String prettyPrint(final InetSocketAddress address) {
+        if (address == null) {
+            return "0.0.0.0:0";
+        } else {
+            return address.getHostName() + ":" + address.getPort();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/ClusterServiceLocator.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/ClusterServiceLocator.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/ClusterServiceLocator.java
new file mode 100644
index 0000000..bebfde8
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/ClusterServiceLocator.java
@@ -0,0 +1,229 @@
+/*
+ * 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.nifi.cluster.protocol.impl;
+
+import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
+import org.apache.nifi.io.socket.multicast.DiscoverableService;
+import org.apache.nifi.io.socket.multicast.DiscoverableServiceImpl;
+import org.apache.nifi.io.socket.multicast.ServiceDiscovery;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Implements the ServiceLocator interface for locating the socket address
+ * of a cluster service.  Depending on configuration, the address may be located
+ * using service discovery.  If using service discovery, then the service methods
+ * must be used for starting and stopping discovery.
+ * 
+ * Service discovery may be used in conjunction with a fixed port.  In this case,
+ * the service discovery will yield the service IP/host while the fixed port will
+ * be used for the port.
+ * 
+ * Alternatively, the instance may be configured with exact service location, in
+ * which case, no service discovery occurs and the caller will always receive the
+ * configured service.
+ * 
+ * @author unattributed
+ */
+public class ClusterServiceLocator implements ServiceDiscovery {
+    
+    private static final Logger logger = LoggerFactory.getLogger(ClusterServiceLocator.class);
+    
+    private final String serviceName;
+    
+    private final ClusterServiceDiscovery serviceDiscovery;
+    
+    private final DiscoverableService fixedService;
+
+    private final int fixedServicePort;
+    
+    private final AttemptsConfig attemptsConfig = new AttemptsConfig();
+    
+    private final AtomicBoolean running = new AtomicBoolean(false);
+    
+    public ClusterServiceLocator(final ClusterServiceDiscovery serviceDiscovery) {
+        if(serviceDiscovery == null) {
+            throw new IllegalArgumentException("ClusterServiceDiscovery may not be null.");
+        }
+        this.serviceDiscovery = serviceDiscovery;
+        this.fixedService = null;
+        this.fixedServicePort = 0;
+        this.serviceName = serviceDiscovery.getServiceName();
+    }
+    
+    public ClusterServiceLocator(final ClusterServiceDiscovery serviceDiscovery, final int fixedServicePort) {
+        if(serviceDiscovery == null) {
+            throw new IllegalArgumentException("ClusterServiceDiscovery may not be null.");
+        }
+        this.serviceDiscovery = serviceDiscovery;
+        this.fixedService = null;
+        this.fixedServicePort = fixedServicePort;
+        this.serviceName = serviceDiscovery.getServiceName();
+    }
+    
+    public ClusterServiceLocator(final DiscoverableService fixedService) {
+        if(fixedService == null) {
+            throw new IllegalArgumentException("Service may not be null.");
+        }
+        this.serviceDiscovery = null;
+        this.fixedService = fixedService;
+        this.fixedServicePort = 0;
+        this.serviceName = fixedService.getServiceName();
+    }
+    
+    @Override
+    public DiscoverableService getService() {
+        
+        final int numAttemptsValue;
+        final int secondsBetweenAttempts;
+        synchronized(this) {
+            numAttemptsValue = attemptsConfig.numAttempts;
+            secondsBetweenAttempts = attemptsConfig.getTimeBetweenAttempts();
+        }
+        
+        // try for a configured amount of attempts to retrieve the service address
+        for(int i = 0; i < numAttemptsValue; i++) {
+
+            if(fixedService != null) {
+                return fixedService;
+            } else if(serviceDiscovery != null) {
+                
+                final DiscoverableService discoveredService = serviceDiscovery.getService();
+                
+                // if we received an address
+                if(discoveredService != null) {
+                    // if we were configured with a fixed port, then use the discovered host and fixed port; otherwise use the discovered address
+                    if(fixedServicePort > 0) {
+                        // create service using discovered service name and address with fixed service port
+                        final InetSocketAddress addr = InetSocketAddress.createUnresolved(discoveredService.getServiceAddress().getHostName(), fixedServicePort);
+                        final DiscoverableService result = new DiscoverableServiceImpl(discoveredService.getServiceName(), addr);
+                        return result;
+                    } else {
+                        return discoveredService;
+                    }
+                }
+            }
+            
+            // could not obtain service address, so sleep a bit
+            try {
+                logger.debug(String.format("Locating Cluster Service '%s' Attempt: %d of %d failed.  Trying again in %d seconds.", 
+                    serviceName, (i + 1), numAttemptsValue, secondsBetweenAttempts));
+                Thread.sleep(secondsBetweenAttempts * 1000);
+            } catch(final InterruptedException ie) {
+                break;
+            }
+            
+        }
+
+        return null;
+    }
+
+    public boolean isRunning() {
+        if(serviceDiscovery != null) {
+            return serviceDiscovery.isRunning();
+        } else {
+            return running.get();
+        }
+    }
+
+    public void start() throws IOException {
+        
+        if(isRunning()) {
+            throw new IllegalStateException("Instance is already started.");
+        }
+        
+        if(serviceDiscovery != null) {
+            serviceDiscovery.start();
+        }
+        running.set(true);
+    }
+
+    public void stop() throws IOException {
+        
+        if(isRunning() == false) {
+            throw new IllegalStateException("Instance is already stopped.");
+        }
+        
+        if(serviceDiscovery != null) {
+            serviceDiscovery.stop();
+        }
+        running.set(false);
+    }
+    
+    public synchronized void setAttemptsConfig(final AttemptsConfig config) {
+        if(config == null) {
+            throw new IllegalArgumentException("Attempts configuration may not be null.");
+        }
+        this.attemptsConfig.numAttempts = config.numAttempts;
+        this.attemptsConfig.timeBetweenAttempts = config.timeBetweenAttempts;
+        this.attemptsConfig.timeBetweenAttempsUnit = config.timeBetweenAttempsUnit;
+    }
+
+    public synchronized AttemptsConfig getAttemptsConfig() {
+        final AttemptsConfig config = new AttemptsConfig();
+        config.numAttempts = this.attemptsConfig.numAttempts;
+        config.timeBetweenAttempts = this.attemptsConfig.timeBetweenAttempts;
+        config.timeBetweenAttempsUnit = this.attemptsConfig.timeBetweenAttempsUnit;
+        return config;
+    }
+    
+    public static class AttemptsConfig {
+        
+        private int numAttempts = 1;
+        
+        private int timeBetweenAttempts = 1;
+        
+        private TimeUnit timeBetweenAttempsUnit = TimeUnit.SECONDS;
+        
+        public int getNumAttempts() {
+            return numAttempts;
+        }
+
+        public void setNumAttempts(int numAttempts) {
+            if(numAttempts <= 0) {
+                throw new IllegalArgumentException("Number of attempts must be positive: " + numAttempts);
+            }
+            this.numAttempts = numAttempts;
+        }
+
+        public TimeUnit getTimeBetweenAttemptsUnit() {
+            return timeBetweenAttempsUnit;
+        }
+
+        public void setTimeBetweenAttempsUnit(TimeUnit timeBetweenAttempsUnit) {
+            if(timeBetweenAttempts <= 0) {
+                throw new IllegalArgumentException("Time between attempts must be positive: " + numAttempts);
+            } 
+            this.timeBetweenAttempsUnit = timeBetweenAttempsUnit;
+        }
+
+        public int getTimeBetweenAttempts() {
+            return timeBetweenAttempts;
+        }
+
+        public void setTimeBetweenAttempts(int timeBetweenAttempts) {
+            if(timeBetweenAttempts <= 0) {
+            throw new IllegalArgumentException("Time between attempts must be positive: " + numAttempts);
+        } 
+            this.timeBetweenAttempts = timeBetweenAttempts;
+        }
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/ClusterServicesBroadcaster.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/ClusterServicesBroadcaster.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/ClusterServicesBroadcaster.java
new file mode 100644
index 0000000..e9e7d5b
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/ClusterServicesBroadcaster.java
@@ -0,0 +1,182 @@
+/*
+ * 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.nifi.cluster.protocol.impl;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.net.DatagramPacket;
+import java.net.InetSocketAddress;
+import java.net.MulticastSocket;
+import java.util.*;
+import java.util.concurrent.CopyOnWriteArraySet;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.nifi.io.socket.multicast.DiscoverableService;
+import org.apache.nifi.io.socket.multicast.MulticastConfiguration;
+import org.apache.nifi.io.socket.multicast.MulticastServicesBroadcaster;
+import org.apache.nifi.io.socket.multicast.MulticastUtils;
+import org.apache.nifi.logging.NiFiLog;
+import org.apache.nifi.util.FormatUtils;
+import org.apache.nifi.cluster.protocol.ProtocolContext;
+import org.apache.nifi.cluster.protocol.ProtocolMessageMarshaller;
+import org.apache.nifi.cluster.protocol.message.ProtocolMessage;
+import org.apache.nifi.cluster.protocol.message.ServiceBroadcastMessage;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Broadcasts services used by the clustering software using multicast communication.
+ * A configurable delay occurs after broadcasting the collection of services.
+ * 
+ * The client caller is responsible for starting and stopping the broadcasting.
+ * The instance must be stopped before termination of the JVM to ensure proper
+ * resource clean-up.
+ * 
+ * @author unattributed
+ */
+public class ClusterServicesBroadcaster implements MulticastServicesBroadcaster {
+    
+    private static final Logger logger = new NiFiLog(LoggerFactory.getLogger(ClusterServicesBroadcaster.class));
+    
+    private final Set<DiscoverableService> services = new CopyOnWriteArraySet<>();
+
+    private final InetSocketAddress multicastAddress;
+    
+    private final MulticastConfiguration multicastConfiguration;
+    
+    private final ProtocolContext<ProtocolMessage> protocolContext;
+    
+    private final int broadcastDelayMs;
+    
+    private Timer broadcaster;
+    
+    private MulticastSocket multicastSocket;
+    
+    public ClusterServicesBroadcaster(final InetSocketAddress multicastAddress, 
+            final MulticastConfiguration multicastConfiguration, 
+            final ProtocolContext<ProtocolMessage> protocolContext, final String broadcastDelay) {
+        
+        if(multicastAddress == null) {
+            throw new IllegalArgumentException("Multicast address may not be null.");
+        } else if(multicastAddress.getAddress().isMulticastAddress() == false) {
+            throw new IllegalArgumentException("Multicast group address is not a Class D IP address.");
+        } else if(protocolContext == null) {
+            throw new IllegalArgumentException("Protocol Context may not be null.");
+        } else if(multicastConfiguration == null) {
+            throw new IllegalArgumentException("Multicast configuration may not be null.");
+        }
+        
+        this.services.addAll(services);
+        this.multicastAddress = multicastAddress;
+        this.multicastConfiguration = multicastConfiguration;
+        this.protocolContext = protocolContext;
+        this.broadcastDelayMs = (int) FormatUtils.getTimeDuration(broadcastDelay, TimeUnit.MILLISECONDS);
+    }
+    
+    public void start() throws IOException {
+
+        if(isRunning()) {
+            throw new IllegalStateException("Instance is already started.");
+        }
+        
+        // setup socket
+        multicastSocket = MulticastUtils.createMulticastSocket(multicastConfiguration);
+        
+        // setup broadcaster
+        broadcaster = new Timer("Cluster Services Broadcaster", /* is daemon */ true);
+        broadcaster.schedule(new TimerTask() {
+            @Override
+            public void run() {
+                for(final DiscoverableService service : services) {
+                    try {
+
+                        final InetSocketAddress serviceAddress = service.getServiceAddress();
+                        logger.debug(String.format("Broadcasting Cluster Service '%s' at address %s:%d", 
+                            service.getServiceName(), serviceAddress.getHostName(), serviceAddress.getPort()));
+                        
+                        // create message
+                        final ServiceBroadcastMessage msg = new ServiceBroadcastMessage();
+                        msg.setServiceName(service.getServiceName());
+                        msg.setAddress(serviceAddress.getHostName());
+                        msg.setPort(serviceAddress.getPort());
+
+                        // marshal message to output stream
+                        final ProtocolMessageMarshaller<ProtocolMessage> marshaller = protocolContext.createMarshaller();
+                        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+                        marshaller.marshal(msg, baos);
+                        final byte[] packetBytes = baos.toByteArray();
+
+                        // send message
+                        final DatagramPacket packet = new DatagramPacket(packetBytes, packetBytes.length, multicastAddress);
+                        multicastSocket.send(packet);
+
+                    } catch(final Exception ex) {
+                        logger.warn(String.format("Cluster Services Broadcaster failed broadcasting service '%s' due to: %s", service.getServiceName(), ex), ex);
+                    }
+                }
+            }
+        }, 0, broadcastDelayMs);
+    }
+    
+    public boolean isRunning() {
+        return (broadcaster != null);
+    }
+    
+    public void stop() {
+        
+        if(isRunning() == false) {
+            throw new IllegalStateException("Instance is already stopped.");
+        }
+        
+        broadcaster.cancel();
+        broadcaster = null;
+
+        // close socket
+        MulticastUtils.closeQuietly(multicastSocket);
+        
+    }
+
+    @Override
+    public int getBroadcastDelayMs() {
+        return broadcastDelayMs;
+    }
+    
+    @Override
+    public Set<DiscoverableService> getServices() {
+        return Collections.unmodifiableSet(services);
+    }
+
+    @Override
+    public InetSocketAddress getMulticastAddress() {
+        return multicastAddress;
+    }
+    
+    @Override
+    public boolean addService(final DiscoverableService service) {
+        return services.add(service);
+    }
+    
+    @Override
+    public boolean removeService(final String serviceName) {
+        for(final DiscoverableService service : services) {
+            if(service.getServiceName().equals(serviceName)) {
+                return services.remove(service);
+            }
+        }
+        return false;
+    }
+}


[15/20] incubator-nifi git commit: NIFI-410 pushed RAT exclusions down to the relevant modules and stopped doing broad test resource exclusion - is now specific

Posted by jo...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/HttpClusterManager.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/HttpClusterManager.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/HttpClusterManager.java
deleted file mode 100644
index 2cf5812..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/HttpClusterManager.java
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * 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.nifi.cluster.manager;
-
-import org.apache.nifi.cluster.manager.exception.DisconnectedNodeMutableRequestException;
-import org.apache.nifi.cluster.manager.exception.UriConstructionException;
-import org.apache.nifi.cluster.manager.exception.ConnectingNodeMutableRequestException;
-import org.apache.nifi.cluster.manager.exception.NoConnectedNodesException;
-import org.apache.nifi.cluster.manager.exception.NoResponseFromNodesException;
-import org.apache.nifi.cluster.manager.exception.SafeModeMutableRequestException;
-import org.apache.nifi.cluster.protocol.NodeIdentifier;
-
-import java.net.URI;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * Extends the ClusterManager interface to define how requests issued to the
- * cluster manager are federated to the nodes. Specifically, the HTTP protocol
- * is used for communicating requests to the cluster manager and to the nodes.
- *
- * @author unattributed
- */
-public interface HttpClusterManager extends ClusterManager {
-
-    /**
-     * Federates the HTTP request to all connected nodes in the cluster. The
-     * given URI's host and port will not be used and instead will be adjusted
-     * for each node's host and port. The node URIs are guaranteed to be
-     * constructed before issuing any requests, so if a UriConstructionException
-     * is thrown, then it is guaranteed that no request was issued.
-     *
-     * @param method the HTTP method (e.g., GET, POST, PUT, DELETE, HEAD)
-     * @param uri the base request URI (up to, but not including, the query
-     * string)
-     * @param parameters the request parameters
-     * @param headers the request headers
-     *
-     * @return the client response
-     *
-     * @throws NoConnectedNodesException if no nodes are connected as results of
-     * the request
-     * @throws NoResponseFromNodesException if no response could be obtained
-     * @throws UriConstructionException if there was an issue constructing the
-     * URIs tailored for each individual node
-     * @throws ConnectingNodeMutableRequestException if the request was a PUT,
-     * POST, DELETE and a node is connecting to the cluster
-     * @throws DisconnectedNodeMutableRequestException if the request was a PUT,
-     * POST, DELETE and a node is disconnected from the cluster
-     * @throws SafeModeMutableRequestException if the request was a PUT, POST,
-     * DELETE and a the cluster is in safe mode
-     */
-    NodeResponse applyRequest(String method, URI uri, Map<String, List<String>> parameters, Map<String, String> headers)
-            throws NoConnectedNodesException, NoResponseFromNodesException, UriConstructionException, ConnectingNodeMutableRequestException,
-            DisconnectedNodeMutableRequestException, SafeModeMutableRequestException;
-
-    /**
-     * Federates the HTTP request to the nodes specified. The given URI's host
-     * and port will not be used and instead will be adjusted for each node's
-     * host and port. The node URIs are guaranteed to be constructed before
-     * issuing any requests, so if a UriConstructionException is thrown, then it
-     * is guaranteed that no request was issued.
-     *
-     * @param method the HTTP method (e.g., GET, POST, PUT, DELETE, HEAD)
-     * @param uri the base request URI (up to, but not including, the query
-     * string)
-     * @param parameters the request parameters
-     * @param headers the request headers
-     * @param nodeIdentifiers the NodeIdentifier for each node that the request
-     * should be replaced to
-     *
-     * @return the client response
-     *
-     * @throws NoConnectedNodesException if no nodes are connected as results of
-     * the request
-     * @throws NoResponseFromNodesException if no response could be obtained
-     * @throws UriConstructionException if there was an issue constructing the
-     * URIs tailored for each individual node
-     * @throws ConnectingNodeMutableRequestException if the request was a PUT,
-     * POST, DELETE and a node is connecting to the cluster
-     * @throws DisconnectedNodeMutableRequestException if the request was a PUT,
-     * POST, DELETE and a node is disconnected from the cluster
-     * @throws SafeModeMutableRequestException if the request was a PUT, POST,
-     * DELETE and a the cluster is in safe mode
-     */
-    NodeResponse applyRequest(String method, URI uri, Map<String, List<String>> parameters, Map<String, String> headers,
-            Set<NodeIdentifier> nodeIdentifiers)
-            throws NoConnectedNodesException, NoResponseFromNodesException, UriConstructionException, ConnectingNodeMutableRequestException,
-            DisconnectedNodeMutableRequestException, SafeModeMutableRequestException;
-
-    /**
-     * Federates the HTTP request to all connected nodes in the cluster. The
-     * given URI's host and port will not be used and instead will be adjusted
-     * for each node's host and port. The node URIs are guaranteed to be
-     * constructed before issuing any requests, so if a UriConstructionException
-     * is thrown, then it is guaranteed that no request was issued.
-     *
-     * @param method the HTTP method (e.g., GET, POST, PUT, DELETE, HEAD)
-     * @param uri the base request URI (up to, but not including, the query
-     * string)
-     * @param entity the HTTP request entity
-     * @param headers the request headers
-     *
-     * @return the client response
-     *
-     * @throws NoConnectedNodesException if no nodes are connected as results of
-     * the request
-     * @throws NoResponseFromNodesException if no response could be obtained
-     * @throws UriConstructionException if there was an issue constructing the
-     * URIs tailored for each individual node
-     * @throws ConnectingNodeMutableRequestException if the request was a PUT,
-     * POST, DELETE and a node is connecting to the cluster
-     * @throws DisconnectedNodeMutableRequestException if the request was a PUT,
-     * POST, DELETE and a node is disconnected from the cluster
-     * @throws SafeModeMutableRequestException if the request was a PUT, POST,
-     * DELETE and a the cluster is in safe mode
-     */
-    NodeResponse applyRequest(String method, URI uri, Object entity, Map<String, String> headers)
-            throws NoConnectedNodesException, NoResponseFromNodesException, UriConstructionException, ConnectingNodeMutableRequestException,
-            DisconnectedNodeMutableRequestException, SafeModeMutableRequestException;
-
-    /**
-     * Federates the HTTP request to the nodes specified. The given URI's host
-     * and port will not be used and instead will be adjusted for each node's
-     * host and port. The node URIs are guaranteed to be constructed before
-     * issuing any requests, so if a UriConstructionException is thrown, then it
-     * is guaranteed that no request was issued.
-     *
-     * @param method the HTTP method (e.g., GET, POST, PUT, DELETE, HEAD)
-     * @param uri the base request URI (up to, but not including, the query
-     * string)
-     * @param entity the HTTP request entity
-     * @param headers the request headers
-     * @param nodeIdentifiers the NodeIdentifier for each node that the request
-     * should be replaced to
-     *
-     * @return the client response
-     *
-     * @throws NoConnectedNodesException if no nodes are connected as results of
-     * the request
-     * @throws NoResponseFromNodesException if no response could be obtained
-     * @throws UriConstructionException if there was an issue constructing the
-     * URIs tailored for each individual node
-     * @throws ConnectingNodeMutableRequestException if the request was a PUT,
-     * POST, DELETE and a node is connecting to the cluster
-     * @throws DisconnectedNodeMutableRequestException if the request was a PUT,
-     * POST, DELETE and a node is disconnected from the cluster
-     * @throws SafeModeMutableRequestException if the request was a PUT, POST,
-     * DELETE and a the cluster is in safe mode
-     */
-    NodeResponse applyRequest(String method, URI uri, Object entity, Map<String, String> headers, Set<NodeIdentifier> nodeIdentifiers)
-            throws NoConnectedNodesException, NoResponseFromNodesException, UriConstructionException, ConnectingNodeMutableRequestException,
-            DisconnectedNodeMutableRequestException, SafeModeMutableRequestException;
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/HttpRequestReplicator.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/HttpRequestReplicator.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/HttpRequestReplicator.java
deleted file mode 100644
index fb57622..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/HttpRequestReplicator.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * 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.nifi.cluster.manager;
-
-import org.apache.nifi.cluster.manager.exception.UriConstructionException;
-import java.net.URI;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import org.apache.nifi.cluster.protocol.NodeIdentifier;
-
-/**
- * A service for managing the replication of requests to nodes. It is up to the
- * implementing class to decide if requests are sent concurrently or serially.
- *
- * Clients must call start() and stop() to initialize and shutdown the instance.
- * The instance must be started before issuing any replication requests.
- *
- * @author unattributed
- */
-public interface HttpRequestReplicator {
-
-    /**
-     * Starts the instance for replicating requests. Start may only be called if
-     * the instance is not running.
-     */
-    void start();
-
-    /**
-     * Stops the instance from replicating requests. Stop may only be called if
-     * the instance is running.
-     */
-    void stop();
-
-    /**
-     * @return true if the instance is started; false otherwise.
-     */
-    boolean isRunning();
-
-    /**
-     * Requests are sent to each node in the cluster. If the request results in
-     * an exception, then the NodeResourceResponse will contain the exception.
-     *
-     * HTTP DELETE and OPTIONS methods must supply an empty parameters map or
-     * else and IllegalArgumentException is thrown.
-     *
-     * @param nodeIds the node identifiers
-     * @param method the HTTP method (e.g., GET, POST, PUT, DELETE, HEAD,
-     * OPTIONS)
-     * @param uri the base request URI (up to, but not including, the query
-     * string)
-     * @param parameters any request parameters
-     * @param headers any HTTP headers
-     *
-     * @return the set of node responses
-     *
-     * @throws UriConstructionException if a request for a node failed to be
-     * constructed from the given prototype URI. If thrown, it is guaranteed
-     * that no request was sent.
-     */
-    Set<NodeResponse> replicate(Set<NodeIdentifier> nodeIds, String method, URI uri, Map<String, List<String>> parameters, Map<String, String> headers) throws UriConstructionException;
-
-    /**
-     * Requests are sent to each node in the cluster. If the request results in
-     * an exception, then the NodeResourceResponse will contain the exception.
-     *
-     * HTTP DELETE, GET, HEAD, and OPTIONS methods will throw an
-     * IllegalArgumentException if used.
-     *
-     * @param nodeIds the node identifiers
-     * @param method the HTTP method (e.g., POST, PUT)
-     * @param uri the base request URI (up to, but not including, the query
-     * string)
-     * @param entity an entity
-     * @param headers any HTTP headers
-     *
-     * @return the set of node responses
-     *
-     * @throws UriConstructionException if a request for a node failed to be
-     * constructed from the given prototype URI. If thrown, it is guaranteed
-     * that no request was sent.
-     */
-    Set<NodeResponse> replicate(Set<NodeIdentifier> nodeIds, String method, URI uri, Object entity, Map<String, String> headers) throws UriConstructionException;
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/HttpResponseMapper.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/HttpResponseMapper.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/HttpResponseMapper.java
deleted file mode 100644
index 843a666..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/HttpResponseMapper.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * 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.nifi.cluster.manager;
-
-import java.net.URI;
-import java.util.Map;
-import java.util.Set;
-import org.apache.nifi.cluster.node.Node.Status;
-
-/**
- * Maps a HTTP response to a node status.
- *
- * @author unattributed
- */
-public interface HttpResponseMapper {
-
-    /**
-     * Maps a HTTP response to a node response and the corresponding node
-     * status.
-     *
-     * @param requestURI the original request URI
-     * @param nodeResponses a set of node resource responses
-     *
-     * @return a map associating the node response to the node status
-     */
-    Map<NodeResponse, Status> map(URI requestURI, Set<NodeResponse> nodeResponses);
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/NodeResponse.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/NodeResponse.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/NodeResponse.java
deleted file mode 100644
index 3f966e5..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/NodeResponse.java
+++ /dev/null
@@ -1,329 +0,0 @@
-/*
- * 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.nifi.cluster.manager;
-
-import com.sun.jersey.api.client.ClientResponse;
-import java.io.BufferedInputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.net.URI;
-import java.util.List;
-import java.util.Objects;
-import java.util.concurrent.TimeUnit;
-
-import javax.ws.rs.HttpMethod;
-import javax.ws.rs.WebApplicationException;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.Response.ResponseBuilder;
-import javax.ws.rs.core.Response.Status;
-import javax.ws.rs.core.StreamingOutput;
-import org.apache.nifi.cluster.protocol.NodeIdentifier;
-import org.apache.nifi.web.api.entity.Entity;
-
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.lang3.StringUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Encapsulates a node's response in regards to receiving a external API
- * request.
- *
- * Both the ClientResponse and (server) Response may be obtained from this
- * instance. The ClientResponse is stored as it is received from the node. This
- * includes the entity input stream. The Response is constructed on demand when
- * mapping a ClientResponse to the Response. The ClientResponse to Response
- * mapping includes copying the ClientResponse's input stream to the Response.
- * Therefore, the getResponse() method should not be called more than once.
- * Furthermore, the method should not be called if the caller has already read
- * the ClientResponse's input stream.
- *
- * If a ClientResponse was unable to be created, then a NodeResponse will store
- * the Throwable, which may be obtained by calling getThrowable().
- *
- * This class overrides hashCode and equals and considers two instances to be
- * equal if they have the equal NodeIdentifiers.
- *
- * @author unattributed
- */
-public class NodeResponse {
-
-    private static final Logger logger = LoggerFactory.getLogger(NodeResponse.class);
-    private final String httpMethod;
-    private final URI requestUri;
-    private final ClientResponse clientResponse;
-    private final NodeIdentifier nodeId;
-    private final Throwable throwable;
-    private boolean hasCreatedResponse = false;
-    private final Entity updatedEntity;
-    private final long requestDurationNanos;
-    private final String requestId;
-
-    public NodeResponse(final NodeIdentifier nodeId, final String httpMethod, final URI requestUri, final ClientResponse clientResponse, final long requestDurationNanos, final String requestId) {
-        if (nodeId == null) {
-            throw new IllegalArgumentException("Node identifier may not be null.");
-        } else if (StringUtils.isBlank(httpMethod)) {
-            throw new IllegalArgumentException("Http method may not be null or empty.");
-        } else if (requestUri == null) {
-            throw new IllegalArgumentException("Request URI may not be null.");
-        } else if (clientResponse == null) {
-            throw new IllegalArgumentException("ClientResponse may not be null.");
-        }
-        this.nodeId = nodeId;
-        this.httpMethod = httpMethod;
-        this.requestUri = requestUri;
-        this.clientResponse = clientResponse;
-        this.throwable = null;
-        this.updatedEntity = null;
-        this.requestDurationNanos = requestDurationNanos;
-        this.requestId = requestId;
-    }
-
-    public NodeResponse(final NodeIdentifier nodeId, final String httpMethod, final URI requestUri, final Throwable throwable) {
-        if (nodeId == null) {
-            throw new IllegalArgumentException("Node identifier may not be null.");
-        } else if (StringUtils.isBlank(httpMethod)) {
-            throw new IllegalArgumentException("Http method may not be null or empty.");
-        } else if (requestUri == null) {
-            throw new IllegalArgumentException("Request URI may not be null.");
-        } else if (throwable == null) {
-            throw new IllegalArgumentException("Throwable may not be null.");
-        }
-        this.nodeId = nodeId;
-        this.httpMethod = httpMethod;
-        this.requestUri = requestUri;
-        this.clientResponse = null;
-        this.throwable = throwable;
-        this.updatedEntity = null;
-        this.requestDurationNanos = -1L;
-        this.requestId = null;
-    }
-
-    public NodeResponse(final NodeResponse example, final Entity updatedEntity) {
-        Objects.requireNonNull(example, "NodeResponse cannot be null");
-        Objects.requireNonNull(updatedEntity, "UpdatedEntity cannot be null");
-
-        this.nodeId = example.nodeId;
-        this.httpMethod = example.httpMethod;
-        this.requestUri = example.requestUri;
-        this.clientResponse = example.clientResponse;
-        this.throwable = example.throwable;
-        this.updatedEntity = updatedEntity;
-        this.requestDurationNanos = example.requestDurationNanos;
-        this.requestId = null;
-    }
-
-    public NodeIdentifier getNodeId() {
-        return nodeId;
-    }
-
-    public String getHttpMethod() {
-        return httpMethod;
-    }
-
-    public URI getRequestUri() {
-        return requestUri;
-    }
-
-    /**
-     * @return the HTTP response status code
-     */
-    public int getStatus() {
-        if (hasThrowable()) {
-            /*
-             * since there is a throwable, there is no client input stream to 
-             * worry about maintaining, so we can call getResponse() method
-             */
-            return getResponse().getStatus();
-        } else {
-            /*
-             * use client response's status instead of calling getResponse().getStatus()
-             * so that we don't read the client's input stream as part of creating 
-             * the response in the getResponse() method
-             */
-            return clientResponse.getStatus();
-        }
-    }
-
-    /**
-     * Returns true if the response status is 2xx, false otherwise.
-     *
-     * @return
-     */
-    public boolean is2xx() {
-        final int statusCode = getStatus();
-        return (200 <= statusCode && statusCode <= 299);
-    }
-
-    /**
-     * Returns true if the response status is 5xx, false otherwise.
-     *
-     * @return
-     */
-    public boolean is5xx() {
-        final int statusCode = getStatus();
-        return (500 <= statusCode && statusCode <= 599);
-    }
-
-    /**
-     * Returns null if hasThrowable() is true; otherwise the client's response
-     * is returned.
-     *
-     * The ClientResponse's input stream can only be read once.
-     *
-     * @return the client's response
-     */
-    public ClientResponse getClientResponse() {
-        return clientResponse;
-    }
-
-    /**
-     * Creates a Response by mapping the ClientResponse values to it. Since the
-     * ClientResponse's input stream can only be read once, this method should
-     * only be called once. Furthermore, the caller should not have already read
-     * the ClientResponse's input stream.
-     *
-     * @return the response
-     */
-    public Response getResponse() {
-        // if the response encapsulates a throwable, then the input stream is never read and the below warning is irrelevant
-        if (hasCreatedResponse && !hasThrowable()) {
-            logger.warn("ClientResponse's input stream has already been read.  The created response will not contain this data.");
-        }
-        hasCreatedResponse = true;
-        return createResponse();
-    }
-
-    /**
-     * Returns the throwable or null if no throwable exists.
-     *
-     * @return the throwable or null if no throwable exists
-     */
-    public Throwable getThrowable() {
-        return throwable;
-    }
-
-    /**
-     * Returns true if a throwable was thrown and a response was not able to be
-     * created; false otherwise.
-     *
-     * @return true if a throwable was thrown and a response was not able to be
-     * created; false otherwise
-     */
-    public boolean hasThrowable() {
-        return getThrowable() != null;
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-        if (obj == null) {
-            return false;
-        }
-        if (getClass() != obj.getClass()) {
-            return false;
-        }
-        final NodeResponse other = (NodeResponse) obj;
-        if (this.nodeId != other.nodeId && (this.nodeId == null || !this.nodeId.equals(other.nodeId))) {
-            return false;
-        }
-        return true;
-    }
-
-    @Override
-    public int hashCode() {
-        int hash = 7;
-        hash = 13 * hash + (this.nodeId != null ? this.nodeId.hashCode() : 0);
-        return hash;
-    }
-
-    public long getRequestDuration(final TimeUnit timeUnit) {
-        return timeUnit.convert(requestDurationNanos, TimeUnit.NANOSECONDS);
-    }
-
-    public String getRequestId() {
-        return requestId;
-    }
-
-    private Response createResponse() {
-
-        // if no client response was created, then generate a 500 response
-        if (hasThrowable()) {
-            return Response.status(Status.INTERNAL_SERVER_ERROR).build();
-        }
-
-        // set the status
-        final ResponseBuilder responseBuilder = Response.status(clientResponse.getStatus());
-
-        // set the headers
-        for (final String key : clientResponse.getHeaders().keySet()) {
-            final List<String> values = clientResponse.getHeaders().get(key);
-            for (final String value : values) {
-
-                if (key.equalsIgnoreCase("transfer-encoding") || key.equalsIgnoreCase("content-length")) {
-                    /*
-                     * do not copy the transfer-encoding header (i.e., chunked encoding) or
-                     * the content-length. Let the outgoing response builder determine it.
-                     */
-                    continue;
-                } else if (key.equals("X-ClusterContext")) {
-                    /*
-                     * do not copy the cluster context to the response because
-                     * this information is private and should not be sent to
-                     * the client
-                     */
-                    continue;
-                }
-                responseBuilder.header(key, value);
-            }
-        }
-
-        // head requests must not have a message-body in the response
-        if (!HttpMethod.HEAD.equalsIgnoreCase(httpMethod)) {
-
-            // set the entity
-            if (updatedEntity == null) {
-                responseBuilder.entity(new StreamingOutput() {
-                    @Override
-                    public void write(final OutputStream output) throws IOException, WebApplicationException {
-                        BufferedInputStream bis = null;
-                        try {
-                            bis = new BufferedInputStream(clientResponse.getEntityInputStream());
-                            IOUtils.copy(bis, output);
-                        } finally {
-                            IOUtils.closeQuietly(bis);
-                        }
-                    }
-                });
-            } else {
-                responseBuilder.entity(updatedEntity);
-            }
-        }
-
-        return responseBuilder.build();
-    }
-
-    @Override
-    public String toString() {
-        final StringBuilder sb = new StringBuilder();
-        sb.append("NodeResponse[nodeUri=").append(nodeId.getApiAddress()).append(":").append(nodeId.getApiPort()).append(",")
-                .append("method=").append(httpMethod)
-                .append(",URI=").append(requestUri)
-                .append(",ResponseCode=").append(getStatus())
-                .append(",Duration=").append(TimeUnit.MILLISECONDS.convert(requestDurationNanos, TimeUnit.NANOSECONDS)).append(" ms]");
-        return sb.toString();
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/BlockedByFirewallException.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/BlockedByFirewallException.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/BlockedByFirewallException.java
deleted file mode 100644
index 49bcd35..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/BlockedByFirewallException.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * 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.nifi.cluster.manager.exception;
-
-import org.apache.nifi.cluster.protocol.NodeIdentifier;
-
-/**
- *
- */
-public class BlockedByFirewallException extends ClusterException {
-
-    private final NodeIdentifier nodeId;
-    private final boolean isExistingNode;
-
-    public BlockedByFirewallException(NodeIdentifier nodeId, boolean isExistingNode, String msg, Throwable cause) {
-        super(msg, cause);
-        this.nodeId = nodeId;
-        this.isExistingNode = isExistingNode;
-    }
-
-    public BlockedByFirewallException(NodeIdentifier nodeId, boolean isExistingNode, Throwable cause) {
-        super(cause);
-        this.nodeId = nodeId;
-        this.isExistingNode = isExistingNode;
-    }
-
-    public BlockedByFirewallException(NodeIdentifier nodeId, boolean isExistingNode, String msg) {
-        super(msg);
-        this.nodeId = nodeId;
-        this.isExistingNode = isExistingNode;
-    }
-
-    public BlockedByFirewallException(NodeIdentifier nodeId, boolean isExistingNode) {
-        this.nodeId = nodeId;
-        this.isExistingNode = isExistingNode;
-    }
-
-    public NodeIdentifier getNodeId() {
-        return nodeId;
-    }
-
-    public boolean isExistingNode() {
-        return isExistingNode;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/ClusterException.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/ClusterException.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/ClusterException.java
deleted file mode 100644
index 3bf9752..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/ClusterException.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * 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.nifi.cluster.manager.exception;
-
-/**
- * The base exception class for cluster related exceptions.
- *
- * @author unattributed
- */
-public class ClusterException extends RuntimeException {
-
-    public ClusterException() {
-    }
-
-    public ClusterException(String msg) {
-        super(msg);
-    }
-
-    public ClusterException(Throwable cause) {
-        super(cause);
-    }
-
-    public ClusterException(String msg, Throwable cause) {
-        super(msg, cause);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/ConnectingNodeMutableRequestException.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/ConnectingNodeMutableRequestException.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/ConnectingNodeMutableRequestException.java
deleted file mode 100644
index 365b5f0..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/ConnectingNodeMutableRequestException.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * 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.nifi.cluster.manager.exception;
-
-/**
- * Represents the exceptional case when a HTTP request that may change a node's
- * dataflow is to be replicated while a node is connecting to the cluster.
- *
- * @author unattributed
- */
-public class ConnectingNodeMutableRequestException extends MutableRequestException {
-
-    public ConnectingNodeMutableRequestException() {
-    }
-
-    public ConnectingNodeMutableRequestException(String msg) {
-        super(msg);
-    }
-
-    public ConnectingNodeMutableRequestException(Throwable cause) {
-        super(cause);
-    }
-
-    public ConnectingNodeMutableRequestException(String msg, Throwable cause) {
-        super(msg, cause);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/DisconnectedNodeMutableRequestException.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/DisconnectedNodeMutableRequestException.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/DisconnectedNodeMutableRequestException.java
deleted file mode 100644
index 412a555..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/DisconnectedNodeMutableRequestException.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * 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.nifi.cluster.manager.exception;
-
-/**
- * Represents the exceptional case when a HTTP request that may change a node's
- * dataflow is to be replicated while one or more nodes are disconnected.
- *
- * @author unattributed
- */
-public class DisconnectedNodeMutableRequestException extends MutableRequestException {
-
-    public DisconnectedNodeMutableRequestException() {
-    }
-
-    public DisconnectedNodeMutableRequestException(String msg) {
-        super(msg);
-    }
-
-    public DisconnectedNodeMutableRequestException(Throwable cause) {
-        super(cause);
-    }
-
-    public DisconnectedNodeMutableRequestException(String msg, Throwable cause) {
-        super(msg, cause);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/IllegalClusterStateException.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/IllegalClusterStateException.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/IllegalClusterStateException.java
deleted file mode 100644
index 6c4e670..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/IllegalClusterStateException.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * 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.nifi.cluster.manager.exception;
-
-/**
- * Signals that an operation to be performed on a cluster has been invoked at an
- * illegal or inappropriate time.
- *
- * @author unattributed
- */
-public class IllegalClusterStateException extends ClusterException {
-
-    public IllegalClusterStateException() {
-    }
-
-    public IllegalClusterStateException(String msg) {
-        super(msg);
-    }
-
-    public IllegalClusterStateException(Throwable cause) {
-        super(cause);
-    }
-
-    public IllegalClusterStateException(String msg, Throwable cause) {
-        super(msg, cause);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/IllegalNodeDeletionException.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/IllegalNodeDeletionException.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/IllegalNodeDeletionException.java
deleted file mode 100644
index adef62a..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/IllegalNodeDeletionException.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * 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.nifi.cluster.manager.exception;
-
-/**
- * Represents the exceptional case when a deletion request is issued to a node
- * that cannot be deleted (e.g., the node is not disconnected).
- *
- * @author unattributed
- */
-public class IllegalNodeDeletionException extends IllegalClusterStateException {
-
-    public IllegalNodeDeletionException() {
-    }
-
-    public IllegalNodeDeletionException(String msg) {
-        super(msg);
-    }
-
-    public IllegalNodeDeletionException(Throwable cause) {
-        super(cause);
-    }
-
-    public IllegalNodeDeletionException(String msg, Throwable cause) {
-        super(msg, cause);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/IllegalNodeDisconnectionException.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/IllegalNodeDisconnectionException.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/IllegalNodeDisconnectionException.java
deleted file mode 100644
index 7e61b24..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/IllegalNodeDisconnectionException.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * 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.nifi.cluster.manager.exception;
-
-/**
- * Represents the exceptional case when a disconnection request is issued to a
- * node that cannot be disconnected (e.g., last node in cluster, node is primary
- * node).
- *
- * @author unattributed
- */
-public class IllegalNodeDisconnectionException extends IllegalClusterStateException {
-
-    public IllegalNodeDisconnectionException() {
-    }
-
-    public IllegalNodeDisconnectionException(String msg) {
-        super(msg);
-    }
-
-    public IllegalNodeDisconnectionException(Throwable cause) {
-        super(cause);
-    }
-
-    public IllegalNodeDisconnectionException(String msg, Throwable cause) {
-        super(msg, cause);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/IllegalNodeReconnectionException.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/IllegalNodeReconnectionException.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/IllegalNodeReconnectionException.java
deleted file mode 100644
index 96c76bc..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/IllegalNodeReconnectionException.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * 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.nifi.cluster.manager.exception;
-
-/**
- * Represents the exceptional case when a reconnection request is issued to a
- * node that cannot be reconnected (e.g., the node is not disconnected).
- *
- * @author unattributed
- */
-public class IllegalNodeReconnectionException extends IllegalClusterStateException {
-
-    public IllegalNodeReconnectionException() {
-    }
-
-    public IllegalNodeReconnectionException(String msg) {
-        super(msg);
-    }
-
-    public IllegalNodeReconnectionException(Throwable cause) {
-        super(cause);
-    }
-
-    public IllegalNodeReconnectionException(String msg, Throwable cause) {
-        super(msg, cause);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/IneligiblePrimaryNodeException.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/IneligiblePrimaryNodeException.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/IneligiblePrimaryNodeException.java
deleted file mode 100644
index 4b0097a..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/IneligiblePrimaryNodeException.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * 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.nifi.cluster.manager.exception;
-
-/**
- * Represents the exceptional case when the primary role cannot be assigned to a
- * node because the node is ineligible for the role.
- *
- * @author unattributed
- */
-public class IneligiblePrimaryNodeException extends IllegalClusterStateException {
-
-    public IneligiblePrimaryNodeException() {
-    }
-
-    public IneligiblePrimaryNodeException(String msg) {
-        super(msg);
-    }
-
-    public IneligiblePrimaryNodeException(Throwable cause) {
-        super(cause);
-    }
-
-    public IneligiblePrimaryNodeException(String msg, Throwable cause) {
-        super(msg, cause);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/MutableRequestException.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/MutableRequestException.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/MutableRequestException.java
deleted file mode 100644
index d160587..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/MutableRequestException.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * 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.nifi.cluster.manager.exception;
-
-/**
- * Represents the exceptional case when a HTTP request that may change a node's
- * state is to be replicated while the cluster or connected nodes are unable to
- * change their state (e.g., a new node is connecting to the cluster).
- *
- * @author unattributed
- */
-public class MutableRequestException extends IllegalClusterStateException {
-
-    public MutableRequestException() {
-    }
-
-    public MutableRequestException(String msg) {
-        super(msg);
-    }
-
-    public MutableRequestException(Throwable cause) {
-        super(cause);
-    }
-
-    public MutableRequestException(String msg, Throwable cause) {
-        super(msg, cause);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/NoConnectedNodesException.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/NoConnectedNodesException.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/NoConnectedNodesException.java
deleted file mode 100644
index 8d704b9..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/NoConnectedNodesException.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * 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.nifi.cluster.manager.exception;
-
-/**
- * Represents the exceptional case when the cluster is unable to service a
- * request because no nodes are connected.
- *
- * @author unattributed
- */
-public class NoConnectedNodesException extends ClusterException {
-
-    public NoConnectedNodesException() {
-    }
-
-    public NoConnectedNodesException(String msg) {
-        super(msg);
-    }
-
-    public NoConnectedNodesException(Throwable cause) {
-        super(cause);
-    }
-
-    public NoConnectedNodesException(String msg, Throwable cause) {
-        super(msg, cause);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/NoResponseFromNodesException.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/NoResponseFromNodesException.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/NoResponseFromNodesException.java
deleted file mode 100644
index 9e17a23..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/NoResponseFromNodesException.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * 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.nifi.cluster.manager.exception;
-
-/**
- * Represents the exceptional case when the cluster is unable to service a
- * request because no nodes returned a response. When the given request is not
- * mutable the nodes are left in their previous state.
- *
- * @author unattributed
- */
-public class NoResponseFromNodesException extends ClusterException {
-
-    public NoResponseFromNodesException() {
-    }
-
-    public NoResponseFromNodesException(String msg) {
-        super(msg);
-    }
-
-    public NoResponseFromNodesException(Throwable cause) {
-        super(cause);
-    }
-
-    public NoResponseFromNodesException(String msg, Throwable cause) {
-        super(msg, cause);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/NodeDisconnectionException.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/NodeDisconnectionException.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/NodeDisconnectionException.java
deleted file mode 100644
index 3bd2f4b..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/NodeDisconnectionException.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * 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.nifi.cluster.manager.exception;
-
-/**
- * Represents the exceptional case when a disconnection request to a node
- * failed.
- *
- * @author unattributed
- */
-public class NodeDisconnectionException extends ClusterException {
-
-    public NodeDisconnectionException() {
-    }
-
-    public NodeDisconnectionException(String msg) {
-        super(msg);
-    }
-
-    public NodeDisconnectionException(Throwable cause) {
-        super(cause);
-    }
-
-    public NodeDisconnectionException(String msg, Throwable cause) {
-        super(msg, cause);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/NodeReconnectionException.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/NodeReconnectionException.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/NodeReconnectionException.java
deleted file mode 100644
index 8c40cef..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/NodeReconnectionException.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * 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.nifi.cluster.manager.exception;
-
-/**
- * Represents the exceptional case when a reconnection request to a node failed.
- *
- * @author unattributed
- */
-public class NodeReconnectionException extends ClusterException {
-
-    public NodeReconnectionException() {
-    }
-
-    public NodeReconnectionException(String msg) {
-        super(msg);
-    }
-
-    public NodeReconnectionException(Throwable cause) {
-        super(cause);
-    }
-
-    public NodeReconnectionException(String msg, Throwable cause) {
-        super(msg, cause);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/PrimaryRoleAssignmentException.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/PrimaryRoleAssignmentException.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/PrimaryRoleAssignmentException.java
deleted file mode 100644
index 403f7a5..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/PrimaryRoleAssignmentException.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * 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.nifi.cluster.manager.exception;
-
-/**
- * Represents the exceptional case when the cluster is unable to update the
- * primary role of a node.
- *
- * @author unattributed
- */
-public class PrimaryRoleAssignmentException extends IllegalClusterStateException {
-
-    public PrimaryRoleAssignmentException() {
-    }
-
-    public PrimaryRoleAssignmentException(String msg) {
-        super(msg);
-    }
-
-    public PrimaryRoleAssignmentException(Throwable cause) {
-        super(cause);
-    }
-
-    public PrimaryRoleAssignmentException(String msg, Throwable cause) {
-        super(msg, cause);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/SafeModeMutableRequestException.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/SafeModeMutableRequestException.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/SafeModeMutableRequestException.java
deleted file mode 100644
index f544f26..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/SafeModeMutableRequestException.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * 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.nifi.cluster.manager.exception;
-
-/**
- * Represents the exceptional case when a HTTP request that may change a node's
- * dataflow is to be replicated while the cluster is in safe mode.
- *
- * @author unattributed
- */
-public class SafeModeMutableRequestException extends MutableRequestException {
-
-    public SafeModeMutableRequestException() {
-    }
-
-    public SafeModeMutableRequestException(String msg) {
-        super(msg);
-    }
-
-    public SafeModeMutableRequestException(Throwable cause) {
-        super(cause);
-    }
-
-    public SafeModeMutableRequestException(String msg, Throwable cause) {
-        super(msg, cause);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/UnknownNodeException.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/UnknownNodeException.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/UnknownNodeException.java
deleted file mode 100644
index 914bb56..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/UnknownNodeException.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * 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.nifi.cluster.manager.exception;
-
-/**
- * Represents the exceptional case when a request is made for a node that does
- * not exist.
- *
- * @author unattributed
- */
-public class UnknownNodeException extends ClusterException {
-
-    public UnknownNodeException() {
-    }
-
-    public UnknownNodeException(String msg) {
-        super(msg);
-    }
-
-    public UnknownNodeException(Throwable cause) {
-        super(cause);
-    }
-
-    public UnknownNodeException(String msg, Throwable cause) {
-        super(msg, cause);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/UriConstructionException.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/UriConstructionException.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/UriConstructionException.java
deleted file mode 100644
index 773d7b5..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/UriConstructionException.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * 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.nifi.cluster.manager.exception;
-
-/**
- * Represents the exceptional case when a URI cannot be constructed from the
- * given information. This exception is similar to Java's URISyntaxException
- * except that it extends RuntimeException.
- *
- * @author unattributed
- */
-public class UriConstructionException extends RuntimeException {
-
-    public UriConstructionException() {
-    }
-
-    public UriConstructionException(String msg) {
-        super(msg);
-    }
-
-    public UriConstructionException(Throwable cause) {
-        super(cause);
-    }
-
-    public UriConstructionException(String msg, Throwable cause) {
-        super(msg, cause);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/impl/ClusteredEventAccess.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/impl/ClusteredEventAccess.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/impl/ClusteredEventAccess.java
deleted file mode 100644
index 2015530..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/impl/ClusteredEventAccess.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * 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.nifi.cluster.manager.impl;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.nifi.controller.status.ProcessGroupStatus;
-import org.apache.nifi.events.EventReporter;
-import org.apache.nifi.provenance.ProvenanceEventBuilder;
-import org.apache.nifi.provenance.ProvenanceEventRecord;
-import org.apache.nifi.provenance.ProvenanceEventRepository;
-import org.apache.nifi.provenance.lineage.ComputeLineageSubmission;
-import org.apache.nifi.provenance.search.Query;
-import org.apache.nifi.provenance.search.QuerySubmission;
-import org.apache.nifi.provenance.search.SearchableField;
-import org.apache.nifi.reporting.EventAccess;
-
-public class ClusteredEventAccess implements EventAccess {
-
-    private final WebClusterManager clusterManager;
-
-    public ClusteredEventAccess(final WebClusterManager clusterManager) {
-        this.clusterManager = clusterManager;
-    }
-
-    @Override
-    public ProcessGroupStatus getControllerStatus() {
-        return clusterManager.getProcessGroupStatus(WebClusterManager.ROOT_GROUP_ID_ALIAS);
-    }
-
-    @Override
-    public List<ProvenanceEventRecord> getProvenanceEvents(long arg0, int arg1) throws IOException {
-        return new ArrayList<>();
-    }
-
-    @Override
-    public ProvenanceEventRepository getProvenanceRepository() {
-        // NCM doesn't have provenance events, because it doesn't process FlowFiles.
-        // So we just use a Provenance Event Repository that does nothing.
-        return new ProvenanceEventRepository() {
-            @Override
-            public void close() throws IOException {
-            }
-
-            @Override
-            public ProvenanceEventRecord getEvent(long eventId) throws IOException {
-                return null;
-            }
-
-            @Override
-            public List<ProvenanceEventRecord> getEvents(long startEventId, int maxEvents) throws IOException {
-                return new ArrayList<>();
-            }
-
-            @Override
-            public Long getMaxEventId() {
-                return null;
-            }
-
-            @Override
-            public List<SearchableField> getSearchableAttributes() {
-                return new ArrayList<>();
-            }
-
-            @Override
-            public List<SearchableField> getSearchableFields() {
-                return new ArrayList<>();
-            }
-
-            @Override
-            public void registerEvent(final ProvenanceEventRecord event) {
-            }
-
-            @Override
-            public void registerEvents(final Iterable<ProvenanceEventRecord> events) {
-            }
-
-            @Override
-            public ComputeLineageSubmission retrieveLineageSubmission(final String submissionId) {
-                return null;
-            }
-
-            @Override
-            public QuerySubmission retrieveQuerySubmission(final String submissionId) {
-                return null;
-            }
-
-            @Override
-            public ComputeLineageSubmission submitExpandChildren(final long eventId) {
-                return null;
-            }
-
-            @Override
-            public ComputeLineageSubmission submitExpandParents(final long eventId) {
-                return null;
-            }
-
-            @Override
-            public ComputeLineageSubmission submitLineageComputation(final String flowFileUuid) {
-                return null;
-            }
-
-            @Override
-            public QuerySubmission submitQuery(final Query query) {
-                return null;
-            }
-
-            @Override
-            public ProvenanceEventBuilder eventBuilder() {
-                return null;
-            }
-
-            @Override
-            public void initialize(EventReporter eventReporter) throws IOException {
-
-            }
-        };
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/impl/ClusteredReportingContext.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/impl/ClusteredReportingContext.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/impl/ClusteredReportingContext.java
deleted file mode 100644
index e546f87..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/impl/ClusteredReportingContext.java
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * 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.nifi.cluster.manager.impl;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.nifi.attribute.expression.language.PreparedQuery;
-import org.apache.nifi.attribute.expression.language.Query;
-import org.apache.nifi.components.PropertyDescriptor;
-import org.apache.nifi.components.PropertyValue;
-import org.apache.nifi.controller.ControllerServiceLookup;
-import org.apache.nifi.controller.service.ControllerServiceProvider;
-import org.apache.nifi.controller.status.PortStatus;
-import org.apache.nifi.controller.status.ProcessGroupStatus;
-import org.apache.nifi.controller.status.ProcessorStatus;
-import org.apache.nifi.events.BulletinFactory;
-import org.apache.nifi.processor.StandardPropertyValue;
-import org.apache.nifi.reporting.Bulletin;
-import org.apache.nifi.reporting.BulletinRepository;
-import org.apache.nifi.reporting.EventAccess;
-import org.apache.nifi.reporting.ReportingContext;
-import org.apache.nifi.reporting.Severity;
-
-public class ClusteredReportingContext implements ReportingContext {
-
-    private final EventAccess eventAccess;
-    private final BulletinRepository bulletinRepository;
-    private final ControllerServiceProvider serviceProvider;
-    private final Map<PropertyDescriptor, String> properties;
-    private final Map<PropertyDescriptor, PreparedQuery> preparedQueries;
-
-    public ClusteredReportingContext(final EventAccess eventAccess, final BulletinRepository bulletinRepository,
-            final Map<PropertyDescriptor, String> properties, final ControllerServiceProvider serviceProvider) {
-        this.eventAccess = eventAccess;
-        this.bulletinRepository = bulletinRepository;
-        this.properties = Collections.unmodifiableMap(properties);
-        this.serviceProvider = serviceProvider;
-
-        preparedQueries = new HashMap<>();
-        for (final Map.Entry<PropertyDescriptor, String> entry : properties.entrySet()) {
-            final PropertyDescriptor desc = entry.getKey();
-            String value = entry.getValue();
-            if (value == null) {
-                value = desc.getDefaultValue();
-            }
-
-            final PreparedQuery pq = Query.prepare(value);
-            preparedQueries.put(desc, pq);
-        }
-    }
-
-    @Override
-    public EventAccess getEventAccess() {
-        return eventAccess;
-    }
-
-    @Override
-    public BulletinRepository getBulletinRepository() {
-        return bulletinRepository;
-    }
-
-    @Override
-    public Bulletin createBulletin(final String category, final Severity severity, final String message) {
-        return BulletinFactory.createBulletin(category, severity.name(), message);
-    }
-
-    @Override
-    public Bulletin createBulletin(final String componentId, final String category, final Severity severity, final String message) {
-        final ProcessGroupStatus rootGroupStatus = eventAccess.getControllerStatus();
-        final String groupId = findGroupId(rootGroupStatus, componentId);
-        final String componentName = findComponentName(rootGroupStatus, componentId);
-
-        return BulletinFactory.createBulletin(groupId, componentId, componentName, category, severity.name(), message);
-    }
-
-    @Override
-    public Map<PropertyDescriptor, String> getProperties() {
-        return Collections.unmodifiableMap(properties);
-    }
-
-    @Override
-    public PropertyValue getProperty(final PropertyDescriptor property) {
-        final String configuredValue = properties.get(property);
-        return new StandardPropertyValue(configuredValue == null ? property.getDefaultValue() : configuredValue, serviceProvider, preparedQueries.get(property));
-    }
-
-    @Override
-    public ControllerServiceLookup getControllerServiceLookup() {
-        return serviceProvider;
-    }
-
-    String findGroupId(final ProcessGroupStatus groupStatus, final String componentId) {
-        for (final ProcessorStatus procStatus : groupStatus.getProcessorStatus()) {
-            if (procStatus.getId().equals(componentId)) {
-                return groupStatus.getId();
-            }
-        }
-
-        for (final PortStatus portStatus : groupStatus.getInputPortStatus()) {
-            if (portStatus.getId().equals(componentId)) {
-                return groupStatus.getId();
-            }
-        }
-
-        for (final PortStatus portStatus : groupStatus.getOutputPortStatus()) {
-            if (portStatus.getId().equals(componentId)) {
-                return groupStatus.getId();
-            }
-        }
-
-        for (final ProcessGroupStatus childGroup : groupStatus.getProcessGroupStatus()) {
-            final String groupId = findGroupId(childGroup, componentId);
-            if (groupId != null) {
-                return groupId;
-            }
-        }
-
-        return null;
-    }
-
-    private String findComponentName(final ProcessGroupStatus groupStatus, final String componentId) {
-        for (final ProcessorStatus procStatus : groupStatus.getProcessorStatus()) {
-            if (procStatus.getId().equals(componentId)) {
-                return procStatus.getName();
-            }
-        }
-
-        for (final PortStatus portStatus : groupStatus.getInputPortStatus()) {
-            if (portStatus.getId().equals(componentId)) {
-                return groupStatus.getName();
-            }
-        }
-
-        for (final PortStatus portStatus : groupStatus.getOutputPortStatus()) {
-            if (portStatus.getId().equals(componentId)) {
-                return groupStatus.getName();
-            }
-        }
-
-        for (final ProcessGroupStatus childGroup : groupStatus.getProcessGroupStatus()) {
-            final String componentName = findComponentName(childGroup, componentId);
-            if (componentName != null) {
-                return componentName;
-            }
-        }
-
-        return null;
-    }
-}


[04/20] incubator-nifi git commit: NIFI-410 pushed RAT exclusions down to the relevant modules and stopped doing broad test resource exclusion - is now specific

Posted by jo...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/impl/WebClusterManager.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/impl/WebClusterManager.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/impl/WebClusterManager.java
new file mode 100644
index 0000000..4d5455f
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/impl/WebClusterManager.java
@@ -0,0 +1,3628 @@
+/*
+ * 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.nifi.cluster.manager.impl;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.Serializable;
+import java.net.URI;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Map;
+import java.util.Queue;
+import java.util.Set;
+import java.util.Timer;
+import java.util.TimerTask;
+import java.util.TreeMap;
+import java.util.UUID;
+import java.util.concurrent.CompletionService;
+import java.util.concurrent.ConcurrentLinkedQueue;
+import java.util.concurrent.ExecutorCompletionService;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+import java.util.regex.Pattern;
+
+import javax.net.ssl.SSLContext;
+import javax.ws.rs.HttpMethod;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.StreamingOutput;
+import javax.xml.XMLConstants;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.validation.Schema;
+import javax.xml.validation.SchemaFactory;
+import javax.xml.validation.Validator;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.nifi.admin.service.AuditService;
+import org.apache.nifi.cluster.BulletinsPayload;
+import org.apache.nifi.cluster.HeartbeatPayload;
+import org.apache.nifi.cluster.context.ClusterContext;
+import org.apache.nifi.cluster.context.ClusterContextImpl;
+import org.apache.nifi.cluster.event.Event;
+import org.apache.nifi.cluster.event.EventManager;
+import org.apache.nifi.cluster.firewall.ClusterNodeFirewall;
+import org.apache.nifi.cluster.flow.ClusterDataFlow;
+import org.apache.nifi.cluster.flow.DaoException;
+import org.apache.nifi.cluster.flow.DataFlowManagementService;
+import org.apache.nifi.cluster.flow.PersistedFlowState;
+import org.apache.nifi.cluster.manager.HttpClusterManager;
+import org.apache.nifi.cluster.manager.HttpRequestReplicator;
+import org.apache.nifi.cluster.manager.HttpResponseMapper;
+import org.apache.nifi.cluster.manager.NodeResponse;
+import org.apache.nifi.cluster.manager.exception.ConnectingNodeMutableRequestException;
+import org.apache.nifi.cluster.manager.exception.DisconnectedNodeMutableRequestException;
+import org.apache.nifi.cluster.manager.exception.IllegalClusterStateException;
+import org.apache.nifi.cluster.manager.exception.IllegalNodeDeletionException;
+import org.apache.nifi.cluster.manager.exception.IllegalNodeDisconnectionException;
+import org.apache.nifi.cluster.manager.exception.IllegalNodeReconnectionException;
+import org.apache.nifi.cluster.manager.exception.IneligiblePrimaryNodeException;
+import org.apache.nifi.cluster.manager.exception.NoConnectedNodesException;
+import org.apache.nifi.cluster.manager.exception.NoResponseFromNodesException;
+import org.apache.nifi.cluster.manager.exception.NodeDisconnectionException;
+import org.apache.nifi.cluster.manager.exception.NodeReconnectionException;
+import org.apache.nifi.cluster.manager.exception.PrimaryRoleAssignmentException;
+import org.apache.nifi.cluster.manager.exception.SafeModeMutableRequestException;
+import org.apache.nifi.cluster.manager.exception.UnknownNodeException;
+import org.apache.nifi.cluster.manager.exception.UriConstructionException;
+import org.apache.nifi.cluster.node.Node;
+import org.apache.nifi.cluster.node.Node.Status;
+import org.apache.nifi.cluster.protocol.ConnectionRequest;
+import org.apache.nifi.cluster.protocol.ConnectionResponse;
+import org.apache.nifi.cluster.protocol.Heartbeat;
+import org.apache.nifi.cluster.protocol.NodeBulletins;
+import org.apache.nifi.cluster.protocol.NodeIdentifier;
+import org.apache.nifi.cluster.protocol.ProtocolException;
+import org.apache.nifi.cluster.protocol.ProtocolHandler;
+import org.apache.nifi.cluster.protocol.StandardDataFlow;
+import org.apache.nifi.cluster.protocol.impl.ClusterManagerProtocolSenderListener;
+import org.apache.nifi.cluster.protocol.impl.ClusterServicesBroadcaster;
+import org.apache.nifi.cluster.protocol.message.ConnectionRequestMessage;
+import org.apache.nifi.cluster.protocol.message.ConnectionResponseMessage;
+import org.apache.nifi.cluster.protocol.message.ControllerStartupFailureMessage;
+import org.apache.nifi.cluster.protocol.message.DisconnectMessage;
+import org.apache.nifi.cluster.protocol.message.HeartbeatMessage;
+import org.apache.nifi.cluster.protocol.message.NodeBulletinsMessage;
+import org.apache.nifi.cluster.protocol.message.PrimaryRoleAssignmentMessage;
+import org.apache.nifi.cluster.protocol.message.ProtocolMessage;
+import org.apache.nifi.cluster.protocol.message.ProtocolMessage.MessageType;
+import org.apache.nifi.cluster.protocol.message.ReconnectionFailureMessage;
+import org.apache.nifi.cluster.protocol.message.ReconnectionRequestMessage;
+import org.apache.nifi.components.PropertyDescriptor;
+import org.apache.nifi.controller.ControllerService;
+import org.apache.nifi.controller.Heartbeater;
+import org.apache.nifi.controller.ReportingTaskNode;
+import org.apache.nifi.controller.ValidationContextFactory;
+import org.apache.nifi.controller.reporting.ClusteredReportingTaskNode;
+import org.apache.nifi.controller.reporting.ReportingTaskInstantiationException;
+import org.apache.nifi.controller.reporting.StandardReportingInitializationContext;
+import org.apache.nifi.controller.scheduling.StandardProcessScheduler;
+import org.apache.nifi.controller.scheduling.TimerDrivenSchedulingAgent;
+import org.apache.nifi.controller.service.ControllerServiceNode;
+import org.apache.nifi.controller.service.ControllerServiceProvider;
+import org.apache.nifi.controller.service.StandardControllerServiceProvider;
+import org.apache.nifi.controller.status.ProcessGroupStatus;
+import org.apache.nifi.controller.status.RemoteProcessGroupStatus;
+import org.apache.nifi.controller.status.history.ComponentStatusRepository;
+import org.apache.nifi.controller.status.history.MetricDescriptor;
+import org.apache.nifi.controller.status.history.StatusHistory;
+import org.apache.nifi.controller.status.history.StatusHistoryUtil;
+import org.apache.nifi.controller.status.history.StatusSnapshot;
+import org.apache.nifi.diagnostics.GarbageCollection;
+import org.apache.nifi.diagnostics.StorageUsage;
+import org.apache.nifi.diagnostics.SystemDiagnostics;
+import org.apache.nifi.encrypt.StringEncryptor;
+import org.apache.nifi.engine.FlowEngine;
+import org.apache.nifi.events.BulletinFactory;
+import org.apache.nifi.events.VolatileBulletinRepository;
+import org.apache.nifi.framework.security.util.SslContextFactory;
+import org.apache.nifi.io.socket.multicast.DiscoverableService;
+import org.apache.nifi.logging.NiFiLog;
+import org.apache.nifi.nar.ExtensionManager;
+import org.apache.nifi.nar.NarCloseable;
+import org.apache.nifi.nar.NarThreadContextClassLoader;
+import org.apache.nifi.processor.StandardValidationContextFactory;
+import org.apache.nifi.remote.RemoteResourceManager;
+import org.apache.nifi.remote.RemoteSiteListener;
+import org.apache.nifi.remote.SocketRemoteSiteListener;
+import org.apache.nifi.remote.cluster.ClusterNodeInformation;
+import org.apache.nifi.remote.cluster.NodeInformation;
+import org.apache.nifi.remote.protocol.socket.ClusterManagerServerProtocol;
+import org.apache.nifi.reporting.Bulletin;
+import org.apache.nifi.reporting.BulletinRepository;
+import org.apache.nifi.reporting.InitializationException;
+import org.apache.nifi.reporting.ReportingInitializationContext;
+import org.apache.nifi.reporting.ReportingTask;
+import org.apache.nifi.reporting.Severity;
+import org.apache.nifi.scheduling.SchedulingStrategy;
+import org.apache.nifi.util.DomUtils;
+import org.apache.nifi.util.FormatUtils;
+import org.apache.nifi.util.NiFiProperties;
+import org.apache.nifi.web.Revision;
+import org.apache.nifi.web.api.dto.FlowSnippetDTO;
+import org.apache.nifi.web.api.dto.NodeDTO;
+import org.apache.nifi.web.api.dto.ProcessGroupDTO;
+import org.apache.nifi.web.api.dto.ProcessorDTO;
+import org.apache.nifi.web.api.dto.RemoteProcessGroupContentsDTO;
+import org.apache.nifi.web.api.dto.RemoteProcessGroupDTO;
+import org.apache.nifi.web.api.dto.RemoteProcessGroupPortDTO;
+import org.apache.nifi.web.api.dto.provenance.ProvenanceDTO;
+import org.apache.nifi.web.api.dto.provenance.ProvenanceEventDTO;
+import org.apache.nifi.web.api.dto.provenance.ProvenanceRequestDTO;
+import org.apache.nifi.web.api.dto.provenance.ProvenanceResultsDTO;
+import org.apache.nifi.web.api.dto.status.ClusterStatusHistoryDTO;
+import org.apache.nifi.web.api.dto.status.NodeStatusHistoryDTO;
+import org.apache.nifi.web.api.dto.status.StatusHistoryDTO;
+import org.apache.nifi.web.api.dto.status.StatusSnapshotDTO;
+import org.apache.nifi.web.api.entity.FlowSnippetEntity;
+import org.apache.nifi.web.api.entity.ProcessGroupEntity;
+import org.apache.nifi.web.api.entity.ProcessorEntity;
+import org.apache.nifi.web.api.entity.ProcessorsEntity;
+import org.apache.nifi.web.api.entity.ProvenanceEntity;
+import org.apache.nifi.web.api.entity.ProvenanceEventEntity;
+import org.apache.nifi.web.api.entity.RemoteProcessGroupEntity;
+import org.apache.nifi.web.api.entity.RemoteProcessGroupsEntity;
+import org.apache.nifi.web.util.WebUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.w3c.dom.DOMException;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+
+import com.sun.jersey.api.client.ClientResponse;
+
+/**
+ * Provides a cluster manager implementation. The manager federates incoming
+ * HTTP client requests to the nodes' external API using the HTTP protocol. The
+ * manager also communicates with nodes using the nodes' internal socket
+ * protocol.
+ *
+ * The manager's socket address may broadcasted using multicast if a
+ * MulticastServiceBroadcaster instance is set on this instance. The manager
+ * instance must be started after setting the broadcaster.
+ *
+ * The manager may be configured with an EventManager for recording noteworthy
+ * lifecycle events (e.g., first heartbeat received, node status change).
+ *
+ * The start() and stop() methods must be called to initialize and stop the
+ * instance.
+ *
+ * @author unattributed
+ */
+public class WebClusterManager implements HttpClusterManager, ProtocolHandler, ControllerServiceProvider {
+
+    public static final String ROOT_GROUP_ID_ALIAS = "root";
+    public static final String BULLETIN_CATEGORY = "Clustering";
+
+    private static final Logger logger = new NiFiLog(LoggerFactory.getLogger(WebClusterManager.class));
+    private static final Logger heartbeatLogger = new NiFiLog(LoggerFactory.getLogger("org.apache.nifi.cluster.heartbeat"));
+
+    /**
+     * The HTTP header to store a cluster context. An example of what may be
+     * stored in the context is a node's auditable actions in response to a
+     * cluster request. The cluster context is serialized using Java's
+     * serialization mechanism and hex encoded.
+     */
+    public static final String CLUSTER_CONTEXT_HTTP_HEADER = "X-ClusterContext";
+
+    /**
+     * HTTP Header that stores a unique ID for each request that is replicated
+     * to the nodes. This is used for logging purposes so that request
+     * information, such as timing, can be correlated between the NCM and the
+     * nodes
+     */
+    public static final String REQUEST_ID_HEADER = "X-RequestID";
+
+    /**
+     * The HTTP header that the NCM specifies to ask a node if they are able to
+     * process a given request. The value is always 150-NodeContinue. The node
+     * will respond with 150 CONTINUE if it is able to process the request, 417
+     * EXPECTATION_FAILED otherwise.
+     */
+    public static final String NCM_EXPECTS_HTTP_HEADER = "X-NcmExpects";
+    public static final int NODE_CONTINUE_STATUS_CODE = 150;
+
+    /**
+     * The HTTP header that the NCM specifies to indicate that a node should
+     * invalidate the specified user group. This is done to ensure that user
+     * cache is not stale when an administrator modifies a group through the UI.
+     */
+    public static final String CLUSTER_INVALIDATE_USER_GROUP_HEADER = "X-ClusterInvalidateUserGroup";
+
+    /**
+     * The HTTP header that the NCM specifies to indicate that a node should
+     * invalidate the specified user. This is done to ensure that user cache is
+     * not stale when an administrator modifies a user through the UI.
+     */
+    public static final String CLUSTER_INVALIDATE_USER_HEADER = "X-ClusterInvalidateUser";
+
+    /**
+     * The default number of seconds to respond to a connecting node if the
+     * manager cannot provide it with a current data flow.
+     */
+    private static final int DEFAULT_CONNECTION_REQUEST_TRY_AGAIN_SECONDS = 5;
+
+    public static final String DEFAULT_COMPONENT_STATUS_REPO_IMPLEMENTATION = "org.apache.nifi.controller.status.history.VolatileComponentStatusRepository";
+
+    public static final Pattern PROCESSORS_URI_PATTERN = Pattern.compile("/nifi-api/controller/process-groups/(?:(?:root)|(?:[a-f0-9\\-]{36}))/processors");
+    public static final Pattern PROCESSOR_URI_PATTERN = Pattern.compile("/nifi-api/controller/process-groups/(?:(?:root)|(?:[a-f0-9\\-]{36}))/processors/[a-f0-9\\-]{36}");
+
+    public static final Pattern REMOTE_PROCESS_GROUPS_URI_PATTERN = Pattern.compile("/nifi-api/controller/process-groups/(?:(?:root)|(?:[a-f0-9\\-]{36}))/remote-process-groups");
+    public static final Pattern REMOTE_PROCESS_GROUP_URI_PATTERN = Pattern.compile("/nifi-api/controller/process-groups/(?:(?:root)|(?:[a-f0-9\\-]{36}))/remote-process-groups/[a-f0-9\\-]{36}");
+
+    public static final Pattern PROCESS_GROUP_URI_PATTERN = Pattern.compile("/nifi-api/controller/process-groups/(?:(?:root)|(?:[a-f0-9\\-]{36}))");
+    public static final Pattern TEMPLATE_INSTANCE_URI_PATTERN = Pattern.compile("/nifi-api/controller/process-groups/(?:(?:root)|(?:[a-f0-9\\-]{36}))/template-instance");
+    public static final Pattern FLOW_SNIPPET_INSTANCE_URI_PATTERN = Pattern.compile("/nifi-api/controller/process-groups/(?:(?:root)|(?:[a-f0-9\\-]{36}))/snippet-instance");
+
+    public static final String PROVENANCE_URI = "/nifi-api/controller/provenance";
+    public static final Pattern PROVENANCE_QUERY_URI = Pattern.compile("/nifi-api/controller/provenance/[a-f0-9\\-]{36}");
+    public static final Pattern PROVENANCE_EVENT_URI = Pattern.compile("/nifi-api/controller/provenance/events/[0-9]+");
+
+    private final NiFiProperties properties;
+    private final HttpRequestReplicator httpRequestReplicator;
+    private final HttpResponseMapper httpResponseMapper;
+    private final DataFlowManagementService dataFlowManagementService;
+    private final ClusterManagerProtocolSenderListener senderListener;
+    private final StringEncryptor encryptor;
+    private final Queue<Heartbeat> pendingHeartbeats = new ConcurrentLinkedQueue<>();
+    private final ReentrantReadWriteLock resourceRWLock = new ReentrantReadWriteLock();
+    private final ClusterManagerLock readLock = new ClusterManagerLock(resourceRWLock.readLock(), "Read");
+    private final ClusterManagerLock writeLock = new ClusterManagerLock(resourceRWLock.writeLock(), "Write");
+
+    private final Set<Node> nodes = new HashSet<>();
+    private final Set<ReportingTaskNode> reportingTasks = new HashSet<>();
+
+    // null means the dataflow should be read from disk
+    private StandardDataFlow cachedDataFlow = null;
+    private NodeIdentifier primaryNodeId = null;
+    private Revision revision = new Revision(0L, "");
+    private Timer heartbeatMonitor;
+    private Timer heartbeatProcessor;
+    private volatile ClusterServicesBroadcaster servicesBroadcaster = null;
+    private volatile EventManager eventManager = null;
+    private volatile ClusterNodeFirewall clusterFirewall = null;
+    private volatile AuditService auditService = null;
+    private volatile ControllerServiceProvider controllerServiceProvider = null;
+
+    private final RemoteSiteListener remoteSiteListener;
+    private final Integer remoteInputPort;
+    private final Boolean remoteCommsSecure;
+    private final BulletinRepository bulletinRepository;
+    private final String instanceId;
+    private final FlowEngine reportingTaskEngine;
+    private final Map<NodeIdentifier, ComponentStatusRepository> componentMetricsRepositoryMap = new HashMap<>();
+    private final StandardProcessScheduler processScheduler;
+    private final long componentStatusSnapshotMillis;
+
+    public WebClusterManager(final HttpRequestReplicator httpRequestReplicator, final HttpResponseMapper httpResponseMapper,
+            final DataFlowManagementService dataFlowManagementService, final ClusterManagerProtocolSenderListener senderListener,
+            final NiFiProperties properties, final StringEncryptor encryptor) {
+
+        if (httpRequestReplicator == null) {
+            throw new IllegalArgumentException("HttpRequestReplicator may not be null.");
+        } else if (httpResponseMapper == null) {
+            throw new IllegalArgumentException("HttpResponseMapper may not be null.");
+        } else if (dataFlowManagementService == null) {
+            throw new IllegalArgumentException("DataFlowManagementService may not be null.");
+        } else if (senderListener == null) {
+            throw new IllegalArgumentException("ClusterManagerProtocolSenderListener may not be null.");
+        } else if (properties == null) {
+            throw new IllegalArgumentException("NiFiProperties may not be null.");
+        }
+
+        // Ensure that our encryptor/decryptor is properly initialized
+        this.httpRequestReplicator = httpRequestReplicator;
+        this.httpResponseMapper = httpResponseMapper;
+        this.dataFlowManagementService = dataFlowManagementService;
+        this.properties = properties;
+        this.controllerServiceProvider = new StandardControllerServiceProvider();
+        this.bulletinRepository = new VolatileBulletinRepository();
+        this.instanceId = UUID.randomUUID().toString();
+        this.senderListener = senderListener;
+        this.encryptor = encryptor;
+        senderListener.addHandler(this);
+        senderListener.setBulletinRepository(bulletinRepository);
+
+        final String snapshotFrequency = properties.getProperty(NiFiProperties.COMPONENT_STATUS_SNAPSHOT_FREQUENCY, NiFiProperties.DEFAULT_COMPONENT_STATUS_SNAPSHOT_FREQUENCY);
+        long snapshotMillis;
+        try {
+            snapshotMillis = FormatUtils.getTimeDuration(snapshotFrequency, TimeUnit.MILLISECONDS);
+        } catch (final Exception e) {
+            snapshotMillis = FormatUtils.getTimeDuration(NiFiProperties.DEFAULT_COMPONENT_STATUS_SNAPSHOT_FREQUENCY, TimeUnit.MILLISECONDS);
+        }
+        componentStatusSnapshotMillis = snapshotMillis;
+
+        remoteInputPort = properties.getRemoteInputPort();
+        if (remoteInputPort == null) {
+            remoteSiteListener = null;
+            remoteCommsSecure = null;
+        } else {
+            // Register the ClusterManagerServerProtocol as the appropriate resource for site-to-site Server Protocol
+            RemoteResourceManager.setServerProtocolImplementation(ClusterManagerServerProtocol.RESOURCE_NAME, ClusterManagerServerProtocol.class);
+            remoteCommsSecure = properties.isSiteToSiteSecure();
+            if (remoteCommsSecure) {
+                final SSLContext sslContext = SslContextFactory.createSslContext(properties, false);
+
+                if (sslContext == null) {
+                    throw new IllegalStateException("NiFi Configured to allow Secure Site-to-Site communications but the Keystore/Truststore properties are not configured");
+                }
+
+                remoteSiteListener = new SocketRemoteSiteListener(remoteInputPort.intValue(), sslContext, this);
+            } else {
+                remoteSiteListener = new SocketRemoteSiteListener(remoteInputPort.intValue(), null, this);
+            }
+        }
+
+        reportingTaskEngine = new FlowEngine(8, "Reporting Task Thread");
+
+        processScheduler = new StandardProcessScheduler(new Heartbeater() {
+            @Override
+            public void heartbeat() {
+            }
+        }, this, encryptor);
+        processScheduler.setSchedulingAgent(SchedulingStrategy.TIMER_DRIVEN, new TimerDrivenSchedulingAgent(null, reportingTaskEngine, null, encryptor));
+        processScheduler.setMaxThreadCount(SchedulingStrategy.TIMER_DRIVEN, 10);
+        processScheduler.setMaxThreadCount(SchedulingStrategy.CRON_DRIVEN, 10);
+    }
+
+    public void start() throws IOException {
+        writeLock.lock();
+        try {
+
+            if (isRunning()) {
+                throw new IllegalStateException("Instance is already started.");
+            }
+
+            try {
+                // setup heartbeat monitoring
+                heartbeatMonitor = new Timer("Heartbeat Monitor", /* is daemon */ true);
+                heartbeatMonitor.scheduleAtFixedRate(new HeartbeatMonitoringTimerTask(), 0, getHeartbeatMonitoringIntervalSeconds() * 1000);
+
+                heartbeatProcessor = new Timer("Process Pending Heartbeats", true);
+                final int processPendingHeartbeatDelay = 1000 * Math.max(1, getClusterProtocolHeartbeatSeconds() / 2);
+                heartbeatProcessor.schedule(new ProcessPendingHeartbeatsTask(), processPendingHeartbeatDelay, processPendingHeartbeatDelay);
+
+                // start request replication service
+                httpRequestReplicator.start();
+
+                // start protocol service
+                senderListener.start();
+
+                // start flow management service
+                dataFlowManagementService.start();
+
+                if (remoteSiteListener != null) {
+                    remoteSiteListener.start();
+                }
+
+                // load flow
+                if (dataFlowManagementService.isFlowCurrent()) {
+                    final ClusterDataFlow clusterDataFlow = dataFlowManagementService.loadDataFlow();
+                    cachedDataFlow = clusterDataFlow.getDataFlow();
+                    primaryNodeId = clusterDataFlow.getPrimaryNodeId();
+                } else {
+                    throw new IOException("Flow is not current.");
+                }
+
+                // start multicast broadcasting service, if configured
+                if (servicesBroadcaster != null) {
+                    servicesBroadcaster.start();
+                }
+
+                // start in safe mode
+                executeSafeModeTask();
+
+                // Load and start running Reporting Tasks
+                final File taskFile = new File(properties.getProperty(NiFiProperties.TASK_CONFIGURATION_FILE));
+                reportingTasks.addAll(loadReportingTasks(taskFile));
+            } catch (final IOException ioe) {
+                logger.warn("Failed to initialize cluster services due to: " + ioe, ioe);
+                stop();
+                throw ioe;
+            }
+
+        } finally {
+            writeLock.unlock("START");
+        }
+    }
+
+    public void stop() throws IOException {
+        writeLock.lock();
+        try {
+
+            // returns true if any service is running
+            if (isRunning() == false) {
+                throw new IllegalArgumentException("Instance is already stopped.");
+            }
+
+            boolean encounteredException = false;
+
+            // stop the heartbeat monitoring
+            if (isHeartbeatMonitorRunning()) {
+                heartbeatMonitor.cancel();
+                heartbeatMonitor = null;
+            }
+
+            if (heartbeatProcessor != null) {
+                heartbeatProcessor.cancel();
+                heartbeatProcessor = null;
+            }
+
+            // stop the HTTP request replicator service
+            if (httpRequestReplicator.isRunning()) {
+                httpRequestReplicator.stop();
+            }
+
+            // stop the flow management service
+            if (dataFlowManagementService.isRunning()) {
+                dataFlowManagementService.stop();
+            }
+
+            if (remoteSiteListener != null) {
+                remoteSiteListener.stop();
+            }
+
+            // stop the protocol listener service
+            if (senderListener.isRunning()) {
+                try {
+                    senderListener.stop();
+                } catch (final IOException ioe) {
+                    encounteredException = true;
+                    logger.warn("Failed to shutdown protocol service due to: " + ioe, ioe);
+                }
+            }
+
+            // stop the service broadcaster
+            if (isBroadcasting()) {
+                servicesBroadcaster.stop();
+            }
+
+            if ( processScheduler != null ) {
+                processScheduler.shutdown();
+            }
+            
+            if (encounteredException) {
+                throw new IOException("Failed to shutdown Cluster Manager because one or more cluster services failed to shutdown.  Check the logs for details.");
+            }
+
+        } finally {
+            writeLock.unlock("STOP");
+        }
+    }
+
+    public boolean isRunning() {
+        readLock.lock();
+        try {
+            return isHeartbeatMonitorRunning()
+                    || httpRequestReplicator.isRunning()
+                    || senderListener.isRunning()
+                    || dataFlowManagementService.isRunning()
+                    || isBroadcasting();
+        } finally {
+            readLock.unlock("isRunning");
+        }
+    }
+
+    @Override
+    public boolean canHandle(ProtocolMessage msg) {
+        return MessageType.CONNECTION_REQUEST == msg.getType()
+                || MessageType.HEARTBEAT == msg.getType()
+                || MessageType.CONTROLLER_STARTUP_FAILURE == msg.getType()
+                || MessageType.BULLETINS == msg.getType()
+                || MessageType.RECONNECTION_FAILURE == msg.getType();
+    }
+
+    @Override
+    public ProtocolMessage handle(final ProtocolMessage protocolMessage) throws ProtocolException {
+        switch (protocolMessage.getType()) {
+            case CONNECTION_REQUEST:
+                return handleConnectionRequest((ConnectionRequestMessage) protocolMessage);
+            case HEARTBEAT:
+                final HeartbeatMessage heartbeatMessage = (HeartbeatMessage) protocolMessage;
+
+                final Heartbeat original = heartbeatMessage.getHeartbeat();
+                final NodeIdentifier originalNodeId = original.getNodeIdentifier();
+                final Heartbeat heartbeatWithDn = new Heartbeat(addRequestorDn(originalNodeId, heartbeatMessage.getRequestorDN()), original.isPrimary(), original.isConnected(), original.getPayload());
+
+                handleHeartbeat(heartbeatWithDn);
+                return null;
+            case CONTROLLER_STARTUP_FAILURE:
+                new Thread(new Runnable() {
+                    @Override
+                    public void run() {
+                        handleControllerStartupFailure((ControllerStartupFailureMessage) protocolMessage);
+                    }
+                }, "Handle Controller Startup Failure Message from " + ((ControllerStartupFailureMessage) protocolMessage).getNodeId()).start();
+                return null;
+            case RECONNECTION_FAILURE:
+                new Thread(new Runnable() {
+                    @Override
+                    public void run() {
+                        handleReconnectionFailure((ReconnectionFailureMessage) protocolMessage);
+                    }
+                }, "Handle Reconnection Failure Message from " + ((ReconnectionFailureMessage) protocolMessage).getNodeId()).start();
+                return null;
+            case BULLETINS:
+                final NodeBulletinsMessage bulletinsMessage = (NodeBulletinsMessage) protocolMessage;
+                handleBulletins(bulletinsMessage.getBulletins());
+                return null;
+            default:
+                throw new ProtocolException("No handler defined for message type: " + protocolMessage.getType());
+        }
+    }
+
+    /**
+     * Services connection requests. If the data flow management service is
+     * unable to provide a current copy of the data flow, then the returned
+     * connection response will indicate the node should try later. Otherwise,
+     * the connection response will contain the the flow and the node
+     * identifier.
+     *
+     * If this instance is configured with a firewall and the request is
+     * blocked, then the response will not contain a node identifier.
+     *
+     * @param request a connection request
+     *
+     * @return a connection response
+     */
+    @Override
+    public ConnectionResponse requestConnection(final ConnectionRequest request) {
+        final boolean lockObtained = writeLock.tryLock(3, TimeUnit.SECONDS);
+        if (!lockObtained) {
+            // Create try-later response because we are too busy to service the request right now. We do not want
+            // to wait long because we want Node/NCM comms to be very responsive
+            final int tryAgainSeconds;
+            if (dataFlowManagementService.getRetrievalDelaySeconds() <= 0) {
+                tryAgainSeconds = DEFAULT_CONNECTION_REQUEST_TRY_AGAIN_SECONDS;
+            } else {
+                tryAgainSeconds = dataFlowManagementService.getRetrievalDelaySeconds();
+            }
+
+            // record event
+            final String msg = "Connection requested from node, but manager was too busy to service request.  Instructing node to try again in " + tryAgainSeconds + " seconds.";
+            addEvent(request.getProposedNodeIdentifier(), msg);
+            addBulletin(request.getProposedNodeIdentifier(), Severity.INFO, msg);
+
+            // return try later response
+            return new ConnectionResponse(tryAgainSeconds);
+        }
+
+        try {
+            // resolve the proposed node identifier to a valid node identifier
+            final NodeIdentifier resolvedNodeIdentifier = resolveProposedNodeIdentifier(request.getProposedNodeIdentifier());
+
+            if (isBlockedByFirewall(resolvedNodeIdentifier.getSocketAddress())) {
+                // if the socket address is not listed in the firewall, then return a null response
+                logger.info("Firewall blocked connection request from node " + resolvedNodeIdentifier);
+                return ConnectionResponse.createBlockedByFirewallResponse();
+            }
+
+            // get a raw reference to the node (if it doesn't exist, node will be null)
+            Node node = getRawNode(resolvedNodeIdentifier.getId());
+
+            // create a new node if necessary and set status to connecting
+            if (node == null) {
+                node = new Node(resolvedNodeIdentifier, Status.CONNECTING);
+                addEvent(node.getNodeId(), "Connection requested from new node.  Setting status to connecting.");
+                nodes.add(node);
+            } else {
+                node.setStatus(Status.CONNECTING);
+                addEvent(resolvedNodeIdentifier, "Connection requested from existing node.  Setting status to connecting");
+            }
+
+            // record the time of the connection request
+            node.setConnectionRequestedTimestamp(new Date().getTime());
+
+            // clear out old heartbeat info
+            node.setHeartbeat(null);
+
+            // try to obtain a current flow
+            if (dataFlowManagementService.isFlowCurrent()) {
+                // if a cached copy does not exist, load it from disk
+                if (cachedDataFlow == null) {
+                    final ClusterDataFlow clusterDataFlow = dataFlowManagementService.loadDataFlow();
+                    cachedDataFlow = clusterDataFlow.getDataFlow();
+                    primaryNodeId = clusterDataFlow.getPrimaryNodeId();
+                }
+
+                // determine if this node should be assigned the primary role
+                final boolean primaryRole;
+                if (primaryNodeId == null || primaryNodeId.logicallyEquals(node.getNodeId())) {
+                    setPrimaryNodeId(node.getNodeId());
+                    addEvent(node.getNodeId(), "Setting primary role in connection response.");
+                    primaryRole = true;
+                } else {
+                    primaryRole = false;
+                }
+
+                return new ConnectionResponse(node.getNodeId(), cachedDataFlow, primaryRole, remoteInputPort, remoteCommsSecure, instanceId);
+            }
+
+            /*
+             * The manager does not have a current copy of the data flow, 
+             * so it will instruct the node to try connecting at a later 
+             * time.  Meanwhile, the flow will be locked down from user 
+             * changes because the node is marked as connecting.
+             */
+
+            /*
+             * Create try-later response based on flow retrieval delay to give 
+             * the flow management service a chance to retrieve a curren flow
+             */
+            final int tryAgainSeconds;
+            if (dataFlowManagementService.getRetrievalDelaySeconds() <= 0) {
+                tryAgainSeconds = DEFAULT_CONNECTION_REQUEST_TRY_AGAIN_SECONDS;
+            } else {
+                tryAgainSeconds = dataFlowManagementService.getRetrievalDelaySeconds();
+            }
+
+            // record event
+            addEvent(node.getNodeId(), "Connection requested from node, but manager was unable to obtain current flow.  Instructing node to try again in " + tryAgainSeconds + " seconds.");
+
+            // return try later response
+            return new ConnectionResponse(tryAgainSeconds);
+
+        } finally {
+            writeLock.unlock("requestConnection");
+        }
+    }
+
+    /**
+     * Services reconnection requests for a given node. If the node indicates
+     * reconnection failure, then the node will be set to disconnected and if
+     * the node has primary role, then the role will be revoked. Otherwise, a
+     * reconnection request will be sent to the node, initiating the connection
+     * handshake.
+     *
+     * @param nodeId a node identifier
+     *
+     * @throws UnknownNodeException if the node does not exist
+     * @throws IllegalNodeReconnectionException if the node cannot be
+     * reconnected because the node is not disconnected
+     * @throws NodeReconnectionException if the reconnection message failed to
+     * be sent or the cluster could not provide a current data flow for the
+     * reconnection request
+     */
+    @Override
+    public void requestReconnection(final String nodeId, final String userDn) throws UnknownNodeException, IllegalNodeReconnectionException {
+        Node node = null;
+
+        final boolean primaryRole;
+        final int tryAgainSeconds;
+
+        writeLock.lock();
+        try {
+            // check if we know about this node and that it is disconnected
+            node = getRawNode(nodeId);
+            logger.info("Request was made by {} to reconnect node {} to cluster", userDn, node == null ? nodeId : node);
+
+            if (node == null) {
+                throw new UnknownNodeException("Node does not exist.");
+            } else if (Status.DISCONNECTED != node.getStatus()) {
+                throw new IllegalNodeReconnectionException("Node must be disconnected before it can reconnect.");
+            }
+
+            // clear out old heartbeat info
+            node.setHeartbeat(null);
+
+            // get the dataflow to send with the reconnection request
+            if (!dataFlowManagementService.isFlowCurrent()) {
+                /* node remains disconnected */
+                final String msg = "Reconnection requested for node, but manager was unable to obtain current flow.  Setting node to disconnected.";
+                addEvent(node.getNodeId(), msg);
+                addBulletin(node, Severity.WARNING, msg);
+                throw new NodeReconnectionException("Manager was unable to obtain current flow to provide in reconnection request to node.  Try again in a few seconds.");
+            }
+
+            // if a cached copy does not exist, load it from disk
+            if (cachedDataFlow == null) {
+                final ClusterDataFlow clusterDataFlow = dataFlowManagementService.loadDataFlow();
+                cachedDataFlow = clusterDataFlow.getDataFlow();
+                primaryNodeId = clusterDataFlow.getPrimaryNodeId();
+            }
+
+            node.setStatus(Status.CONNECTING);
+            addEvent(node.getNodeId(), "Reconnection requested for node.  Setting status to connecting.");
+
+            // determine if this node should be assigned the primary role
+            if (primaryNodeId == null || primaryNodeId.logicallyEquals(node.getNodeId())) {
+                setPrimaryNodeId(node.getNodeId());
+                addEvent(node.getNodeId(), "Setting primary role in reconnection request.");
+                primaryRole = true;
+            } else {
+                primaryRole = false;
+            }
+
+            if (dataFlowManagementService.getRetrievalDelaySeconds() <= 0) {
+                tryAgainSeconds = DEFAULT_CONNECTION_REQUEST_TRY_AGAIN_SECONDS;
+            } else {
+                tryAgainSeconds = dataFlowManagementService.getRetrievalDelaySeconds();
+            }
+        } catch (final UnknownNodeException | IllegalNodeReconnectionException | NodeReconnectionException une) {
+            throw une;
+        } catch (final Exception ex) {
+            logger.warn("Problem encountered issuing reconnection request to node " + node.getNodeId() + " due to: " + ex, ex);
+
+            node.setStatus(Status.DISCONNECTED);
+            final String eventMsg = "Problem encountered issuing reconnection request. Node will remain disconnected: " + ex;
+            addEvent(node.getNodeId(), eventMsg);
+            addBulletin(node, Severity.WARNING, eventMsg);
+
+            // Exception thrown will include node ID but event/bulletin do not because the node/id is passed along with the message
+            throw new NodeReconnectionException("Problem encountered issuing reconnection request to " + node.getNodeId() + ". Node will remain disconnected: " + ex, ex);
+        } finally {
+            writeLock.unlock("requestReconnection");
+        }
+
+        // Asynchronously start attempting reconnection. This is not completely thread-safe, as
+        // we do this by releasing the write lock and then obtaining a read lock for each attempt,
+        // so we suffer from the ABA problem. However, we are willing to accept the consequences of
+        // this situation in order to avoid holding a lock for the entire duration. "The consequences"
+        // are that a second thread could potentially be doing the same thing, issuing a reconnection request.
+        // However, this is very unlikely to happen, based on the conditions under which we issue a reconnection
+        // request. And if we do, the node will simply reconnect multiple times, which is not a big deal.
+        requestReconnectionAsynchronously(node, primaryRole, 10, tryAgainSeconds);
+    }
+
+    private void requestReconnectionAsynchronously(final Node node, final boolean primaryRole, final int reconnectionAttempts, final int retrySeconds) {
+        final Thread reconnectionThread = new Thread(new Runnable() {
+            @Override
+            public void run() {
+                for (int i = 0; i < reconnectionAttempts; i++) {
+                    final ReconnectionRequestMessage request = new ReconnectionRequestMessage();
+
+                    try {
+                        readLock.lock();
+                        try {
+                            if (Status.CONNECTING != node.getStatus()) {
+                                // the node status has changed. It's no longer appropriate to attempt reconnection.
+                                return;
+                            }
+
+                            // create the request
+                            request.setNodeId(node.getNodeId());
+                            request.setDataFlow(cachedDataFlow);
+                            request.setPrimary(primaryRole);
+                            request.setManagerRemoteSiteCommsSecure(remoteCommsSecure);
+                            request.setManagerRemoteSiteListeningPort(remoteInputPort);
+                            request.setInstanceId(instanceId);
+                        } finally {
+                            readLock.unlock("Reconnect " + node.getNodeId());
+                        }
+
+                        // Issue a reconnection request to the node.
+                        senderListener.requestReconnection(request);
+
+                        node.setConnectionRequestedTimestamp(System.currentTimeMillis());
+
+                        // successfully told node to reconnect -- we're done!
+                        return;
+                    } catch (final Exception e) {
+                        logger.warn("Problem encountered issuing reconnection request to node " + node.getNodeId() + " due to: " + e);
+                        if (logger.isDebugEnabled()) {
+                            logger.warn("", e);
+                        }
+
+                        addBulletin(node, Severity.WARNING, "Problem encountered issuing reconnection request to node " + node.getNodeId() + " due to: " + e);
+                    }
+
+                    try {
+                        Thread.sleep(1000L * retrySeconds);
+                    } catch (final InterruptedException ie) {
+                        break;
+                    }
+                }
+
+                // We failed to reconnect 10 times. We must now mark node as disconnected.
+                writeLock.lock();
+                try {
+                    if (Status.CONNECTING == node.getStatus()) {
+                        requestDisconnectionQuietly(node.getNodeId(), "Failed to issue Reconnection Request " + reconnectionAttempts + " times");
+                    }
+                } finally {
+                    writeLock.unlock("Mark node as Disconnected as a result of reconnection failure");
+                }
+            }
+        }, "Reconnect " + node.getNodeId());
+
+        reconnectionThread.start();
+    }
+
+    private List<ReportingTaskNode> loadReportingTasks(final File taskConfigXml) {
+        final List<ReportingTaskNode> tasks = new ArrayList<>();
+        if (taskConfigXml == null) {
+            logger.info("No controller tasks to start");
+            return tasks;
+        }
+
+        try {
+            final URL schemaUrl = getClass().getResource("/ReportingTaskConfiguration.xsd");
+            final Document document = parse(taskConfigXml, schemaUrl);
+
+            final NodeList tasksNodes = document.getElementsByTagName("tasks");
+            final Element tasksElement = (Element) tasksNodes.item(0);
+
+            //optional properties for all ReportingTasks
+            for (final Element taskElement : DomUtils.getChildElementsByTagName(tasksElement, "task")) {
+                //add global properties common to all tasks
+                Map<String, String> properties = new HashMap<>();
+
+                //get properties for the specific reporting task - id, name, class,
+                //and schedulingPeriod must be set
+                final String taskId = DomUtils.getChild(taskElement, "id").getTextContent().trim();
+                final String taskName = DomUtils.getChild(taskElement, "name").getTextContent().trim();
+
+                final List<Element> schedulingStrategyNodeList = DomUtils.getChildElementsByTagName(taskElement, "schedulingStrategy");
+                String schedulingStrategyValue = SchedulingStrategy.TIMER_DRIVEN.name();
+                if (schedulingStrategyNodeList.size() == 1) {
+                    final String specifiedValue = schedulingStrategyNodeList.get(0).getTextContent();
+
+                    try {
+                        schedulingStrategyValue = SchedulingStrategy.valueOf(specifiedValue).name();
+                    } catch (final Exception e) {
+                        throw new RuntimeException("Cannot start Reporting Task with id " + taskId + " because its Scheduling Strategy does not have a valid value", e);
+                    }
+                }
+
+                final SchedulingStrategy schedulingStrategy = SchedulingStrategy.valueOf(schedulingStrategyValue);
+                final String taskSchedulingPeriod = DomUtils.getChild(taskElement, "schedulingPeriod").getTextContent().trim();
+                final String taskClass = DomUtils.getChild(taskElement, "class").getTextContent().trim();
+
+                //optional task-specific properties
+                for (final Element optionalProperty : DomUtils.getChildElementsByTagName(taskElement, "property")) {
+                    final String name = optionalProperty.getAttribute("name");
+                    final String value = optionalProperty.getTextContent().trim();
+                    properties.put(name, value);
+                }
+
+                //set the class to be used for the configured reporting task
+                final ReportingTaskNode reportingTaskNode;
+                try {
+                    reportingTaskNode = createReportingTask(taskClass, taskId);
+                } catch (final ReportingTaskInstantiationException e) {
+                    logger.error("Unable to load reporting task {} due to {}", new Object[]{taskId, e});
+                    if (logger.isDebugEnabled()) {
+                        logger.error("", e);
+                    }
+                    continue;
+                }
+
+                final ReportingTask reportingTask = reportingTaskNode.getReportingTask();
+
+                final ReportingInitializationContext config = new StandardReportingInitializationContext(taskId, taskName, schedulingStrategy, taskSchedulingPeriod, this);
+                reportingTask.initialize(config);
+
+                final Map<PropertyDescriptor, String> resolvedProps;
+                try (final NarCloseable narCloseable = NarCloseable.withNarLoader()) {
+                    resolvedProps = new HashMap<>();
+                    for (final Map.Entry<String, String> entry : properties.entrySet()) {
+                        final PropertyDescriptor descriptor = reportingTask.getPropertyDescriptor(entry.getKey());
+                        resolvedProps.put(descriptor, entry.getValue());
+                    }
+                }
+
+                for (final Map.Entry<PropertyDescriptor, String> entry : resolvedProps.entrySet()) {
+                    reportingTaskNode.setProperty(entry.getKey().getName(), entry.getValue());
+                }
+
+                processScheduler.schedule(reportingTaskNode);
+                tasks.add(reportingTaskNode);
+            }
+        } catch (final SAXException | ParserConfigurationException | IOException | DOMException | NumberFormatException | InitializationException t) {
+            logger.error("Unable to load reporting tasks from {} due to {}", new Object[]{taskConfigXml, t});
+            if (logger.isDebugEnabled()) {
+                logger.error("", t);
+            }
+        }
+
+        return tasks;
+    }
+
+    private ReportingTaskNode createReportingTask(final String type, final String id) throws ReportingTaskInstantiationException {
+        if (type == null) {
+            throw new NullPointerException();
+        }
+        ReportingTask task = null;
+        final ClassLoader ctxClassLoader = Thread.currentThread().getContextClassLoader();
+        try {
+            final ClassLoader detectedClassLoader = ExtensionManager.getClassLoader(type);
+            final Class<?> rawClass;
+            if (detectedClassLoader == null) {
+                rawClass = Class.forName(type);
+            } else {
+                rawClass = Class.forName(type, false, detectedClassLoader);
+            }
+
+            Thread.currentThread().setContextClassLoader(detectedClassLoader);
+            final Class<? extends ReportingTask> reportingTaskClass = rawClass.asSubclass(ReportingTask.class);
+            final Object reportingTaskObj = reportingTaskClass.newInstance();
+            task = reportingTaskClass.cast(reportingTaskObj);
+        } catch (final ClassNotFoundException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException t) {
+            throw new ReportingTaskInstantiationException(type, t);
+        } finally {
+            if (ctxClassLoader != null) {
+                Thread.currentThread().setContextClassLoader(ctxClassLoader);
+            }
+        }
+
+        final ValidationContextFactory validationContextFactory = new StandardValidationContextFactory(this);
+        final ReportingTaskNode taskNode = new ClusteredReportingTaskNode(task, id, processScheduler,
+                new ClusteredEventAccess(this), bulletinRepository, controllerServiceProvider, validationContextFactory);
+        return taskNode;
+    }
+
+    private Document parse(final File xmlFile, final URL schemaUrl) throws SAXException, ParserConfigurationException, IOException {
+        final SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
+        final Schema schema = schemaFactory.newSchema(schemaUrl);
+        final DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
+        docFactory.setSchema(schema);
+        final DocumentBuilder builder = docFactory.newDocumentBuilder();
+
+        builder.setErrorHandler(new org.xml.sax.ErrorHandler() {
+            @Override
+            public void fatalError(final SAXParseException err) throws SAXException {
+                logger.error("Config file line " + err.getLineNumber() + ", col " + err.getColumnNumber() + ", uri " + err.getSystemId() + " :message: " + err.getMessage());
+                if (logger.isDebugEnabled()) {
+                    logger.error("Error Stack Dump", err);
+                }
+                throw err;
+            }
+
+            @Override
+            public void error(final SAXParseException err) throws SAXParseException {
+                logger.error("Config file line " + err.getLineNumber() + ", col " + err.getColumnNumber() + ", uri " + err.getSystemId() + " :message: " + err.getMessage());
+                if (logger.isDebugEnabled()) {
+                    logger.error("Error Stack Dump", err);
+                }
+                throw err;
+            }
+
+            @Override
+            public void warning(final SAXParseException err) throws SAXParseException {
+                logger.warn(" Config file line " + err.getLineNumber() + ", uri " + err.getSystemId() + " : message : " + err.getMessage());
+                if (logger.isDebugEnabled()) {
+                    logger.warn("Warning stack dump", err);
+                }
+                throw err;
+            }
+        });
+
+        // build the docuemnt
+        final Document document = builder.parse(xmlFile);
+
+        // ensure schema compliance
+        final Validator validator = schema.newValidator();
+        validator.validate(new DOMSource(document));
+
+        return document;
+    }
+
+    private void addBulletin(final Node node, final Severity severity, final String msg) {
+        addBulletin(node.getNodeId(), severity, msg);
+    }
+
+    private void addBulletin(final NodeIdentifier nodeId, final Severity severity, final String msg) {
+        bulletinRepository.addBulletin(BulletinFactory.createBulletin(BULLETIN_CATEGORY, severity.toString(),
+                nodeId.getApiAddress() + ":" + nodeId.getApiPort() + " -- " + msg));
+    }
+
+    /**
+     * Services a disconnection request.
+     *
+     * @param nodeId a node identifier
+     * @param userDn the DN of the user requesting the disconnection
+     *
+     * @throws UnknownNodeException if the node does not exist
+     * @throws IllegalNodeDisconnectionException if the node cannot be
+     * disconnected due to the cluster's state (e.g., node is last connected
+     * node or node is primary)
+     * @throws NodeDisconnectionException if the disconnection message fails to
+     * be sent.
+     */
+    @Override
+    public void requestDisconnection(final String nodeId, final String userDn) throws UnknownNodeException, IllegalNodeDisconnectionException, NodeDisconnectionException {
+        writeLock.lock();
+        try {
+            // check that the node is known
+            final Node node = getNode(nodeId);
+            if (node == null) {
+                throw new UnknownNodeException("Node does not exist.");
+            }
+            requestDisconnection(node.getNodeId(), /* ignore last node */ false, "User " + userDn + " Disconnected Node");
+        } finally {
+            writeLock.unlock("requestDisconnection(String)");
+        }
+    }
+
+    /**
+     * Requests a disconnection to the node with the given node ID, but any
+     * exception thrown is suppressed.
+     *
+     * @param nodeId the node ID
+     */
+    private void requestDisconnectionQuietly(final NodeIdentifier nodeId, final String explanation) {
+        try {
+            requestDisconnection(nodeId, /* ignore node check */ true, explanation);
+        } catch (final IllegalNodeDisconnectionException | NodeDisconnectionException ex) { /* suppress exception */ }
+    }
+
+    /**
+     * Issues a disconnection message to the node identified by the given node
+     * ID. If the node is not known, then a UnknownNodeException is thrown. If
+     * the node cannot be disconnected due to the cluster's state and
+     * ignoreLastNodeCheck is false, then a IllegalNodeDisconnectionException is
+     * thrown. Otherwise, a disconnection message is issued to the node.
+     *
+     * Whether the disconnection message is successfully sent to the node, the
+     * node is marked as disconnected and if the node is the primary node, then
+     * the primary role is revoked.
+     *
+     * @param nodeId the ID of the node
+     * @param ignoreNodeChecks if false, checks will be made to ensure the
+     * cluster supports the node's disconnection (e.g., the node is not the last
+     * connected node in the cluster; the node is not the primary); otherwise,
+     * the request is made regardless of the cluster state
+     * @param explanation
+     *
+     * @throws IllegalNodeDisconnectionException if the node cannot be
+     * disconnected due to the cluster's state (e.g., node is last connected
+     * node or node is primary). Not thrown if ignoreNodeChecks is true.
+     * @throws NodeDisconnectionException if the disconnection message fails to
+     * be sent.
+     */
+    private void requestDisconnection(final NodeIdentifier nodeId, final boolean ignoreNodeChecks, final String explanation)
+            throws IllegalNodeDisconnectionException, NodeDisconnectionException {
+
+        writeLock.lock();
+        try {
+
+            // check that the node is known
+            final Node node = getRawNode(nodeId.getId());
+            if (node == null) {
+                if (ignoreNodeChecks) {
+                    // issue the disconnection
+                    final DisconnectMessage request = new DisconnectMessage();
+                    request.setNodeId(nodeId);
+                    request.setExplanation(explanation);
+
+                    addEvent(nodeId, "Disconnection requested due to " + explanation);
+                    senderListener.disconnect(request);
+                    addEvent(nodeId, "Node disconnected due to " + explanation);
+                    addBulletin(nodeId, Severity.INFO, "Node disconnected due to " + explanation);
+                    return;
+                } else {
+                    throw new UnknownNodeException("Node does not exist");
+                }
+            }
+
+            // if necessary, check that the node may be disconnected
+            if (!ignoreNodeChecks) {
+                final Set<NodeIdentifier> connectedNodes = getNodeIds(Status.CONNECTED);
+                // cannot disconnect the last connected node in the cluster
+                if (connectedNodes.size() == 1 && connectedNodes.iterator().next().equals(nodeId)) {
+                    throw new IllegalNodeDisconnectionException("Node may not be disconnected because it is the only connected node in the cluster.");
+                } else if (isPrimaryNode(nodeId)) {
+                    // cannot disconnect the primary node in the cluster
+                    throw new IllegalNodeDisconnectionException("Node may not be disconnected because it is the primary node in the cluster.");
+                }
+            }
+
+            // update status
+            node.setStatus(Status.DISCONNECTED);
+            notifyDataFlowManagementServiceOfNodeStatusChange();
+
+            // issue the disconnection
+            final DisconnectMessage request = new DisconnectMessage();
+            request.setNodeId(nodeId);
+            request.setExplanation(explanation);
+
+            addEvent(nodeId, "Disconnection requested due to " + explanation);
+            senderListener.disconnect(request);
+            addEvent(nodeId, "Node disconnected due to " + explanation);
+            addBulletin(node, Severity.INFO, "Node disconnected due to " + explanation);
+        } finally {
+            writeLock.unlock("requestDisconnection(NodeIdentifier, boolean)");
+        }
+    }
+
+    /**
+     * Messages the node to have the primary role. If the messaging fails, then
+     * the node is marked as disconnected.
+     *
+     * @param nodeId the node ID to assign primary role
+     *
+     * @return true if primary role assigned; false otherwise
+     */
+    private boolean assignPrimaryRole(final NodeIdentifier nodeId) {
+        writeLock.lock();
+        try {
+            // create primary role message
+            final PrimaryRoleAssignmentMessage msg = new PrimaryRoleAssignmentMessage();
+            msg.setNodeId(nodeId);
+            msg.setPrimary(true);
+            logger.info("Attempting to assign primary role to node: " + nodeId);
+
+            // message 
+            senderListener.assignPrimaryRole(msg);
+
+            logger.info("Assigned primary role to node: " + nodeId);
+            addBulletin(nodeId, Severity.INFO, "Node assigned primary role");
+
+            // true indicates primary role assigned
+            return true;
+
+        } catch (final ProtocolException ex) {
+
+            logger.warn("Failed attempt to assign primary role to node " + nodeId + " due to " + ex);
+            addBulletin(nodeId, Severity.ERROR, "Failed to assign primary role to node due to: " + ex);
+
+            // mark node as disconnected and log/record the event
+            final Node node = getRawNode(nodeId.getId());
+            node.setStatus(Status.DISCONNECTED);
+            addEvent(node.getNodeId(), "Disconnected because of failed attempt to assign primary role.");
+
+            addBulletin(nodeId, Severity.WARNING, "Node disconnected because of failed attempt to assign primary role");
+
+            // false indicates primary role failed to be assigned
+            return false;
+        } finally {
+            writeLock.unlock("assignPrimaryRole");
+        }
+    }
+
+    /**
+     * Messages the node with the given node ID to no longer have the primary
+     * role. If the messaging fails, then the node is marked as disconnected.
+     *
+     * @return true if the primary role was revoked from the node; false
+     * otherwise
+     */
+    private boolean revokePrimaryRole(final NodeIdentifier nodeId) {
+        writeLock.lock();
+        try {
+            // create primary role message
+            final PrimaryRoleAssignmentMessage msg = new PrimaryRoleAssignmentMessage();
+            msg.setNodeId(nodeId);
+            msg.setPrimary(false);
+            logger.info("Attempting to revoke primary role from node: " + nodeId);
+
+            // send message
+            senderListener.assignPrimaryRole(msg);
+
+            logger.info("Revoked primary role from node: " + nodeId);
+            addBulletin(nodeId, Severity.INFO, "Primary Role revoked from node");
+
+            // true indicates primary role was revoked
+            return true;
+        } catch (final ProtocolException ex) {
+
+            logger.warn("Failed attempt to revoke primary role from node " + nodeId + " due to " + ex);
+
+            // mark node as disconnected and log/record the event
+            final Node node = getRawNode(nodeId.getId());
+            node.setStatus(Status.DISCONNECTED);
+            addEvent(node.getNodeId(), "Disconnected because of failed attempt to revoke primary role.");
+            addBulletin(node, Severity.ERROR, "Node disconnected because of failed attempt to revoke primary role");
+
+            // false indicates primary role failed to be revoked
+            return false;
+        } finally {
+            writeLock.unlock("revokePrimaryRole");
+        }
+    }
+
+    private NodeIdentifier addRequestorDn(final NodeIdentifier nodeId, final String dn) {
+        return new NodeIdentifier(nodeId.getId(), nodeId.getApiAddress(),
+                nodeId.getApiPort(), nodeId.getSocketAddress(), nodeId.getSocketPort(), dn);
+    }
+
+    private ConnectionResponseMessage handleConnectionRequest(final ConnectionRequestMessage requestMessage) {
+        final NodeIdentifier proposedIdentifier = requestMessage.getConnectionRequest().getProposedNodeIdentifier();
+        final ConnectionRequest requestWithDn = new ConnectionRequest(addRequestorDn(proposedIdentifier, requestMessage.getRequestorDN()));
+
+        final ConnectionResponse response = requestConnection(requestWithDn);
+        final ConnectionResponseMessage responseMessage = new ConnectionResponseMessage();
+        responseMessage.setConnectionResponse(response);
+        return responseMessage;
+    }
+
+    private void handleControllerStartupFailure(final ControllerStartupFailureMessage msg) {
+        writeLock.lock();
+        try {
+            final Node node = getRawNode(msg.getNodeId().getId());
+            if (node != null) {
+                node.setStatus(Status.DISCONNECTED);
+                addEvent(msg.getNodeId(), "Node could not join cluster because it failed to start up properly. Setting node to Disconnected. Node reported the following error: " + msg.getExceptionMessage());
+                addBulletin(node, Severity.ERROR, "Node could not join cluster because it failed to start up properly. Setting node to Disconnected. Node reported the following error: " + msg.getExceptionMessage());
+            }
+        } finally {
+            writeLock.unlock("handleControllerStartupFailure");
+        }
+    }
+
+    private void handleReconnectionFailure(final ReconnectionFailureMessage msg) {
+        writeLock.lock();
+        try {
+            final Node node = getRawNode(msg.getNodeId().getId());
+            if (node != null) {
+                node.setStatus(Status.DISCONNECTED);
+                final String errorMsg = "Node could not rejoin cluster. Setting node to Disconnected. Node reported the following error: " + msg.getExceptionMessage();
+                addEvent(msg.getNodeId(), errorMsg);
+                addBulletin(node, Severity.ERROR, errorMsg);
+            }
+        } finally {
+            writeLock.unlock("handleControllerStartupFailure");
+        }
+    }
+
+
+    @Override
+    public ControllerService getControllerService(String serviceIdentifier) {
+        return controllerServiceProvider.getControllerService(serviceIdentifier);
+    }
+
+    @Override
+    public ControllerServiceNode getControllerServiceNode(final String id) {
+        return controllerServiceProvider.getControllerServiceNode(id);
+    }
+
+    @Override
+    public boolean isControllerServiceEnabled(final ControllerService service) {
+        return controllerServiceProvider.isControllerServiceEnabled(service);
+    }
+
+    @Override
+    public boolean isControllerServiceEnabled(final String serviceIdentifier) {
+        return controllerServiceProvider.isControllerServiceEnabled(serviceIdentifier);
+    }
+
+    @Override
+    public ControllerServiceNode createControllerService(final String type, final String id, final boolean firstTimeAdded) {
+        return controllerServiceProvider.createControllerService(type, id, firstTimeAdded);
+    }
+    
+    @Override
+    public void removeControllerService(final ControllerServiceNode serviceNode) {
+        controllerServiceProvider.removeControllerService(serviceNode);
+    }
+    
+
+    @Override
+    public void enableControllerService(final ControllerServiceNode serviceNode) {
+        controllerServiceProvider.enableControllerService(serviceNode);
+    }
+    
+    @Override
+    public void disableControllerService(final ControllerServiceNode serviceNode) {
+        controllerServiceProvider.disableControllerService(serviceNode);
+    }
+    
+    
+    /**
+     * Handle a bulletins message.
+     *
+     * @param bulletins
+     */
+    public void handleBulletins(final NodeBulletins bulletins) {
+        final NodeIdentifier nodeIdentifier = bulletins.getNodeIdentifier();
+        final String nodeAddress = nodeIdentifier.getApiAddress() + ":" + nodeIdentifier.getApiPort();
+
+        // unmarshal the message
+        BulletinsPayload payload = BulletinsPayload.unmarshal(bulletins.getPayload());
+        for (final Bulletin bulletin : payload.getBulletins()) {
+            bulletin.setNodeAddress(nodeAddress);
+            bulletinRepository.addBulletin(bulletin);
+        }
+    }
+
+    /**
+     * Handles a node's heartbeat. If this heartbeat is a node's first heartbeat
+     * since its connection request, then the manager will mark the node as
+     * connected. If the node was previously disconnected due to a lack of
+     * heartbeat, then a reconnection request is issued. If the node was
+     * disconnected for other reasons, then a disconnection request is issued.
+     * If this instance is configured with a firewall and the heartbeat is
+     * blocked, then a disconnection request is issued.
+     *
+     * @param heartbeat
+     */
+    @Override
+    public void handleHeartbeat(final Heartbeat heartbeat) {
+        // sanity check heartbeat
+        if (heartbeat == null) {
+            throw new IllegalArgumentException("Heartbeat may not be null.");
+        } else if (heartbeat.getNodeIdentifier() == null) {
+            throw new IllegalArgumentException("Heartbeat does not contain a node ID.");
+        }
+
+        /*
+         * Processing a heartbeat requires a write lock, which may take a while
+         * to obtain.  Only the last heartbeat is necessary to process per node.
+         * Futhermore, since many could pile up, heartbeats are processed in 
+         * bulk.
+         * 
+         * The below queue stores the pending heartbeats.
+         */
+        pendingHeartbeats.add(heartbeat);
+    }
+
+    private void processPendingHeartbeats() {
+        Node node;
+
+        writeLock.lock();
+        try {
+            /*
+             * Get the most recent heartbeats for the nodes in the cluster.  This
+             * is achieved by "draining" the pending heartbeats queue, populating
+             * a map that associates a node identifier with its latest heartbeat, and
+             * finally, getting the values of the map.
+             */
+            final Map<NodeIdentifier, Heartbeat> mostRecentHeartbeatsMap = new HashMap<>();
+            Heartbeat aHeartbeat;
+            while ((aHeartbeat = pendingHeartbeats.poll()) != null) {
+                mostRecentHeartbeatsMap.put(aHeartbeat.getNodeIdentifier(), aHeartbeat);
+            }
+            final Collection<Heartbeat> mostRecentHeartbeats = new ArrayList<>(mostRecentHeartbeatsMap.values());
+
+            // return fast if no work to do
+            if (mostRecentHeartbeats.isEmpty()) {
+                return;
+            }
+
+            logNodes("Before Heartbeat Processing", heartbeatLogger);
+
+            final int numPendingHeartbeats = mostRecentHeartbeats.size();
+            if (heartbeatLogger.isDebugEnabled()) {
+                heartbeatLogger.debug(String.format("Handling %s heartbeat%s", numPendingHeartbeats, (numPendingHeartbeats > 1) ? "s" : ""));
+            }
+
+            for (final Heartbeat mostRecentHeartbeat : mostRecentHeartbeats) {
+                try {
+                    // resolve the proposed node identifier to valid node identifier
+                    final NodeIdentifier resolvedNodeIdentifier = resolveProposedNodeIdentifier(mostRecentHeartbeat.getNodeIdentifier());
+
+                    // get a raw reference to the node (if it doesn't exist, node will be null)
+                    node = getRawNode(resolvedNodeIdentifier.getId());
+
+                    // if the node thinks it has the primary role, but the manager has assigned the role to a different node, then revoke the role
+                    if (mostRecentHeartbeat.isPrimary() && !isPrimaryNode(resolvedNodeIdentifier)) {
+                        addEvent(resolvedNodeIdentifier, "Heartbeat indicates node is running as primary node.  Revoking primary role because primary role is assigned to a different node.");
+                        revokePrimaryRole(resolvedNodeIdentifier);
+                    }
+
+                    final boolean heartbeatIndicatesNotYetConnected = !mostRecentHeartbeat.isConnected();
+
+                    if (isBlockedByFirewall(resolvedNodeIdentifier.getSocketAddress())) {
+                        if (node == null) {
+                            logger.info("Firewall blocked heartbeat received from unknown node " + resolvedNodeIdentifier + ".  Issuing disconnection request.");
+                        } else {
+                            // record event
+                            addEvent(resolvedNodeIdentifier, "Firewall blocked received heartbeat.  Issuing disconnection request.");
+                        }
+
+                        // request node to disconnect
+                        requestDisconnectionQuietly(resolvedNodeIdentifier, "Blocked By Firewall");
+
+                    } else if (node == null) {  // unknown node, so issue reconnect request
+                        // create new node and add to node set
+                        final Node newNode = new Node(resolvedNodeIdentifier, Status.DISCONNECTED);
+                        nodes.add(newNode);
+
+                        // record event
+                        addEvent(newNode.getNodeId(), "Received heartbeat from unknown node.  Issuing reconnection request.");
+
+                        // record heartbeat
+                        newNode.setHeartbeat(mostRecentHeartbeat);
+                        requestReconnection(resolvedNodeIdentifier.getId(), "NCM Heartbeat Processing");
+                    } else if (heartbeatIndicatesNotYetConnected) {
+                        if (Status.CONNECTED == node.getStatus()) {
+                            // record event
+                            addEvent(node.getNodeId(), "Received heartbeat from node that thinks it is not yet part of the cluster, though the Manager thought it was. Marking as Disconnected and issuing reconnection request.");
+
+                            // record heartbeat
+                            node.setHeartbeat(null);
+                            node.setStatus(Status.DISCONNECTED);
+
+                            requestReconnection(resolvedNodeIdentifier.getId(), "NCM Heartbeat Processing");
+                        }
+                    } else if (Status.DISCONNECTED == node.getStatus()) {
+                        // ignore heartbeats from nodes disconnected by means other than lack of heartbeat, unless it is
+                        // the only node. We allow it if it is the only node because if we have a one-node cluster, then
+                        // we cannot manually reconnect it.
+                        if (node.isHeartbeatDisconnection() || nodes.size() == 1) {
+                            // record event
+                            if (node.isHeartbeatDisconnection()) {
+                                addEvent(resolvedNodeIdentifier, "Received heartbeat from node previously disconnected due to lack of heartbeat.  Issuing reconnection request.");
+                            } else {
+                                addEvent(resolvedNodeIdentifier, "Received heartbeat from node previously disconnected, but it is the only known node, so issuing reconnection request.");
+                            }
+
+                            // record heartbeat
+                            node.setHeartbeat(mostRecentHeartbeat);
+
+                            // request reconnection
+                            requestReconnection(resolvedNodeIdentifier.getId(), "NCM Heartbeat Processing");
+                        } else {
+                            // disconnected nodes should not heartbeat, so we need to issue a disconnection request
+                            heartbeatLogger.info("Ignoring received heartbeat from disconnected node " + resolvedNodeIdentifier + ".  Issuing disconnection request.");
+
+                            // request node to disconnect
+                            requestDisconnectionQuietly(resolvedNodeIdentifier, "Received Heartbeat from Node, but Manager has already marked Node as Disconnected");
+                        }
+
+                    } else if (Status.DISCONNECTING == node.getStatus()) {
+                        /* ignore spurious heartbeat */
+                    } else {  // node is either either connected or connecting
+                        // first heartbeat causes status change from connecting to connected
+                        if (Status.CONNECTING == node.getStatus()) {
+                            if (mostRecentHeartbeat.getCreatedTimestamp() < node.getConnectionRequestedTimestamp()) {
+                                heartbeatLogger.info("Received heartbeat for node " + resolvedNodeIdentifier + " but ignoring because it was generated before the node was last asked to reconnect.");
+                                continue;
+                            }
+
+                            // set status to connected
+                            node.setStatus(Status.CONNECTED);
+
+                            // record event
+                            addEvent(resolvedNodeIdentifier, "Received first heartbeat from connecting node.  Setting node to connected.");
+
+                            // notify service of updated node set
+                            notifyDataFlowManagementServiceOfNodeStatusChange();
+
+                            addBulletin(node, Severity.INFO, "Node Connected");
+                        } else {
+                            heartbeatLogger.info("Received heartbeat for node " + resolvedNodeIdentifier + ".");
+                        }
+
+                        // record heartbeat
+                        node.setHeartbeat(mostRecentHeartbeat);
+
+                        ComponentStatusRepository statusRepository = componentMetricsRepositoryMap.get(node.getNodeId());
+                        if (statusRepository == null) {
+                            statusRepository = createComponentStatusRepository();
+                            componentMetricsRepositoryMap.put(node.getNodeId(), statusRepository);
+                        }
+
+                        // If it's been a while since we've captured, capture this metric.
+                        final Date lastCaptureDate = statusRepository.getLastCaptureDate();
+                        final long millisSinceLastCapture = (lastCaptureDate == null) ? Long.MAX_VALUE : (System.currentTimeMillis() - lastCaptureDate.getTime());
+
+                        if (millisSinceLastCapture > componentStatusSnapshotMillis) {
+                            statusRepository.capture(node.getHeartbeatPayload().getProcessGroupStatus());
+                        }
+                    }
+                } catch (final Exception e) {
+                    logger.error("Failed to process heartbeat from {}:{} due to {}", mostRecentHeartbeat.getNodeIdentifier().getApiAddress(), mostRecentHeartbeat.getNodeIdentifier().getApiPort(), e.toString());
+                    if (logger.isDebugEnabled()) {
+                        logger.error("", e);
+                    }
+                }
+            }
+
+            logNodes("After Heartbeat Processing", heartbeatLogger);
+        } finally {
+            writeLock.unlock("processPendingHeartbeats");
+        }
+    }
+
+    private ComponentStatusRepository createComponentStatusRepository() {
+        final String implementationClassName = properties.getProperty(NiFiProperties.COMPONENT_STATUS_REPOSITORY_IMPLEMENTATION, DEFAULT_COMPONENT_STATUS_REPO_IMPLEMENTATION);
+        if (implementationClassName == null) {
+            throw new RuntimeException("Cannot create Component Status Repository because the NiFi Properties is missing the following property: "
+                    + NiFiProperties.COMPONENT_STATUS_REPOSITORY_IMPLEMENTATION);
+        }
+
+        try {
+            return NarThreadContextClassLoader.createInstance(implementationClassName, ComponentStatusRepository.class);
+        } catch (final Exception e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    @Override
+    public Set<Node> getNodes(final Status... statuses) {
+        final Set<Status> desiredStatusSet = new HashSet<>();
+        for (final Status status : statuses) {
+            desiredStatusSet.add(status);
+        }
+
+        readLock.lock();
+        try {
+            final Set<Node> clonedNodes = new HashSet<>();
+            for (final Node node : nodes) {
+                if (desiredStatusSet.isEmpty() || desiredStatusSet.contains(node.getStatus())) {
+                    clonedNodes.add(node.clone());
+                }
+            }
+            return Collections.unmodifiableSet(clonedNodes);
+        } finally {
+            readLock.unlock("getNodes(Status...)");
+        }
+    }
+
+    @Override
+    public Node getNode(final String nodeId) {
+        readLock.lock();
+        try {
+            for (final Node node : nodes) {
+                if (node.getNodeId().getId().equals(nodeId)) {
+                    return node.clone();
+                }
+            }
+            return null;
+        } finally {
+            readLock.unlock("getNode(String)");
+        }
+    }
+
+    @Override
+    public Node getPrimaryNode() {
+        readLock.lock();
+        try {
+            if (primaryNodeId == null) {
+                return null;
+            } else {
+                return getNode(primaryNodeId.getId());
+            }
+        } finally {
+            readLock.unlock("getPrimaryNode");
+        }
+    }
+
+    @Override
+    public void deleteNode(final String nodeId, final String userDn) throws UnknownNodeException, IllegalNodeDeletionException {
+        writeLock.lock();
+        try {
+            final Node node = getNode(nodeId);
+            if (node == null) {
+                throw new UnknownNodeException("Node does not exist.");
+            } else if (Status.DISCONNECTED == node.getStatus()) {
+                nodes.remove(node);
+
+                if (eventManager != null) {
+                    eventManager.clearEventHistory(node.getNodeId().getId());
+                }
+
+                logger.info("Removing node {} from cluster because this action was requested by {}", node, userDn);
+            } else {
+                throw new IllegalNodeDeletionException("Node may not be deleted because it is not disconnected.");
+            }
+        } finally {
+            writeLock.unlock("deleteNode");
+        }
+    }
+
+    @Override
+    public Set<NodeIdentifier> getNodeIds(final Status... statuses) {
+        readLock.lock();
+        try {
+            final Set<NodeIdentifier> nodeIds = new HashSet<>();
+            for (final Node node : nodes) {
+                if (statuses == null || statuses.length == 0) {
+                    nodeIds.add(node.getNodeId());
+                } else {
+                    for (final Node.Status status : statuses) {
+                        if (node.getStatus() == status) {
+                            nodeIds.add(node.getNodeId());
+                            break;
+                        }
+                    }
+                }
+            }
+            return nodeIds;
+        } finally {
+            readLock.unlock("getNodeIds(Status...)");
+        }
+    }
+
+    @Override
+    public void setPrimaryNode(final String nodeId, final String userDn) throws UnknownNodeException, IneligiblePrimaryNodeException, PrimaryRoleAssignmentException {
+        writeLock.lock();
+        try {
+
+            final Node node = getNode(nodeId);
+            if (node == null) {
+                throw new UnknownNodeException("Node does not exist.");
+            } else if (Status.CONNECTED != node.getStatus()) {
+                throw new IneligiblePrimaryNodeException("Node must be connected before it can be assigned as the primary node.");
+            }
+
+            // revoke primary role
+            final Node primaryNode;
+            if ((primaryNode = getPrimaryNode()) != null) {
+                if (primaryNode.getStatus() == Status.DISCONNECTED) {
+                    throw new PrimaryRoleAssignmentException("A disconnected, primary node exists.  Delete the node before assigning the primary role to a different node.");
+                } else if (revokePrimaryRole(primaryNode.getNodeId())) {
+                    addEvent(primaryNode.getNodeId(), "Role revoked from this node as part of primary role reassignment.");
+                } else {
+                    throw new PrimaryRoleAssignmentException(
+                            "Failed to revoke primary role from node. Primary node is now disconnected. Delete the node before assigning the primary role to a different node.");
+                }
+            }
+
+            // change the primary node ID to the given node
+            setPrimaryNodeId(node.getNodeId());
+
+            // assign primary role
+            if (assignPrimaryRole(node.getNodeId())) {
+                addEvent(node.getNodeId(), "Role assigned to this node as part of primary role reassignment. Action performed by " + userDn);
+                addBulletin(node, Severity.INFO, "Primary Role assigned to node by " + userDn);
+            } else {
+                throw new PrimaryRoleAssignmentException(
+                        "Cluster manager assigned primary role to node, but the node failed to accept the assignment.  Cluster manager disconnected node.");
+            }
+        } finally {
+            writeLock.unlock("setPrimaryNode");
+        }
+    }
+
+    private int getClusterProtocolHeartbeatSeconds() {
+        return (int) FormatUtils.getTimeDuration(properties.getClusterProtocolHeartbeatInterval(), TimeUnit.SECONDS);
+    }
+
+    @Override
+    public int getHeartbeatMonitoringIntervalSeconds() {
+        return 4 * getClusterProtocolHeartbeatSeconds();
+    }
+
+    @Override
+    public int getMaxHeartbeatGapSeconds() {
+        return 8 * getClusterProtocolHeartbeatSeconds();
+    }
+
+    @Override
+    public List<Event> getNodeEvents(final String nodeId) {
+        readLock.lock();
+        try {
+            List<Event> events = null;
+            final EventManager eventMgr = eventManager;
+            if (eventMgr != null) {
+                events = eventMgr.getEvents(nodeId);
+            }
+
+            if (events == null) {
+                return Collections.emptyList();
+            } else {
+                return Collections.unmodifiableList(events);
+            }
+        } finally {
+            readLock.unlock("getNodeEvents");
+        }
+    }
+
+    @Override
+    public NodeResponse applyRequest(final String method, final URI uri, final Map<String, List<String>> parameters, final Map<String, String> headers)
+            throws NoConnectedNodesException, NoResponseFromNodesException, UriConstructionException, ConnectingNodeMutableRequestException, DisconnectedNodeMutableRequestException, SafeModeMutableRequestException {
+        return applyRequest(method, uri, parameters, headers, getNodeIds(Status.CONNECTED));
+    }
+
+    @Override
+    public NodeResponse applyRequest(final String method, final URI uri, final Map<String, List<String>> parameters, final Map<String, String> headers, final Set<NodeIdentifier> nodeIdentifiers)
+            throws NoConnectedNodesException, NoResponseFromNodesException, UriConstructionException, ConnectingNodeMutableRequestException, DisconnectedNodeMutableRequestException, SafeModeMutableRequestException {
+
+        final boolean mutableRequest = canChangeNodeState(method, uri);
+        final ClusterManagerLock lock = mutableRequest ? writeLock : readLock;
+
+        lock.lock();
+        try {
+            // check that the request can be applied
+            if (mutableRequest) {
+                if (isInSafeMode()) {
+                    throw new SafeModeMutableRequestException("Received a mutable request [" + method + " -- " + uri + "] while in safe mode");
+                } else if (!getNodeIds(Status.DISCONNECTED, Status.DISCONNECTING).isEmpty()) {
+                    throw new DisconnectedNodeMutableRequestException("Received a mutable request [" + method + " -- " + uri + "] while a node is disconnected from the cluster");
+                } else if (!getNodeIds(Status.CONNECTING).isEmpty()) {
+                    // if any node is connecting and a request can change the flow, then we throw an exception
+                    throw new ConnectingNodeMutableRequestException("Received a mutable request [" + method + " -- " + uri + "] while a node is trying to connect to the cluster");
+                }
+            }
+
+            final NodeResponse clientResponse = federateRequest(method, uri, parameters, null, headers, nodeIdentifiers);
+            if (clientResponse == null) {
+                if (mutableRequest) {
+                    throw new NoConnectedNodesException(String.format("All nodes were disconnected as a result of applying request %s %s", method, uri));
+                } else {
+                    throw new NoResponseFromNodesException("No nodes were able to process this request.");
+                }
+            } else {
+                return clientResponse;
+            }
+        } finally {
+            lock.unlock("applyRequest(String, URI, M

<TRUNCATED>

[06/20] incubator-nifi git commit: NIFI-410 pushed RAT exclusions down to the relevant modules and stopped doing broad test resource exclusion - is now specific

Posted by jo...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/flow/PersistedFlowState.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/flow/PersistedFlowState.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/flow/PersistedFlowState.java
new file mode 100644
index 0000000..b3afc6e
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/flow/PersistedFlowState.java
@@ -0,0 +1,37 @@
+/*
+ * 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.nifi.cluster.flow;
+
+/**
+ * Represents the various state of a flow managed by the cluster.
+ *
+ * The semantics of the values are:
+ * <ul>
+ * <li> CURRENT - the flow is current </li>
+ * <li> STALE - the flow is not current, but is eligible to be updated. </li>
+ * <li> UNKNOWN - the flow is not current and is not eligible to be updated.
+ * </li>
+ * </ul>
+ *
+ * @author unattributed
+ */
+public enum PersistedFlowState {
+
+    CURRENT,
+    STALE,
+    UNKNOWN
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/flow/StaleFlowException.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/flow/StaleFlowException.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/flow/StaleFlowException.java
new file mode 100644
index 0000000..ce5a08b
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/flow/StaleFlowException.java
@@ -0,0 +1,42 @@
+/*
+ * 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.nifi.cluster.flow;
+
+/**
+ * Represents the exceptional case when a caller is requesting the current flow,
+ * but a current flow is not available.
+ *
+ * @author unattributed
+ */
+public class StaleFlowException extends RuntimeException {
+
+    public StaleFlowException(String message, Throwable cause) {
+        super(message, cause);
+    }
+
+    public StaleFlowException(String message) {
+        super(message);
+    }
+
+    public StaleFlowException(Throwable cause) {
+        super(cause);
+    }
+
+    public StaleFlowException() {
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/flow/impl/DataFlowDaoImpl.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/flow/impl/DataFlowDaoImpl.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/flow/impl/DataFlowDaoImpl.java
new file mode 100644
index 0000000..72b594a
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/flow/impl/DataFlowDaoImpl.java
@@ -0,0 +1,600 @@
+/*
+ * 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.nifi.cluster.flow.impl;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.FilenameFilter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.util.Arrays;
+import java.util.UUID;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Marshaller;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.apache.commons.compress.archivers.ArchiveEntry;
+import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
+import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
+import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream;
+import org.apache.nifi.cluster.flow.ClusterDataFlow;
+import org.apache.nifi.cluster.flow.DaoException;
+import org.apache.nifi.cluster.flow.DataFlowDao;
+import org.apache.nifi.cluster.flow.PersistedFlowState;
+import org.apache.nifi.cluster.protocol.DataFlow;
+import org.apache.nifi.cluster.protocol.NodeIdentifier;
+import org.apache.nifi.cluster.protocol.StandardDataFlow;
+import org.apache.nifi.cluster.protocol.jaxb.message.NodeIdentifierAdapter;
+import org.apache.nifi.logging.NiFiLog;
+import org.apache.nifi.stream.io.BufferedInputStream;
+import org.apache.nifi.stream.io.BufferedOutputStream;
+import org.apache.nifi.stream.io.ByteArrayInputStream;
+import org.apache.nifi.stream.io.StreamUtils;
+import org.apache.nifi.util.file.FileUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+/**
+ * Implements the FlowDao interface. The implementation tracks the state of the
+ * dataflow by annotating the filename of the flow state file. Specifically, the
+ * implementation correlates PersistedFlowState states to filename extensions.
+ * The correlation is as follows:
+ * <ul>
+ * <li> CURRENT maps to flow.xml </li>
+ * <li> STALE maps to flow.xml.stale </li>
+ * <li> UNKNOWN maps to flow.xml.unknown </li>
+ * </ul>
+ * Whenever the flow state changes, the flow state file's name is updated to
+ * denote its state.
+ *
+ * The implementation also provides for a restore directory that may be
+ * configured for higher availability. At instance creation, if the primary or
+ * restore directories have multiple flow state files, an exception is thrown.
+ * If the primary directory has a current flow state file, but the restore
+ * directory does not, then the primary flow state file is copied to the restore
+ * directory. If the restore directory has a current flow state file, but the
+ * primary directory does not, then the restore flow state file is copied to the
+ * primary directory. If both the primary and restore directories have a current
+ * flow state file and the files are different, then an exception is thrown.
+ *
+ * When the flow state file is saved, it is always saved first to the restore
+ * directory followed by a save to the primary directory. When the flow state
+ * file is loaded, a check is made to verify that the primary and restore flow
+ * state files are both current. If either is not current, then an exception is
+ * thrown. The primary flow state file is always read when the load method is
+ * called.
+ *
+ * @author unattributed
+ */
+public class DataFlowDaoImpl implements DataFlowDao {
+
+    private final File primaryDirectory;
+    private final File restoreDirectory;
+    private final boolean autoStart;
+    private final String generatedRootGroupId = UUID.randomUUID().toString();
+
+    public static final String STALE_EXT = ".stale";
+    public static final String UNKNOWN_EXT = ".unknown";
+    public static final String FLOW_PACKAGE = "flow.tar";
+    public static final String FLOW_XML_FILENAME = "flow.xml";
+    public static final String TEMPLATES_FILENAME = "templates.xml";
+    public static final String SNIPPETS_FILENAME = "snippets.xml";
+    public static final String CLUSTER_INFO_FILENAME = "cluster-info.xml";
+
+    private static final Logger logger = new NiFiLog(LoggerFactory.getLogger(DataFlowDaoImpl.class));
+
+    public DataFlowDaoImpl(final File primaryDirectory) throws DaoException {
+        this(primaryDirectory, null, false);
+    }
+
+    public DataFlowDaoImpl(final File primaryDirectory, final File restoreDirectory, final boolean autoStart) throws DaoException {
+
+        // sanity check that primary directory is a directory, creating it if necessary
+        if (primaryDirectory == null) {
+            throw new IllegalArgumentException("Primary directory may not be null.");
+        } else if (!primaryDirectory.exists()) {
+            if (!primaryDirectory.mkdir()) {
+                throw new DaoException(String.format("Failed to create primary directory '%s'", primaryDirectory.getAbsolutePath()));
+            }
+        } else if (!primaryDirectory.isDirectory()) {
+            throw new IllegalArgumentException("Primary directory must be a directory.");
+        }
+
+        this.autoStart = autoStart;
+
+        try {
+            this.primaryDirectory = primaryDirectory;
+            this.restoreDirectory = restoreDirectory;
+
+            if (restoreDirectory == null) {
+                // check that we have exactly one current flow state file
+                ensureSingleCurrentStateFile(primaryDirectory);
+            } else {
+
+                // check that restore directory is a directory, creating it if necessary
+                FileUtils.ensureDirectoryExistAndCanAccess(restoreDirectory);
+
+                // check that restore directory is not the same as the primary directory
+                if (primaryDirectory.getAbsolutePath().equals(restoreDirectory.getAbsolutePath())) {
+                    throw new IllegalArgumentException(String.format("Primary directory '%s' is the same as restore directory '%s' ",
+                            primaryDirectory.getAbsolutePath(), restoreDirectory.getAbsolutePath()));
+                }
+
+                final File[] primaryFlowStateFiles = getFlowStateFiles(primaryDirectory);
+                final File[] restoreFlowStateFiles = getFlowStateFiles(restoreDirectory);
+
+                // if more than one state file in either primary or restore, then throw exception
+                if (primaryFlowStateFiles.length > 1) {
+                    throw new IllegalStateException(String.format("Found multiple dataflow state files in primary directory '%s'", primaryDirectory));
+                } else if (restoreFlowStateFiles.length > 1) {
+                    throw new IllegalStateException(String.format("Found multiple dataflow state files in restore directory '%s'", restoreDirectory));
+                }
+
+                // check that the single primary state file we found is current or create a new one
+                final File primaryFlowStateFile = ensureSingleCurrentStateFile(primaryDirectory);
+
+                // check that the single restore state file we found is current or create a new one
+                final File restoreFlowStateFile = ensureSingleCurrentStateFile(restoreDirectory);
+
+                // if there was a difference in flow state file directories, then copy the appropriate files
+                if (restoreFlowStateFiles.length == 0 && primaryFlowStateFiles.length != 0) {
+                    // copy primary state file to restore
+                    FileUtils.copyFile(primaryFlowStateFile, restoreFlowStateFile, false, false, logger);
+                } else if (primaryFlowStateFiles.length == 0 && restoreFlowStateFiles.length != 0) {
+                    // copy restore state file to primary
+                    FileUtils.copyFile(restoreFlowStateFile, primaryFlowStateFile, false, false, logger);
+                } else {
+                    // sync the primary copy with the restore copy
+                    syncWithRestore(primaryFlowStateFile, restoreFlowStateFile);
+                }
+
+            }
+        } catch (final IOException | IllegalArgumentException | IllegalStateException | JAXBException ex) {
+            throw new DaoException(ex);
+        }
+    }
+    
+    
+    private void syncWithRestore(final File primaryFile, final File restoreFile) throws IOException {
+        try (final FileInputStream primaryFis = new FileInputStream(primaryFile);
+             final TarArchiveInputStream primaryIn = new TarArchiveInputStream(primaryFis);
+             final FileInputStream restoreFis = new FileInputStream(restoreFile);
+             final TarArchiveInputStream restoreIn = new TarArchiveInputStream(restoreFis)) {
+            
+            final ArchiveEntry primaryEntry = primaryIn.getNextEntry();
+            final ArchiveEntry restoreEntry = restoreIn.getNextEntry();
+
+            if ( primaryEntry == null && restoreEntry == null ) {
+                return;
+            }
+
+            if ( (primaryEntry == null && restoreEntry != null) || (primaryEntry != null && restoreEntry == null) ) {
+                throw new IllegalStateException(String.format("Primary file '%s' is different than restore file '%s'",
+                        primaryFile.getAbsoluteFile(), restoreFile.getAbsolutePath()));
+            }
+            
+            final byte[] primaryMd5 = calculateMd5(primaryIn);
+            final byte[] restoreMd5 = calculateMd5(restoreIn);
+            
+            if ( !Arrays.equals(primaryMd5, restoreMd5) ) {
+                throw new IllegalStateException(String.format("Primary file '%s' is different than restore file '%s'",
+                        primaryFile.getAbsoluteFile(), restoreFile.getAbsolutePath()));
+            }
+        }
+    }
+    
+    private byte[] calculateMd5(final InputStream in) throws IOException {
+        final MessageDigest digest;
+        try {
+            digest = MessageDigest.getInstance("MD5");
+        } catch (final NoSuchAlgorithmException nsae) {
+            throw new IOException(nsae);
+        }
+        
+        int len;
+        final byte[] buffer = new byte[8192];
+        while ((len = in.read(buffer)) > -1) {
+            if (len > 0) {
+                digest.update(buffer, 0, len);
+            }
+        }
+        return digest.digest();
+    }
+
+    @Override
+    public ClusterDataFlow loadDataFlow() throws DaoException {
+        try {
+            return parseDataFlow(getExistingFlowStateFile(primaryDirectory));
+        } catch (final IOException | JAXBException ex) {
+            throw new DaoException(ex);
+        }
+    }
+
+    @Override
+    public void saveDataFlow(final ClusterDataFlow dataFlow) throws DaoException {
+        try {
+
+            final File primaryStateFile = getFlowStateFile(primaryDirectory);
+
+            // write to restore before writing to primary in case primary experiences problems
+            if (restoreDirectory != null) {
+                final File restoreStateFile = getFlowStateFile(restoreDirectory);
+                if (restoreStateFile == null) {
+                    if (primaryStateFile == null) {
+                        writeDataFlow(createNewFlowStateFile(restoreDirectory), dataFlow);
+                    } else {
+                        throw new DaoException(String.format("Unable to save dataflow because dataflow state file in primary directory '%s' exists, but it does not exist in the restore directory '%s'",
+                                primaryDirectory.getAbsolutePath(), restoreDirectory.getAbsolutePath()));
+                    }
+                } else {
+                    if (primaryStateFile == null) {
+                        throw new DaoException(String.format("Unable to save dataflow because dataflow state file in restore directory '%s' exists, but it does not exist in the primary directory '%s'",
+                                restoreDirectory.getAbsolutePath(), primaryDirectory.getAbsolutePath()));
+                    } else {
+                        final PersistedFlowState primaryFlowState = getPersistedFlowState(primaryStateFile);
+                        final PersistedFlowState restoreFlowState = getPersistedFlowState(restoreStateFile);
+                        if (primaryFlowState == restoreFlowState) {
+                            writeDataFlow(restoreStateFile, dataFlow);
+                        } else {
+                            throw new DaoException(String.format("Unable to save dataflow because state file in primary directory '%s' has state '%s', but the state file in the restore directory '%s' has state '%s'",
+                                    primaryDirectory.getAbsolutePath(), primaryFlowState, restoreDirectory.getAbsolutePath(), restoreFlowState));
+                        }
+                    }
+                }
+            }
+
+            // write dataflow to primary 
+            if (primaryStateFile == null) {
+                writeDataFlow(createNewFlowStateFile(primaryDirectory), dataFlow);
+            } else {
+                writeDataFlow(primaryStateFile, dataFlow);
+            }
+
+        } catch (final IOException | JAXBException ex) {
+            throw new DaoException(ex);
+        }
+    }
+
+    @Override
+    public PersistedFlowState getPersistedFlowState() {
+        // trust restore over primary if configured for restore
+        if (restoreDirectory == null) {
+            return getPersistedFlowState(getExistingFlowStateFile(primaryDirectory));
+        } else {
+            return getPersistedFlowState(getExistingFlowStateFile(restoreDirectory));
+        }
+    }
+
+    @Override
+    public void setPersistedFlowState(final PersistedFlowState flowState) throws DaoException {
+        // rename restore before primary if configured for restore
+        if (restoreDirectory != null) {
+            renameFlowStateFile(getExistingFlowStateFile(restoreDirectory), flowState);
+        }
+        renameFlowStateFile(getExistingFlowStateFile(primaryDirectory), flowState);
+    }
+
+    private File ensureSingleCurrentStateFile(final File dir) throws IOException, JAXBException {
+
+        // ensure that we have at most one state file and if we have one, it is current
+        final File[] directoryFlowStateFiles = getFlowStateFiles(dir);
+        if (directoryFlowStateFiles.length > 1) {
+            throw new DaoException(String.format("Found multiple dataflow state files in directory '%s'", dir));
+        } else if (directoryFlowStateFiles.length == 0) {
+            // create a new file if none exist
+            return createNewFlowStateFile(dir);
+        } else {
+            // check that the single flow state file is current
+            final PersistedFlowState flowState = getPersistedFlowState(directoryFlowStateFiles[0]);
+            if (PersistedFlowState.CURRENT == flowState) {
+                return directoryFlowStateFiles[0];
+            } else {
+                throw new DaoException(String.format("Dataflow state file '%s' must be current.", directoryFlowStateFiles[0].getAbsolutePath()));
+            }
+        }
+
+    }
+
+    private PersistedFlowState getPersistedFlowState(final File file) {
+        final String path = file.getAbsolutePath();
+        if (path.endsWith(STALE_EXT)) {
+            return PersistedFlowState.STALE;
+        } else if (path.endsWith(UNKNOWN_EXT)) {
+            return PersistedFlowState.UNKNOWN;
+        } else {
+            return PersistedFlowState.CURRENT;
+        }
+    }
+
+    private File getFlowStateFile(final File dir) {
+        final File[] files = getFlowStateFiles(dir);
+        if (files.length > 1) {
+            throw new IllegalStateException(String.format("Expected at most one dataflow state file, but found %s files.", files.length));
+        } else if (files.length == 0) {
+            return null;
+        } else {
+            return files[0];
+        }
+    }
+
+    private File getExistingFlowStateFile(final File dir) {
+        final File file = getFlowStateFile(dir);
+        if (file == null) {
+            throw new IllegalStateException(String.format("Expected a dataflow state file, but none existed in directory '%s'", dir.getAbsolutePath()));
+        }
+        return file;
+    }
+
+    private File[] getFlowStateFiles(final File dir) {
+        final File[] files = dir.listFiles(new FilenameFilter() {
+            @Override
+            public boolean accept(File dir, String name) {
+                return (name.equals(FLOW_PACKAGE) || name.endsWith(STALE_EXT) || name.endsWith(UNKNOWN_EXT));
+            }
+        });
+
+        if (files == null) {
+            return new File[0];
+        } else {
+            return files;
+        }
+    }
+
+    private File removeStateFileExtension(final File file) {
+
+        final String path = file.getAbsolutePath();
+        final int stateFileExtIndex;
+        if (path.endsWith(STALE_EXT)) {
+            stateFileExtIndex = path.lastIndexOf(STALE_EXT);
+        } else if (path.endsWith(UNKNOWN_EXT)) {
+            stateFileExtIndex = path.lastIndexOf(UNKNOWN_EXT);
+        } else {
+            stateFileExtIndex = path.length();
+        }
+
+        return new File(path.substring(0, stateFileExtIndex));
+    }
+
+    private File addStateFileExtension(final File file, final PersistedFlowState state) {
+        switch (state) {
+            case CURRENT: {
+                return file;
+            }
+            case STALE: {
+                return new File(file.getAbsolutePath() + STALE_EXT);
+            }
+            case UNKNOWN: {
+                return new File(file.getAbsolutePath() + UNKNOWN_EXT);
+            }
+            default: {
+                throw new RuntimeException("Unsupported PersistedFlowState Enum value: " + state);
+            }
+        }
+    }
+
+    private File createNewFlowStateFile(final File dir) throws IOException, JAXBException {
+        final File stateFile = new File(dir, FLOW_PACKAGE);
+        stateFile.createNewFile();
+
+        final byte[] flowBytes = getEmptyFlowBytes();
+        final byte[] templateBytes = new byte[0];
+        final byte[] snippetBytes = new byte[0];
+        final DataFlow dataFlow = new StandardDataFlow(flowBytes, templateBytes, snippetBytes);
+
+        final ClusterMetadata clusterMetadata = new ClusterMetadata();
+        writeDataFlow(stateFile, dataFlow, clusterMetadata);
+
+        return stateFile;
+    }
+
+    private byte[] getEmptyFlowBytes() throws IOException {
+        try {
+            final DocumentBuilder docBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+            final Document document = docBuilder.newDocument();
+
+            final Element controller = document.createElement("flowController");
+            document.appendChild(controller);
+
+            controller.appendChild(createTextElement(document, "maxThreadCount", "15"));
+
+            final Element rootGroup = document.createElement("rootGroup");
+            rootGroup.appendChild(createTextElement(document, "id", generatedRootGroupId));
+            rootGroup.appendChild(createTextElement(document, "name", "NiFi Flow"));
+
+            // create the position element
+            final Element positionElement = createTextElement(document, "position", "");
+            positionElement.setAttribute("x", "0.0");
+            positionElement.setAttribute("y", "0.0");
+            rootGroup.appendChild(positionElement);
+
+            rootGroup.appendChild(createTextElement(document, "comment", ""));
+            controller.appendChild(rootGroup);
+
+            final Transformer transformer = TransformerFactory.newInstance().newTransformer();
+            transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
+            transformer.setOutputProperty(OutputKeys.INDENT, "yes");
+
+            final DOMSource source = new DOMSource(document);
+            final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+            final StreamResult result = new StreamResult(baos);
+            transformer.transform(source, result);
+
+            return baos.toByteArray();
+        } catch (final Exception e) {
+            throw new IOException(e);
+        }
+    }
+
+    private Element createTextElement(final Document document, final String elementName, final String value) {
+        final Element element = document.createElement(elementName);
+        element.setTextContent(value);
+        return element;
+    }
+
+    private void renameFlowStateFile(final File flowStateFile, final PersistedFlowState newState) throws DaoException {
+        final PersistedFlowState existingState = getPersistedFlowState(flowStateFile);
+        if (existingState != newState) {
+            final File newFlowStateFile = addStateFileExtension(removeStateFileExtension(flowStateFile), newState);
+            if (flowStateFile.renameTo(newFlowStateFile) == false) {
+                throw new DaoException(
+                        String.format("Failed to rename flow state file '%s' to new name '%s'", flowStateFile.getAbsolutePath(), newFlowStateFile.getAbsolutePath()));
+            }
+        }
+    }
+
+    private ClusterDataFlow parseDataFlow(final File file) throws IOException, JAXBException, DaoException {
+        byte[] flowBytes = new byte[0];
+        byte[] templateBytes = new byte[0];
+        byte[] snippetBytes = new byte[0];
+        byte[] clusterInfoBytes = new byte[0];
+
+        try (final InputStream inStream = new FileInputStream(file);
+                final TarArchiveInputStream tarIn = new TarArchiveInputStream(new BufferedInputStream(inStream))) {
+            TarArchiveEntry tarEntry;
+            while ((tarEntry = tarIn.getNextTarEntry()) != null) {
+                switch (tarEntry.getName()) {
+                    case FLOW_XML_FILENAME:
+                        flowBytes = new byte[(int) tarEntry.getSize()];
+                        StreamUtils.fillBuffer(tarIn, flowBytes, true);
+                        break;
+                    case TEMPLATES_FILENAME:
+                        templateBytes = new byte[(int) tarEntry.getSize()];
+                        StreamUtils.fillBuffer(tarIn, templateBytes, true);
+                        break;
+                    case SNIPPETS_FILENAME:
+                        snippetBytes = new byte[(int) tarEntry.getSize()];
+                        StreamUtils.fillBuffer(tarIn, snippetBytes, true);
+                        break;
+                    case CLUSTER_INFO_FILENAME:
+                        clusterInfoBytes = new byte[(int) tarEntry.getSize()];
+                        StreamUtils.fillBuffer(tarIn, clusterInfoBytes, true);
+                        break;
+                    default:
+                        throw new DaoException("Found Unexpected file in dataflow configuration: " + tarEntry.getName());
+                }
+            }
+        }
+
+        final ClusterMetadata clusterMetadata;
+        if (clusterInfoBytes.length == 0) {
+            clusterMetadata = null;
+        } else {
+            final Unmarshaller clusterMetadataUnmarshaller = ClusterMetadata.jaxbCtx.createUnmarshaller();
+            clusterMetadata = (ClusterMetadata) clusterMetadataUnmarshaller.unmarshal(new ByteArrayInputStream(clusterInfoBytes));
+        }
+
+        final StandardDataFlow dataFlow = new StandardDataFlow(flowBytes, templateBytes, snippetBytes);
+        dataFlow.setAutoStartProcessors(autoStart);
+
+        return new ClusterDataFlow(dataFlow, (clusterMetadata == null) ? null : clusterMetadata.getPrimaryNodeId());
+    }
+
+    private void writeDataFlow(final File file, final ClusterDataFlow clusterDataFlow) throws IOException, JAXBException {
+
+        // get the data flow
+        DataFlow dataFlow = clusterDataFlow.getDataFlow();
+
+        // if no dataflow, then write a new dataflow
+        if (dataFlow == null) {
+            dataFlow = new StandardDataFlow(new byte[0], new byte[0], new byte[0]);
+        }
+
+        // setup the cluster metadata
+        final ClusterMetadata clusterMetadata = new ClusterMetadata();
+        clusterMetadata.setPrimaryNodeId(clusterDataFlow.getPrimaryNodeId());
+
+        // write to disk
+        writeDataFlow(file, dataFlow, clusterMetadata);
+    }
+
+    private void writeTarEntry(final TarArchiveOutputStream tarOut, final String filename, final byte[] bytes) throws IOException {
+        final TarArchiveEntry flowEntry = new TarArchiveEntry(filename);
+        flowEntry.setSize(bytes.length);
+        tarOut.putArchiveEntry(flowEntry);
+        tarOut.write(bytes);
+        tarOut.closeArchiveEntry();
+    }
+
+    private void writeDataFlow(final File file, final DataFlow dataFlow, final ClusterMetadata clusterMetadata) throws IOException, JAXBException {
+
+        try (final OutputStream fos = new FileOutputStream(file);
+                final TarArchiveOutputStream tarOut = new TarArchiveOutputStream(new BufferedOutputStream(fos))) {
+
+            writeTarEntry(tarOut, FLOW_XML_FILENAME, dataFlow.getFlow());
+            writeTarEntry(tarOut, TEMPLATES_FILENAME, dataFlow.getTemplates());
+            writeTarEntry(tarOut, SNIPPETS_FILENAME, dataFlow.getSnippets());
+
+            final ByteArrayOutputStream baos = new ByteArrayOutputStream(256);
+            writeClusterMetadata(clusterMetadata, baos);
+            final byte[] clusterInfoBytes = baos.toByteArray();
+
+            writeTarEntry(tarOut, CLUSTER_INFO_FILENAME, clusterInfoBytes);
+        }
+    }
+
+    private void writeClusterMetadata(final ClusterMetadata clusterMetadata, final OutputStream os) throws IOException, JAXBException {
+        // write cluster metadata to output stream
+        final Marshaller marshaller = ClusterMetadata.jaxbCtx.createMarshaller();
+        marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
+        marshaller.setProperty(Marshaller.JAXB_FRAGMENT, true);
+        marshaller.setProperty(Marshaller.JAXB_ENCODING, "UTF-8");
+        marshaller.marshal(clusterMetadata, os);
+    }
+
+    @XmlRootElement(name = "clusterMetadata")
+    private static class ClusterMetadata {
+
+        private NodeIdentifier primaryNodeId;
+
+        private static final JAXBContext jaxbCtx;
+
+        static {
+            try {
+                jaxbCtx = JAXBContext.newInstance(ClusterMetadata.class);
+            } catch (final JAXBException je) {
+                throw new RuntimeException(je);
+            }
+        }
+
+        @XmlJavaTypeAdapter(NodeIdentifierAdapter.class)
+        public NodeIdentifier getPrimaryNodeId() {
+            return primaryNodeId;
+        }
+
+        public void setPrimaryNodeId(final NodeIdentifier primaryNodeId) {
+            this.primaryNodeId = primaryNodeId;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/flow/impl/DataFlowManagementServiceImpl.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/flow/impl/DataFlowManagementServiceImpl.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/flow/impl/DataFlowManagementServiceImpl.java
new file mode 100644
index 0000000..e135af3
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/flow/impl/DataFlowManagementServiceImpl.java
@@ -0,0 +1,356 @@
+/*
+ * 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.nifi.cluster.flow.impl;
+
+import java.util.Collections;
+import java.util.Date;
+import java.util.Set;
+import java.util.Timer;
+import java.util.TimerTask;
+import java.util.concurrent.CopyOnWriteArraySet;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicLong;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
+
+import org.apache.nifi.cluster.flow.ClusterDataFlow;
+import org.apache.nifi.cluster.flow.DaoException;
+import org.apache.nifi.cluster.flow.DataFlowDao;
+import org.apache.nifi.cluster.flow.DataFlowManagementService;
+import org.apache.nifi.cluster.flow.PersistedFlowState;
+import org.apache.nifi.cluster.protocol.ClusterManagerProtocolSender;
+import org.apache.nifi.cluster.protocol.NodeIdentifier;
+import org.apache.nifi.cluster.protocol.StandardDataFlow;
+import org.apache.nifi.cluster.protocol.message.FlowRequestMessage;
+import org.apache.nifi.cluster.protocol.message.FlowResponseMessage;
+import org.apache.nifi.logging.NiFiLog;
+import org.apache.nifi.util.FormatUtils;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Implements FlowManagementService interface. The service tries to keep the
+ * cluster's flow current with regards to the available nodes.
+ *
+ * The instance may be configured with a retrieval delay, which will reduce the
+ * number of retrievals performed by the service at the expense of increasing
+ * the chances that the service will not be able to provide a current flow to
+ * the caller.
+ *
+ * By default, the service will try to update the flow as quickly as possible.
+ * Configuring a delay enables a less aggressive retrieval strategy.
+ * Specifically, the eligible retrieval time is reset every time the flow state
+ * is set to STALE. If the state is set to UNKNOWN or CURRENT, then the flow
+ * will not be retrieved.
+ *
+ * @author unattributed
+ */
+public class DataFlowManagementServiceImpl implements DataFlowManagementService {
+
+    /*
+     * Developer Note: 
+     * 
+     * This class maintains an ExecutorService and a Runnable.
+     * Although the class is not externally threadsafe, its internals are protected to
+     * accommodate multithread access between the ExecutorServer and the Runnable.
+     * 
+     */
+    private static final Logger logger = new NiFiLog(LoggerFactory.getLogger(DataFlowManagementServiceImpl.class));
+
+    private final DataFlowDao flowDao;
+
+    private final ClusterManagerProtocolSender sender;
+
+    private final Set<NodeIdentifier> nodeIds = new CopyOnWriteArraySet<>();
+
+    private final AtomicBoolean stopRequested = new AtomicBoolean(false);
+
+    private final AtomicLong lastRetrievalTime = new AtomicLong(-1);
+
+    private Timer flowRetriever;
+
+    private long retrievableAfterTime = 0L;
+
+    private AtomicInteger retrievalDelaySeconds = new AtomicInteger(0);
+
+    private final TimingReentrantLock resourceLock = new TimingReentrantLock(new ReentrantLock());
+
+    public DataFlowManagementServiceImpl(final DataFlowDao flowDao, final ClusterManagerProtocolSender sender) {
+        if (flowDao == null) {
+            throw new IllegalArgumentException("Flow DAO may not be null.");
+        } else if (sender == null) {
+            throw new IllegalArgumentException("Cluster Manager Protocol Sender may not be null.");
+        }
+        this.flowDao = flowDao;
+        this.sender = sender;
+    }
+
+    @Override
+    public void start() {
+
+        if (isRunning()) {
+            throw new IllegalArgumentException("Instance is already running.");
+        }
+
+        // reset stop requested
+        stopRequested.set(false);
+
+        // setup flow retreiver timer
+        flowRetriever = new Timer("Flow Management Service", /* is daemon */ true);
+        flowRetriever.schedule(new FlowRetrieverTimerTask(), 0, 500);
+    }
+
+    @Override
+    public boolean isRunning() {
+        return (flowRetriever != null);
+    }
+
+    @Override
+    public void stop() {
+
+        if (isRunning() == false) {
+            throw new IllegalArgumentException("Instance is already stopped.");
+        }
+
+        // record stop request
+        stopRequested.set(true);
+
+        flowRetriever.cancel();
+        flowRetriever = null;
+
+    }
+
+    @Override
+    public ClusterDataFlow loadDataFlow() throws DaoException {
+        resourceLock.lock();
+        try {
+            return flowDao.loadDataFlow();
+        } finally {
+            resourceLock.unlock("loadDataFlow");
+        }
+    }
+
+    @Override
+    public void updatePrimaryNode(final NodeIdentifier nodeId) {
+        resourceLock.lock();
+        try {
+            final ClusterDataFlow existingClusterDataFlow = flowDao.loadDataFlow();
+
+            final StandardDataFlow dataFlow;
+            if (existingClusterDataFlow == null) {
+                dataFlow = null;
+            } else {
+                dataFlow = existingClusterDataFlow.getDataFlow();
+            }
+
+            flowDao.saveDataFlow(new ClusterDataFlow(dataFlow, nodeId));
+        } finally {
+            resourceLock.unlock("updatePrimaryNode");
+        }
+    }
+
+    @Override
+    public PersistedFlowState getPersistedFlowState() {
+        resourceLock.lock();
+        try {
+            return flowDao.getPersistedFlowState();
+        } finally {
+            resourceLock.unlock("getPersistedFlowState");
+        }
+    }
+
+    @Override
+    public boolean isFlowCurrent() {
+        return PersistedFlowState.CURRENT == getPersistedFlowState();
+    }
+
+    @Override
+    public void setPersistedFlowState(final PersistedFlowState flowState) {
+        // lock to ensure state change and retrievable time update are atomic
+        resourceLock.lock();
+        try {
+            flowDao.setPersistedFlowState(flowState);
+            if (PersistedFlowState.STALE == flowState) {
+                retrievableAfterTime = new Date().getTime() + (getRetrievalDelaySeconds() * 1000);
+            } else if (PersistedFlowState.UNKNOWN == flowState || PersistedFlowState.CURRENT == flowState) {
+                retrievableAfterTime = Long.MAX_VALUE;
+            }
+        } finally {
+            resourceLock.unlock("setPersistedFlowState");
+        }
+    }
+
+    @Override
+    public Set<NodeIdentifier> getNodeIds() {
+        return Collections.unmodifiableSet(nodeIds);
+    }
+
+    @Override
+    public void setNodeIds(final Set<NodeIdentifier> nodeIds) {
+
+        if (nodeIds == null) {
+            throw new IllegalArgumentException("Node IDs may not be null.");
+        }
+
+        resourceLock.lock();
+        try {
+
+            if (this.nodeIds.equals(nodeIds)) {
+                return;
+            }
+
+            this.nodeIds.clear();
+            this.nodeIds.addAll(nodeIds);
+
+        } finally {
+            resourceLock.unlock("setNodeIds");
+        }
+
+    }
+
+    @Override
+    public int getRetrievalDelaySeconds() {
+        return retrievalDelaySeconds.get();
+    }
+
+    @Override
+    public void setRetrievalDelay(final String retrievalDelay) {
+        this.retrievalDelaySeconds.set((int) FormatUtils.getTimeDuration(retrievalDelay, TimeUnit.SECONDS));
+    }
+
+    public ClusterManagerProtocolSender getSender() {
+        return sender;
+    }
+
+    public long getLastRetrievalTime() {
+        return lastRetrievalTime.get();
+    }
+
+    /**
+     * A timer task for issuing FlowRequestMessage messages to nodes to retrieve
+     * an updated flow.
+     */
+    private class FlowRetrieverTimerTask extends TimerTask {
+
+        @Override
+        public void run() {
+
+            resourceLock.lock();
+            try {
+                // if flow is current, then we're done
+                if (isFlowCurrent()) {
+                    return;
+                }
+            } catch (final Exception ex) {
+                logger.info("Encountered exception checking if flow is current caused by " + ex, ex);
+            } finally {
+                resourceLock.unlock("FlowRetrieverTimerTask - isFlowCurrent");
+            }
+
+            final FlowRequestMessage request = new FlowRequestMessage();
+            for (final NodeIdentifier nodeId : getNodeIds()) {
+                try {
+                    // setup request
+                    request.setNodeId(nodeId);
+
+                    // record request time
+                    final long requestSentTime = new Date().getTime();
+
+                    resourceLock.lock();
+                    try {
+                        // sanity checks before making request
+                        if (stopRequested.get()) {  // did we receive a stop request
+                            logger.debug("Stopping runnable prematurely because a request to stop was issued.");
+                            return;
+                        } else if (requestSentTime < retrievableAfterTime) {
+                            /*
+                             * Retrievable after time was updated while obtaining
+                             * the lock, so try again later
+                             */
+                            return;
+                        }
+                    } finally {
+                        resourceLock.unlock("FlowRetrieverTimerTask - check stopRequested");
+                    }
+
+                    // send request
+                    final FlowResponseMessage response = sender.requestFlow(request);
+
+                    resourceLock.lock();
+                    try {
+                        // check if the retrieved flow is still valid
+                        if (requestSentTime > retrievableAfterTime) {
+                            logger.info("Saving retrieved flow.");
+
+                            final StandardDataFlow dataFlow = response.getDataFlow();
+                            final ClusterDataFlow existingClusterDataFlow = flowDao.loadDataFlow();
+                            final ClusterDataFlow currentClusterDataFlow;
+                            if (existingClusterDataFlow == null) {
+                                currentClusterDataFlow = new ClusterDataFlow(dataFlow, null);
+                            } else {
+                                currentClusterDataFlow = new ClusterDataFlow(dataFlow, existingClusterDataFlow.getPrimaryNodeId());
+                            }
+                            flowDao.saveDataFlow(currentClusterDataFlow);
+                            flowDao.setPersistedFlowState(PersistedFlowState.CURRENT);
+                            lastRetrievalTime.set(new Date().getTime());
+                        }
+
+                        /*
+                         * Retrievable after time was updated while requesting
+                         * the flow, so try again later.
+                         */
+                    } finally {
+                        resourceLock.unlock("FlowRetrieverTimerTask - saveDataFlow");
+                    }
+
+                } catch (final Throwable t) {
+                    logger.info("Encountered exception retrieving flow from node " + nodeId + " caused by " + t, t);
+                }
+            }
+        }
+    }
+
+    private static class TimingReentrantLock {
+
+        private final Lock lock;
+        private static final Logger logger = LoggerFactory.getLogger("dataFlowManagementService.lock");
+
+        private final ThreadLocal<Long> lockTime = new ThreadLocal<>();
+
+        public TimingReentrantLock(final Lock lock) {
+            this.lock = lock;
+        }
+
+        public void lock() {
+            lock.lock();
+            lockTime.set(System.nanoTime());
+        }
+
+        public void unlock(final String task) {
+            final long nanosLocked = System.nanoTime() - lockTime.get();
+            lock.unlock();
+
+            final long millisLocked = TimeUnit.MILLISECONDS.convert(nanosLocked, TimeUnit.NANOSECONDS);
+            if (millisLocked > 100L) {
+                logger.debug("Lock held for {} milliseconds for task: {}", millisLocked, task);
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/ClusterManager.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/ClusterManager.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/ClusterManager.java
new file mode 100644
index 0000000..3a1dfb2
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/ClusterManager.java
@@ -0,0 +1,225 @@
+/*
+ * 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.nifi.cluster.manager;
+
+import java.util.List;
+import java.util.Set;
+
+import org.apache.nifi.cluster.event.Event;
+import org.apache.nifi.cluster.manager.exception.IllegalNodeDeletionException;
+import org.apache.nifi.cluster.manager.exception.IllegalNodeDisconnectionException;
+import org.apache.nifi.cluster.manager.exception.IllegalNodeReconnectionException;
+import org.apache.nifi.cluster.manager.exception.IneligiblePrimaryNodeException;
+import org.apache.nifi.cluster.manager.exception.NodeDisconnectionException;
+import org.apache.nifi.cluster.manager.exception.PrimaryRoleAssignmentException;
+import org.apache.nifi.cluster.manager.exception.UnknownNodeException;
+import org.apache.nifi.cluster.node.Node;
+import org.apache.nifi.cluster.node.Node.Status;
+import org.apache.nifi.cluster.protocol.ConnectionRequest;
+import org.apache.nifi.cluster.protocol.ConnectionResponse;
+import org.apache.nifi.cluster.protocol.Heartbeat;
+import org.apache.nifi.cluster.protocol.NodeIdentifier;
+import org.apache.nifi.controller.status.ProcessGroupStatus;
+import org.apache.nifi.diagnostics.SystemDiagnostics;
+import org.apache.nifi.remote.cluster.NodeInformant;
+import org.apache.nifi.reporting.BulletinRepository;
+
+/**
+ * Defines the interface for a ClusterManager. The cluster manager is a
+ * threadsafe centralized manager for a cluster. Members of a cluster are nodes.
+ * A member becomes a node by issuing a connection request to the manager. The
+ * manager maintains the set of nodes. Nodes may be disconnected, reconnected,
+ * and deleted.
+ *
+ * Nodes are responsible for sending heartbeats to the manager to indicate their
+ * liveliness. A manager may disconnect a node if it does not receive a
+ * heartbeat within a configurable time period. A cluster manager instance may
+ * be configured with how often to monitor received heartbeats
+ * (getHeartbeatMonitoringIntervalSeconds()) and the maximum time that may
+ * elapse between node heartbeats before disconnecting the node
+ * (getMaxHeartbeatGapSeconds()).
+ *
+ * Since only a single node may execute isolated processors, the cluster manager
+ * maintains the notion of a primary node. The primary node is chosen at cluster
+ * startup and retains the role until a user requests a different node to be the
+ * primary node.
+ *
+ * @author unattributed
+ */
+public interface ClusterManager extends NodeInformant {
+
+    /**
+     * Handles a node's heartbeat.
+     *
+     * @param heartbeat a heartbeat
+     *
+     */
+    void handleHeartbeat(Heartbeat heartbeat);
+
+    /**
+     * @param statuses the statuses of the nodes
+     * @return the set of nodes
+     */
+    Set<Node> getNodes(Status... statuses);
+
+    /**
+     * @param nodeId
+     * @return returns the node with the given identifier or null if node does
+     * not exist
+     */
+    Node getNode(String nodeId);
+
+    /**
+     * @param statuses
+     * @return the set of node identifiers with the given node status
+     */
+    Set<NodeIdentifier> getNodeIds(Status... statuses);
+
+    /**
+     * Deletes the node with the given node identifier. If the given node is the
+     * primary node, then a subsequent request may be made to the manager to set
+     * a new primary node.
+     *
+     * @param nodeId the node identifier
+     * @param userDn the Distinguished Name of the user requesting the node be
+     * deleted from the cluster
+     *
+     * @throws UnknownNodeException if the node does not exist
+     * @throws IllegalNodeDeletionException if the node is not in a disconnected
+     * state
+     */
+    void deleteNode(String nodeId, String userDn) throws UnknownNodeException, IllegalNodeDeletionException;
+
+    /**
+     * Requests a connection to the cluster.
+     *
+     * @param request the request
+     *
+     * @return the response
+     */
+    ConnectionResponse requestConnection(ConnectionRequest request);
+
+    /**
+     * Services reconnection requests for a given node. If the node indicates
+     * reconnection failure, then the node will be set to disconnected.
+     * Otherwise, a reconnection request will be sent to the node, initiating
+     * the connection handshake.
+     *
+     * @param nodeId a node identifier
+     * @param userDn the Distinguished Name of the user requesting the
+     * reconnection
+     *
+     * @throws UnknownNodeException if the node does not exist
+     * @throws IllegalNodeReconnectionException if the node is not disconnected
+     */
+    void requestReconnection(String nodeId, String userDn) throws UnknownNodeException, IllegalNodeReconnectionException;
+
+    /**
+     * Requests the node with the given identifier be disconnected.
+     *
+     * @param nodeId the node identifier
+     * @param userDn the Distinguished Name of the user requesting the
+     * disconnection
+     *
+     * @throws UnknownNodeException if the node does not exist
+     * @throws IllegalNodeDisconnectionException if the node cannot be
+     * disconnected due to the cluster's state (e.g., node is last connected
+     * node or node is primary)
+     * @throws UnknownNodeException if the node does not exist
+     * @throws IllegalNodeDisconnectionException if the node is not disconnected
+     * @throws NodeDisconnectionException if the disconnection failed
+     */
+    void requestDisconnection(String nodeId, String userDn) throws UnknownNodeException, IllegalNodeDisconnectionException, NodeDisconnectionException;
+
+    /**
+     * @return the time in seconds to wait between successive executions of
+     * heartbeat monitoring
+     */
+    int getHeartbeatMonitoringIntervalSeconds();
+
+    /**
+     * @return the maximum time in seconds that is allowed between successive
+     * heartbeats of a node before disconnecting the node
+     */
+    int getMaxHeartbeatGapSeconds();
+
+    /**
+     * Returns a list of node events for the node with the given identifier. The
+     * events will be returned in order of most recent to least recent according
+     * to the creation date of the event.
+     *
+     * @param nodeId the node identifier
+     *
+     * @return the list of events or an empty list if no node exists with the
+     * given identifier
+     */
+    List<Event> getNodeEvents(final String nodeId);
+
+    /**
+     * Revokes the primary role from the current primary node and assigns the
+     * primary role to given given node ID.
+     *
+     * If role revocation fails, then the current primary node is set to
+     * disconnected while retaining the primary role and no role assignment is
+     * performed.
+     *
+     * If role assignment fails, then the given node is set to disconnected and
+     * is given the primary role.
+     *
+     * @param nodeId the node identifier
+     * @param userDn the Distinguished Name of the user requesting that the
+     * Primary Node be assigned
+     *
+     * @throws UnknownNodeException if the node with the given identifier does
+     * not exist
+     * @throws IneligiblePrimaryNodeException if the node with the given
+     * identifier is not eligible to be the primary node
+     * @throws PrimaryRoleAssignmentException if the cluster was unable to
+     * change the primary role to the requested node
+     */
+    void setPrimaryNode(String nodeId, String userDn) throws UnknownNodeException, IneligiblePrimaryNodeException, PrimaryRoleAssignmentException;
+
+    /**
+     * @return the primary node of the cluster or null if no primary node exists
+     */
+    Node getPrimaryNode();
+
+    /**
+     * Returns the bulletin repository.
+     *
+     * @return
+     */
+    BulletinRepository getBulletinRepository();
+
+    /**
+     * Returns a {@link ProcessGroupStatus} that represents the status of all
+     * nodes with the given {@link Status}es for the given ProcessGroup id, or
+     * null if no nodes exist with the given statuses
+     *
+     * @param groupId
+     * @return
+     */
+    ProcessGroupStatus getProcessGroupStatus(String groupId);
+
+    /**
+     * Returns a merged representation of the System Diagnostics for all nodes
+     * in the cluster
+     *
+     * @return
+     */
+    SystemDiagnostics getSystemDiagnostics();
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/HttpClusterManager.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/HttpClusterManager.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/HttpClusterManager.java
new file mode 100644
index 0000000..2cf5812
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/HttpClusterManager.java
@@ -0,0 +1,169 @@
+/*
+ * 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.nifi.cluster.manager;
+
+import org.apache.nifi.cluster.manager.exception.DisconnectedNodeMutableRequestException;
+import org.apache.nifi.cluster.manager.exception.UriConstructionException;
+import org.apache.nifi.cluster.manager.exception.ConnectingNodeMutableRequestException;
+import org.apache.nifi.cluster.manager.exception.NoConnectedNodesException;
+import org.apache.nifi.cluster.manager.exception.NoResponseFromNodesException;
+import org.apache.nifi.cluster.manager.exception.SafeModeMutableRequestException;
+import org.apache.nifi.cluster.protocol.NodeIdentifier;
+
+import java.net.URI;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Extends the ClusterManager interface to define how requests issued to the
+ * cluster manager are federated to the nodes. Specifically, the HTTP protocol
+ * is used for communicating requests to the cluster manager and to the nodes.
+ *
+ * @author unattributed
+ */
+public interface HttpClusterManager extends ClusterManager {
+
+    /**
+     * Federates the HTTP request to all connected nodes in the cluster. The
+     * given URI's host and port will not be used and instead will be adjusted
+     * for each node's host and port. The node URIs are guaranteed to be
+     * constructed before issuing any requests, so if a UriConstructionException
+     * is thrown, then it is guaranteed that no request was issued.
+     *
+     * @param method the HTTP method (e.g., GET, POST, PUT, DELETE, HEAD)
+     * @param uri the base request URI (up to, but not including, the query
+     * string)
+     * @param parameters the request parameters
+     * @param headers the request headers
+     *
+     * @return the client response
+     *
+     * @throws NoConnectedNodesException if no nodes are connected as results of
+     * the request
+     * @throws NoResponseFromNodesException if no response could be obtained
+     * @throws UriConstructionException if there was an issue constructing the
+     * URIs tailored for each individual node
+     * @throws ConnectingNodeMutableRequestException if the request was a PUT,
+     * POST, DELETE and a node is connecting to the cluster
+     * @throws DisconnectedNodeMutableRequestException if the request was a PUT,
+     * POST, DELETE and a node is disconnected from the cluster
+     * @throws SafeModeMutableRequestException if the request was a PUT, POST,
+     * DELETE and a the cluster is in safe mode
+     */
+    NodeResponse applyRequest(String method, URI uri, Map<String, List<String>> parameters, Map<String, String> headers)
+            throws NoConnectedNodesException, NoResponseFromNodesException, UriConstructionException, ConnectingNodeMutableRequestException,
+            DisconnectedNodeMutableRequestException, SafeModeMutableRequestException;
+
+    /**
+     * Federates the HTTP request to the nodes specified. The given URI's host
+     * and port will not be used and instead will be adjusted for each node's
+     * host and port. The node URIs are guaranteed to be constructed before
+     * issuing any requests, so if a UriConstructionException is thrown, then it
+     * is guaranteed that no request was issued.
+     *
+     * @param method the HTTP method (e.g., GET, POST, PUT, DELETE, HEAD)
+     * @param uri the base request URI (up to, but not including, the query
+     * string)
+     * @param parameters the request parameters
+     * @param headers the request headers
+     * @param nodeIdentifiers the NodeIdentifier for each node that the request
+     * should be replaced to
+     *
+     * @return the client response
+     *
+     * @throws NoConnectedNodesException if no nodes are connected as results of
+     * the request
+     * @throws NoResponseFromNodesException if no response could be obtained
+     * @throws UriConstructionException if there was an issue constructing the
+     * URIs tailored for each individual node
+     * @throws ConnectingNodeMutableRequestException if the request was a PUT,
+     * POST, DELETE and a node is connecting to the cluster
+     * @throws DisconnectedNodeMutableRequestException if the request was a PUT,
+     * POST, DELETE and a node is disconnected from the cluster
+     * @throws SafeModeMutableRequestException if the request was a PUT, POST,
+     * DELETE and a the cluster is in safe mode
+     */
+    NodeResponse applyRequest(String method, URI uri, Map<String, List<String>> parameters, Map<String, String> headers,
+            Set<NodeIdentifier> nodeIdentifiers)
+            throws NoConnectedNodesException, NoResponseFromNodesException, UriConstructionException, ConnectingNodeMutableRequestException,
+            DisconnectedNodeMutableRequestException, SafeModeMutableRequestException;
+
+    /**
+     * Federates the HTTP request to all connected nodes in the cluster. The
+     * given URI's host and port will not be used and instead will be adjusted
+     * for each node's host and port. The node URIs are guaranteed to be
+     * constructed before issuing any requests, so if a UriConstructionException
+     * is thrown, then it is guaranteed that no request was issued.
+     *
+     * @param method the HTTP method (e.g., GET, POST, PUT, DELETE, HEAD)
+     * @param uri the base request URI (up to, but not including, the query
+     * string)
+     * @param entity the HTTP request entity
+     * @param headers the request headers
+     *
+     * @return the client response
+     *
+     * @throws NoConnectedNodesException if no nodes are connected as results of
+     * the request
+     * @throws NoResponseFromNodesException if no response could be obtained
+     * @throws UriConstructionException if there was an issue constructing the
+     * URIs tailored for each individual node
+     * @throws ConnectingNodeMutableRequestException if the request was a PUT,
+     * POST, DELETE and a node is connecting to the cluster
+     * @throws DisconnectedNodeMutableRequestException if the request was a PUT,
+     * POST, DELETE and a node is disconnected from the cluster
+     * @throws SafeModeMutableRequestException if the request was a PUT, POST,
+     * DELETE and a the cluster is in safe mode
+     */
+    NodeResponse applyRequest(String method, URI uri, Object entity, Map<String, String> headers)
+            throws NoConnectedNodesException, NoResponseFromNodesException, UriConstructionException, ConnectingNodeMutableRequestException,
+            DisconnectedNodeMutableRequestException, SafeModeMutableRequestException;
+
+    /**
+     * Federates the HTTP request to the nodes specified. The given URI's host
+     * and port will not be used and instead will be adjusted for each node's
+     * host and port. The node URIs are guaranteed to be constructed before
+     * issuing any requests, so if a UriConstructionException is thrown, then it
+     * is guaranteed that no request was issued.
+     *
+     * @param method the HTTP method (e.g., GET, POST, PUT, DELETE, HEAD)
+     * @param uri the base request URI (up to, but not including, the query
+     * string)
+     * @param entity the HTTP request entity
+     * @param headers the request headers
+     * @param nodeIdentifiers the NodeIdentifier for each node that the request
+     * should be replaced to
+     *
+     * @return the client response
+     *
+     * @throws NoConnectedNodesException if no nodes are connected as results of
+     * the request
+     * @throws NoResponseFromNodesException if no response could be obtained
+     * @throws UriConstructionException if there was an issue constructing the
+     * URIs tailored for each individual node
+     * @throws ConnectingNodeMutableRequestException if the request was a PUT,
+     * POST, DELETE and a node is connecting to the cluster
+     * @throws DisconnectedNodeMutableRequestException if the request was a PUT,
+     * POST, DELETE and a node is disconnected from the cluster
+     * @throws SafeModeMutableRequestException if the request was a PUT, POST,
+     * DELETE and a the cluster is in safe mode
+     */
+    NodeResponse applyRequest(String method, URI uri, Object entity, Map<String, String> headers, Set<NodeIdentifier> nodeIdentifiers)
+            throws NoConnectedNodesException, NoResponseFromNodesException, UriConstructionException, ConnectingNodeMutableRequestException,
+            DisconnectedNodeMutableRequestException, SafeModeMutableRequestException;
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/HttpRequestReplicator.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/HttpRequestReplicator.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/HttpRequestReplicator.java
new file mode 100644
index 0000000..fb57622
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/HttpRequestReplicator.java
@@ -0,0 +1,99 @@
+/*
+ * 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.nifi.cluster.manager;
+
+import org.apache.nifi.cluster.manager.exception.UriConstructionException;
+import java.net.URI;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import org.apache.nifi.cluster.protocol.NodeIdentifier;
+
+/**
+ * A service for managing the replication of requests to nodes. It is up to the
+ * implementing class to decide if requests are sent concurrently or serially.
+ *
+ * Clients must call start() and stop() to initialize and shutdown the instance.
+ * The instance must be started before issuing any replication requests.
+ *
+ * @author unattributed
+ */
+public interface HttpRequestReplicator {
+
+    /**
+     * Starts the instance for replicating requests. Start may only be called if
+     * the instance is not running.
+     */
+    void start();
+
+    /**
+     * Stops the instance from replicating requests. Stop may only be called if
+     * the instance is running.
+     */
+    void stop();
+
+    /**
+     * @return true if the instance is started; false otherwise.
+     */
+    boolean isRunning();
+
+    /**
+     * Requests are sent to each node in the cluster. If the request results in
+     * an exception, then the NodeResourceResponse will contain the exception.
+     *
+     * HTTP DELETE and OPTIONS methods must supply an empty parameters map or
+     * else and IllegalArgumentException is thrown.
+     *
+     * @param nodeIds the node identifiers
+     * @param method the HTTP method (e.g., GET, POST, PUT, DELETE, HEAD,
+     * OPTIONS)
+     * @param uri the base request URI (up to, but not including, the query
+     * string)
+     * @param parameters any request parameters
+     * @param headers any HTTP headers
+     *
+     * @return the set of node responses
+     *
+     * @throws UriConstructionException if a request for a node failed to be
+     * constructed from the given prototype URI. If thrown, it is guaranteed
+     * that no request was sent.
+     */
+    Set<NodeResponse> replicate(Set<NodeIdentifier> nodeIds, String method, URI uri, Map<String, List<String>> parameters, Map<String, String> headers) throws UriConstructionException;
+
+    /**
+     * Requests are sent to each node in the cluster. If the request results in
+     * an exception, then the NodeResourceResponse will contain the exception.
+     *
+     * HTTP DELETE, GET, HEAD, and OPTIONS methods will throw an
+     * IllegalArgumentException if used.
+     *
+     * @param nodeIds the node identifiers
+     * @param method the HTTP method (e.g., POST, PUT)
+     * @param uri the base request URI (up to, but not including, the query
+     * string)
+     * @param entity an entity
+     * @param headers any HTTP headers
+     *
+     * @return the set of node responses
+     *
+     * @throws UriConstructionException if a request for a node failed to be
+     * constructed from the given prototype URI. If thrown, it is guaranteed
+     * that no request was sent.
+     */
+    Set<NodeResponse> replicate(Set<NodeIdentifier> nodeIds, String method, URI uri, Object entity, Map<String, String> headers) throws UriConstructionException;
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/HttpResponseMapper.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/HttpResponseMapper.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/HttpResponseMapper.java
new file mode 100644
index 0000000..843a666
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/HttpResponseMapper.java
@@ -0,0 +1,42 @@
+/*
+ * 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.nifi.cluster.manager;
+
+import java.net.URI;
+import java.util.Map;
+import java.util.Set;
+import org.apache.nifi.cluster.node.Node.Status;
+
+/**
+ * Maps a HTTP response to a node status.
+ *
+ * @author unattributed
+ */
+public interface HttpResponseMapper {
+
+    /**
+     * Maps a HTTP response to a node response and the corresponding node
+     * status.
+     *
+     * @param requestURI the original request URI
+     * @param nodeResponses a set of node resource responses
+     *
+     * @return a map associating the node response to the node status
+     */
+    Map<NodeResponse, Status> map(URI requestURI, Set<NodeResponse> nodeResponses);
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/NodeResponse.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/NodeResponse.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/NodeResponse.java
new file mode 100644
index 0000000..3f966e5
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/NodeResponse.java
@@ -0,0 +1,329 @@
+/*
+ * 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.nifi.cluster.manager;
+
+import com.sun.jersey.api.client.ClientResponse;
+import java.io.BufferedInputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.net.URI;
+import java.util.List;
+import java.util.Objects;
+import java.util.concurrent.TimeUnit;
+
+import javax.ws.rs.HttpMethod;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.ResponseBuilder;
+import javax.ws.rs.core.Response.Status;
+import javax.ws.rs.core.StreamingOutput;
+import org.apache.nifi.cluster.protocol.NodeIdentifier;
+import org.apache.nifi.web.api.entity.Entity;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Encapsulates a node's response in regards to receiving a external API
+ * request.
+ *
+ * Both the ClientResponse and (server) Response may be obtained from this
+ * instance. The ClientResponse is stored as it is received from the node. This
+ * includes the entity input stream. The Response is constructed on demand when
+ * mapping a ClientResponse to the Response. The ClientResponse to Response
+ * mapping includes copying the ClientResponse's input stream to the Response.
+ * Therefore, the getResponse() method should not be called more than once.
+ * Furthermore, the method should not be called if the caller has already read
+ * the ClientResponse's input stream.
+ *
+ * If a ClientResponse was unable to be created, then a NodeResponse will store
+ * the Throwable, which may be obtained by calling getThrowable().
+ *
+ * This class overrides hashCode and equals and considers two instances to be
+ * equal if they have the equal NodeIdentifiers.
+ *
+ * @author unattributed
+ */
+public class NodeResponse {
+
+    private static final Logger logger = LoggerFactory.getLogger(NodeResponse.class);
+    private final String httpMethod;
+    private final URI requestUri;
+    private final ClientResponse clientResponse;
+    private final NodeIdentifier nodeId;
+    private final Throwable throwable;
+    private boolean hasCreatedResponse = false;
+    private final Entity updatedEntity;
+    private final long requestDurationNanos;
+    private final String requestId;
+
+    public NodeResponse(final NodeIdentifier nodeId, final String httpMethod, final URI requestUri, final ClientResponse clientResponse, final long requestDurationNanos, final String requestId) {
+        if (nodeId == null) {
+            throw new IllegalArgumentException("Node identifier may not be null.");
+        } else if (StringUtils.isBlank(httpMethod)) {
+            throw new IllegalArgumentException("Http method may not be null or empty.");
+        } else if (requestUri == null) {
+            throw new IllegalArgumentException("Request URI may not be null.");
+        } else if (clientResponse == null) {
+            throw new IllegalArgumentException("ClientResponse may not be null.");
+        }
+        this.nodeId = nodeId;
+        this.httpMethod = httpMethod;
+        this.requestUri = requestUri;
+        this.clientResponse = clientResponse;
+        this.throwable = null;
+        this.updatedEntity = null;
+        this.requestDurationNanos = requestDurationNanos;
+        this.requestId = requestId;
+    }
+
+    public NodeResponse(final NodeIdentifier nodeId, final String httpMethod, final URI requestUri, final Throwable throwable) {
+        if (nodeId == null) {
+            throw new IllegalArgumentException("Node identifier may not be null.");
+        } else if (StringUtils.isBlank(httpMethod)) {
+            throw new IllegalArgumentException("Http method may not be null or empty.");
+        } else if (requestUri == null) {
+            throw new IllegalArgumentException("Request URI may not be null.");
+        } else if (throwable == null) {
+            throw new IllegalArgumentException("Throwable may not be null.");
+        }
+        this.nodeId = nodeId;
+        this.httpMethod = httpMethod;
+        this.requestUri = requestUri;
+        this.clientResponse = null;
+        this.throwable = throwable;
+        this.updatedEntity = null;
+        this.requestDurationNanos = -1L;
+        this.requestId = null;
+    }
+
+    public NodeResponse(final NodeResponse example, final Entity updatedEntity) {
+        Objects.requireNonNull(example, "NodeResponse cannot be null");
+        Objects.requireNonNull(updatedEntity, "UpdatedEntity cannot be null");
+
+        this.nodeId = example.nodeId;
+        this.httpMethod = example.httpMethod;
+        this.requestUri = example.requestUri;
+        this.clientResponse = example.clientResponse;
+        this.throwable = example.throwable;
+        this.updatedEntity = updatedEntity;
+        this.requestDurationNanos = example.requestDurationNanos;
+        this.requestId = null;
+    }
+
+    public NodeIdentifier getNodeId() {
+        return nodeId;
+    }
+
+    public String getHttpMethod() {
+        return httpMethod;
+    }
+
+    public URI getRequestUri() {
+        return requestUri;
+    }
+
+    /**
+     * @return the HTTP response status code
+     */
+    public int getStatus() {
+        if (hasThrowable()) {
+            /*
+             * since there is a throwable, there is no client input stream to 
+             * worry about maintaining, so we can call getResponse() method
+             */
+            return getResponse().getStatus();
+        } else {
+            /*
+             * use client response's status instead of calling getResponse().getStatus()
+             * so that we don't read the client's input stream as part of creating 
+             * the response in the getResponse() method
+             */
+            return clientResponse.getStatus();
+        }
+    }
+
+    /**
+     * Returns true if the response status is 2xx, false otherwise.
+     *
+     * @return
+     */
+    public boolean is2xx() {
+        final int statusCode = getStatus();
+        return (200 <= statusCode && statusCode <= 299);
+    }
+
+    /**
+     * Returns true if the response status is 5xx, false otherwise.
+     *
+     * @return
+     */
+    public boolean is5xx() {
+        final int statusCode = getStatus();
+        return (500 <= statusCode && statusCode <= 599);
+    }
+
+    /**
+     * Returns null if hasThrowable() is true; otherwise the client's response
+     * is returned.
+     *
+     * The ClientResponse's input stream can only be read once.
+     *
+     * @return the client's response
+     */
+    public ClientResponse getClientResponse() {
+        return clientResponse;
+    }
+
+    /**
+     * Creates a Response by mapping the ClientResponse values to it. Since the
+     * ClientResponse's input stream can only be read once, this method should
+     * only be called once. Furthermore, the caller should not have already read
+     * the ClientResponse's input stream.
+     *
+     * @return the response
+     */
+    public Response getResponse() {
+        // if the response encapsulates a throwable, then the input stream is never read and the below warning is irrelevant
+        if (hasCreatedResponse && !hasThrowable()) {
+            logger.warn("ClientResponse's input stream has already been read.  The created response will not contain this data.");
+        }
+        hasCreatedResponse = true;
+        return createResponse();
+    }
+
+    /**
+     * Returns the throwable or null if no throwable exists.
+     *
+     * @return the throwable or null if no throwable exists
+     */
+    public Throwable getThrowable() {
+        return throwable;
+    }
+
+    /**
+     * Returns true if a throwable was thrown and a response was not able to be
+     * created; false otherwise.
+     *
+     * @return true if a throwable was thrown and a response was not able to be
+     * created; false otherwise
+     */
+    public boolean hasThrowable() {
+        return getThrowable() != null;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (obj == null) {
+            return false;
+        }
+        if (getClass() != obj.getClass()) {
+            return false;
+        }
+        final NodeResponse other = (NodeResponse) obj;
+        if (this.nodeId != other.nodeId && (this.nodeId == null || !this.nodeId.equals(other.nodeId))) {
+            return false;
+        }
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int hash = 7;
+        hash = 13 * hash + (this.nodeId != null ? this.nodeId.hashCode() : 0);
+        return hash;
+    }
+
+    public long getRequestDuration(final TimeUnit timeUnit) {
+        return timeUnit.convert(requestDurationNanos, TimeUnit.NANOSECONDS);
+    }
+
+    public String getRequestId() {
+        return requestId;
+    }
+
+    private Response createResponse() {
+
+        // if no client response was created, then generate a 500 response
+        if (hasThrowable()) {
+            return Response.status(Status.INTERNAL_SERVER_ERROR).build();
+        }
+
+        // set the status
+        final ResponseBuilder responseBuilder = Response.status(clientResponse.getStatus());
+
+        // set the headers
+        for (final String key : clientResponse.getHeaders().keySet()) {
+            final List<String> values = clientResponse.getHeaders().get(key);
+            for (final String value : values) {
+
+                if (key.equalsIgnoreCase("transfer-encoding") || key.equalsIgnoreCase("content-length")) {
+                    /*
+                     * do not copy the transfer-encoding header (i.e., chunked encoding) or
+                     * the content-length. Let the outgoing response builder determine it.
+                     */
+                    continue;
+                } else if (key.equals("X-ClusterContext")) {
+                    /*
+                     * do not copy the cluster context to the response because
+                     * this information is private and should not be sent to
+                     * the client
+                     */
+                    continue;
+                }
+                responseBuilder.header(key, value);
+            }
+        }
+
+        // head requests must not have a message-body in the response
+        if (!HttpMethod.HEAD.equalsIgnoreCase(httpMethod)) {
+
+            // set the entity
+            if (updatedEntity == null) {
+                responseBuilder.entity(new StreamingOutput() {
+                    @Override
+                    public void write(final OutputStream output) throws IOException, WebApplicationException {
+                        BufferedInputStream bis = null;
+                        try {
+                            bis = new BufferedInputStream(clientResponse.getEntityInputStream());
+                            IOUtils.copy(bis, output);
+                        } finally {
+                            IOUtils.closeQuietly(bis);
+                        }
+                    }
+                });
+            } else {
+                responseBuilder.entity(updatedEntity);
+            }
+        }
+
+        return responseBuilder.build();
+    }
+
+    @Override
+    public String toString() {
+        final StringBuilder sb = new StringBuilder();
+        sb.append("NodeResponse[nodeUri=").append(nodeId.getApiAddress()).append(":").append(nodeId.getApiPort()).append(",")
+                .append("method=").append(httpMethod)
+                .append(",URI=").append(requestUri)
+                .append(",ResponseCode=").append(getStatus())
+                .append(",Duration=").append(TimeUnit.MILLISECONDS.convert(requestDurationNanos, TimeUnit.NANOSECONDS)).append(" ms]");
+        return sb.toString();
+    }
+}


[11/20] incubator-nifi git commit: NIFI-410 pushed RAT exclusions down to the relevant modules and stopped doing broad test resource exclusion - is now specific

Posted by jo...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/test/java/org/apache/nifi/cluster/manager/testutils/HttpRequest.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/test/java/org/apache/nifi/cluster/manager/testutils/HttpRequest.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/test/java/org/apache/nifi/cluster/manager/testutils/HttpRequest.java
deleted file mode 100644
index 35380dd..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/test/java/org/apache/nifi/cluster/manager/testutils/HttpRequest.java
+++ /dev/null
@@ -1,239 +0,0 @@
-/*
- * 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.nifi.cluster.manager.testutils;
-
-import java.io.IOException;
-import java.io.Reader;
-import java.io.UnsupportedEncodingException;
-import java.net.URLDecoder;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import javax.ws.rs.HttpMethod;
-import javax.ws.rs.core.MediaType;
-import org.apache.commons.lang3.StringUtils;
-
-/**
- * Encapsulates an HTTP request. The toString method returns the
- * specification-compliant request.
- *
- * @author unattributed
- */
-public class HttpRequest {
-
-    private String method;
-    private String uri;
-    private String rawUri;
-    private String version;
-    private String body;
-    private String rawRequest;
-    private Map<String, String> headers = new HashMap<>();
-    private Map<String, List<String>> parameters = new HashMap<>();
-
-    public static HttpRequestBuilder createFromRequestLine(final String requestLine) {
-        return new HttpRequestBuilder(requestLine);
-    }
-
-    public String getBody() {
-        return body;
-    }
-
-    public Map<String, String> getHeaders() {
-        return Collections.unmodifiableMap(headers);
-    }
-
-    public String getHeaderValue(final String header) {
-        for (final Map.Entry<String, String> entry : getHeaders().entrySet()) {
-            if (entry.getKey().equalsIgnoreCase(header)) {
-                return entry.getValue();
-            }
-        }
-        return null;
-    }
-
-    public String getMethod() {
-        return method;
-    }
-
-    public Map<String, List<String>> getParameters() {
-        final Map<String, List<String>> result = new HashMap<>();
-        for (final Map.Entry<String, List<String>> entry : parameters.entrySet()) {
-            result.put(entry.getKey(), Collections.unmodifiableList(entry.getValue()));
-        }
-        return Collections.unmodifiableMap(result);
-    }
-
-    public String getUri() {
-        return uri;
-    }
-
-    public String getRawUri() {
-        return rawUri;
-    }
-
-    public String getVersion() {
-        return version;
-    }
-
-    @Override
-    public String toString() {
-        return rawRequest;
-    }
-
-    /**
-     * A builder for constructing basic HTTP requests. It handles only enough of
-     * the HTTP specification to support basic unit testing, and it should not
-     * be used otherwise.
-     */
-    public static class HttpRequestBuilder {
-
-        private String method;
-        private String uri;
-        private String rawUri;
-        private String version;
-        private Map<String, String> headers = new HashMap<>();
-        private Map<String, List<String>> parameters = new HashMap<>();
-        private int contentLength = 0;
-        private String contentType;
-        private String body = "";
-        private StringBuilder rawRequest = new StringBuilder();
-
-        private HttpRequestBuilder(final String requestLine) {
-
-            final String[] tokens = requestLine.split(" ");
-            if (tokens.length != 3) {
-                throw new IllegalArgumentException("Invalid HTTP Request Line: " + requestLine);
-            }
-
-            method = tokens[0];
-            if (HttpMethod.GET.equalsIgnoreCase(method) || HttpMethod.HEAD.equalsIgnoreCase(method) || HttpMethod.DELETE.equalsIgnoreCase(method) || HttpMethod.OPTIONS.equalsIgnoreCase(method)) {
-                final int queryIndex = tokens[1].indexOf("?");
-                if (queryIndex > -1) {
-                    uri = tokens[1].substring(0, queryIndex);
-                    addParameters(tokens[1].substring(queryIndex + 1));
-                } else {
-                    uri = tokens[1];
-                }
-            }
-            rawUri = tokens[1];
-            version = tokens[2];
-            rawRequest.append(requestLine).append("\n");
-        }
-
-        private void addHeader(final String key, final String value) {
-            if (key.contains(" ")) {
-                throw new IllegalArgumentException("Header key may not contain spaces.");
-            } else if ("content-length".equalsIgnoreCase(key)) {
-                contentLength = (StringUtils.isBlank(value.trim())) ? 0 : Integer.parseInt(value.trim());
-            } else if ("content-type".equalsIgnoreCase(key)) {
-                contentType = value.trim();
-            }
-            headers.put(key, value);
-        }
-
-        public void addHeader(final String header) {
-            final int firstColonIndex = header.indexOf(":");
-            if (firstColonIndex < 0) {
-                throw new IllegalArgumentException("Invalid HTTP Header line: " + header);
-            }
-            addHeader(header.substring(0, firstColonIndex), header.substring(firstColonIndex + 1));
-            rawRequest.append(header).append("\n");
-        }
-
-        // final because constructor calls it
-        public final void addParameters(final String queryString) {
-
-            if (StringUtils.isBlank(queryString)) {
-                return;
-            }
-
-            final String normQueryString;
-            if (queryString.startsWith("?")) {
-                normQueryString = queryString.substring(1);
-            } else {
-                normQueryString = queryString;
-            }
-            final String[] keyValuePairs = normQueryString.split("&");
-            for (final String keyValuePair : keyValuePairs) {
-                final String[] keyValueTokens = keyValuePair.split("=");
-                try {
-                    addParameter(
-                            URLDecoder.decode(keyValueTokens[0], "utf-8"),
-                            URLDecoder.decode(keyValueTokens[1], "utf-8")
-                    );
-                } catch (UnsupportedEncodingException use) {
-                    throw new RuntimeException(use);
-                }
-            }
-        }
-
-        public void addParameter(final String key, final String value) {
-
-            if (key.contains(" ")) {
-                throw new IllegalArgumentException("Parameter key may not contain spaces: " + key);
-            }
-
-            final List<String> values;
-            if (parameters.containsKey(key)) {
-                values = parameters.get(key);
-            } else {
-                values = new ArrayList<>();
-                parameters.put(key, values);
-            }
-            values.add(value);
-        }
-
-        public void addBody(final Reader reader) throws IOException {
-
-            if (contentLength <= 0) {
-                return;
-            }
-
-            final char[] buf = new char[contentLength];
-            int offset = 0;
-            int numRead = 0;
-            while (offset < buf.length && (numRead = reader.read(buf, offset, buf.length - offset)) >= 0) {
-                offset += numRead;
-            }
-            body = new String(buf);
-            rawRequest.append("\n");
-            rawRequest.append(body);
-        }
-
-        public HttpRequest build() throws UnsupportedEncodingException {
-
-            if (HttpMethod.GET.equalsIgnoreCase(method) == false && HttpMethod.HEAD.equalsIgnoreCase(method) == false && contentType.equalsIgnoreCase(MediaType.APPLICATION_FORM_URLENCODED)) {
-                addParameters(body);
-            }
-
-            final HttpRequest request = new HttpRequest();
-            request.method = this.method;
-            request.uri = this.uri;
-            request.rawUri = this.rawUri;
-            request.version = this.version;
-            request.headers.putAll(this.headers);
-            request.parameters.putAll(this.parameters);
-            request.body = this.body;
-            request.rawRequest = this.rawRequest.toString();
-
-            return request;
-        }
-
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/test/java/org/apache/nifi/cluster/manager/testutils/HttpResponse.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/test/java/org/apache/nifi/cluster/manager/testutils/HttpResponse.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/test/java/org/apache/nifi/cluster/manager/testutils/HttpResponse.java
deleted file mode 100644
index 3aa2931..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/test/java/org/apache/nifi/cluster/manager/testutils/HttpResponse.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * 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.nifi.cluster.manager.testutils;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import javax.ws.rs.core.Response.Status;
-
-/**
- * Encapsulates an HTTP response. The toString method returns the
- * specification-compliant response.
- *
- * @author unattributed
- */
-public class HttpResponse {
-
-    private final Status status;
-    private final String entity;
-    private final Map<String, String> headers = new HashMap<>();
-
-    public HttpResponse(final Status status, final String entity) {
-        this.status = status;
-        this.entity = entity;
-        headers.put("content-length", String.valueOf(entity.getBytes().length));
-    }
-
-    public String getEntity() {
-        return entity;
-    }
-
-    public Status getStatus() {
-        return status;
-    }
-
-    public Map<String, String> getHeaders() {
-        return Collections.unmodifiableMap(headers);
-    }
-
-    public void addHeader(final String key, final String value) {
-        if (key.contains(" ")) {
-            throw new IllegalArgumentException("Header key may not contain spaces.");
-        } else if ("content-length".equalsIgnoreCase(key)) {
-            throw new IllegalArgumentException("Content-Length header is set automatically based on length of content.");
-        }
-        headers.put(key, value);
-    }
-
-    public void addHeaders(final Map<String, String> headers) {
-        for (final Map.Entry<String, String> entry : headers.entrySet()) {
-            addHeader(entry.getKey(), entry.getValue());
-        }
-    }
-
-    @Override
-    public String toString() {
-
-        final StringBuilder strb = new StringBuilder();
-
-        // response line
-        strb.append("HTTP/1.1 ")
-                .append(status.getStatusCode())
-                .append(" ")
-                .append(status.getReasonPhrase())
-                .append("\n");
-
-        // headers
-        for (final Map.Entry<String, String> entry : headers.entrySet()) {
-            strb.append(entry.getKey()).append(": ").append(entry.getValue()).append("\n");
-        }
-
-        strb.append("\n");
-
-        // body
-        strb.append(entity);
-
-        return strb.toString();
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/test/java/org/apache/nifi/cluster/manager/testutils/HttpResponseAction.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/test/java/org/apache/nifi/cluster/manager/testutils/HttpResponseAction.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/test/java/org/apache/nifi/cluster/manager/testutils/HttpResponseAction.java
deleted file mode 100644
index 28615d0..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/test/java/org/apache/nifi/cluster/manager/testutils/HttpResponseAction.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * 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.nifi.cluster.manager.testutils;
-
-/**
- * Wraps a HttpResponse with a time-delay. When the action is applied, the
- * currently executing thread sleeps for the given delay before returning the
- * response to the caller.
- *
- * This class is good for simulating network latency.
- *
- * @author unattributed
- */
-public class HttpResponseAction {
-
-    private final HttpResponse response;
-
-    private final int waitTimeMs;
-
-    public HttpResponseAction(final HttpResponse response) {
-        this(response, 0);
-    }
-
-    public HttpResponseAction(final HttpResponse response, final int waitTimeMs) {
-        this.response = response;
-        this.waitTimeMs = waitTimeMs;
-    }
-
-    public HttpResponse apply() {
-        try {
-            Thread.sleep(waitTimeMs);
-        } catch (final InterruptedException ie) {
-            throw new RuntimeException(ie);
-        }
-
-        return response;
-    }
-
-    public HttpResponse getResponse() {
-        return response;
-    }
-
-    public int getWaitTimeMs() {
-        return waitTimeMs;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/test/java/org/apache/nifi/cluster/manager/testutils/HttpServer.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/test/java/org/apache/nifi/cluster/manager/testutils/HttpServer.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/test/java/org/apache/nifi/cluster/manager/testutils/HttpServer.java
deleted file mode 100644
index f17a66c..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/test/java/org/apache/nifi/cluster/manager/testutils/HttpServer.java
+++ /dev/null
@@ -1,240 +0,0 @@
-/*
- * 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.nifi.cluster.manager.testutils;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.PrintWriter;
-import java.io.Reader;
-import java.net.ServerSocket;
-import java.net.Socket;
-import java.net.SocketException;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Queue;
-import java.util.concurrent.ConcurrentLinkedQueue;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-import org.apache.nifi.cluster.manager.testutils.HttpRequest.HttpRequestBuilder;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * A simple HTTP web server that allows clients to register canned-responses to
- * respond to received requests.
- *
- * @author unattributed
- */
-public class HttpServer {
-
-    private static final Logger logger = LoggerFactory.getLogger(HttpServer.class);
-
-    private final ExecutorService executorService;
-    private final ServerSocket serverSocket;
-    private final Queue<HttpResponseAction> responseQueue = new ConcurrentLinkedQueue<>();
-    private final Map<String, String> checkedHeaders = new HashMap<>();
-    private final Map<String, List<String>> checkedParameters = new HashMap<>();
-    private final int port;
-
-    public HttpServer(int numThreads, int port) throws IOException {
-        this.port = port;
-        executorService = Executors.newFixedThreadPool(numThreads);
-        serverSocket = new ServerSocket(port);
-    }
-
-    public void start() {
-
-        new Thread() {
-            @Override
-            public void run() {
-                while (isRunning()) {
-                    try {
-                        final Socket conn = serverSocket.accept();
-                        executorService.execute(new Runnable() {
-                            @Override
-                            public void run() {
-                                handleRequest(conn);
-                                if (conn.isClosed() == false) {
-                                    try {
-                                        conn.close();
-                                    } catch (IOException ioe) {
-                                    }
-                                }
-                            }
-                        });
-                    } catch (final SocketException se) {
-                        /* ignored */
-                    } catch (final IOException ioe) {
-                        if (logger.isDebugEnabled()) {
-                            logger.warn("", ioe);
-                        }
-                    }
-                }
-            }
-        ;
-    }
-
-    .start();
-    }
-
-    public boolean isRunning() {
-        return executorService.isShutdown() == false;
-    }
-
-    public void stop() {
-        // shutdown server socket
-        try {
-            if (serverSocket.isClosed() == false) {
-                serverSocket.close();
-            }
-        } catch (final Exception ex) {
-            throw new RuntimeException(ex);
-        }
-
-        // shutdown executor service
-        try {
-            executorService.shutdown();
-            executorService.awaitTermination(3, TimeUnit.SECONDS);
-        } catch (final Exception ex) {
-            throw new RuntimeException(ex);
-        }
-    }
-
-    public int getPort() {
-        if (isRunning()) {
-            return serverSocket.getLocalPort();
-        } else {
-            return port;
-        }
-    }
-
-    public Queue<HttpResponseAction> addResponseAction(final HttpResponseAction response) {
-        responseQueue.add(response);
-        return responseQueue;
-    }
-
-    public void addCheckedHeaders(final Map<String, String> headers) {
-        checkedHeaders.putAll(headers);
-    }
-
-    public void addCheckedParameters(final Map<String, List<String>> parameters) {
-        checkedParameters.putAll(parameters);
-    }
-
-    private void handleRequest(final Socket conn) {
-        try {
-
-            final HttpRequest httpRequest = buildRequest(conn.getInputStream());
-
-            if (logger.isDebugEnabled()) {
-                logger.debug("\n" + httpRequest);
-            }
-
-            // check headers
-            final Map<String, String> reqHeaders = httpRequest.getHeaders();
-            for (final Map.Entry<String, String> entry : checkedHeaders.entrySet()) {
-                if (reqHeaders.containsKey(entry.getKey())) {
-                    if (entry.getValue().equals(reqHeaders.get(entry.getKey()))) {
-                        logger.error("Incorrect HTTP request header value received for checked header: " + entry.getKey());
-                        conn.close();
-                        return;
-                    }
-                } else {
-                    logger.error("Missing checked header: " + entry.getKey());
-                    conn.close();
-                    return;
-                }
-            }
-
-            // check parameters
-            final Map<String, List<String>> reqParams = httpRequest.getParameters();
-            for (final Map.Entry<String, List<String>> entry : checkedParameters.entrySet()) {
-                if (reqParams.containsKey(entry.getKey())) {
-                    if (entry.getValue().equals(reqParams.get(entry.getKey())) == false) {
-                        logger.error("Incorrect HTTP request parameter values received for checked parameter: " + entry.getKey());
-                        conn.close();
-                        return;
-                    }
-                } else {
-                    logger.error("Missing checked parameter: " + entry.getKey());
-                    conn.close();
-                    return;
-                }
-            }
-
-            // apply the next response
-            final HttpResponseAction response = responseQueue.remove();
-            response.apply();
-
-            // send the response to client
-            final PrintWriter pw = new PrintWriter(conn.getOutputStream(), true);
-
-            if (logger.isDebugEnabled()) {
-                logger.debug("\n" + response.getResponse());
-            }
-
-            pw.print(response.getResponse());
-            pw.flush();
-
-        } catch (IOException ioe) { /* ignored */ }
-    }
-
-    private HttpRequest buildRequest(final InputStream requestIs) throws IOException {
-        return new HttpRequestReader().read(new InputStreamReader(requestIs));
-    }
-
-    // reads an HTTP request from the given reader
-    private class HttpRequestReader {
-
-        public HttpRequest read(final Reader reader) throws IOException {
-
-            HttpRequestBuilder builder = null;
-            String line = "";
-            boolean isRequestLine = true;
-            while ((line = readLine(reader)).isEmpty() == false) {
-                if (isRequestLine) {
-                    builder = HttpRequest.createFromRequestLine(line);
-                    isRequestLine = false;
-                } else {
-                    builder.addHeader(line);
-                }
-            }
-
-            if (builder != null) {
-                builder.addBody(reader);
-            }
-
-            return builder.build();
-        }
-
-        private String readLine(final Reader reader) throws IOException {
-
-            /* read character at time to prevent blocking */
-            final StringBuilder strb = new StringBuilder();
-            char c;
-            while ((c = (char) reader.read()) != '\n') {
-                if (c != '\r') {
-                    strb.append(c);
-                }
-            }
-            return strb.toString();
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/test/java/org/apache/nifi/cluster/protocol/impl/ClusterManagerProtocolSenderImplTest.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/test/java/org/apache/nifi/cluster/protocol/impl/ClusterManagerProtocolSenderImplTest.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/test/java/org/apache/nifi/cluster/protocol/impl/ClusterManagerProtocolSenderImplTest.java
deleted file mode 100644
index 96943c2..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/test/java/org/apache/nifi/cluster/protocol/impl/ClusterManagerProtocolSenderImplTest.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * 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.nifi.cluster.protocol.impl;
-
-import java.io.IOException;
-import java.net.InetAddress;
-import org.apache.nifi.cluster.protocol.NodeIdentifier;
-import org.apache.nifi.cluster.protocol.ProtocolContext;
-import org.apache.nifi.cluster.protocol.ProtocolException;
-import org.apache.nifi.cluster.protocol.ProtocolHandler;
-import org.apache.nifi.cluster.protocol.jaxb.JaxbProtocolContext;
-import org.apache.nifi.cluster.protocol.jaxb.message.JaxbProtocolUtils;
-import org.apache.nifi.cluster.protocol.message.FlowRequestMessage;
-import org.apache.nifi.cluster.protocol.message.FlowResponseMessage;
-import org.apache.nifi.cluster.protocol.message.PingMessage;
-import org.apache.nifi.cluster.protocol.message.ProtocolMessage;
-import org.apache.nifi.io.socket.ServerSocketConfiguration;
-import org.apache.nifi.io.socket.SocketConfiguration;
-import org.junit.After;
-import static org.junit.Assert.*;
-import org.junit.Before;
-import org.junit.Test;
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.*;
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.stubbing.Answer;
-
-/**
- * @author unattributed
- */
-public class ClusterManagerProtocolSenderImplTest {
-
-    private InetAddress address;
-
-    private int port;
-
-    private SocketProtocolListener listener;
-
-    private ClusterManagerProtocolSenderImpl sender;
-
-    private ProtocolHandler mockHandler;
-
-    @Before
-    public void setup() throws IOException {
-
-        address = InetAddress.getLocalHost();
-        ServerSocketConfiguration serverSocketConfiguration = new ServerSocketConfiguration();
-
-        mockHandler = mock(ProtocolHandler.class);
-
-        ProtocolContext protocolContext = new JaxbProtocolContext(JaxbProtocolUtils.JAXB_CONTEXT);
-
-        listener = new SocketProtocolListener(5, 0, serverSocketConfiguration, protocolContext);
-        listener.addHandler(mockHandler);
-        listener.start();
-
-        port = listener.getPort();
-
-        SocketConfiguration socketConfiguration = new SocketConfiguration();
-        sender = new ClusterManagerProtocolSenderImpl(socketConfiguration, protocolContext);
-    }
-
-    @After
-    public void teardown() throws IOException {
-        if (listener.isRunning()) {
-            listener.stop();
-        }
-    }
-
-    @Test
-    public void testRequestFlow() throws Exception {
-
-        when(mockHandler.canHandle(any(ProtocolMessage.class))).thenReturn(Boolean.TRUE);
-        when(mockHandler.handle(any(ProtocolMessage.class))).thenReturn(new FlowResponseMessage());
-        FlowRequestMessage request = new FlowRequestMessage();
-        request.setNodeId(new NodeIdentifier("id", "api-address", 1, address.getHostAddress(), port));
-        FlowResponseMessage response = sender.requestFlow(request);
-        assertNotNull(response);
-    }
-
-    @Test
-    public void testRequestFlowWithBadResponseMessage() throws Exception {
-
-        when(mockHandler.canHandle(any(ProtocolMessage.class))).thenReturn(Boolean.TRUE);
-        when(mockHandler.handle(any(ProtocolMessage.class))).thenReturn(new PingMessage());
-        FlowRequestMessage request = new FlowRequestMessage();
-        request.setNodeId(new NodeIdentifier("id", "api-address", 1, address.getHostAddress(), port));
-        try {
-            sender.requestFlow(request);
-            fail("failed to throw exception");
-        } catch (ProtocolException pe) {
-        }
-
-    }
-
-    @Test
-    public void testRequestFlowDelayedResponse() throws Exception {
-
-        final int time = 250;
-        sender.getSocketConfiguration().setSocketTimeout(time);
-
-        when(mockHandler.canHandle(any(ProtocolMessage.class))).thenReturn(Boolean.TRUE);
-        when(mockHandler.handle(any(ProtocolMessage.class))).thenAnswer(new Answer<FlowResponseMessage>() {
-            @Override
-            public FlowResponseMessage answer(InvocationOnMock invocation) throws Throwable {
-                Thread.sleep(time * 3);
-                return new FlowResponseMessage();
-            }
-        });
-        FlowRequestMessage request = new FlowRequestMessage();
-        request.setNodeId(new NodeIdentifier("id", "api-address", 1, address.getHostAddress(), port));
-        try {
-            sender.requestFlow(request);
-            fail("failed to throw exception");
-        } catch (ProtocolException pe) {
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/test/java/org/apache/nifi/cluster/protocol/impl/ClusterServiceLocatorTest.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/test/java/org/apache/nifi/cluster/protocol/impl/ClusterServiceLocatorTest.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/test/java/org/apache/nifi/cluster/protocol/impl/ClusterServiceLocatorTest.java
deleted file mode 100644
index 4a69571..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/test/java/org/apache/nifi/cluster/protocol/impl/ClusterServiceLocatorTest.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * 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.nifi.cluster.protocol.impl;
-
-import java.net.InetSocketAddress;
-import java.util.concurrent.TimeUnit;
-import org.apache.nifi.io.socket.multicast.DiscoverableService;
-import org.apache.nifi.io.socket.multicast.DiscoverableServiceImpl;
-import static org.junit.Assert.*;
-import org.junit.Before;
-import org.junit.Test;
-import static org.mockito.Mockito.*;
-import org.mockito.stubbing.OngoingStubbing;
-
-public class ClusterServiceLocatorTest {
-
-    private ClusterServiceDiscovery mockServiceDiscovery;
-
-    private int fixedPort;
-
-    private DiscoverableService fixedService;
-
-    private ClusterServiceLocator serviceDiscoveryLocator;
-
-    private ClusterServiceLocator serviceDiscoveryFixedPortLocator;
-
-    private ClusterServiceLocator fixedServiceLocator;
-
-    @Before
-    public void setup() throws Exception {
-
-        fixedPort = 1;
-        mockServiceDiscovery = mock(ClusterServiceDiscovery.class);
-        fixedService = new DiscoverableServiceImpl("some-service", InetSocketAddress.createUnresolved("some-host", 20));
-
-        serviceDiscoveryLocator = new ClusterServiceLocator(mockServiceDiscovery);
-        serviceDiscoveryFixedPortLocator = new ClusterServiceLocator(mockServiceDiscovery, fixedPort);
-        fixedServiceLocator = new ClusterServiceLocator(fixedService);
-
-    }
-
-    @Test
-    public void getServiceWhenServiceDiscoveryNotStarted() {
-        assertNull(serviceDiscoveryLocator.getService());
-    }
-
-    @Test
-    public void getServiceWhenServiceDiscoveryFixedPortNotStarted() {
-        assertNull(serviceDiscoveryLocator.getService());
-    }
-
-    @Test
-    public void getServiceWhenFixedServiceNotStarted() {
-        assertEquals(fixedService, fixedServiceLocator.getService());
-    }
-
-    @Test
-    public void getServiceNotOnFirstAttempt() {
-
-        ClusterServiceLocator.AttemptsConfig config = new ClusterServiceLocator.AttemptsConfig();
-        config.setNumAttempts(2);
-        config.setTimeBetweenAttempsUnit(TimeUnit.SECONDS);
-        config.setTimeBetweenAttempts(1);
-
-        serviceDiscoveryLocator.setAttemptsConfig(config);
-
-        OngoingStubbing<DiscoverableService> stubbing = null;
-        for (int i = 0; i < config.getNumAttempts() - 1; i++) {
-            if (stubbing == null) {
-                stubbing = when(mockServiceDiscovery.getService()).thenReturn(null);
-            } else {
-                stubbing.thenReturn(null);
-            }
-        }
-        stubbing.thenReturn(fixedService);
-
-        assertEquals(fixedService, serviceDiscoveryLocator.getService());
-
-    }
-
-    @Test
-    public void getServiceNotOnFirstAttemptWithFixedPort() {
-
-        ClusterServiceLocator.AttemptsConfig config = new ClusterServiceLocator.AttemptsConfig();
-        config.setNumAttempts(2);
-        config.setTimeBetweenAttempsUnit(TimeUnit.SECONDS);
-        config.setTimeBetweenAttempts(1);
-
-        serviceDiscoveryFixedPortLocator.setAttemptsConfig(config);
-
-        OngoingStubbing<DiscoverableService> stubbing = null;
-        for (int i = 0; i < config.getNumAttempts() - 1; i++) {
-            if (stubbing == null) {
-                stubbing = when(mockServiceDiscovery.getService()).thenReturn(null);
-            } else {
-                stubbing.thenReturn(null);
-            }
-        }
-        stubbing.thenReturn(fixedService);
-
-        InetSocketAddress resultAddress = InetSocketAddress.createUnresolved(fixedService.getServiceAddress().getHostName(), fixedPort);
-        DiscoverableService resultService = new DiscoverableServiceImpl(fixedService.getServiceName(), resultAddress);
-        assertEquals(resultService, serviceDiscoveryFixedPortLocator.getService());
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/test/java/org/apache/nifi/cluster/protocol/impl/ClusterServicesBroadcasterTest.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/test/java/org/apache/nifi/cluster/protocol/impl/ClusterServicesBroadcasterTest.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/test/java/org/apache/nifi/cluster/protocol/impl/ClusterServicesBroadcasterTest.java
deleted file mode 100644
index 4d85d1a..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/test/java/org/apache/nifi/cluster/protocol/impl/ClusterServicesBroadcasterTest.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * 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.nifi.cluster.protocol.impl;
-
-import java.net.InetSocketAddress;
-import org.apache.nifi.cluster.protocol.ProtocolContext;
-import org.apache.nifi.cluster.protocol.ProtocolException;
-import org.apache.nifi.cluster.protocol.ProtocolHandler;
-import org.apache.nifi.cluster.protocol.jaxb.JaxbProtocolContext;
-import org.apache.nifi.cluster.protocol.jaxb.message.JaxbProtocolUtils;
-import org.apache.nifi.cluster.protocol.message.ProtocolMessage;
-import org.apache.nifi.cluster.protocol.message.ServiceBroadcastMessage;
-import org.apache.nifi.io.socket.multicast.DiscoverableService;
-import org.apache.nifi.io.socket.multicast.DiscoverableServiceImpl;
-import org.apache.nifi.io.socket.multicast.MulticastConfiguration;
-import org.junit.After;
-import static org.junit.Assert.*;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-
-/**
- * @author unattributed
- */
-public class ClusterServicesBroadcasterTest {
-
-    private ClusterServicesBroadcaster broadcaster;
-
-    private MulticastProtocolListener listener;
-
-    private DummyProtocolHandler handler;
-
-    private InetSocketAddress multicastAddress;
-
-    private DiscoverableService broadcastedService;
-
-    private ProtocolContext protocolContext;
-
-    private MulticastConfiguration configuration;
-
-    @Before
-    public void setup() throws Exception {
-
-        broadcastedService = new DiscoverableServiceImpl("some-service", new InetSocketAddress("localhost", 11111));
-
-        multicastAddress = new InetSocketAddress("225.1.1.1", 22222);
-
-        configuration = new MulticastConfiguration();
-
-        protocolContext = new JaxbProtocolContext(JaxbProtocolUtils.JAXB_CONTEXT);
-
-        broadcaster = new ClusterServicesBroadcaster(multicastAddress, configuration, protocolContext, "500 ms");
-        broadcaster.addService(broadcastedService);
-
-        handler = new DummyProtocolHandler();
-        listener = new MulticastProtocolListener(5, multicastAddress, configuration, protocolContext);
-        listener.addHandler(handler);
-    }
-
-    @After
-    public void teardown() {
-
-        if (broadcaster.isRunning()) {
-            broadcaster.stop();
-        }
-
-        try {
-            if (listener.isRunning()) {
-                listener.stop();
-            }
-        } catch (Exception ex) {
-            ex.printStackTrace(System.out);
-        }
-
-    }
-
-    @Test
-    @Ignore
-    public void testBroadcastReceived() throws Exception {
-
-        broadcaster.start();
-        listener.start();
-
-        Thread.sleep(1000);
-
-        listener.stop();
-
-        assertNotNull(handler.getProtocolMessage());
-        assertEquals(ProtocolMessage.MessageType.SERVICE_BROADCAST, handler.getProtocolMessage().getType());
-        final ServiceBroadcastMessage msg = (ServiceBroadcastMessage) handler.getProtocolMessage();
-        assertEquals(broadcastedService.getServiceName(), msg.getServiceName());
-        assertEquals(broadcastedService.getServiceAddress().getHostName(), msg.getAddress());
-        assertEquals(broadcastedService.getServiceAddress().getPort(), msg.getPort());
-    }
-
-    private class DummyProtocolHandler implements ProtocolHandler {
-
-        private ProtocolMessage protocolMessage;
-
-        @Override
-        public boolean canHandle(ProtocolMessage msg) {
-            return true;
-        }
-
-        @Override
-        public ProtocolMessage handle(ProtocolMessage msg) throws ProtocolException {
-            this.protocolMessage = msg;
-            return null;
-        }
-
-        public ProtocolMessage getProtocolMessage() {
-            return protocolMessage;
-        }
-
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/test/java/org/apache/nifi/cluster/protocol/impl/MulticastProtocolListenerTest.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/test/java/org/apache/nifi/cluster/protocol/impl/MulticastProtocolListenerTest.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/test/java/org/apache/nifi/cluster/protocol/impl/MulticastProtocolListenerTest.java
deleted file mode 100644
index 6c79b90..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/test/java/org/apache/nifi/cluster/protocol/impl/MulticastProtocolListenerTest.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- * 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.nifi.cluster.protocol.impl;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.net.DatagramPacket;
-import java.net.InetSocketAddress;
-import java.net.MulticastSocket;
-import java.util.ArrayList;
-import java.util.List;
-import org.apache.nifi.cluster.protocol.ProtocolContext;
-import org.apache.nifi.cluster.protocol.ProtocolException;
-import org.apache.nifi.cluster.protocol.ProtocolHandler;
-import org.apache.nifi.cluster.protocol.ProtocolMessageMarshaller;
-import org.apache.nifi.cluster.protocol.jaxb.JaxbProtocolContext;
-import org.apache.nifi.cluster.protocol.jaxb.message.JaxbProtocolUtils;
-import org.apache.nifi.cluster.protocol.message.MulticastProtocolMessage;
-import org.apache.nifi.cluster.protocol.message.PingMessage;
-import org.apache.nifi.cluster.protocol.message.ProtocolMessage;
-import org.apache.nifi.io.socket.multicast.MulticastConfiguration;
-import org.apache.nifi.io.socket.multicast.MulticastUtils;
-import org.junit.After;
-import static org.junit.Assert.*;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-
-/**
- * @author unattributed
- */
-public class MulticastProtocolListenerTest {
-
-    private MulticastProtocolListener listener;
-
-    private MulticastSocket socket;
-
-    private InetSocketAddress address;
-
-    private MulticastConfiguration configuration;
-
-    private ProtocolContext protocolContext;
-
-    @Before
-    public void setup() throws Exception {
-
-        address = new InetSocketAddress("226.1.1.1", 60000);
-        configuration = new MulticastConfiguration();
-
-        protocolContext = new JaxbProtocolContext(JaxbProtocolUtils.JAXB_CONTEXT);
-
-        listener = new MulticastProtocolListener(5, address, configuration, protocolContext);
-        listener.start();
-
-        socket = MulticastUtils.createMulticastSocket(address.getPort(), configuration);
-    }
-
-    @After
-    public void teardown() throws IOException {
-        try {
-            if (listener.isRunning()) {
-                listener.stop();
-            }
-        } finally {
-            MulticastUtils.closeQuietly(socket);
-        }
-    }
-
-    @Ignore("This test must be reworked.  Requires an active network connection")
-    @Test
-    public void testBadRequest() throws Exception {
-        DelayedProtocolHandler handler = new DelayedProtocolHandler(0);
-        listener.addHandler(handler);
-        DatagramPacket packet = new DatagramPacket(new byte[]{5}, 1, address);
-        socket.send(packet);
-        Thread.sleep(250);
-        assertEquals(0, handler.getMessages().size());
-    }
-
-    @Test
-    @Ignore
-    public void testRequest() throws Exception {
-
-        ReflexiveProtocolHandler handler = new ReflexiveProtocolHandler();
-        listener.addHandler(handler);
-
-        ProtocolMessage msg = new PingMessage();
-        MulticastProtocolMessage multicastMsg = new MulticastProtocolMessage("some-id", msg);
-
-        // marshal message to output stream
-        ProtocolMessageMarshaller marshaller = protocolContext.createMarshaller();
-        ByteArrayOutputStream baos = new ByteArrayOutputStream();
-        marshaller.marshal(multicastMsg, baos);
-        byte[] requestPacketBytes = baos.toByteArray();
-        DatagramPacket packet = new DatagramPacket(requestPacketBytes, requestPacketBytes.length, address);
-        socket.send(packet);
-
-        Thread.sleep(250);
-        assertEquals(1, handler.getMessages().size());
-        assertEquals(msg.getType(), handler.getMessages().get(0).getType());
-
-    }
-
-    private class ReflexiveProtocolHandler implements ProtocolHandler {
-
-        private List<ProtocolMessage> messages = new ArrayList<>();
-
-        @Override
-        public ProtocolMessage handle(ProtocolMessage msg) throws ProtocolException {
-            messages.add(msg);
-            return msg;
-        }
-
-        @Override
-        public boolean canHandle(ProtocolMessage msg) {
-            return true;
-        }
-
-        public List<ProtocolMessage> getMessages() {
-            return messages;
-        }
-
-    }
-
-    private class DelayedProtocolHandler implements ProtocolHandler {
-
-        private int delay = 0;
-
-        private List<ProtocolMessage> messages = new ArrayList<>();
-
-        public DelayedProtocolHandler(int delay) {
-            this.delay = delay;
-        }
-
-        @Override
-        public ProtocolMessage handle(ProtocolMessage msg) throws ProtocolException {
-            try {
-                messages.add(msg);
-                Thread.sleep(delay);
-                return null;
-            } catch (final InterruptedException ie) {
-                throw new ProtocolException(ie);
-            }
-
-        }
-
-        @Override
-        public boolean canHandle(ProtocolMessage msg) {
-            return true;
-        }
-
-        public List<ProtocolMessage> getMessages() {
-            return messages;
-        }
-
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/test/java/org/apache/nifi/cluster/protocol/impl/NodeProtocolSenderImplTest.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/test/java/org/apache/nifi/cluster/protocol/impl/NodeProtocolSenderImplTest.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/test/java/org/apache/nifi/cluster/protocol/impl/NodeProtocolSenderImplTest.java
deleted file mode 100644
index 7c62d2f..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/test/java/org/apache/nifi/cluster/protocol/impl/NodeProtocolSenderImplTest.java
+++ /dev/null
@@ -1,201 +0,0 @@
-/*
- * 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.nifi.cluster.protocol.impl;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import java.io.IOException;
-import java.net.InetSocketAddress;
-import java.util.UUID;
-
-import org.apache.nifi.cluster.HeartbeatPayload;
-import org.apache.nifi.cluster.protocol.ConnectionRequest;
-import org.apache.nifi.cluster.protocol.ConnectionResponse;
-import org.apache.nifi.cluster.protocol.Heartbeat;
-import org.apache.nifi.cluster.protocol.NodeIdentifier;
-import org.apache.nifi.cluster.protocol.ProtocolContext;
-import org.apache.nifi.cluster.protocol.ProtocolException;
-import org.apache.nifi.cluster.protocol.ProtocolHandler;
-import org.apache.nifi.cluster.protocol.StandardDataFlow;
-import org.apache.nifi.cluster.protocol.UnknownServiceAddressException;
-import org.apache.nifi.cluster.protocol.jaxb.JaxbProtocolContext;
-import org.apache.nifi.cluster.protocol.jaxb.message.JaxbProtocolUtils;
-import org.apache.nifi.cluster.protocol.message.ConnectionRequestMessage;
-import org.apache.nifi.cluster.protocol.message.ConnectionResponseMessage;
-import org.apache.nifi.cluster.protocol.message.ControllerStartupFailureMessage;
-import org.apache.nifi.cluster.protocol.message.HeartbeatMessage;
-import org.apache.nifi.cluster.protocol.message.PingMessage;
-import org.apache.nifi.cluster.protocol.message.ProtocolMessage;
-import org.apache.nifi.io.socket.ServerSocketConfiguration;
-import org.apache.nifi.io.socket.SocketConfiguration;
-import org.apache.nifi.io.socket.multicast.DiscoverableService;
-import org.apache.nifi.io.socket.multicast.DiscoverableServiceImpl;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.stubbing.Answer;
-
-/**
- * @author unattributed
- */
-public class NodeProtocolSenderImplTest {
-
-    private SocketProtocolListener listener;
-
-    private NodeProtocolSenderImpl sender;
-
-    private DiscoverableService service;
-
-    private ServerSocketConfiguration serverSocketConfiguration;
-
-    private ClusterServiceLocator mockServiceLocator;
-
-    private ProtocolHandler mockHandler;
-
-    private NodeIdentifier nodeIdentifier;
-
-    @Before
-    public void setup() throws IOException {
-
-        serverSocketConfiguration = new ServerSocketConfiguration();
-
-        mockServiceLocator = mock(ClusterServiceLocator.class);
-        mockHandler = mock(ProtocolHandler.class);
-
-        nodeIdentifier = new NodeIdentifier("1", "localhost", 1234, "localhost", 5678);
-
-        ProtocolContext protocolContext = new JaxbProtocolContext(JaxbProtocolUtils.JAXB_CONTEXT);
-
-        listener = new SocketProtocolListener(5, 0, serverSocketConfiguration, protocolContext);
-        listener.setShutdownListenerSeconds(3);
-        listener.addHandler(mockHandler);
-        listener.start();
-
-        service = new DiscoverableServiceImpl("some-service", new InetSocketAddress("localhost", listener.getPort()));
-
-        SocketConfiguration socketConfiguration = new SocketConfiguration();
-        socketConfiguration.setReuseAddress(true);
-        sender = new NodeProtocolSenderImpl(mockServiceLocator, socketConfiguration, protocolContext);
-    }
-
-    @After
-    public void teardown() throws IOException {
-        if (listener.isRunning()) {
-            listener.stop();
-        }
-    }
-
-    @Test
-    public void testConnect() throws Exception {
-
-        when(mockServiceLocator.getService()).thenReturn(service);
-        when(mockHandler.canHandle(any(ProtocolMessage.class))).thenReturn(Boolean.TRUE);
-        ConnectionResponseMessage mockMessage = new ConnectionResponseMessage();
-        mockMessage.setConnectionResponse(new ConnectionResponse(nodeIdentifier, new StandardDataFlow("flow".getBytes("UTF-8"), new byte[0], new byte[0]), false, null, null, UUID.randomUUID().toString()));
-        when(mockHandler.handle(any(ProtocolMessage.class))).thenReturn(mockMessage);
-
-        ConnectionRequestMessage request = new ConnectionRequestMessage();
-        request.setConnectionRequest(new ConnectionRequest(nodeIdentifier));
-        ConnectionResponseMessage response = sender.requestConnection(request);
-        assertNotNull(response);
-    }
-
-    @Test(expected = UnknownServiceAddressException.class)
-    public void testConnectNoClusterManagerAddress() throws Exception {
-
-        when(mockServiceLocator.getService()).thenReturn(null);
-        when(mockHandler.canHandle(any(ProtocolMessage.class))).thenReturn(Boolean.TRUE);
-        when(mockHandler.handle(any(ProtocolMessage.class))).thenReturn(new ConnectionResponseMessage());
-
-        ConnectionRequestMessage request = new ConnectionRequestMessage();
-        request.setConnectionRequest(new ConnectionRequest(nodeIdentifier));
-
-        sender.requestConnection(request);
-        fail("failed to throw exception");
-    }
-
-    @Test(expected = ProtocolException.class)
-    public void testConnectBadResponse() throws Exception {
-
-        when(mockServiceLocator.getService()).thenReturn(service);
-        when(mockHandler.canHandle(any(ProtocolMessage.class))).thenReturn(Boolean.TRUE);
-        when(mockHandler.handle(any(ProtocolMessage.class))).thenReturn(new PingMessage());
-
-        ConnectionRequestMessage request = new ConnectionRequestMessage();
-        request.setConnectionRequest(new ConnectionRequest(nodeIdentifier));
-
-        sender.requestConnection(request);
-        fail("failed to throw exception");
-
-    }
-
-    @Test(expected = ProtocolException.class)
-    public void testConnectDelayedResponse() throws Exception {
-
-        final int time = 250;
-        sender.getSocketConfiguration().setSocketTimeout(time);
-        when(mockServiceLocator.getService()).thenReturn(service);
-        when(mockHandler.canHandle(any(ProtocolMessage.class))).thenReturn(Boolean.TRUE);
-        when(mockHandler.handle(any(ProtocolMessage.class))).thenAnswer(new Answer<ConnectionResponseMessage>() {
-            @Override
-            public ConnectionResponseMessage answer(InvocationOnMock invocation) throws Throwable {
-                Thread.sleep(time * 3);
-                return new ConnectionResponseMessage();
-            }
-        });
-        ConnectionRequestMessage request = new ConnectionRequestMessage();
-        request.setConnectionRequest(new ConnectionRequest(nodeIdentifier));
-
-        sender.requestConnection(request);
-        fail("failed to throw exception");
-
-    }
-
-    @Test
-    public void testHeartbeat() throws Exception {
-
-        when(mockServiceLocator.getService()).thenReturn(service);
-        when(mockHandler.canHandle(any(ProtocolMessage.class))).thenReturn(Boolean.TRUE);
-        when(mockHandler.handle(any(ProtocolMessage.class))).thenReturn(null);
-
-        HeartbeatMessage msg = new HeartbeatMessage();
-        HeartbeatPayload hbPayload = new HeartbeatPayload();
-        Heartbeat hb = new Heartbeat(new NodeIdentifier("id", "localhost", 3, "localhost", 4), false, false, hbPayload.marshal());
-        msg.setHeartbeat(hb);
-        sender.heartbeat(msg);
-    }
-
-    @Test
-    public void testNotifyControllerStartupFailure() throws Exception {
-
-        when(mockServiceLocator.getService()).thenReturn(service);
-        when(mockHandler.canHandle(any(ProtocolMessage.class))).thenReturn(Boolean.TRUE);
-        when(mockHandler.handle(any(ProtocolMessage.class))).thenReturn(null);
-
-        ControllerStartupFailureMessage msg = new ControllerStartupFailureMessage();
-        msg.setNodeId(new NodeIdentifier("some-id", "some-addr", 1, "some-addr", 1));
-        msg.setExceptionMessage("some exception");
-        sender.notifyControllerStartupFailure(msg);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/test/java/org/apache/nifi/cluster/protocol/impl/SocketProtocolListenerTest.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/test/java/org/apache/nifi/cluster/protocol/impl/SocketProtocolListenerTest.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/test/java/org/apache/nifi/cluster/protocol/impl/SocketProtocolListenerTest.java
deleted file mode 100644
index 92a7d2a..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/test/java/org/apache/nifi/cluster/protocol/impl/SocketProtocolListenerTest.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * 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.nifi.cluster.protocol.impl;
-
-import java.io.IOException;
-import java.net.InetSocketAddress;
-import java.net.Socket;
-import java.net.SocketTimeoutException;
-import org.apache.nifi.cluster.protocol.ProtocolContext;
-import org.apache.nifi.cluster.protocol.ProtocolMessageMarshaller;
-import org.apache.nifi.cluster.protocol.ProtocolMessageUnmarshaller;
-import org.apache.nifi.cluster.protocol.jaxb.JaxbProtocolContext;
-import org.apache.nifi.cluster.protocol.jaxb.message.JaxbProtocolUtils;
-import org.apache.nifi.cluster.protocol.message.PingMessage;
-import org.apache.nifi.cluster.protocol.message.ProtocolMessage;
-import org.apache.nifi.cluster.protocol.testutils.DelayedProtocolHandler;
-import org.apache.nifi.cluster.protocol.testutils.ReflexiveProtocolHandler;
-import org.apache.nifi.io.socket.ServerSocketConfiguration;
-import org.apache.nifi.io.socket.SocketConfiguration;
-import org.apache.nifi.io.socket.SocketUtils;
-import org.junit.After;
-import static org.junit.Assert.*;
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- * @author unattributed
- */
-public class SocketProtocolListenerTest {
-
-    private SocketProtocolListener listener;
-
-    private Socket socket;
-
-    private ProtocolMessageMarshaller<ProtocolMessage> marshaller;
-
-    private ProtocolMessageUnmarshaller<ProtocolMessage> unmarshaller;
-
-    @Before
-    public void setup() throws Exception {
-
-        final ProtocolContext protocolContext = new JaxbProtocolContext(JaxbProtocolUtils.JAXB_CONTEXT);
-        marshaller = protocolContext.createMarshaller();
-        unmarshaller = protocolContext.createUnmarshaller();
-
-        ServerSocketConfiguration configuration = new ServerSocketConfiguration();
-        configuration.setSocketTimeout(1000);
-
-        listener = new SocketProtocolListener(5, 0, configuration, protocolContext);
-        listener.start();
-
-        int port = listener.getPort();
-
-        SocketConfiguration config = new SocketConfiguration();
-        config.setReuseAddress(true);
-        config.setSocketTimeout(1000);
-        socket = SocketUtils.createSocket(new InetSocketAddress("localhost", port), config);
-    }
-
-    @After
-    public void teardown() throws IOException {
-        try {
-            if (listener.isRunning()) {
-                listener.stop();
-            }
-        } finally {
-            SocketUtils.closeQuietly(socket);
-        }
-    }
-
-    @Test
-    public void testBadRequest() throws Exception {
-        DelayedProtocolHandler handler = new DelayedProtocolHandler(0);
-        listener.addHandler(handler);
-        socket.getOutputStream().write(5);
-        Thread.sleep(250);
-        assertEquals(0, handler.getMessages().size());
-    }
-
-    @Test
-    public void testRequest() throws Exception {
-        ProtocolMessage msg = new PingMessage();
-
-        ReflexiveProtocolHandler handler = new ReflexiveProtocolHandler();
-        listener.addHandler(handler);
-
-        // marshal message to output stream
-        marshaller.marshal(msg, socket.getOutputStream());
-
-        // unmarshall response and return
-        ProtocolMessage response = unmarshaller.unmarshal(socket.getInputStream());
-        assertEquals(msg.getType(), response.getType());
-
-        assertEquals(1, handler.getMessages().size());
-        assertEquals(msg.getType(), handler.getMessages().get(0).getType());
-    }
-
-    @Test
-    public void testDelayedRequest() throws Exception {
-        ProtocolMessage msg = new PingMessage();
-
-        DelayedProtocolHandler handler = new DelayedProtocolHandler(2000);
-        listener.addHandler(handler);
-
-        // marshal message to output stream
-        marshaller.marshal(msg, socket.getOutputStream());
-
-        try {
-            socket.getInputStream().read();
-            fail("Socket timeout not received.");
-        } catch (SocketTimeoutException ste) {
-        }
-
-        assertEquals(1, handler.getMessages().size());
-        assertEquals(msg.getType(), handler.getMessages().get(0).getType());
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/test/java/org/apache/nifi/cluster/protocol/testutils/DelayedProtocolHandler.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/test/java/org/apache/nifi/cluster/protocol/testutils/DelayedProtocolHandler.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/test/java/org/apache/nifi/cluster/protocol/testutils/DelayedProtocolHandler.java
deleted file mode 100644
index 2f16777..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/test/java/org/apache/nifi/cluster/protocol/testutils/DelayedProtocolHandler.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * 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.nifi.cluster.protocol.testutils;
-
-import java.util.ArrayList;
-import java.util.List;
-import org.apache.nifi.cluster.protocol.ProtocolException;
-import org.apache.nifi.cluster.protocol.ProtocolHandler;
-import org.apache.nifi.cluster.protocol.message.ProtocolMessage;
-
-/**
- * @author unattributed
- */
-public class DelayedProtocolHandler implements ProtocolHandler {
-
-    private int delay = 0;
-    private List<ProtocolMessage> messages = new ArrayList<>();
-
-    public DelayedProtocolHandler(int delay) {
-        this.delay = delay;
-    }
-
-    @Override
-    public ProtocolMessage handle(ProtocolMessage msg) throws ProtocolException {
-        try {
-            messages.add(msg);
-            Thread.sleep(delay);
-            return null;
-        } catch (final InterruptedException ie) {
-            throw new ProtocolException(ie);
-        }
-
-    }
-
-    @Override
-    public boolean canHandle(ProtocolMessage msg) {
-        return true;
-    }
-
-    public List<ProtocolMessage> getMessages() {
-        return messages;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/test/java/org/apache/nifi/cluster/protocol/testutils/ReflexiveProtocolHandler.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/test/java/org/apache/nifi/cluster/protocol/testutils/ReflexiveProtocolHandler.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/test/java/org/apache/nifi/cluster/protocol/testutils/ReflexiveProtocolHandler.java
deleted file mode 100644
index e80f52c..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/test/java/org/apache/nifi/cluster/protocol/testutils/ReflexiveProtocolHandler.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * 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.nifi.cluster.protocol.testutils;
-
-import java.util.ArrayList;
-import java.util.List;
-import org.apache.nifi.cluster.protocol.ProtocolException;
-import org.apache.nifi.cluster.protocol.ProtocolHandler;
-import org.apache.nifi.cluster.protocol.message.ProtocolMessage;
-
-/**
- * @author unattributed
- */
-public class ReflexiveProtocolHandler implements ProtocolHandler {
-
-    private List<ProtocolMessage> messages = new ArrayList<>();
-
-    @Override
-    public ProtocolMessage handle(ProtocolMessage msg) throws ProtocolException {
-        messages.add(msg);
-        return msg;
-    }
-
-    @Override
-    public boolean canHandle(ProtocolMessage msg) {
-        return true;
-    }
-
-    public List<ProtocolMessage> getMessages() {
-        return messages;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/test/resources/logback-test.xml
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/test/resources/logback-test.xml b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/test/resources/logback-test.xml
deleted file mode 100644
index 92eb78c..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/test/resources/logback-test.xml
+++ /dev/null
@@ -1,48 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-  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.
--->
-
-<configuration scan="true" scanPeriod="30 seconds">
-    <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
-        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
-            <pattern>%-4r [%t] %-5p %c - %m%n</pattern>
-        </encoder>
-    </appender>
-    
-    <!-- valid logging levels: TRACE, DEBUG, INFO, WARN, ERROR -->
-    <logger name="org.apache.nifi" level="INFO"/>
-    
-    <!-- Logger for managing logging statements for nifi clusters. -->
-    <logger name="org.apache.nifi.cluster" level="INFO"/>
-
-    <!-- 
-        Logger for logging HTTP requests received by the web server.  Setting
-        log level to 'debug' activates HTTP request logging.
-    -->
-    <logger name="org.apache.nifi.server.JettyServer" level="INFO"/>
-
-    <!-- Logger for managing logging statements for jetty -->
-    <logger name="org.mortbay" level="INFO"/>
-
-    <!-- Suppress non-error messages due to excessive logging by class -->
-    <logger name="com.sun.jersey.spi.container.servlet.WebComponent" level="ERROR"/>
-
-    <logger name="org.apache.nifi.processors.standard" level="DEBUG"/>
-
-    <root level="INFO">
-        <appender-ref ref="CONSOLE"/>
-    </root>
-    
-</configuration>

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/test/resources/org/apache/nifi/cluster/firewall/impl/empty.txt
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/test/resources/org/apache/nifi/cluster/firewall/impl/empty.txt b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/test/resources/org/apache/nifi/cluster/firewall/impl/empty.txt
deleted file mode 100755
index e69de29..0000000

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/test/resources/org/apache/nifi/cluster/firewall/impl/ips.txt
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/test/resources/org/apache/nifi/cluster/firewall/impl/ips.txt b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/test/resources/org/apache/nifi/cluster/firewall/impl/ips.txt
deleted file mode 100755
index e8e4c2b..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/test/resources/org/apache/nifi/cluster/firewall/impl/ips.txt
+++ /dev/null
@@ -1,12 +0,0 @@
-
-bad data should be skipped
-
-# this is a comment
-  2.2.2.2  # this is another comment ####
-3.3.3.3/8
-
-4.4.4.4/24
-
-5.5.5.255/31
-
-more bad data
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/.gitignore
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/.gitignore b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/.gitignore
new file mode 100755
index 0000000..ea8c4bf
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/.gitignore
@@ -0,0 +1 @@
+/target

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/pom.xml
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/pom.xml b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/pom.xml
new file mode 100644
index 0000000..dc70905
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/pom.xml
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.nifi</groupId>
+        <artifactId>nifi-framework</artifactId>
+        <version>0.0.3-incubating-SNAPSHOT</version>
+    </parent>
+    <artifactId>nifi-framework-cluster-protocol</artifactId>
+    <packaging>jar</packaging>
+    <description>The messaging protocol for clustered NiFi</description>
+    <dependencies>
+        <!-- application dependencies -->
+        <dependency>
+            <groupId>org.apache.nifi</groupId>
+            <artifactId>nifi-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.nifi</groupId>
+            <artifactId>nifi-properties</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.nifi</groupId>
+            <artifactId>nifi-logging-utils</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.nifi</groupId>
+            <artifactId>nifi-socket-utils</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.nifi</groupId>
+            <artifactId>nifi-security</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.nifi</groupId>
+            <artifactId>nifi-framework-core-api</artifactId>
+        </dependency>
+        
+        <!-- spring dependencies -->
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-core</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-beans</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-context</artifactId>
+        </dependency>
+    </dependencies>
+</project>

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ClusterManagerProtocolSender.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ClusterManagerProtocolSender.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ClusterManagerProtocolSender.java
new file mode 100644
index 0000000..fa1547f
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ClusterManagerProtocolSender.java
@@ -0,0 +1,69 @@
+/*
+ * 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.nifi.cluster.protocol;
+
+import org.apache.nifi.cluster.protocol.message.DisconnectMessage;
+import org.apache.nifi.cluster.protocol.message.FlowRequestMessage;
+import org.apache.nifi.cluster.protocol.message.FlowResponseMessage;
+import org.apache.nifi.cluster.protocol.message.PrimaryRoleAssignmentMessage;
+import org.apache.nifi.cluster.protocol.message.ReconnectionRequestMessage;
+import org.apache.nifi.cluster.protocol.message.ReconnectionResponseMessage;
+import org.apache.nifi.reporting.BulletinRepository;
+
+/**
+ * An interface for sending protocol messages from the cluster manager to nodes.
+ * 
+ * @author unattributed
+ */
+public interface ClusterManagerProtocolSender {
+    
+    /**
+     * Sends a "flow request" message to a node.
+     * @param msg a message
+     * @return the response
+     * @throws ProtocolException if communication failed 
+     */
+    FlowResponseMessage requestFlow(FlowRequestMessage msg) throws ProtocolException;
+
+    /**
+     * Sends a "reconnection request" message to a node.
+     * @param msg a message
+     * @return 
+     * @throws ProtocolException if communication failed
+     */
+    ReconnectionResponseMessage requestReconnection(ReconnectionRequestMessage msg) throws ProtocolException;
+    
+    /**
+     * Sends a "disconnection request" message to a node.
+     * @param msg a message
+     * @throws ProtocolException if communication failed
+     */
+    void disconnect(DisconnectMessage msg) throws ProtocolException;
+    
+    /**
+     * Sends an "assign primary role" message to a node.
+     * @param msg a message
+     * @throws ProtocolException if communication failed 
+     */
+    void assignPrimaryRole(PrimaryRoleAssignmentMessage msg) throws ProtocolException;
+
+    /**
+     * Sets the {@link BulletinRepository} that can be used to report bulletins
+     * @param bulletinRepository
+     */
+    void setBulletinRepository(final BulletinRepository bulletinRepository);
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ConnectionRequest.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ConnectionRequest.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ConnectionRequest.java
new file mode 100644
index 0000000..1b5d007
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ConnectionRequest.java
@@ -0,0 +1,44 @@
+/*
+ * 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.nifi.cluster.protocol;
+
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+import org.apache.nifi.cluster.protocol.jaxb.message.ConnectionRequestAdapter;
+
+/**
+ * A node's request to connect to the cluster.  The request contains a proposed
+ * identifier.
+ * 
+ * @author unattributed
+ */
+@XmlJavaTypeAdapter(ConnectionRequestAdapter.class)
+public class ConnectionRequest {
+
+    private final NodeIdentifier proposedNodeIdentifier;
+
+    public ConnectionRequest(final NodeIdentifier proposedNodeIdentifier) {
+        if(proposedNodeIdentifier == null) {
+            throw new IllegalArgumentException("Proposed node identifier may not be null.");
+        }
+        this.proposedNodeIdentifier = proposedNodeIdentifier;
+    }
+
+    public NodeIdentifier getProposedNodeIdentifier() {
+        return proposedNodeIdentifier;
+    }
+
+}


[13/20] incubator-nifi git commit: NIFI-410 pushed RAT exclusions down to the relevant modules and stopped doing broad test resource exclusion - is now specific

Posted by jo...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/impl/WebClusterManager.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/impl/WebClusterManager.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/impl/WebClusterManager.java
deleted file mode 100644
index 4d5455f..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/impl/WebClusterManager.java
+++ /dev/null
@@ -1,3628 +0,0 @@
-/*
- * 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.nifi.cluster.manager.impl;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.Serializable;
-import java.net.URI;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedHashMap;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Map;
-import java.util.Queue;
-import java.util.Set;
-import java.util.Timer;
-import java.util.TimerTask;
-import java.util.TreeMap;
-import java.util.UUID;
-import java.util.concurrent.CompletionService;
-import java.util.concurrent.ConcurrentLinkedQueue;
-import java.util.concurrent.ExecutorCompletionService;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReentrantReadWriteLock;
-import java.util.regex.Pattern;
-
-import javax.net.ssl.SSLContext;
-import javax.ws.rs.HttpMethod;
-import javax.ws.rs.WebApplicationException;
-import javax.ws.rs.core.StreamingOutput;
-import javax.xml.XMLConstants;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.validation.Schema;
-import javax.xml.validation.SchemaFactory;
-import javax.xml.validation.Validator;
-
-import org.apache.commons.lang3.StringUtils;
-import org.apache.nifi.admin.service.AuditService;
-import org.apache.nifi.cluster.BulletinsPayload;
-import org.apache.nifi.cluster.HeartbeatPayload;
-import org.apache.nifi.cluster.context.ClusterContext;
-import org.apache.nifi.cluster.context.ClusterContextImpl;
-import org.apache.nifi.cluster.event.Event;
-import org.apache.nifi.cluster.event.EventManager;
-import org.apache.nifi.cluster.firewall.ClusterNodeFirewall;
-import org.apache.nifi.cluster.flow.ClusterDataFlow;
-import org.apache.nifi.cluster.flow.DaoException;
-import org.apache.nifi.cluster.flow.DataFlowManagementService;
-import org.apache.nifi.cluster.flow.PersistedFlowState;
-import org.apache.nifi.cluster.manager.HttpClusterManager;
-import org.apache.nifi.cluster.manager.HttpRequestReplicator;
-import org.apache.nifi.cluster.manager.HttpResponseMapper;
-import org.apache.nifi.cluster.manager.NodeResponse;
-import org.apache.nifi.cluster.manager.exception.ConnectingNodeMutableRequestException;
-import org.apache.nifi.cluster.manager.exception.DisconnectedNodeMutableRequestException;
-import org.apache.nifi.cluster.manager.exception.IllegalClusterStateException;
-import org.apache.nifi.cluster.manager.exception.IllegalNodeDeletionException;
-import org.apache.nifi.cluster.manager.exception.IllegalNodeDisconnectionException;
-import org.apache.nifi.cluster.manager.exception.IllegalNodeReconnectionException;
-import org.apache.nifi.cluster.manager.exception.IneligiblePrimaryNodeException;
-import org.apache.nifi.cluster.manager.exception.NoConnectedNodesException;
-import org.apache.nifi.cluster.manager.exception.NoResponseFromNodesException;
-import org.apache.nifi.cluster.manager.exception.NodeDisconnectionException;
-import org.apache.nifi.cluster.manager.exception.NodeReconnectionException;
-import org.apache.nifi.cluster.manager.exception.PrimaryRoleAssignmentException;
-import org.apache.nifi.cluster.manager.exception.SafeModeMutableRequestException;
-import org.apache.nifi.cluster.manager.exception.UnknownNodeException;
-import org.apache.nifi.cluster.manager.exception.UriConstructionException;
-import org.apache.nifi.cluster.node.Node;
-import org.apache.nifi.cluster.node.Node.Status;
-import org.apache.nifi.cluster.protocol.ConnectionRequest;
-import org.apache.nifi.cluster.protocol.ConnectionResponse;
-import org.apache.nifi.cluster.protocol.Heartbeat;
-import org.apache.nifi.cluster.protocol.NodeBulletins;
-import org.apache.nifi.cluster.protocol.NodeIdentifier;
-import org.apache.nifi.cluster.protocol.ProtocolException;
-import org.apache.nifi.cluster.protocol.ProtocolHandler;
-import org.apache.nifi.cluster.protocol.StandardDataFlow;
-import org.apache.nifi.cluster.protocol.impl.ClusterManagerProtocolSenderListener;
-import org.apache.nifi.cluster.protocol.impl.ClusterServicesBroadcaster;
-import org.apache.nifi.cluster.protocol.message.ConnectionRequestMessage;
-import org.apache.nifi.cluster.protocol.message.ConnectionResponseMessage;
-import org.apache.nifi.cluster.protocol.message.ControllerStartupFailureMessage;
-import org.apache.nifi.cluster.protocol.message.DisconnectMessage;
-import org.apache.nifi.cluster.protocol.message.HeartbeatMessage;
-import org.apache.nifi.cluster.protocol.message.NodeBulletinsMessage;
-import org.apache.nifi.cluster.protocol.message.PrimaryRoleAssignmentMessage;
-import org.apache.nifi.cluster.protocol.message.ProtocolMessage;
-import org.apache.nifi.cluster.protocol.message.ProtocolMessage.MessageType;
-import org.apache.nifi.cluster.protocol.message.ReconnectionFailureMessage;
-import org.apache.nifi.cluster.protocol.message.ReconnectionRequestMessage;
-import org.apache.nifi.components.PropertyDescriptor;
-import org.apache.nifi.controller.ControllerService;
-import org.apache.nifi.controller.Heartbeater;
-import org.apache.nifi.controller.ReportingTaskNode;
-import org.apache.nifi.controller.ValidationContextFactory;
-import org.apache.nifi.controller.reporting.ClusteredReportingTaskNode;
-import org.apache.nifi.controller.reporting.ReportingTaskInstantiationException;
-import org.apache.nifi.controller.reporting.StandardReportingInitializationContext;
-import org.apache.nifi.controller.scheduling.StandardProcessScheduler;
-import org.apache.nifi.controller.scheduling.TimerDrivenSchedulingAgent;
-import org.apache.nifi.controller.service.ControllerServiceNode;
-import org.apache.nifi.controller.service.ControllerServiceProvider;
-import org.apache.nifi.controller.service.StandardControllerServiceProvider;
-import org.apache.nifi.controller.status.ProcessGroupStatus;
-import org.apache.nifi.controller.status.RemoteProcessGroupStatus;
-import org.apache.nifi.controller.status.history.ComponentStatusRepository;
-import org.apache.nifi.controller.status.history.MetricDescriptor;
-import org.apache.nifi.controller.status.history.StatusHistory;
-import org.apache.nifi.controller.status.history.StatusHistoryUtil;
-import org.apache.nifi.controller.status.history.StatusSnapshot;
-import org.apache.nifi.diagnostics.GarbageCollection;
-import org.apache.nifi.diagnostics.StorageUsage;
-import org.apache.nifi.diagnostics.SystemDiagnostics;
-import org.apache.nifi.encrypt.StringEncryptor;
-import org.apache.nifi.engine.FlowEngine;
-import org.apache.nifi.events.BulletinFactory;
-import org.apache.nifi.events.VolatileBulletinRepository;
-import org.apache.nifi.framework.security.util.SslContextFactory;
-import org.apache.nifi.io.socket.multicast.DiscoverableService;
-import org.apache.nifi.logging.NiFiLog;
-import org.apache.nifi.nar.ExtensionManager;
-import org.apache.nifi.nar.NarCloseable;
-import org.apache.nifi.nar.NarThreadContextClassLoader;
-import org.apache.nifi.processor.StandardValidationContextFactory;
-import org.apache.nifi.remote.RemoteResourceManager;
-import org.apache.nifi.remote.RemoteSiteListener;
-import org.apache.nifi.remote.SocketRemoteSiteListener;
-import org.apache.nifi.remote.cluster.ClusterNodeInformation;
-import org.apache.nifi.remote.cluster.NodeInformation;
-import org.apache.nifi.remote.protocol.socket.ClusterManagerServerProtocol;
-import org.apache.nifi.reporting.Bulletin;
-import org.apache.nifi.reporting.BulletinRepository;
-import org.apache.nifi.reporting.InitializationException;
-import org.apache.nifi.reporting.ReportingInitializationContext;
-import org.apache.nifi.reporting.ReportingTask;
-import org.apache.nifi.reporting.Severity;
-import org.apache.nifi.scheduling.SchedulingStrategy;
-import org.apache.nifi.util.DomUtils;
-import org.apache.nifi.util.FormatUtils;
-import org.apache.nifi.util.NiFiProperties;
-import org.apache.nifi.web.Revision;
-import org.apache.nifi.web.api.dto.FlowSnippetDTO;
-import org.apache.nifi.web.api.dto.NodeDTO;
-import org.apache.nifi.web.api.dto.ProcessGroupDTO;
-import org.apache.nifi.web.api.dto.ProcessorDTO;
-import org.apache.nifi.web.api.dto.RemoteProcessGroupContentsDTO;
-import org.apache.nifi.web.api.dto.RemoteProcessGroupDTO;
-import org.apache.nifi.web.api.dto.RemoteProcessGroupPortDTO;
-import org.apache.nifi.web.api.dto.provenance.ProvenanceDTO;
-import org.apache.nifi.web.api.dto.provenance.ProvenanceEventDTO;
-import org.apache.nifi.web.api.dto.provenance.ProvenanceRequestDTO;
-import org.apache.nifi.web.api.dto.provenance.ProvenanceResultsDTO;
-import org.apache.nifi.web.api.dto.status.ClusterStatusHistoryDTO;
-import org.apache.nifi.web.api.dto.status.NodeStatusHistoryDTO;
-import org.apache.nifi.web.api.dto.status.StatusHistoryDTO;
-import org.apache.nifi.web.api.dto.status.StatusSnapshotDTO;
-import org.apache.nifi.web.api.entity.FlowSnippetEntity;
-import org.apache.nifi.web.api.entity.ProcessGroupEntity;
-import org.apache.nifi.web.api.entity.ProcessorEntity;
-import org.apache.nifi.web.api.entity.ProcessorsEntity;
-import org.apache.nifi.web.api.entity.ProvenanceEntity;
-import org.apache.nifi.web.api.entity.ProvenanceEventEntity;
-import org.apache.nifi.web.api.entity.RemoteProcessGroupEntity;
-import org.apache.nifi.web.api.entity.RemoteProcessGroupsEntity;
-import org.apache.nifi.web.util.WebUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.w3c.dom.DOMException;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-
-import com.sun.jersey.api.client.ClientResponse;
-
-/**
- * Provides a cluster manager implementation. The manager federates incoming
- * HTTP client requests to the nodes' external API using the HTTP protocol. The
- * manager also communicates with nodes using the nodes' internal socket
- * protocol.
- *
- * The manager's socket address may broadcasted using multicast if a
- * MulticastServiceBroadcaster instance is set on this instance. The manager
- * instance must be started after setting the broadcaster.
- *
- * The manager may be configured with an EventManager for recording noteworthy
- * lifecycle events (e.g., first heartbeat received, node status change).
- *
- * The start() and stop() methods must be called to initialize and stop the
- * instance.
- *
- * @author unattributed
- */
-public class WebClusterManager implements HttpClusterManager, ProtocolHandler, ControllerServiceProvider {
-
-    public static final String ROOT_GROUP_ID_ALIAS = "root";
-    public static final String BULLETIN_CATEGORY = "Clustering";
-
-    private static final Logger logger = new NiFiLog(LoggerFactory.getLogger(WebClusterManager.class));
-    private static final Logger heartbeatLogger = new NiFiLog(LoggerFactory.getLogger("org.apache.nifi.cluster.heartbeat"));
-
-    /**
-     * The HTTP header to store a cluster context. An example of what may be
-     * stored in the context is a node's auditable actions in response to a
-     * cluster request. The cluster context is serialized using Java's
-     * serialization mechanism and hex encoded.
-     */
-    public static final String CLUSTER_CONTEXT_HTTP_HEADER = "X-ClusterContext";
-
-    /**
-     * HTTP Header that stores a unique ID for each request that is replicated
-     * to the nodes. This is used for logging purposes so that request
-     * information, such as timing, can be correlated between the NCM and the
-     * nodes
-     */
-    public static final String REQUEST_ID_HEADER = "X-RequestID";
-
-    /**
-     * The HTTP header that the NCM specifies to ask a node if they are able to
-     * process a given request. The value is always 150-NodeContinue. The node
-     * will respond with 150 CONTINUE if it is able to process the request, 417
-     * EXPECTATION_FAILED otherwise.
-     */
-    public static final String NCM_EXPECTS_HTTP_HEADER = "X-NcmExpects";
-    public static final int NODE_CONTINUE_STATUS_CODE = 150;
-
-    /**
-     * The HTTP header that the NCM specifies to indicate that a node should
-     * invalidate the specified user group. This is done to ensure that user
-     * cache is not stale when an administrator modifies a group through the UI.
-     */
-    public static final String CLUSTER_INVALIDATE_USER_GROUP_HEADER = "X-ClusterInvalidateUserGroup";
-
-    /**
-     * The HTTP header that the NCM specifies to indicate that a node should
-     * invalidate the specified user. This is done to ensure that user cache is
-     * not stale when an administrator modifies a user through the UI.
-     */
-    public static final String CLUSTER_INVALIDATE_USER_HEADER = "X-ClusterInvalidateUser";
-
-    /**
-     * The default number of seconds to respond to a connecting node if the
-     * manager cannot provide it with a current data flow.
-     */
-    private static final int DEFAULT_CONNECTION_REQUEST_TRY_AGAIN_SECONDS = 5;
-
-    public static final String DEFAULT_COMPONENT_STATUS_REPO_IMPLEMENTATION = "org.apache.nifi.controller.status.history.VolatileComponentStatusRepository";
-
-    public static final Pattern PROCESSORS_URI_PATTERN = Pattern.compile("/nifi-api/controller/process-groups/(?:(?:root)|(?:[a-f0-9\\-]{36}))/processors");
-    public static final Pattern PROCESSOR_URI_PATTERN = Pattern.compile("/nifi-api/controller/process-groups/(?:(?:root)|(?:[a-f0-9\\-]{36}))/processors/[a-f0-9\\-]{36}");
-
-    public static final Pattern REMOTE_PROCESS_GROUPS_URI_PATTERN = Pattern.compile("/nifi-api/controller/process-groups/(?:(?:root)|(?:[a-f0-9\\-]{36}))/remote-process-groups");
-    public static final Pattern REMOTE_PROCESS_GROUP_URI_PATTERN = Pattern.compile("/nifi-api/controller/process-groups/(?:(?:root)|(?:[a-f0-9\\-]{36}))/remote-process-groups/[a-f0-9\\-]{36}");
-
-    public static final Pattern PROCESS_GROUP_URI_PATTERN = Pattern.compile("/nifi-api/controller/process-groups/(?:(?:root)|(?:[a-f0-9\\-]{36}))");
-    public static final Pattern TEMPLATE_INSTANCE_URI_PATTERN = Pattern.compile("/nifi-api/controller/process-groups/(?:(?:root)|(?:[a-f0-9\\-]{36}))/template-instance");
-    public static final Pattern FLOW_SNIPPET_INSTANCE_URI_PATTERN = Pattern.compile("/nifi-api/controller/process-groups/(?:(?:root)|(?:[a-f0-9\\-]{36}))/snippet-instance");
-
-    public static final String PROVENANCE_URI = "/nifi-api/controller/provenance";
-    public static final Pattern PROVENANCE_QUERY_URI = Pattern.compile("/nifi-api/controller/provenance/[a-f0-9\\-]{36}");
-    public static final Pattern PROVENANCE_EVENT_URI = Pattern.compile("/nifi-api/controller/provenance/events/[0-9]+");
-
-    private final NiFiProperties properties;
-    private final HttpRequestReplicator httpRequestReplicator;
-    private final HttpResponseMapper httpResponseMapper;
-    private final DataFlowManagementService dataFlowManagementService;
-    private final ClusterManagerProtocolSenderListener senderListener;
-    private final StringEncryptor encryptor;
-    private final Queue<Heartbeat> pendingHeartbeats = new ConcurrentLinkedQueue<>();
-    private final ReentrantReadWriteLock resourceRWLock = new ReentrantReadWriteLock();
-    private final ClusterManagerLock readLock = new ClusterManagerLock(resourceRWLock.readLock(), "Read");
-    private final ClusterManagerLock writeLock = new ClusterManagerLock(resourceRWLock.writeLock(), "Write");
-
-    private final Set<Node> nodes = new HashSet<>();
-    private final Set<ReportingTaskNode> reportingTasks = new HashSet<>();
-
-    // null means the dataflow should be read from disk
-    private StandardDataFlow cachedDataFlow = null;
-    private NodeIdentifier primaryNodeId = null;
-    private Revision revision = new Revision(0L, "");
-    private Timer heartbeatMonitor;
-    private Timer heartbeatProcessor;
-    private volatile ClusterServicesBroadcaster servicesBroadcaster = null;
-    private volatile EventManager eventManager = null;
-    private volatile ClusterNodeFirewall clusterFirewall = null;
-    private volatile AuditService auditService = null;
-    private volatile ControllerServiceProvider controllerServiceProvider = null;
-
-    private final RemoteSiteListener remoteSiteListener;
-    private final Integer remoteInputPort;
-    private final Boolean remoteCommsSecure;
-    private final BulletinRepository bulletinRepository;
-    private final String instanceId;
-    private final FlowEngine reportingTaskEngine;
-    private final Map<NodeIdentifier, ComponentStatusRepository> componentMetricsRepositoryMap = new HashMap<>();
-    private final StandardProcessScheduler processScheduler;
-    private final long componentStatusSnapshotMillis;
-
-    public WebClusterManager(final HttpRequestReplicator httpRequestReplicator, final HttpResponseMapper httpResponseMapper,
-            final DataFlowManagementService dataFlowManagementService, final ClusterManagerProtocolSenderListener senderListener,
-            final NiFiProperties properties, final StringEncryptor encryptor) {
-
-        if (httpRequestReplicator == null) {
-            throw new IllegalArgumentException("HttpRequestReplicator may not be null.");
-        } else if (httpResponseMapper == null) {
-            throw new IllegalArgumentException("HttpResponseMapper may not be null.");
-        } else if (dataFlowManagementService == null) {
-            throw new IllegalArgumentException("DataFlowManagementService may not be null.");
-        } else if (senderListener == null) {
-            throw new IllegalArgumentException("ClusterManagerProtocolSenderListener may not be null.");
-        } else if (properties == null) {
-            throw new IllegalArgumentException("NiFiProperties may not be null.");
-        }
-
-        // Ensure that our encryptor/decryptor is properly initialized
-        this.httpRequestReplicator = httpRequestReplicator;
-        this.httpResponseMapper = httpResponseMapper;
-        this.dataFlowManagementService = dataFlowManagementService;
-        this.properties = properties;
-        this.controllerServiceProvider = new StandardControllerServiceProvider();
-        this.bulletinRepository = new VolatileBulletinRepository();
-        this.instanceId = UUID.randomUUID().toString();
-        this.senderListener = senderListener;
-        this.encryptor = encryptor;
-        senderListener.addHandler(this);
-        senderListener.setBulletinRepository(bulletinRepository);
-
-        final String snapshotFrequency = properties.getProperty(NiFiProperties.COMPONENT_STATUS_SNAPSHOT_FREQUENCY, NiFiProperties.DEFAULT_COMPONENT_STATUS_SNAPSHOT_FREQUENCY);
-        long snapshotMillis;
-        try {
-            snapshotMillis = FormatUtils.getTimeDuration(snapshotFrequency, TimeUnit.MILLISECONDS);
-        } catch (final Exception e) {
-            snapshotMillis = FormatUtils.getTimeDuration(NiFiProperties.DEFAULT_COMPONENT_STATUS_SNAPSHOT_FREQUENCY, TimeUnit.MILLISECONDS);
-        }
-        componentStatusSnapshotMillis = snapshotMillis;
-
-        remoteInputPort = properties.getRemoteInputPort();
-        if (remoteInputPort == null) {
-            remoteSiteListener = null;
-            remoteCommsSecure = null;
-        } else {
-            // Register the ClusterManagerServerProtocol as the appropriate resource for site-to-site Server Protocol
-            RemoteResourceManager.setServerProtocolImplementation(ClusterManagerServerProtocol.RESOURCE_NAME, ClusterManagerServerProtocol.class);
-            remoteCommsSecure = properties.isSiteToSiteSecure();
-            if (remoteCommsSecure) {
-                final SSLContext sslContext = SslContextFactory.createSslContext(properties, false);
-
-                if (sslContext == null) {
-                    throw new IllegalStateException("NiFi Configured to allow Secure Site-to-Site communications but the Keystore/Truststore properties are not configured");
-                }
-
-                remoteSiteListener = new SocketRemoteSiteListener(remoteInputPort.intValue(), sslContext, this);
-            } else {
-                remoteSiteListener = new SocketRemoteSiteListener(remoteInputPort.intValue(), null, this);
-            }
-        }
-
-        reportingTaskEngine = new FlowEngine(8, "Reporting Task Thread");
-
-        processScheduler = new StandardProcessScheduler(new Heartbeater() {
-            @Override
-            public void heartbeat() {
-            }
-        }, this, encryptor);
-        processScheduler.setSchedulingAgent(SchedulingStrategy.TIMER_DRIVEN, new TimerDrivenSchedulingAgent(null, reportingTaskEngine, null, encryptor));
-        processScheduler.setMaxThreadCount(SchedulingStrategy.TIMER_DRIVEN, 10);
-        processScheduler.setMaxThreadCount(SchedulingStrategy.CRON_DRIVEN, 10);
-    }
-
-    public void start() throws IOException {
-        writeLock.lock();
-        try {
-
-            if (isRunning()) {
-                throw new IllegalStateException("Instance is already started.");
-            }
-
-            try {
-                // setup heartbeat monitoring
-                heartbeatMonitor = new Timer("Heartbeat Monitor", /* is daemon */ true);
-                heartbeatMonitor.scheduleAtFixedRate(new HeartbeatMonitoringTimerTask(), 0, getHeartbeatMonitoringIntervalSeconds() * 1000);
-
-                heartbeatProcessor = new Timer("Process Pending Heartbeats", true);
-                final int processPendingHeartbeatDelay = 1000 * Math.max(1, getClusterProtocolHeartbeatSeconds() / 2);
-                heartbeatProcessor.schedule(new ProcessPendingHeartbeatsTask(), processPendingHeartbeatDelay, processPendingHeartbeatDelay);
-
-                // start request replication service
-                httpRequestReplicator.start();
-
-                // start protocol service
-                senderListener.start();
-
-                // start flow management service
-                dataFlowManagementService.start();
-
-                if (remoteSiteListener != null) {
-                    remoteSiteListener.start();
-                }
-
-                // load flow
-                if (dataFlowManagementService.isFlowCurrent()) {
-                    final ClusterDataFlow clusterDataFlow = dataFlowManagementService.loadDataFlow();
-                    cachedDataFlow = clusterDataFlow.getDataFlow();
-                    primaryNodeId = clusterDataFlow.getPrimaryNodeId();
-                } else {
-                    throw new IOException("Flow is not current.");
-                }
-
-                // start multicast broadcasting service, if configured
-                if (servicesBroadcaster != null) {
-                    servicesBroadcaster.start();
-                }
-
-                // start in safe mode
-                executeSafeModeTask();
-
-                // Load and start running Reporting Tasks
-                final File taskFile = new File(properties.getProperty(NiFiProperties.TASK_CONFIGURATION_FILE));
-                reportingTasks.addAll(loadReportingTasks(taskFile));
-            } catch (final IOException ioe) {
-                logger.warn("Failed to initialize cluster services due to: " + ioe, ioe);
-                stop();
-                throw ioe;
-            }
-
-        } finally {
-            writeLock.unlock("START");
-        }
-    }
-
-    public void stop() throws IOException {
-        writeLock.lock();
-        try {
-
-            // returns true if any service is running
-            if (isRunning() == false) {
-                throw new IllegalArgumentException("Instance is already stopped.");
-            }
-
-            boolean encounteredException = false;
-
-            // stop the heartbeat monitoring
-            if (isHeartbeatMonitorRunning()) {
-                heartbeatMonitor.cancel();
-                heartbeatMonitor = null;
-            }
-
-            if (heartbeatProcessor != null) {
-                heartbeatProcessor.cancel();
-                heartbeatProcessor = null;
-            }
-
-            // stop the HTTP request replicator service
-            if (httpRequestReplicator.isRunning()) {
-                httpRequestReplicator.stop();
-            }
-
-            // stop the flow management service
-            if (dataFlowManagementService.isRunning()) {
-                dataFlowManagementService.stop();
-            }
-
-            if (remoteSiteListener != null) {
-                remoteSiteListener.stop();
-            }
-
-            // stop the protocol listener service
-            if (senderListener.isRunning()) {
-                try {
-                    senderListener.stop();
-                } catch (final IOException ioe) {
-                    encounteredException = true;
-                    logger.warn("Failed to shutdown protocol service due to: " + ioe, ioe);
-                }
-            }
-
-            // stop the service broadcaster
-            if (isBroadcasting()) {
-                servicesBroadcaster.stop();
-            }
-
-            if ( processScheduler != null ) {
-                processScheduler.shutdown();
-            }
-            
-            if (encounteredException) {
-                throw new IOException("Failed to shutdown Cluster Manager because one or more cluster services failed to shutdown.  Check the logs for details.");
-            }
-
-        } finally {
-            writeLock.unlock("STOP");
-        }
-    }
-
-    public boolean isRunning() {
-        readLock.lock();
-        try {
-            return isHeartbeatMonitorRunning()
-                    || httpRequestReplicator.isRunning()
-                    || senderListener.isRunning()
-                    || dataFlowManagementService.isRunning()
-                    || isBroadcasting();
-        } finally {
-            readLock.unlock("isRunning");
-        }
-    }
-
-    @Override
-    public boolean canHandle(ProtocolMessage msg) {
-        return MessageType.CONNECTION_REQUEST == msg.getType()
-                || MessageType.HEARTBEAT == msg.getType()
-                || MessageType.CONTROLLER_STARTUP_FAILURE == msg.getType()
-                || MessageType.BULLETINS == msg.getType()
-                || MessageType.RECONNECTION_FAILURE == msg.getType();
-    }
-
-    @Override
-    public ProtocolMessage handle(final ProtocolMessage protocolMessage) throws ProtocolException {
-        switch (protocolMessage.getType()) {
-            case CONNECTION_REQUEST:
-                return handleConnectionRequest((ConnectionRequestMessage) protocolMessage);
-            case HEARTBEAT:
-                final HeartbeatMessage heartbeatMessage = (HeartbeatMessage) protocolMessage;
-
-                final Heartbeat original = heartbeatMessage.getHeartbeat();
-                final NodeIdentifier originalNodeId = original.getNodeIdentifier();
-                final Heartbeat heartbeatWithDn = new Heartbeat(addRequestorDn(originalNodeId, heartbeatMessage.getRequestorDN()), original.isPrimary(), original.isConnected(), original.getPayload());
-
-                handleHeartbeat(heartbeatWithDn);
-                return null;
-            case CONTROLLER_STARTUP_FAILURE:
-                new Thread(new Runnable() {
-                    @Override
-                    public void run() {
-                        handleControllerStartupFailure((ControllerStartupFailureMessage) protocolMessage);
-                    }
-                }, "Handle Controller Startup Failure Message from " + ((ControllerStartupFailureMessage) protocolMessage).getNodeId()).start();
-                return null;
-            case RECONNECTION_FAILURE:
-                new Thread(new Runnable() {
-                    @Override
-                    public void run() {
-                        handleReconnectionFailure((ReconnectionFailureMessage) protocolMessage);
-                    }
-                }, "Handle Reconnection Failure Message from " + ((ReconnectionFailureMessage) protocolMessage).getNodeId()).start();
-                return null;
-            case BULLETINS:
-                final NodeBulletinsMessage bulletinsMessage = (NodeBulletinsMessage) protocolMessage;
-                handleBulletins(bulletinsMessage.getBulletins());
-                return null;
-            default:
-                throw new ProtocolException("No handler defined for message type: " + protocolMessage.getType());
-        }
-    }
-
-    /**
-     * Services connection requests. If the data flow management service is
-     * unable to provide a current copy of the data flow, then the returned
-     * connection response will indicate the node should try later. Otherwise,
-     * the connection response will contain the the flow and the node
-     * identifier.
-     *
-     * If this instance is configured with a firewall and the request is
-     * blocked, then the response will not contain a node identifier.
-     *
-     * @param request a connection request
-     *
-     * @return a connection response
-     */
-    @Override
-    public ConnectionResponse requestConnection(final ConnectionRequest request) {
-        final boolean lockObtained = writeLock.tryLock(3, TimeUnit.SECONDS);
-        if (!lockObtained) {
-            // Create try-later response because we are too busy to service the request right now. We do not want
-            // to wait long because we want Node/NCM comms to be very responsive
-            final int tryAgainSeconds;
-            if (dataFlowManagementService.getRetrievalDelaySeconds() <= 0) {
-                tryAgainSeconds = DEFAULT_CONNECTION_REQUEST_TRY_AGAIN_SECONDS;
-            } else {
-                tryAgainSeconds = dataFlowManagementService.getRetrievalDelaySeconds();
-            }
-
-            // record event
-            final String msg = "Connection requested from node, but manager was too busy to service request.  Instructing node to try again in " + tryAgainSeconds + " seconds.";
-            addEvent(request.getProposedNodeIdentifier(), msg);
-            addBulletin(request.getProposedNodeIdentifier(), Severity.INFO, msg);
-
-            // return try later response
-            return new ConnectionResponse(tryAgainSeconds);
-        }
-
-        try {
-            // resolve the proposed node identifier to a valid node identifier
-            final NodeIdentifier resolvedNodeIdentifier = resolveProposedNodeIdentifier(request.getProposedNodeIdentifier());
-
-            if (isBlockedByFirewall(resolvedNodeIdentifier.getSocketAddress())) {
-                // if the socket address is not listed in the firewall, then return a null response
-                logger.info("Firewall blocked connection request from node " + resolvedNodeIdentifier);
-                return ConnectionResponse.createBlockedByFirewallResponse();
-            }
-
-            // get a raw reference to the node (if it doesn't exist, node will be null)
-            Node node = getRawNode(resolvedNodeIdentifier.getId());
-
-            // create a new node if necessary and set status to connecting
-            if (node == null) {
-                node = new Node(resolvedNodeIdentifier, Status.CONNECTING);
-                addEvent(node.getNodeId(), "Connection requested from new node.  Setting status to connecting.");
-                nodes.add(node);
-            } else {
-                node.setStatus(Status.CONNECTING);
-                addEvent(resolvedNodeIdentifier, "Connection requested from existing node.  Setting status to connecting");
-            }
-
-            // record the time of the connection request
-            node.setConnectionRequestedTimestamp(new Date().getTime());
-
-            // clear out old heartbeat info
-            node.setHeartbeat(null);
-
-            // try to obtain a current flow
-            if (dataFlowManagementService.isFlowCurrent()) {
-                // if a cached copy does not exist, load it from disk
-                if (cachedDataFlow == null) {
-                    final ClusterDataFlow clusterDataFlow = dataFlowManagementService.loadDataFlow();
-                    cachedDataFlow = clusterDataFlow.getDataFlow();
-                    primaryNodeId = clusterDataFlow.getPrimaryNodeId();
-                }
-
-                // determine if this node should be assigned the primary role
-                final boolean primaryRole;
-                if (primaryNodeId == null || primaryNodeId.logicallyEquals(node.getNodeId())) {
-                    setPrimaryNodeId(node.getNodeId());
-                    addEvent(node.getNodeId(), "Setting primary role in connection response.");
-                    primaryRole = true;
-                } else {
-                    primaryRole = false;
-                }
-
-                return new ConnectionResponse(node.getNodeId(), cachedDataFlow, primaryRole, remoteInputPort, remoteCommsSecure, instanceId);
-            }
-
-            /*
-             * The manager does not have a current copy of the data flow, 
-             * so it will instruct the node to try connecting at a later 
-             * time.  Meanwhile, the flow will be locked down from user 
-             * changes because the node is marked as connecting.
-             */
-
-            /*
-             * Create try-later response based on flow retrieval delay to give 
-             * the flow management service a chance to retrieve a curren flow
-             */
-            final int tryAgainSeconds;
-            if (dataFlowManagementService.getRetrievalDelaySeconds() <= 0) {
-                tryAgainSeconds = DEFAULT_CONNECTION_REQUEST_TRY_AGAIN_SECONDS;
-            } else {
-                tryAgainSeconds = dataFlowManagementService.getRetrievalDelaySeconds();
-            }
-
-            // record event
-            addEvent(node.getNodeId(), "Connection requested from node, but manager was unable to obtain current flow.  Instructing node to try again in " + tryAgainSeconds + " seconds.");
-
-            // return try later response
-            return new ConnectionResponse(tryAgainSeconds);
-
-        } finally {
-            writeLock.unlock("requestConnection");
-        }
-    }
-
-    /**
-     * Services reconnection requests for a given node. If the node indicates
-     * reconnection failure, then the node will be set to disconnected and if
-     * the node has primary role, then the role will be revoked. Otherwise, a
-     * reconnection request will be sent to the node, initiating the connection
-     * handshake.
-     *
-     * @param nodeId a node identifier
-     *
-     * @throws UnknownNodeException if the node does not exist
-     * @throws IllegalNodeReconnectionException if the node cannot be
-     * reconnected because the node is not disconnected
-     * @throws NodeReconnectionException if the reconnection message failed to
-     * be sent or the cluster could not provide a current data flow for the
-     * reconnection request
-     */
-    @Override
-    public void requestReconnection(final String nodeId, final String userDn) throws UnknownNodeException, IllegalNodeReconnectionException {
-        Node node = null;
-
-        final boolean primaryRole;
-        final int tryAgainSeconds;
-
-        writeLock.lock();
-        try {
-            // check if we know about this node and that it is disconnected
-            node = getRawNode(nodeId);
-            logger.info("Request was made by {} to reconnect node {} to cluster", userDn, node == null ? nodeId : node);
-
-            if (node == null) {
-                throw new UnknownNodeException("Node does not exist.");
-            } else if (Status.DISCONNECTED != node.getStatus()) {
-                throw new IllegalNodeReconnectionException("Node must be disconnected before it can reconnect.");
-            }
-
-            // clear out old heartbeat info
-            node.setHeartbeat(null);
-
-            // get the dataflow to send with the reconnection request
-            if (!dataFlowManagementService.isFlowCurrent()) {
-                /* node remains disconnected */
-                final String msg = "Reconnection requested for node, but manager was unable to obtain current flow.  Setting node to disconnected.";
-                addEvent(node.getNodeId(), msg);
-                addBulletin(node, Severity.WARNING, msg);
-                throw new NodeReconnectionException("Manager was unable to obtain current flow to provide in reconnection request to node.  Try again in a few seconds.");
-            }
-
-            // if a cached copy does not exist, load it from disk
-            if (cachedDataFlow == null) {
-                final ClusterDataFlow clusterDataFlow = dataFlowManagementService.loadDataFlow();
-                cachedDataFlow = clusterDataFlow.getDataFlow();
-                primaryNodeId = clusterDataFlow.getPrimaryNodeId();
-            }
-
-            node.setStatus(Status.CONNECTING);
-            addEvent(node.getNodeId(), "Reconnection requested for node.  Setting status to connecting.");
-
-            // determine if this node should be assigned the primary role
-            if (primaryNodeId == null || primaryNodeId.logicallyEquals(node.getNodeId())) {
-                setPrimaryNodeId(node.getNodeId());
-                addEvent(node.getNodeId(), "Setting primary role in reconnection request.");
-                primaryRole = true;
-            } else {
-                primaryRole = false;
-            }
-
-            if (dataFlowManagementService.getRetrievalDelaySeconds() <= 0) {
-                tryAgainSeconds = DEFAULT_CONNECTION_REQUEST_TRY_AGAIN_SECONDS;
-            } else {
-                tryAgainSeconds = dataFlowManagementService.getRetrievalDelaySeconds();
-            }
-        } catch (final UnknownNodeException | IllegalNodeReconnectionException | NodeReconnectionException une) {
-            throw une;
-        } catch (final Exception ex) {
-            logger.warn("Problem encountered issuing reconnection request to node " + node.getNodeId() + " due to: " + ex, ex);
-
-            node.setStatus(Status.DISCONNECTED);
-            final String eventMsg = "Problem encountered issuing reconnection request. Node will remain disconnected: " + ex;
-            addEvent(node.getNodeId(), eventMsg);
-            addBulletin(node, Severity.WARNING, eventMsg);
-
-            // Exception thrown will include node ID but event/bulletin do not because the node/id is passed along with the message
-            throw new NodeReconnectionException("Problem encountered issuing reconnection request to " + node.getNodeId() + ". Node will remain disconnected: " + ex, ex);
-        } finally {
-            writeLock.unlock("requestReconnection");
-        }
-
-        // Asynchronously start attempting reconnection. This is not completely thread-safe, as
-        // we do this by releasing the write lock and then obtaining a read lock for each attempt,
-        // so we suffer from the ABA problem. However, we are willing to accept the consequences of
-        // this situation in order to avoid holding a lock for the entire duration. "The consequences"
-        // are that a second thread could potentially be doing the same thing, issuing a reconnection request.
-        // However, this is very unlikely to happen, based on the conditions under which we issue a reconnection
-        // request. And if we do, the node will simply reconnect multiple times, which is not a big deal.
-        requestReconnectionAsynchronously(node, primaryRole, 10, tryAgainSeconds);
-    }
-
-    private void requestReconnectionAsynchronously(final Node node, final boolean primaryRole, final int reconnectionAttempts, final int retrySeconds) {
-        final Thread reconnectionThread = new Thread(new Runnable() {
-            @Override
-            public void run() {
-                for (int i = 0; i < reconnectionAttempts; i++) {
-                    final ReconnectionRequestMessage request = new ReconnectionRequestMessage();
-
-                    try {
-                        readLock.lock();
-                        try {
-                            if (Status.CONNECTING != node.getStatus()) {
-                                // the node status has changed. It's no longer appropriate to attempt reconnection.
-                                return;
-                            }
-
-                            // create the request
-                            request.setNodeId(node.getNodeId());
-                            request.setDataFlow(cachedDataFlow);
-                            request.setPrimary(primaryRole);
-                            request.setManagerRemoteSiteCommsSecure(remoteCommsSecure);
-                            request.setManagerRemoteSiteListeningPort(remoteInputPort);
-                            request.setInstanceId(instanceId);
-                        } finally {
-                            readLock.unlock("Reconnect " + node.getNodeId());
-                        }
-
-                        // Issue a reconnection request to the node.
-                        senderListener.requestReconnection(request);
-
-                        node.setConnectionRequestedTimestamp(System.currentTimeMillis());
-
-                        // successfully told node to reconnect -- we're done!
-                        return;
-                    } catch (final Exception e) {
-                        logger.warn("Problem encountered issuing reconnection request to node " + node.getNodeId() + " due to: " + e);
-                        if (logger.isDebugEnabled()) {
-                            logger.warn("", e);
-                        }
-
-                        addBulletin(node, Severity.WARNING, "Problem encountered issuing reconnection request to node " + node.getNodeId() + " due to: " + e);
-                    }
-
-                    try {
-                        Thread.sleep(1000L * retrySeconds);
-                    } catch (final InterruptedException ie) {
-                        break;
-                    }
-                }
-
-                // We failed to reconnect 10 times. We must now mark node as disconnected.
-                writeLock.lock();
-                try {
-                    if (Status.CONNECTING == node.getStatus()) {
-                        requestDisconnectionQuietly(node.getNodeId(), "Failed to issue Reconnection Request " + reconnectionAttempts + " times");
-                    }
-                } finally {
-                    writeLock.unlock("Mark node as Disconnected as a result of reconnection failure");
-                }
-            }
-        }, "Reconnect " + node.getNodeId());
-
-        reconnectionThread.start();
-    }
-
-    private List<ReportingTaskNode> loadReportingTasks(final File taskConfigXml) {
-        final List<ReportingTaskNode> tasks = new ArrayList<>();
-        if (taskConfigXml == null) {
-            logger.info("No controller tasks to start");
-            return tasks;
-        }
-
-        try {
-            final URL schemaUrl = getClass().getResource("/ReportingTaskConfiguration.xsd");
-            final Document document = parse(taskConfigXml, schemaUrl);
-
-            final NodeList tasksNodes = document.getElementsByTagName("tasks");
-            final Element tasksElement = (Element) tasksNodes.item(0);
-
-            //optional properties for all ReportingTasks
-            for (final Element taskElement : DomUtils.getChildElementsByTagName(tasksElement, "task")) {
-                //add global properties common to all tasks
-                Map<String, String> properties = new HashMap<>();
-
-                //get properties for the specific reporting task - id, name, class,
-                //and schedulingPeriod must be set
-                final String taskId = DomUtils.getChild(taskElement, "id").getTextContent().trim();
-                final String taskName = DomUtils.getChild(taskElement, "name").getTextContent().trim();
-
-                final List<Element> schedulingStrategyNodeList = DomUtils.getChildElementsByTagName(taskElement, "schedulingStrategy");
-                String schedulingStrategyValue = SchedulingStrategy.TIMER_DRIVEN.name();
-                if (schedulingStrategyNodeList.size() == 1) {
-                    final String specifiedValue = schedulingStrategyNodeList.get(0).getTextContent();
-
-                    try {
-                        schedulingStrategyValue = SchedulingStrategy.valueOf(specifiedValue).name();
-                    } catch (final Exception e) {
-                        throw new RuntimeException("Cannot start Reporting Task with id " + taskId + " because its Scheduling Strategy does not have a valid value", e);
-                    }
-                }
-
-                final SchedulingStrategy schedulingStrategy = SchedulingStrategy.valueOf(schedulingStrategyValue);
-                final String taskSchedulingPeriod = DomUtils.getChild(taskElement, "schedulingPeriod").getTextContent().trim();
-                final String taskClass = DomUtils.getChild(taskElement, "class").getTextContent().trim();
-
-                //optional task-specific properties
-                for (final Element optionalProperty : DomUtils.getChildElementsByTagName(taskElement, "property")) {
-                    final String name = optionalProperty.getAttribute("name");
-                    final String value = optionalProperty.getTextContent().trim();
-                    properties.put(name, value);
-                }
-
-                //set the class to be used for the configured reporting task
-                final ReportingTaskNode reportingTaskNode;
-                try {
-                    reportingTaskNode = createReportingTask(taskClass, taskId);
-                } catch (final ReportingTaskInstantiationException e) {
-                    logger.error("Unable to load reporting task {} due to {}", new Object[]{taskId, e});
-                    if (logger.isDebugEnabled()) {
-                        logger.error("", e);
-                    }
-                    continue;
-                }
-
-                final ReportingTask reportingTask = reportingTaskNode.getReportingTask();
-
-                final ReportingInitializationContext config = new StandardReportingInitializationContext(taskId, taskName, schedulingStrategy, taskSchedulingPeriod, this);
-                reportingTask.initialize(config);
-
-                final Map<PropertyDescriptor, String> resolvedProps;
-                try (final NarCloseable narCloseable = NarCloseable.withNarLoader()) {
-                    resolvedProps = new HashMap<>();
-                    for (final Map.Entry<String, String> entry : properties.entrySet()) {
-                        final PropertyDescriptor descriptor = reportingTask.getPropertyDescriptor(entry.getKey());
-                        resolvedProps.put(descriptor, entry.getValue());
-                    }
-                }
-
-                for (final Map.Entry<PropertyDescriptor, String> entry : resolvedProps.entrySet()) {
-                    reportingTaskNode.setProperty(entry.getKey().getName(), entry.getValue());
-                }
-
-                processScheduler.schedule(reportingTaskNode);
-                tasks.add(reportingTaskNode);
-            }
-        } catch (final SAXException | ParserConfigurationException | IOException | DOMException | NumberFormatException | InitializationException t) {
-            logger.error("Unable to load reporting tasks from {} due to {}", new Object[]{taskConfigXml, t});
-            if (logger.isDebugEnabled()) {
-                logger.error("", t);
-            }
-        }
-
-        return tasks;
-    }
-
-    private ReportingTaskNode createReportingTask(final String type, final String id) throws ReportingTaskInstantiationException {
-        if (type == null) {
-            throw new NullPointerException();
-        }
-        ReportingTask task = null;
-        final ClassLoader ctxClassLoader = Thread.currentThread().getContextClassLoader();
-        try {
-            final ClassLoader detectedClassLoader = ExtensionManager.getClassLoader(type);
-            final Class<?> rawClass;
-            if (detectedClassLoader == null) {
-                rawClass = Class.forName(type);
-            } else {
-                rawClass = Class.forName(type, false, detectedClassLoader);
-            }
-
-            Thread.currentThread().setContextClassLoader(detectedClassLoader);
-            final Class<? extends ReportingTask> reportingTaskClass = rawClass.asSubclass(ReportingTask.class);
-            final Object reportingTaskObj = reportingTaskClass.newInstance();
-            task = reportingTaskClass.cast(reportingTaskObj);
-        } catch (final ClassNotFoundException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException t) {
-            throw new ReportingTaskInstantiationException(type, t);
-        } finally {
-            if (ctxClassLoader != null) {
-                Thread.currentThread().setContextClassLoader(ctxClassLoader);
-            }
-        }
-
-        final ValidationContextFactory validationContextFactory = new StandardValidationContextFactory(this);
-        final ReportingTaskNode taskNode = new ClusteredReportingTaskNode(task, id, processScheduler,
-                new ClusteredEventAccess(this), bulletinRepository, controllerServiceProvider, validationContextFactory);
-        return taskNode;
-    }
-
-    private Document parse(final File xmlFile, final URL schemaUrl) throws SAXException, ParserConfigurationException, IOException {
-        final SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
-        final Schema schema = schemaFactory.newSchema(schemaUrl);
-        final DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
-        docFactory.setSchema(schema);
-        final DocumentBuilder builder = docFactory.newDocumentBuilder();
-
-        builder.setErrorHandler(new org.xml.sax.ErrorHandler() {
-            @Override
-            public void fatalError(final SAXParseException err) throws SAXException {
-                logger.error("Config file line " + err.getLineNumber() + ", col " + err.getColumnNumber() + ", uri " + err.getSystemId() + " :message: " + err.getMessage());
-                if (logger.isDebugEnabled()) {
-                    logger.error("Error Stack Dump", err);
-                }
-                throw err;
-            }
-
-            @Override
-            public void error(final SAXParseException err) throws SAXParseException {
-                logger.error("Config file line " + err.getLineNumber() + ", col " + err.getColumnNumber() + ", uri " + err.getSystemId() + " :message: " + err.getMessage());
-                if (logger.isDebugEnabled()) {
-                    logger.error("Error Stack Dump", err);
-                }
-                throw err;
-            }
-
-            @Override
-            public void warning(final SAXParseException err) throws SAXParseException {
-                logger.warn(" Config file line " + err.getLineNumber() + ", uri " + err.getSystemId() + " : message : " + err.getMessage());
-                if (logger.isDebugEnabled()) {
-                    logger.warn("Warning stack dump", err);
-                }
-                throw err;
-            }
-        });
-
-        // build the docuemnt
-        final Document document = builder.parse(xmlFile);
-
-        // ensure schema compliance
-        final Validator validator = schema.newValidator();
-        validator.validate(new DOMSource(document));
-
-        return document;
-    }
-
-    private void addBulletin(final Node node, final Severity severity, final String msg) {
-        addBulletin(node.getNodeId(), severity, msg);
-    }
-
-    private void addBulletin(final NodeIdentifier nodeId, final Severity severity, final String msg) {
-        bulletinRepository.addBulletin(BulletinFactory.createBulletin(BULLETIN_CATEGORY, severity.toString(),
-                nodeId.getApiAddress() + ":" + nodeId.getApiPort() + " -- " + msg));
-    }
-
-    /**
-     * Services a disconnection request.
-     *
-     * @param nodeId a node identifier
-     * @param userDn the DN of the user requesting the disconnection
-     *
-     * @throws UnknownNodeException if the node does not exist
-     * @throws IllegalNodeDisconnectionException if the node cannot be
-     * disconnected due to the cluster's state (e.g., node is last connected
-     * node or node is primary)
-     * @throws NodeDisconnectionException if the disconnection message fails to
-     * be sent.
-     */
-    @Override
-    public void requestDisconnection(final String nodeId, final String userDn) throws UnknownNodeException, IllegalNodeDisconnectionException, NodeDisconnectionException {
-        writeLock.lock();
-        try {
-            // check that the node is known
-            final Node node = getNode(nodeId);
-            if (node == null) {
-                throw new UnknownNodeException("Node does not exist.");
-            }
-            requestDisconnection(node.getNodeId(), /* ignore last node */ false, "User " + userDn + " Disconnected Node");
-        } finally {
-            writeLock.unlock("requestDisconnection(String)");
-        }
-    }
-
-    /**
-     * Requests a disconnection to the node with the given node ID, but any
-     * exception thrown is suppressed.
-     *
-     * @param nodeId the node ID
-     */
-    private void requestDisconnectionQuietly(final NodeIdentifier nodeId, final String explanation) {
-        try {
-            requestDisconnection(nodeId, /* ignore node check */ true, explanation);
-        } catch (final IllegalNodeDisconnectionException | NodeDisconnectionException ex) { /* suppress exception */ }
-    }
-
-    /**
-     * Issues a disconnection message to the node identified by the given node
-     * ID. If the node is not known, then a UnknownNodeException is thrown. If
-     * the node cannot be disconnected due to the cluster's state and
-     * ignoreLastNodeCheck is false, then a IllegalNodeDisconnectionException is
-     * thrown. Otherwise, a disconnection message is issued to the node.
-     *
-     * Whether the disconnection message is successfully sent to the node, the
-     * node is marked as disconnected and if the node is the primary node, then
-     * the primary role is revoked.
-     *
-     * @param nodeId the ID of the node
-     * @param ignoreNodeChecks if false, checks will be made to ensure the
-     * cluster supports the node's disconnection (e.g., the node is not the last
-     * connected node in the cluster; the node is not the primary); otherwise,
-     * the request is made regardless of the cluster state
-     * @param explanation
-     *
-     * @throws IllegalNodeDisconnectionException if the node cannot be
-     * disconnected due to the cluster's state (e.g., node is last connected
-     * node or node is primary). Not thrown if ignoreNodeChecks is true.
-     * @throws NodeDisconnectionException if the disconnection message fails to
-     * be sent.
-     */
-    private void requestDisconnection(final NodeIdentifier nodeId, final boolean ignoreNodeChecks, final String explanation)
-            throws IllegalNodeDisconnectionException, NodeDisconnectionException {
-
-        writeLock.lock();
-        try {
-
-            // check that the node is known
-            final Node node = getRawNode(nodeId.getId());
-            if (node == null) {
-                if (ignoreNodeChecks) {
-                    // issue the disconnection
-                    final DisconnectMessage request = new DisconnectMessage();
-                    request.setNodeId(nodeId);
-                    request.setExplanation(explanation);
-
-                    addEvent(nodeId, "Disconnection requested due to " + explanation);
-                    senderListener.disconnect(request);
-                    addEvent(nodeId, "Node disconnected due to " + explanation);
-                    addBulletin(nodeId, Severity.INFO, "Node disconnected due to " + explanation);
-                    return;
-                } else {
-                    throw new UnknownNodeException("Node does not exist");
-                }
-            }
-
-            // if necessary, check that the node may be disconnected
-            if (!ignoreNodeChecks) {
-                final Set<NodeIdentifier> connectedNodes = getNodeIds(Status.CONNECTED);
-                // cannot disconnect the last connected node in the cluster
-                if (connectedNodes.size() == 1 && connectedNodes.iterator().next().equals(nodeId)) {
-                    throw new IllegalNodeDisconnectionException("Node may not be disconnected because it is the only connected node in the cluster.");
-                } else if (isPrimaryNode(nodeId)) {
-                    // cannot disconnect the primary node in the cluster
-                    throw new IllegalNodeDisconnectionException("Node may not be disconnected because it is the primary node in the cluster.");
-                }
-            }
-
-            // update status
-            node.setStatus(Status.DISCONNECTED);
-            notifyDataFlowManagementServiceOfNodeStatusChange();
-
-            // issue the disconnection
-            final DisconnectMessage request = new DisconnectMessage();
-            request.setNodeId(nodeId);
-            request.setExplanation(explanation);
-
-            addEvent(nodeId, "Disconnection requested due to " + explanation);
-            senderListener.disconnect(request);
-            addEvent(nodeId, "Node disconnected due to " + explanation);
-            addBulletin(node, Severity.INFO, "Node disconnected due to " + explanation);
-        } finally {
-            writeLock.unlock("requestDisconnection(NodeIdentifier, boolean)");
-        }
-    }
-
-    /**
-     * Messages the node to have the primary role. If the messaging fails, then
-     * the node is marked as disconnected.
-     *
-     * @param nodeId the node ID to assign primary role
-     *
-     * @return true if primary role assigned; false otherwise
-     */
-    private boolean assignPrimaryRole(final NodeIdentifier nodeId) {
-        writeLock.lock();
-        try {
-            // create primary role message
-            final PrimaryRoleAssignmentMessage msg = new PrimaryRoleAssignmentMessage();
-            msg.setNodeId(nodeId);
-            msg.setPrimary(true);
-            logger.info("Attempting to assign primary role to node: " + nodeId);
-
-            // message 
-            senderListener.assignPrimaryRole(msg);
-
-            logger.info("Assigned primary role to node: " + nodeId);
-            addBulletin(nodeId, Severity.INFO, "Node assigned primary role");
-
-            // true indicates primary role assigned
-            return true;
-
-        } catch (final ProtocolException ex) {
-
-            logger.warn("Failed attempt to assign primary role to node " + nodeId + " due to " + ex);
-            addBulletin(nodeId, Severity.ERROR, "Failed to assign primary role to node due to: " + ex);
-
-            // mark node as disconnected and log/record the event
-            final Node node = getRawNode(nodeId.getId());
-            node.setStatus(Status.DISCONNECTED);
-            addEvent(node.getNodeId(), "Disconnected because of failed attempt to assign primary role.");
-
-            addBulletin(nodeId, Severity.WARNING, "Node disconnected because of failed attempt to assign primary role");
-
-            // false indicates primary role failed to be assigned
-            return false;
-        } finally {
-            writeLock.unlock("assignPrimaryRole");
-        }
-    }
-
-    /**
-     * Messages the node with the given node ID to no longer have the primary
-     * role. If the messaging fails, then the node is marked as disconnected.
-     *
-     * @return true if the primary role was revoked from the node; false
-     * otherwise
-     */
-    private boolean revokePrimaryRole(final NodeIdentifier nodeId) {
-        writeLock.lock();
-        try {
-            // create primary role message
-            final PrimaryRoleAssignmentMessage msg = new PrimaryRoleAssignmentMessage();
-            msg.setNodeId(nodeId);
-            msg.setPrimary(false);
-            logger.info("Attempting to revoke primary role from node: " + nodeId);
-
-            // send message
-            senderListener.assignPrimaryRole(msg);
-
-            logger.info("Revoked primary role from node: " + nodeId);
-            addBulletin(nodeId, Severity.INFO, "Primary Role revoked from node");
-
-            // true indicates primary role was revoked
-            return true;
-        } catch (final ProtocolException ex) {
-
-            logger.warn("Failed attempt to revoke primary role from node " + nodeId + " due to " + ex);
-
-            // mark node as disconnected and log/record the event
-            final Node node = getRawNode(nodeId.getId());
-            node.setStatus(Status.DISCONNECTED);
-            addEvent(node.getNodeId(), "Disconnected because of failed attempt to revoke primary role.");
-            addBulletin(node, Severity.ERROR, "Node disconnected because of failed attempt to revoke primary role");
-
-            // false indicates primary role failed to be revoked
-            return false;
-        } finally {
-            writeLock.unlock("revokePrimaryRole");
-        }
-    }
-
-    private NodeIdentifier addRequestorDn(final NodeIdentifier nodeId, final String dn) {
-        return new NodeIdentifier(nodeId.getId(), nodeId.getApiAddress(),
-                nodeId.getApiPort(), nodeId.getSocketAddress(), nodeId.getSocketPort(), dn);
-    }
-
-    private ConnectionResponseMessage handleConnectionRequest(final ConnectionRequestMessage requestMessage) {
-        final NodeIdentifier proposedIdentifier = requestMessage.getConnectionRequest().getProposedNodeIdentifier();
-        final ConnectionRequest requestWithDn = new ConnectionRequest(addRequestorDn(proposedIdentifier, requestMessage.getRequestorDN()));
-
-        final ConnectionResponse response = requestConnection(requestWithDn);
-        final ConnectionResponseMessage responseMessage = new ConnectionResponseMessage();
-        responseMessage.setConnectionResponse(response);
-        return responseMessage;
-    }
-
-    private void handleControllerStartupFailure(final ControllerStartupFailureMessage msg) {
-        writeLock.lock();
-        try {
-            final Node node = getRawNode(msg.getNodeId().getId());
-            if (node != null) {
-                node.setStatus(Status.DISCONNECTED);
-                addEvent(msg.getNodeId(), "Node could not join cluster because it failed to start up properly. Setting node to Disconnected. Node reported the following error: " + msg.getExceptionMessage());
-                addBulletin(node, Severity.ERROR, "Node could not join cluster because it failed to start up properly. Setting node to Disconnected. Node reported the following error: " + msg.getExceptionMessage());
-            }
-        } finally {
-            writeLock.unlock("handleControllerStartupFailure");
-        }
-    }
-
-    private void handleReconnectionFailure(final ReconnectionFailureMessage msg) {
-        writeLock.lock();
-        try {
-            final Node node = getRawNode(msg.getNodeId().getId());
-            if (node != null) {
-                node.setStatus(Status.DISCONNECTED);
-                final String errorMsg = "Node could not rejoin cluster. Setting node to Disconnected. Node reported the following error: " + msg.getExceptionMessage();
-                addEvent(msg.getNodeId(), errorMsg);
-                addBulletin(node, Severity.ERROR, errorMsg);
-            }
-        } finally {
-            writeLock.unlock("handleControllerStartupFailure");
-        }
-    }
-
-
-    @Override
-    public ControllerService getControllerService(String serviceIdentifier) {
-        return controllerServiceProvider.getControllerService(serviceIdentifier);
-    }
-
-    @Override
-    public ControllerServiceNode getControllerServiceNode(final String id) {
-        return controllerServiceProvider.getControllerServiceNode(id);
-    }
-
-    @Override
-    public boolean isControllerServiceEnabled(final ControllerService service) {
-        return controllerServiceProvider.isControllerServiceEnabled(service);
-    }
-
-    @Override
-    public boolean isControllerServiceEnabled(final String serviceIdentifier) {
-        return controllerServiceProvider.isControllerServiceEnabled(serviceIdentifier);
-    }
-
-    @Override
-    public ControllerServiceNode createControllerService(final String type, final String id, final boolean firstTimeAdded) {
-        return controllerServiceProvider.createControllerService(type, id, firstTimeAdded);
-    }
-    
-    @Override
-    public void removeControllerService(final ControllerServiceNode serviceNode) {
-        controllerServiceProvider.removeControllerService(serviceNode);
-    }
-    
-
-    @Override
-    public void enableControllerService(final ControllerServiceNode serviceNode) {
-        controllerServiceProvider.enableControllerService(serviceNode);
-    }
-    
-    @Override
-    public void disableControllerService(final ControllerServiceNode serviceNode) {
-        controllerServiceProvider.disableControllerService(serviceNode);
-    }
-    
-    
-    /**
-     * Handle a bulletins message.
-     *
-     * @param bulletins
-     */
-    public void handleBulletins(final NodeBulletins bulletins) {
-        final NodeIdentifier nodeIdentifier = bulletins.getNodeIdentifier();
-        final String nodeAddress = nodeIdentifier.getApiAddress() + ":" + nodeIdentifier.getApiPort();
-
-        // unmarshal the message
-        BulletinsPayload payload = BulletinsPayload.unmarshal(bulletins.getPayload());
-        for (final Bulletin bulletin : payload.getBulletins()) {
-            bulletin.setNodeAddress(nodeAddress);
-            bulletinRepository.addBulletin(bulletin);
-        }
-    }
-
-    /**
-     * Handles a node's heartbeat. If this heartbeat is a node's first heartbeat
-     * since its connection request, then the manager will mark the node as
-     * connected. If the node was previously disconnected due to a lack of
-     * heartbeat, then a reconnection request is issued. If the node was
-     * disconnected for other reasons, then a disconnection request is issued.
-     * If this instance is configured with a firewall and the heartbeat is
-     * blocked, then a disconnection request is issued.
-     *
-     * @param heartbeat
-     */
-    @Override
-    public void handleHeartbeat(final Heartbeat heartbeat) {
-        // sanity check heartbeat
-        if (heartbeat == null) {
-            throw new IllegalArgumentException("Heartbeat may not be null.");
-        } else if (heartbeat.getNodeIdentifier() == null) {
-            throw new IllegalArgumentException("Heartbeat does not contain a node ID.");
-        }
-
-        /*
-         * Processing a heartbeat requires a write lock, which may take a while
-         * to obtain.  Only the last heartbeat is necessary to process per node.
-         * Futhermore, since many could pile up, heartbeats are processed in 
-         * bulk.
-         * 
-         * The below queue stores the pending heartbeats.
-         */
-        pendingHeartbeats.add(heartbeat);
-    }
-
-    private void processPendingHeartbeats() {
-        Node node;
-
-        writeLock.lock();
-        try {
-            /*
-             * Get the most recent heartbeats for the nodes in the cluster.  This
-             * is achieved by "draining" the pending heartbeats queue, populating
-             * a map that associates a node identifier with its latest heartbeat, and
-             * finally, getting the values of the map.
-             */
-            final Map<NodeIdentifier, Heartbeat> mostRecentHeartbeatsMap = new HashMap<>();
-            Heartbeat aHeartbeat;
-            while ((aHeartbeat = pendingHeartbeats.poll()) != null) {
-                mostRecentHeartbeatsMap.put(aHeartbeat.getNodeIdentifier(), aHeartbeat);
-            }
-            final Collection<Heartbeat> mostRecentHeartbeats = new ArrayList<>(mostRecentHeartbeatsMap.values());
-
-            // return fast if no work to do
-            if (mostRecentHeartbeats.isEmpty()) {
-                return;
-            }
-
-            logNodes("Before Heartbeat Processing", heartbeatLogger);
-
-            final int numPendingHeartbeats = mostRecentHeartbeats.size();
-            if (heartbeatLogger.isDebugEnabled()) {
-                heartbeatLogger.debug(String.format("Handling %s heartbeat%s", numPendingHeartbeats, (numPendingHeartbeats > 1) ? "s" : ""));
-            }
-
-            for (final Heartbeat mostRecentHeartbeat : mostRecentHeartbeats) {
-                try {
-                    // resolve the proposed node identifier to valid node identifier
-                    final NodeIdentifier resolvedNodeIdentifier = resolveProposedNodeIdentifier(mostRecentHeartbeat.getNodeIdentifier());
-
-                    // get a raw reference to the node (if it doesn't exist, node will be null)
-                    node = getRawNode(resolvedNodeIdentifier.getId());
-
-                    // if the node thinks it has the primary role, but the manager has assigned the role to a different node, then revoke the role
-                    if (mostRecentHeartbeat.isPrimary() && !isPrimaryNode(resolvedNodeIdentifier)) {
-                        addEvent(resolvedNodeIdentifier, "Heartbeat indicates node is running as primary node.  Revoking primary role because primary role is assigned to a different node.");
-                        revokePrimaryRole(resolvedNodeIdentifier);
-                    }
-
-                    final boolean heartbeatIndicatesNotYetConnected = !mostRecentHeartbeat.isConnected();
-
-                    if (isBlockedByFirewall(resolvedNodeIdentifier.getSocketAddress())) {
-                        if (node == null) {
-                            logger.info("Firewall blocked heartbeat received from unknown node " + resolvedNodeIdentifier + ".  Issuing disconnection request.");
-                        } else {
-                            // record event
-                            addEvent(resolvedNodeIdentifier, "Firewall blocked received heartbeat.  Issuing disconnection request.");
-                        }
-
-                        // request node to disconnect
-                        requestDisconnectionQuietly(resolvedNodeIdentifier, "Blocked By Firewall");
-
-                    } else if (node == null) {  // unknown node, so issue reconnect request
-                        // create new node and add to node set
-                        final Node newNode = new Node(resolvedNodeIdentifier, Status.DISCONNECTED);
-                        nodes.add(newNode);
-
-                        // record event
-                        addEvent(newNode.getNodeId(), "Received heartbeat from unknown node.  Issuing reconnection request.");
-
-                        // record heartbeat
-                        newNode.setHeartbeat(mostRecentHeartbeat);
-                        requestReconnection(resolvedNodeIdentifier.getId(), "NCM Heartbeat Processing");
-                    } else if (heartbeatIndicatesNotYetConnected) {
-                        if (Status.CONNECTED == node.getStatus()) {
-                            // record event
-                            addEvent(node.getNodeId(), "Received heartbeat from node that thinks it is not yet part of the cluster, though the Manager thought it was. Marking as Disconnected and issuing reconnection request.");
-
-                            // record heartbeat
-                            node.setHeartbeat(null);
-                            node.setStatus(Status.DISCONNECTED);
-
-                            requestReconnection(resolvedNodeIdentifier.getId(), "NCM Heartbeat Processing");
-                        }
-                    } else if (Status.DISCONNECTED == node.getStatus()) {
-                        // ignore heartbeats from nodes disconnected by means other than lack of heartbeat, unless it is
-                        // the only node. We allow it if it is the only node because if we have a one-node cluster, then
-                        // we cannot manually reconnect it.
-                        if (node.isHeartbeatDisconnection() || nodes.size() == 1) {
-                            // record event
-                            if (node.isHeartbeatDisconnection()) {
-                                addEvent(resolvedNodeIdentifier, "Received heartbeat from node previously disconnected due to lack of heartbeat.  Issuing reconnection request.");
-                            } else {
-                                addEvent(resolvedNodeIdentifier, "Received heartbeat from node previously disconnected, but it is the only known node, so issuing reconnection request.");
-                            }
-
-                            // record heartbeat
-                            node.setHeartbeat(mostRecentHeartbeat);
-
-                            // request reconnection
-                            requestReconnection(resolvedNodeIdentifier.getId(), "NCM Heartbeat Processing");
-                        } else {
-                            // disconnected nodes should not heartbeat, so we need to issue a disconnection request
-                            heartbeatLogger.info("Ignoring received heartbeat from disconnected node " + resolvedNodeIdentifier + ".  Issuing disconnection request.");
-
-                            // request node to disconnect
-                            requestDisconnectionQuietly(resolvedNodeIdentifier, "Received Heartbeat from Node, but Manager has already marked Node as Disconnected");
-                        }
-
-                    } else if (Status.DISCONNECTING == node.getStatus()) {
-                        /* ignore spurious heartbeat */
-                    } else {  // node is either either connected or connecting
-                        // first heartbeat causes status change from connecting to connected
-                        if (Status.CONNECTING == node.getStatus()) {
-                            if (mostRecentHeartbeat.getCreatedTimestamp() < node.getConnectionRequestedTimestamp()) {
-                                heartbeatLogger.info("Received heartbeat for node " + resolvedNodeIdentifier + " but ignoring because it was generated before the node was last asked to reconnect.");
-                                continue;
-                            }
-
-                            // set status to connected
-                            node.setStatus(Status.CONNECTED);
-
-                            // record event
-                            addEvent(resolvedNodeIdentifier, "Received first heartbeat from connecting node.  Setting node to connected.");
-
-                            // notify service of updated node set
-                            notifyDataFlowManagementServiceOfNodeStatusChange();
-
-                            addBulletin(node, Severity.INFO, "Node Connected");
-                        } else {
-                            heartbeatLogger.info("Received heartbeat for node " + resolvedNodeIdentifier + ".");
-                        }
-
-                        // record heartbeat
-                        node.setHeartbeat(mostRecentHeartbeat);
-
-                        ComponentStatusRepository statusRepository = componentMetricsRepositoryMap.get(node.getNodeId());
-                        if (statusRepository == null) {
-                            statusRepository = createComponentStatusRepository();
-                            componentMetricsRepositoryMap.put(node.getNodeId(), statusRepository);
-                        }
-
-                        // If it's been a while since we've captured, capture this metric.
-                        final Date lastCaptureDate = statusRepository.getLastCaptureDate();
-                        final long millisSinceLastCapture = (lastCaptureDate == null) ? Long.MAX_VALUE : (System.currentTimeMillis() - lastCaptureDate.getTime());
-
-                        if (millisSinceLastCapture > componentStatusSnapshotMillis) {
-                            statusRepository.capture(node.getHeartbeatPayload().getProcessGroupStatus());
-                        }
-                    }
-                } catch (final Exception e) {
-                    logger.error("Failed to process heartbeat from {}:{} due to {}", mostRecentHeartbeat.getNodeIdentifier().getApiAddress(), mostRecentHeartbeat.getNodeIdentifier().getApiPort(), e.toString());
-                    if (logger.isDebugEnabled()) {
-                        logger.error("", e);
-                    }
-                }
-            }
-
-            logNodes("After Heartbeat Processing", heartbeatLogger);
-        } finally {
-            writeLock.unlock("processPendingHeartbeats");
-        }
-    }
-
-    private ComponentStatusRepository createComponentStatusRepository() {
-        final String implementationClassName = properties.getProperty(NiFiProperties.COMPONENT_STATUS_REPOSITORY_IMPLEMENTATION, DEFAULT_COMPONENT_STATUS_REPO_IMPLEMENTATION);
-        if (implementationClassName == null) {
-            throw new RuntimeException("Cannot create Component Status Repository because the NiFi Properties is missing the following property: "
-                    + NiFiProperties.COMPONENT_STATUS_REPOSITORY_IMPLEMENTATION);
-        }
-
-        try {
-            return NarThreadContextClassLoader.createInstance(implementationClassName, ComponentStatusRepository.class);
-        } catch (final Exception e) {
-            throw new RuntimeException(e);
-        }
-    }
-
-    @Override
-    public Set<Node> getNodes(final Status... statuses) {
-        final Set<Status> desiredStatusSet = new HashSet<>();
-        for (final Status status : statuses) {
-            desiredStatusSet.add(status);
-        }
-
-        readLock.lock();
-        try {
-            final Set<Node> clonedNodes = new HashSet<>();
-            for (final Node node : nodes) {
-                if (desiredStatusSet.isEmpty() || desiredStatusSet.contains(node.getStatus())) {
-                    clonedNodes.add(node.clone());
-                }
-            }
-            return Collections.unmodifiableSet(clonedNodes);
-        } finally {
-            readLock.unlock("getNodes(Status...)");
-        }
-    }
-
-    @Override
-    public Node getNode(final String nodeId) {
-        readLock.lock();
-        try {
-            for (final Node node : nodes) {
-                if (node.getNodeId().getId().equals(nodeId)) {
-                    return node.clone();
-                }
-            }
-            return null;
-        } finally {
-            readLock.unlock("getNode(String)");
-        }
-    }
-
-    @Override
-    public Node getPrimaryNode() {
-        readLock.lock();
-        try {
-            if (primaryNodeId == null) {
-                return null;
-            } else {
-                return getNode(primaryNodeId.getId());
-            }
-        } finally {
-            readLock.unlock("getPrimaryNode");
-        }
-    }
-
-    @Override
-    public void deleteNode(final String nodeId, final String userDn) throws UnknownNodeException, IllegalNodeDeletionException {
-        writeLock.lock();
-        try {
-            final Node node = getNode(nodeId);
-            if (node == null) {
-                throw new UnknownNodeException("Node does not exist.");
-            } else if (Status.DISCONNECTED == node.getStatus()) {
-                nodes.remove(node);
-
-                if (eventManager != null) {
-                    eventManager.clearEventHistory(node.getNodeId().getId());
-                }
-
-                logger.info("Removing node {} from cluster because this action was requested by {}", node, userDn);
-            } else {
-                throw new IllegalNodeDeletionException("Node may not be deleted because it is not disconnected.");
-            }
-        } finally {
-            writeLock.unlock("deleteNode");
-        }
-    }
-
-    @Override
-    public Set<NodeIdentifier> getNodeIds(final Status... statuses) {
-        readLock.lock();
-        try {
-            final Set<NodeIdentifier> nodeIds = new HashSet<>();
-            for (final Node node : nodes) {
-                if (statuses == null || statuses.length == 0) {
-                    nodeIds.add(node.getNodeId());
-                } else {
-                    for (final Node.Status status : statuses) {
-                        if (node.getStatus() == status) {
-                            nodeIds.add(node.getNodeId());
-                            break;
-                        }
-                    }
-                }
-            }
-            return nodeIds;
-        } finally {
-            readLock.unlock("getNodeIds(Status...)");
-        }
-    }
-
-    @Override
-    public void setPrimaryNode(final String nodeId, final String userDn) throws UnknownNodeException, IneligiblePrimaryNodeException, PrimaryRoleAssignmentException {
-        writeLock.lock();
-        try {
-
-            final Node node = getNode(nodeId);
-            if (node == null) {
-                throw new UnknownNodeException("Node does not exist.");
-            } else if (Status.CONNECTED != node.getStatus()) {
-                throw new IneligiblePrimaryNodeException("Node must be connected before it can be assigned as the primary node.");
-            }
-
-            // revoke primary role
-            final Node primaryNode;
-            if ((primaryNode = getPrimaryNode()) != null) {
-                if (primaryNode.getStatus() == Status.DISCONNECTED) {
-                    throw new PrimaryRoleAssignmentException("A disconnected, primary node exists.  Delete the node before assigning the primary role to a different node.");
-                } else if (revokePrimaryRole(primaryNode.getNodeId())) {
-                    addEvent(primaryNode.getNodeId(), "Role revoked from this node as part of primary role reassignment.");
-                } else {
-                    throw new PrimaryRoleAssignmentException(
-                            "Failed to revoke primary role from node. Primary node is now disconnected. Delete the node before assigning the primary role to a different node.");
-                }
-            }
-
-            // change the primary node ID to the given node
-            setPrimaryNodeId(node.getNodeId());
-
-            // assign primary role
-            if (assignPrimaryRole(node.getNodeId())) {
-                addEvent(node.getNodeId(), "Role assigned to this node as part of primary role reassignment. Action performed by " + userDn);
-                addBulletin(node, Severity.INFO, "Primary Role assigned to node by " + userDn);
-            } else {
-                throw new PrimaryRoleAssignmentException(
-                        "Cluster manager assigned primary role to node, but the node failed to accept the assignment.  Cluster manager disconnected node.");
-            }
-        } finally {
-            writeLock.unlock("setPrimaryNode");
-        }
-    }
-
-    private int getClusterProtocolHeartbeatSeconds() {
-        return (int) FormatUtils.getTimeDuration(properties.getClusterProtocolHeartbeatInterval(), TimeUnit.SECONDS);
-    }
-
-    @Override
-    public int getHeartbeatMonitoringIntervalSeconds() {
-        return 4 * getClusterProtocolHeartbeatSeconds();
-    }
-
-    @Override
-    public int getMaxHeartbeatGapSeconds() {
-        return 8 * getClusterProtocolHeartbeatSeconds();
-    }
-
-    @Override
-    public List<Event> getNodeEvents(final String nodeId) {
-        readLock.lock();
-        try {
-            List<Event> events = null;
-            final EventManager eventMgr = eventManager;
-            if (eventMgr != null) {
-                events = eventMgr.getEvents(nodeId);
-            }
-
-            if (events == null) {
-                return Collections.emptyList();
-            } else {
-                return Collections.unmodifiableList(events);
-            }
-        } finally {
-            readLock.unlock("getNodeEvents");
-        }
-    }
-
-    @Override
-    public NodeResponse applyRequest(final String method, final URI uri, final Map<String, List<String>> parameters, final Map<String, String> headers)
-            throws NoConnectedNodesException, NoResponseFromNodesException, UriConstructionException, ConnectingNodeMutableRequestException, DisconnectedNodeMutableRequestException, SafeModeMutableRequestException {
-        return applyRequest(method, uri, parameters, headers, getNodeIds(Status.CONNECTED));
-    }
-
-    @Override
-    public NodeResponse applyRequest(final String method, final URI uri, final Map<String, List<String>> parameters, final Map<String, String> headers, final Set<NodeIdentifier> nodeIdentifiers)
-            throws NoConnectedNodesException, NoResponseFromNodesException, UriConstructionException, ConnectingNodeMutableRequestException, DisconnectedNodeMutableRequestException, SafeModeMutableRequestException {
-
-        final boolean mutableRequest = canChangeNodeState(method, uri);
-        final ClusterManagerLock lock = mutableRequest ? writeLock : readLock;
-
-        lock.lock();
-        try {
-            // check that the request can be applied
-            if (mutableRequest) {
-                if (isInSafeMode()) {
-                    throw new SafeModeMutableRequestException("Received a mutable request [" + method + " -- " + uri + "] while in safe mode");
-                } else if (!getNodeIds(Status.DISCONNECTED, Status.DISCONNECTING).isEmpty()) {
-                    throw new DisconnectedNodeMutableRequestException("Received a mutable request [" + method + " -- " + uri + "] while a node is disconnected from the cluster");
-                } else if (!getNodeIds(Status.CONNECTING).isEmpty()) {
-                    // if any node is connecting and a request can change the flow, then we throw an exception
-                    throw new ConnectingNodeMutableRequestException("Received a mutable request [" + method + " -- " + uri + "] while a node is trying to connect to the cluster");
-                }
-            }
-
-            final NodeResponse clientResponse = federateRequest(method, uri, parameters, null, headers, nodeIdentifiers);
-            if (clientResponse == null) {
-                if (mutableRequest) {
-                    throw new NoConnectedNodesException(String.format("All nodes were disconnected as a result of applying request %s %s", method, uri));
-                } else {
-                    throw new NoResponseFromNodesException("No nodes were able to process this request.");
-                }
-            } else {
-                return clientResponse;
-            }
-        } finally {
-            lock.unlock("applyRequest(String, URI, Map<String, List<String>>, Map<String

<TRUNCATED>

[09/20] incubator-nifi git commit: NIFI-410 pushed RAT exclusions down to the relevant modules and stopped doing broad test resource exclusion - is now specific

Posted by jo...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/CopyingInputStream.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/CopyingInputStream.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/CopyingInputStream.java
new file mode 100644
index 0000000..680df65
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/CopyingInputStream.java
@@ -0,0 +1,77 @@
+/*
+ * 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.nifi.cluster.protocol.impl;
+
+import java.io.ByteArrayOutputStream;
+import java.io.FilterInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+public class CopyingInputStream extends FilterInputStream {
+    private final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+    private final int maxBytesToCopy;
+    private final InputStream in;
+
+    public CopyingInputStream(final InputStream in, final int maxBytesToCopy) {
+        super(in);
+        this.maxBytesToCopy = maxBytesToCopy;
+        this.in = in;
+    }
+    
+    @Override
+    public int read() throws IOException {
+        final int delegateRead = in.read();
+        if ( delegateRead != -1 && getNumberOfBytesCopied() < maxBytesToCopy ) {
+            baos.write(delegateRead);
+        }
+        
+        return delegateRead;
+    }
+    
+    @Override
+    public int read(byte[] b) throws IOException {
+        final int delegateRead = in.read(b);
+        if ( delegateRead >= 0 ) {
+            baos.write(b, 0, Math.min(delegateRead, maxBytesToCopy - getNumberOfBytesCopied()));
+        }
+        
+        return delegateRead;
+    }
+    
+    @Override
+    public int read(byte[] b, int off, int len) throws IOException {
+        final int delegateRead = in.read(b, off, len);
+        if ( delegateRead >= 0 ) {
+            baos.write(b, off, Math.min(delegateRead, maxBytesToCopy - getNumberOfBytesCopied()));
+        }
+        
+        return delegateRead;
+    }
+    
+    public byte[] getBytesRead() {
+        return baos.toByteArray();
+    }
+    
+    public void writeBytes(final OutputStream out) throws IOException {
+        baos.writeTo(out);
+    }
+    
+    public int getNumberOfBytesCopied() {
+        return baos.size();
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/MulticastProtocolListener.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/MulticastProtocolListener.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/MulticastProtocolListener.java
new file mode 100644
index 0000000..d3764b3
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/MulticastProtocolListener.java
@@ -0,0 +1,204 @@
+/*
+ * 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.nifi.cluster.protocol.impl;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.net.DatagramPacket;
+import java.net.InetSocketAddress;
+import java.net.MulticastSocket;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.UUID;
+import java.util.concurrent.CopyOnWriteArrayList;
+import org.apache.nifi.io.socket.multicast.MulticastConfiguration;
+import org.apache.nifi.io.socket.multicast.MulticastListener;
+import org.apache.nifi.logging.NiFiLog;
+import org.apache.nifi.reporting.Bulletin;
+import org.apache.nifi.reporting.BulletinRepository;
+import org.apache.nifi.cluster.protocol.ProtocolContext;
+import org.apache.nifi.cluster.protocol.ProtocolException;
+import org.apache.nifi.cluster.protocol.ProtocolHandler;
+import org.apache.nifi.cluster.protocol.ProtocolListener;
+import org.apache.nifi.cluster.protocol.ProtocolMessageMarshaller;
+import org.apache.nifi.cluster.protocol.ProtocolMessageUnmarshaller;
+import org.apache.nifi.cluster.protocol.message.MulticastProtocolMessage;
+import org.apache.nifi.cluster.protocol.message.ProtocolMessage;
+import org.apache.nifi.events.BulletinFactory;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Implements a listener for protocol messages sent over multicast.  If a message
+ * is of type MulticastProtocolMessage, then the underlying protocol message is
+ * passed to the handler.  If the receiving handler produces a message response,
+ * then the message is wrapped with a MulticastProtocolMessage before being 
+ * sent to the originator.
+ * 
+ * The client caller is responsible for starting and stopping the listener.
+ * The instance must be stopped before termination of the JVM to ensure proper
+ * resource clean-up.
+ * 
+ * @author unattributed
+ */
+public class MulticastProtocolListener extends MulticastListener implements ProtocolListener {
+    
+    private static final Logger logger = new NiFiLog(LoggerFactory.getLogger(MulticastProtocolListener.class));
+
+    // immutable members
+    private final Collection<ProtocolHandler> handlers = new CopyOnWriteArrayList<>();
+    private final String listenerId = UUID.randomUUID().toString();
+    private final ProtocolContext<ProtocolMessage> protocolContext;
+    private volatile BulletinRepository bulletinRepository;
+
+    public MulticastProtocolListener(
+            final int numThreads,
+            final InetSocketAddress multicastAddress,
+            final MulticastConfiguration configuration,
+            final ProtocolContext<ProtocolMessage> protocolContext) {
+
+        super(numThreads, multicastAddress, configuration);
+        
+        if (protocolContext == null) {
+            throw new IllegalArgumentException("Protocol Context may not be null.");
+        }
+        this.protocolContext = protocolContext;
+    }
+
+    @Override
+    public void setBulletinRepository(final BulletinRepository bulletinRepository) {
+        this.bulletinRepository = bulletinRepository;
+    }
+
+    @Override
+    public void start() throws IOException {
+
+        if(super.isRunning()) {
+            throw new IllegalStateException("Instance is already started.");
+        }
+        
+        super.start();
+        
+    }
+
+    @Override
+    public void stop() throws IOException {
+
+        if(super.isRunning() == false) {
+            throw new IllegalStateException("Instance is already stopped.");
+        }
+        
+        // shutdown listener
+        super.stop();
+
+    }
+
+    @Override
+    public Collection<ProtocolHandler> getHandlers() {
+        return Collections.unmodifiableCollection(handlers);
+    }
+
+    @Override
+    public void addHandler(final ProtocolHandler handler) {
+        if(handler == null) {
+            throw new NullPointerException("Protocol handler may not be null.");
+        }
+        handlers.add(handler);
+    }
+    
+    @Override
+    public boolean removeHandler(final ProtocolHandler handler) {
+        return handlers.remove(handler);
+    }
+    
+    @Override
+    public void dispatchRequest(final MulticastSocket multicastSocket, final DatagramPacket packet) {
+
+        try {
+
+            // unmarshall message
+            final ProtocolMessageUnmarshaller<ProtocolMessage> unmarshaller = protocolContext.createUnmarshaller();
+            final ProtocolMessage request = unmarshaller.unmarshal(new ByteArrayInputStream(packet.getData(), 0, packet.getLength()));
+
+            // unwrap multicast message, if necessary
+            final ProtocolMessage unwrappedRequest;
+            if(request instanceof MulticastProtocolMessage) {
+                final MulticastProtocolMessage multicastRequest = (MulticastProtocolMessage) request;
+                // don't process a message we sent
+                if(listenerId.equals(multicastRequest.getId())) {
+                    return;
+                } else {
+                    unwrappedRequest = multicastRequest.getProtocolMessage();
+                }
+            } else {
+                unwrappedRequest = request;
+            }
+            
+            // dispatch message to handler
+            ProtocolHandler desiredHandler = null;
+            for (final ProtocolHandler handler : getHandlers()) {
+                if (handler.canHandle(unwrappedRequest)) {
+                    desiredHandler = handler;
+                    break;
+                }
+            }
+
+            // if no handler found, throw exception; otherwise handle request
+            if (desiredHandler == null) {
+                throw new ProtocolException("No handler assigned to handle message type: " + request.getType());
+            } else {
+                final ProtocolMessage response = desiredHandler.handle(request);
+                if(response != null) {
+                    try {
+                        
+                        // wrap with listener id
+                        final MulticastProtocolMessage multicastResponse = new MulticastProtocolMessage(listenerId, response);
+                        
+                        // marshal message
+                        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+                        final ProtocolMessageMarshaller<ProtocolMessage> marshaller = protocolContext.createMarshaller();
+                        marshaller.marshal(multicastResponse, baos);
+                        final byte[] responseBytes = baos.toByteArray();
+                        
+                        final int maxPacketSizeBytes = getMaxPacketSizeBytes();
+                        if(responseBytes.length > maxPacketSizeBytes) {
+                            logger.warn("Cluster protocol handler '" + desiredHandler.getClass() + 
+                                "' produced a multicast response with length greater than configured max packet size '" + maxPacketSizeBytes + "'");
+                        }
+                        
+                        // create and send packet
+                        final DatagramPacket responseDatagram = new DatagramPacket(responseBytes, responseBytes.length, getMulticastAddress().getAddress(), getMulticastAddress().getPort()); 
+                        multicastSocket.send(responseDatagram);
+                        
+                    } catch (final IOException ioe) {
+                        throw new ProtocolException("Failed marshalling protocol message in response to message type: " + request.getType() + " due to: " + ioe, ioe);
+                    }
+                }
+            }
+
+        } catch (final Throwable t) {
+            logger.warn("Failed processing protocol message due to " + t, t);
+            
+            if ( bulletinRepository != null ) {
+                final Bulletin bulletin = BulletinFactory.createBulletin("Clustering", "WARNING", "Failed to process Protocol Message due to " + t.toString());
+                bulletinRepository.addBulletin(bulletin);
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/NodeProtocolSenderImpl.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/NodeProtocolSenderImpl.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/NodeProtocolSenderImpl.java
new file mode 100644
index 0000000..dc86d24
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/NodeProtocolSenderImpl.java
@@ -0,0 +1,171 @@
+/*
+ * 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.nifi.cluster.protocol.impl;
+
+import java.io.IOException;
+import java.net.Socket;
+
+import javax.net.ssl.SSLSocket;
+import javax.security.cert.X509Certificate;
+
+import org.apache.nifi.cluster.protocol.NodeProtocolSender;
+import org.apache.nifi.cluster.protocol.ProtocolContext;
+import org.apache.nifi.cluster.protocol.ProtocolException;
+import org.apache.nifi.cluster.protocol.ProtocolMessageMarshaller;
+import org.apache.nifi.cluster.protocol.ProtocolMessageUnmarshaller;
+import org.apache.nifi.cluster.protocol.UnknownServiceAddressException;
+import org.apache.nifi.cluster.protocol.message.ConnectionRequestMessage;
+import org.apache.nifi.cluster.protocol.message.ConnectionResponseMessage;
+import org.apache.nifi.cluster.protocol.message.ControllerStartupFailureMessage;
+import org.apache.nifi.cluster.protocol.message.HeartbeatMessage;
+import org.apache.nifi.cluster.protocol.message.NodeBulletinsMessage;
+import org.apache.nifi.cluster.protocol.message.ProtocolMessage;
+import org.apache.nifi.cluster.protocol.message.ProtocolMessage.MessageType;
+import org.apache.nifi.cluster.protocol.message.ReconnectionFailureMessage;
+import org.apache.nifi.io.socket.SocketConfiguration;
+import org.apache.nifi.io.socket.SocketUtils;
+import org.apache.nifi.io.socket.multicast.DiscoverableService;
+
+public class NodeProtocolSenderImpl implements NodeProtocolSender {
+    private final SocketConfiguration socketConfiguration;
+    private final ClusterServiceLocator clusterManagerProtocolServiceLocator;
+    private final ProtocolContext<ProtocolMessage> protocolContext;
+    
+    public NodeProtocolSenderImpl(final ClusterServiceLocator clusterManagerProtocolServiceLocator, 
+            final SocketConfiguration socketConfiguration, final ProtocolContext<ProtocolMessage> protocolContext) {
+        if(clusterManagerProtocolServiceLocator == null) {
+            throw new IllegalArgumentException("Protocol Service Locator may not be null.");
+        } else if(socketConfiguration == null) {
+            throw new IllegalArgumentException("Socket configuration may not be null.");
+        } else if(protocolContext == null) {
+            throw new IllegalArgumentException("Protocol Context may not be null.");
+        }
+        
+        this.clusterManagerProtocolServiceLocator = clusterManagerProtocolServiceLocator;
+        this.socketConfiguration = socketConfiguration;
+        this.protocolContext = protocolContext;
+    }
+    
+    
+    @Override
+    public ConnectionResponseMessage requestConnection(final ConnectionRequestMessage msg) throws ProtocolException, UnknownServiceAddressException {
+        Socket socket = null;
+        try {
+            socket = createSocket();
+            
+            String ncmDn = null;
+            if ( socket instanceof SSLSocket ) {
+                final SSLSocket sslSocket = (SSLSocket) socket;
+                try {
+                    final X509Certificate[] certChains = sslSocket.getSession().getPeerCertificateChain();
+                    if ( certChains != null && certChains.length > 0 ) {
+                        ncmDn = certChains[0].getSubjectDN().getName();
+                    }
+                } catch (final ProtocolException pe) {
+                    throw pe;
+                } catch (final Exception e) {
+                    throw new ProtocolException(e);
+                }
+            }
+            
+            try {
+                // marshal message to output stream
+                final ProtocolMessageMarshaller<ProtocolMessage> marshaller = protocolContext.createMarshaller();
+                marshaller.marshal(msg, socket.getOutputStream());
+            } catch(final IOException ioe) {
+                throw new ProtocolException("Failed marshalling '" + msg.getType() + "' protocol message due to: " + ioe, ioe);
+            } 
+            
+            final ProtocolMessage response;
+            try {
+                // unmarshall response and return
+                final ProtocolMessageUnmarshaller<ProtocolMessage> unmarshaller = protocolContext.createUnmarshaller();
+                response = unmarshaller.unmarshal(socket.getInputStream());
+            } catch(final IOException ioe) {
+                throw new ProtocolException("Failed unmarshalling '" + MessageType.CONNECTION_RESPONSE + "' protocol message due to: " + ioe, ioe);
+            } 
+            
+            if(MessageType.CONNECTION_RESPONSE == response.getType()) {
+                final ConnectionResponseMessage connectionResponse = (ConnectionResponseMessage) response;
+                connectionResponse.setClusterManagerDN(ncmDn);
+                return connectionResponse;
+            } else {
+                throw new ProtocolException("Expected message type '" + MessageType.CONNECTION_RESPONSE + "' but found '" + response.getType() + "'");
+            }
+        } finally {
+            SocketUtils.closeQuietly(socket);
+        }
+    }
+    
+    
+    @Override
+    public void heartbeat(final HeartbeatMessage msg) throws ProtocolException, UnknownServiceAddressException {
+        sendProtocolMessage(msg);
+    }
+
+    @Override
+    public void sendBulletins(NodeBulletinsMessage msg) throws ProtocolException, UnknownServiceAddressException {
+        sendProtocolMessage(msg);
+    }
+
+    @Override
+    public void notifyControllerStartupFailure(final ControllerStartupFailureMessage msg) throws ProtocolException, UnknownServiceAddressException {
+        sendProtocolMessage(msg);
+    }
+
+    @Override
+    public void notifyReconnectionFailure(ReconnectionFailureMessage msg) throws ProtocolException, UnknownServiceAddressException {
+        sendProtocolMessage(msg);
+    }
+    
+    private Socket createSocket() {
+        // determine the cluster manager's address
+        final DiscoverableService service = clusterManagerProtocolServiceLocator.getService(); 
+        if(service == null) {
+            throw new UnknownServiceAddressException("Cluster Manager's service is not known.  Verify a cluster manager is running.");
+        }
+        
+        try {
+            // create a socket
+            return SocketUtils.createSocket(service.getServiceAddress(), socketConfiguration); 
+        } catch(final IOException ioe) {
+            throw new ProtocolException("Failed to create socket due to: " + ioe, ioe);
+        }
+    }
+    
+    private void sendProtocolMessage(final ProtocolMessage msg) {
+        Socket socket = null;
+        try {
+            socket = createSocket();
+
+            try {
+                // marshal message to output stream
+                final ProtocolMessageMarshaller<ProtocolMessage> marshaller = protocolContext.createMarshaller();
+                marshaller.marshal(msg, socket.getOutputStream());
+            } catch(final IOException ioe) {
+                throw new ProtocolException("Failed marshalling '" + msg.getType() + "' protocol message due to: " + ioe, ioe);
+            }
+        } finally {
+            SocketUtils.closeQuietly(socket);
+        }
+    }
+    
+    public SocketConfiguration getSocketConfiguration() {
+        return socketConfiguration;
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/NodeProtocolSenderListener.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/NodeProtocolSenderListener.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/NodeProtocolSenderListener.java
new file mode 100644
index 0000000..4b359f4
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/NodeProtocolSenderListener.java
@@ -0,0 +1,115 @@
+/*
+ * 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.nifi.cluster.protocol.impl;
+
+import java.io.IOException;
+import java.util.Collection;
+
+import org.apache.nifi.cluster.protocol.NodeProtocolSender;
+import org.apache.nifi.cluster.protocol.ProtocolException;
+import org.apache.nifi.cluster.protocol.ProtocolHandler;
+import org.apache.nifi.cluster.protocol.ProtocolListener;
+import org.apache.nifi.cluster.protocol.UnknownServiceAddressException;
+import org.apache.nifi.cluster.protocol.message.NodeBulletinsMessage;
+import org.apache.nifi.cluster.protocol.message.ConnectionRequestMessage;
+import org.apache.nifi.cluster.protocol.message.ConnectionResponseMessage;
+import org.apache.nifi.cluster.protocol.message.ControllerStartupFailureMessage;
+import org.apache.nifi.cluster.protocol.message.HeartbeatMessage;
+import org.apache.nifi.cluster.protocol.message.ReconnectionFailureMessage;
+import org.apache.nifi.reporting.BulletinRepository;
+
+public class NodeProtocolSenderListener implements NodeProtocolSender, ProtocolListener {
+    
+    private final NodeProtocolSender sender;
+    private final ProtocolListener listener;
+    
+    public NodeProtocolSenderListener(final NodeProtocolSender sender, final ProtocolListener listener) {
+        if(sender == null) {
+            throw new IllegalArgumentException("NodeProtocolSender may not be null.");
+        } else if(listener == null) {
+            throw new IllegalArgumentException("ProtocolListener may not be null.");
+        }
+        this.sender = sender;
+        this.listener = listener;
+    }
+
+    @Override
+    public void stop() throws IOException {
+        if(!isRunning()) {
+            throw new IllegalStateException("Instance is already stopped.");
+        }
+        listener.stop();
+    }
+
+    @Override
+    public void start() throws IOException {
+        if(isRunning()) {
+            throw new IllegalStateException("Instance is already started.");
+        }
+        listener.start();
+    }
+
+    @Override
+    public boolean isRunning() {
+        return listener.isRunning();
+    }
+
+    @Override
+    public boolean removeHandler(final ProtocolHandler handler) {
+        return listener.removeHandler(handler);
+    }
+
+    @Override
+    public Collection<ProtocolHandler> getHandlers() {
+        return listener.getHandlers();
+    }
+
+    @Override
+    public void addHandler(final ProtocolHandler handler) {
+        listener.addHandler(handler);
+    }
+
+    @Override
+    public void heartbeat(final HeartbeatMessage msg) throws ProtocolException, UnknownServiceAddressException {
+        sender.heartbeat(msg);
+    }
+
+    @Override
+    public ConnectionResponseMessage requestConnection(final ConnectionRequestMessage msg) throws ProtocolException, UnknownServiceAddressException {
+        return sender.requestConnection(msg);
+    }
+    
+    @Override
+    public void notifyControllerStartupFailure(final ControllerStartupFailureMessage msg) throws ProtocolException, UnknownServiceAddressException {
+        sender.notifyControllerStartupFailure(msg);
+    }
+    
+    @Override
+    public void notifyReconnectionFailure(final ReconnectionFailureMessage msg) throws ProtocolException, UnknownServiceAddressException {
+        sender.notifyReconnectionFailure(msg);
+    }
+
+    @Override
+    public void sendBulletins(NodeBulletinsMessage msg) throws ProtocolException, UnknownServiceAddressException {
+        sender.sendBulletins(msg);
+    }
+
+    @Override
+    public void setBulletinRepository(final BulletinRepository bulletinRepository) {
+        listener.setBulletinRepository(bulletinRepository);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/SocketProtocolListener.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/SocketProtocolListener.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/SocketProtocolListener.java
new file mode 100644
index 0000000..ca30d9b
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/SocketProtocolListener.java
@@ -0,0 +1,205 @@
+/*
+ * 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.nifi.cluster.protocol.impl;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.Socket;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.UUID;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.TimeUnit;
+
+import javax.net.ssl.SSLSocket;
+import javax.security.cert.X509Certificate;
+
+import org.apache.nifi.cluster.protocol.ProtocolContext;
+import org.apache.nifi.cluster.protocol.ProtocolException;
+import org.apache.nifi.cluster.protocol.ProtocolHandler;
+import org.apache.nifi.cluster.protocol.ProtocolListener;
+import org.apache.nifi.cluster.protocol.ProtocolMessageMarshaller;
+import org.apache.nifi.cluster.protocol.ProtocolMessageUnmarshaller;
+import org.apache.nifi.cluster.protocol.message.ProtocolMessage;
+import org.apache.nifi.events.BulletinFactory;
+import org.apache.nifi.io.socket.ServerSocketConfiguration;
+import org.apache.nifi.io.socket.SocketListener;
+import org.apache.nifi.logging.NiFiLog;
+import org.apache.nifi.reporting.Bulletin;
+import org.apache.nifi.reporting.BulletinRepository;
+import org.apache.nifi.util.StopWatch;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Implements a listener for protocol messages sent over unicast socket. 
+ * 
+ * @author unattributed
+ */
+public class SocketProtocolListener extends SocketListener implements ProtocolListener {
+
+    private static final Logger logger = new NiFiLog(LoggerFactory.getLogger(SocketProtocolListener.class));
+    private final ProtocolContext<ProtocolMessage> protocolContext;
+    private final Collection<ProtocolHandler> handlers = new CopyOnWriteArrayList<>();
+    private volatile BulletinRepository bulletinRepository;
+    
+    public SocketProtocolListener(
+            final int numThreads,
+            final int port,
+            final ServerSocketConfiguration configuration,
+            final ProtocolContext<ProtocolMessage> protocolContext) {
+
+        super(numThreads, port, configuration);
+        
+        if(protocolContext == null) {
+            throw new IllegalArgumentException("Protocol Context may not be null.");
+        }
+        
+        this.protocolContext = protocolContext;
+    }
+
+    @Override
+    public void setBulletinRepository(final BulletinRepository bulletinRepository) {
+        this.bulletinRepository = bulletinRepository;
+    }
+    
+    @Override
+    public void start() throws IOException {
+
+        if(super.isRunning()) {
+            throw new IllegalStateException("Instance is already started.");
+        }
+        
+        super.start();
+    }
+
+    @Override
+    public void stop() throws IOException {
+
+        if(super.isRunning() == false) {
+            throw new IOException("Instance is already stopped.");
+        }
+        
+        super.stop();
+
+    }
+
+    @Override
+    public Collection<ProtocolHandler> getHandlers() {
+        return Collections.unmodifiableCollection(handlers);
+    }
+
+    @Override
+    public void addHandler(final ProtocolHandler handler) {
+        if(handler == null) {
+            throw new NullPointerException("Protocol handler may not be null.");
+        }
+        handlers.add(handler);
+    }
+    
+    @Override
+    public boolean removeHandler(final ProtocolHandler handler) {
+        return handlers.remove(handler);
+    }
+
+    @Override
+    public void dispatchRequest(final Socket socket) {
+        byte[] receivedMessage = null;
+        String hostname = null;
+        final int maxMsgBuffer = 1024 * 1024;   // don't buffer more than 1 MB of the message
+        try {
+            final StopWatch stopWatch = new StopWatch(true);
+            hostname = socket.getInetAddress().getHostName();
+            final String requestId = UUID.randomUUID().toString();
+            logger.info("Received request {} from {}", requestId, hostname);
+            
+            String requestorDn = null;
+            if ( socket instanceof SSLSocket ) {
+                final SSLSocket sslSocket = (SSLSocket) socket;
+                try {
+                    final X509Certificate[] certChains = sslSocket.getSession().getPeerCertificateChain();
+                    if ( certChains != null && certChains.length > 0 ) {
+                        requestorDn = certChains[0].getSubjectDN().getName();
+                    }
+                } catch (final ProtocolException pe) {
+                    throw pe;
+                } catch (final Exception e) {
+                    throw new ProtocolException(e);
+                }
+            }
+            
+            // unmarshall message
+            final ProtocolMessageUnmarshaller<ProtocolMessage> unmarshaller = protocolContext.createUnmarshaller();
+            final InputStream inStream = socket.getInputStream();
+            final CopyingInputStream copyingInputStream = new CopyingInputStream(inStream, maxMsgBuffer); // don't copy more than 1 MB
+            logger.debug("Request {} has a message length of {}", requestId, copyingInputStream.getNumberOfBytesCopied());
+            
+            final ProtocolMessage request;
+            try {
+                request = unmarshaller.unmarshal(copyingInputStream);
+            } finally {
+                receivedMessage = copyingInputStream.getBytesRead();
+            }
+            
+            request.setRequestorDN(requestorDn);
+            
+            // dispatch message to handler
+            ProtocolHandler desiredHandler = null;
+            for (final ProtocolHandler handler : getHandlers()) {
+                if (handler.canHandle(request)) {
+                    desiredHandler = handler;
+                    break;
+                }
+            }
+
+            // if no handler found, throw exception; otherwise handle request
+            if (desiredHandler == null) {
+                throw new ProtocolException("No handler assigned to handle message type: " + request.getType());
+            } else {
+                final ProtocolMessage response = desiredHandler.handle(request);
+                if(response != null) {
+                    try {
+                        logger.debug("Sending response for request {}", requestId);
+                            
+                        // marshal message to output stream
+                        final ProtocolMessageMarshaller<ProtocolMessage> marshaller = protocolContext.createMarshaller();
+                        marshaller.marshal(response, socket.getOutputStream());
+                    } catch (final IOException ioe) {
+                        throw new ProtocolException("Failed marshalling protocol message in response to message type: " + request.getType() + " due to " + ioe, ioe);
+                    }
+                }
+            }
+            
+            stopWatch.stop();
+            logger.info("Finished processing request {} (type={}, length={} bytes) in {} millis", requestId, request.getType(), receivedMessage.length, stopWatch.getDuration(TimeUnit.MILLISECONDS));
+        } catch (final IOException e) {
+            logger.warn("Failed processing protocol message from " + hostname + " due to " + e, e);
+            
+            if ( bulletinRepository != null ) {
+                final Bulletin bulletin = BulletinFactory.createBulletin("Clustering", "WARNING", String.format("Failed to process protocol message from %s due to: %s", hostname, e.toString()));
+                bulletinRepository.addBulletin(bulletin);
+            }
+        } catch (final ProtocolException e) {
+            logger.warn("Failed processing protocol message from " + hostname + " due to " + e, e);
+            if ( bulletinRepository != null ) {
+                final Bulletin bulletin = BulletinFactory.createBulletin("Clustering", "WARNING", String.format("Failed to process protocol message from %s due to: %s", hostname, e.toString()));
+                bulletinRepository.addBulletin(bulletin);
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/JaxbProtocolContext.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/JaxbProtocolContext.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/JaxbProtocolContext.java
new file mode 100644
index 0000000..bc68630
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/JaxbProtocolContext.java
@@ -0,0 +1,148 @@
+/*
+ * 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.nifi.cluster.protocol.jaxb;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.EOFException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.nio.ByteBuffer;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Marshaller;
+import javax.xml.bind.Unmarshaller;
+
+import org.apache.nifi.cluster.protocol.ProtocolContext;
+import org.apache.nifi.cluster.protocol.ProtocolMessageMarshaller;
+import org.apache.nifi.cluster.protocol.ProtocolMessageUnmarshaller;
+
+/**
+ * Implements a context for communicating internally amongst the cluster using
+ * JAXB.
+ * 
+ * @param <T> The type of protocol message.
+ *
+ * @author unattributed
+ */
+public class JaxbProtocolContext<T> implements ProtocolContext {
+
+    private static final int BUF_SIZE = (int) Math.pow(2, 10);  // 1k
+    
+    /*
+     * A sentinel is used to detect corrupted messages.  Relying on the integrity
+     * of the message size can cause memory issues if the value is corrupted 
+     * and equal to a number larger than the memory size.
+     */
+    private static final byte MESSAGE_PROTOCOL_START_SENTINEL = 0x5A;
+    
+    private final JAXBContext jaxbCtx;
+    
+    public JaxbProtocolContext(final JAXBContext jaxbCtx) {
+        this.jaxbCtx = jaxbCtx;
+    }
+    
+    @Override
+    public ProtocolMessageMarshaller<T> createMarshaller() {
+        return new ProtocolMessageMarshaller<T>() {
+
+            @Override
+            public void marshal(final T msg, final OutputStream os) throws IOException {
+
+                try {
+
+                    // marshal message to output stream
+                    final Marshaller marshaller = jaxbCtx.createMarshaller();
+                    final ByteArrayOutputStream msgBytes = new ByteArrayOutputStream();
+                    marshaller.marshal(msg, msgBytes);
+
+                    final DataOutputStream dos = new DataOutputStream(os);
+
+                    // write message protocol sentinel
+                    dos.write(MESSAGE_PROTOCOL_START_SENTINEL);
+                    
+                    // write message size in bytes
+                    dos.writeInt(msgBytes.size());
+
+                    // write message
+                    dos.write(msgBytes.toByteArray());
+
+                    dos.flush();
+
+                } catch (final JAXBException je) {
+                    throw new IOException("Failed marshalling protocol message due to: " + je, je);
+                }
+
+            }
+        };
+    }
+
+    @Override
+    public ProtocolMessageUnmarshaller<T> createUnmarshaller() {
+        return new ProtocolMessageUnmarshaller<T>() {
+
+            @Override
+            public T unmarshal(final InputStream is) throws IOException {
+
+                try {
+
+                    final DataInputStream dis = new DataInputStream(is);
+
+                    // check for the presence of the message protocol sentinel
+                    final byte sentinel = (byte) dis.read();
+                    if ( sentinel == -1 ) {
+                        throw new EOFException();
+                    }
+
+                    if(MESSAGE_PROTOCOL_START_SENTINEL != sentinel) {
+                        throw new IOException("Failed reading protocol message due to malformed header");
+                    }
+                    
+                    // read the message size
+                    final int msgBytesSize = dis.readInt();
+
+                    // read the message
+                    final ByteBuffer buffer = ByteBuffer.allocate(msgBytesSize);
+                    int totalBytesRead = 0;
+                    do {
+                        final int bytesToRead;
+                        if ((msgBytesSize - totalBytesRead) >= BUF_SIZE) {
+                            bytesToRead = BUF_SIZE;
+                        } else {
+                            bytesToRead = msgBytesSize - totalBytesRead;
+                        }
+                        totalBytesRead += dis.read(buffer.array(), totalBytesRead, bytesToRead);
+                    } while (totalBytesRead < msgBytesSize);
+
+                    // unmarshall message and return
+                    final Unmarshaller unmarshaller = jaxbCtx.createUnmarshaller();
+                    final byte[] msg = new byte[totalBytesRead];
+                    buffer.get(msg);
+                    return (T) unmarshaller.unmarshal(new ByteArrayInputStream(msg));
+
+                } catch (final JAXBException je) {
+                    throw new IOException("Failed unmarshalling protocol message due to: " + je, je);
+                }
+
+            }
+        };
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/AdaptedConnectionRequest.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/AdaptedConnectionRequest.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/AdaptedConnectionRequest.java
new file mode 100644
index 0000000..d9de24f
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/AdaptedConnectionRequest.java
@@ -0,0 +1,40 @@
+/*
+ * 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.nifi.cluster.protocol.jaxb.message;
+
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+import org.apache.nifi.cluster.protocol.NodeIdentifier;
+
+/**
+ * @author unattributed
+ */
+public class AdaptedConnectionRequest {
+    
+    private NodeIdentifier nodeIdentifier;
+    
+    public AdaptedConnectionRequest() {}
+
+    @XmlJavaTypeAdapter(NodeIdentifierAdapter.class)
+    public NodeIdentifier getNodeIdentifier() {
+        return nodeIdentifier;
+    }
+
+    public void setNodeIdentifier(final NodeIdentifier nodeIdentifier) {
+        this.nodeIdentifier = nodeIdentifier;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/AdaptedConnectionResponse.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/AdaptedConnectionResponse.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/AdaptedConnectionResponse.java
new file mode 100644
index 0000000..c7c783b
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/AdaptedConnectionResponse.java
@@ -0,0 +1,109 @@
+/*
+ * 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.nifi.cluster.protocol.jaxb.message;
+
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+
+import org.apache.nifi.cluster.protocol.NodeIdentifier;
+import org.apache.nifi.cluster.protocol.StandardDataFlow;
+
+/**
+ * @author unattributed
+ */
+public class AdaptedConnectionResponse {
+    
+    private StandardDataFlow dataFlow;
+    private NodeIdentifier nodeIdentifier;
+    private boolean blockedByFirewall;
+    private boolean primary;
+    private int tryLaterSeconds;
+    private Integer managerRemoteInputPort;
+    private Boolean managerRemoteCommsSecure;
+    private String instanceId;
+    
+    public AdaptedConnectionResponse() {}
+
+    @XmlJavaTypeAdapter(DataFlowAdapter.class)
+    public StandardDataFlow getDataFlow() {
+        return dataFlow;
+    }
+
+    public void setDataFlow(StandardDataFlow dataFlow) {
+        this.dataFlow = dataFlow;
+    }
+
+    @XmlJavaTypeAdapter(NodeIdentifierAdapter.class)
+    public NodeIdentifier getNodeIdentifier() {
+        return nodeIdentifier;
+    }
+
+    public void setNodeIdentifier(NodeIdentifier nodeIdentifier) {
+        this.nodeIdentifier = nodeIdentifier;
+    }
+
+    public int getTryLaterSeconds() {
+        return tryLaterSeconds;
+    }
+
+    public void setTryLaterSeconds(int tryLaterSeconds) {
+        this.tryLaterSeconds = tryLaterSeconds;
+    }
+
+    public boolean isBlockedByFirewall() {
+        return blockedByFirewall;
+    }
+
+    public void setBlockedByFirewall(boolean blockedByFirewall) {
+        this.blockedByFirewall = blockedByFirewall;
+    }
+
+    public boolean isPrimary() {
+        return primary;
+    }
+
+    public void setPrimary(boolean primary) {
+        this.primary = primary;
+    }
+
+    public boolean shouldTryLater() {
+        return tryLaterSeconds > 0;
+    }
+    
+    public void setManagerRemoteInputPort(Integer managerRemoteInputPort) {
+        this.managerRemoteInputPort = managerRemoteInputPort;
+    }
+    
+    public Integer getManagerRemoteInputPort() {
+        return managerRemoteInputPort;
+    }
+    
+    public void setManagerRemoteCommsSecure(Boolean secure) {
+        this.managerRemoteCommsSecure = secure;
+    }
+    
+    public Boolean isManagerRemoteCommsSecure() {
+        return managerRemoteCommsSecure;
+    }
+    
+    public void setInstanceId(String instanceId) {
+        this.instanceId = instanceId;
+    }
+    
+    public String getInstanceId() {
+        return instanceId;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/AdaptedCounter.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/AdaptedCounter.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/AdaptedCounter.java
new file mode 100644
index 0000000..89d903b
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/AdaptedCounter.java
@@ -0,0 +1,56 @@
+/*
+ * 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.nifi.cluster.protocol.jaxb.message;
+
+/**
+ * @author unattributed
+ */
+public class AdaptedCounter {
+    
+    private String groupName;
+    
+    private String name;
+    
+    private long value;
+
+    public AdaptedCounter() {}
+
+    public String getGroupName() {
+        return groupName;
+    }
+
+    public void setGroupName(String counterGroupName) {
+        this.groupName = counterGroupName;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String counterName) {
+        this.name = counterName;
+    }
+
+    public long getValue() {
+        return value;
+    }
+
+    public void setValue(long value) {
+        this.value = value;
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/AdaptedDataFlow.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/AdaptedDataFlow.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/AdaptedDataFlow.java
new file mode 100644
index 0000000..bb97619
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/AdaptedDataFlow.java
@@ -0,0 +1,64 @@
+/*
+ * 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.nifi.cluster.protocol.jaxb.message;
+
+/**
+ * @author unattributed
+ */
+public class AdaptedDataFlow {
+    
+    private byte[] flow;
+    private byte[] templates;
+    private byte[] snippets;
+    
+    private boolean autoStartProcessors;
+    
+    public AdaptedDataFlow() {}
+
+    public byte[] getFlow() {
+        return flow;
+    }
+
+    public void setFlow(byte[] flow) {
+        this.flow = flow;
+    }
+
+    public byte[] getTemplates() {
+        return templates;
+    }
+
+    public void setTemplates(byte[] templates) {
+        this.templates = templates;
+    }
+
+    public byte[] getSnippets() {
+        return snippets;
+    }
+
+    public void setSnippets(byte[] snippets) {
+        this.snippets = snippets;
+    }
+
+    public boolean isAutoStartProcessors() {
+        return autoStartProcessors;
+    }
+
+    public void setAutoStartProcessors(boolean runningAllProcessors) {
+        this.autoStartProcessors = runningAllProcessors;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/AdaptedHeartbeat.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/AdaptedHeartbeat.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/AdaptedHeartbeat.java
new file mode 100644
index 0000000..5b9d9b7
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/AdaptedHeartbeat.java
@@ -0,0 +1,66 @@
+/*
+ * 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.nifi.cluster.protocol.jaxb.message;
+
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+import org.apache.nifi.cluster.protocol.NodeIdentifier;
+
+/**
+ * @author unattributed
+ */
+public class AdaptedHeartbeat {
+    
+    private NodeIdentifier nodeIdentifier;
+    private byte[] payload;
+    private boolean primary;
+    private boolean connected;
+    
+    public AdaptedHeartbeat() {}
+
+    @XmlJavaTypeAdapter(NodeIdentifierAdapter.class)
+    public NodeIdentifier getNodeIdentifier() {
+        return nodeIdentifier;
+    }
+
+    public void setNodeIdentifier(NodeIdentifier nodeIdentifier) {
+        this.nodeIdentifier = nodeIdentifier;
+    }
+    
+    public boolean isPrimary() {
+        return primary;
+    }
+
+    public void setPrimary(boolean primary) {
+        this.primary = primary;
+    }
+
+    public boolean isConnected() {
+        return connected;
+    }
+    
+    public void setConnected(boolean connected) {
+        this.connected = connected;
+    }
+    
+    public byte[] getPayload() {
+        return payload;
+    }
+
+    public void setPayload(byte[] payload) {
+        this.payload = payload;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/AdaptedNodeBulletins.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/AdaptedNodeBulletins.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/AdaptedNodeBulletins.java
new file mode 100644
index 0000000..98e2438
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/AdaptedNodeBulletins.java
@@ -0,0 +1,50 @@
+/*
+ * 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.nifi.cluster.protocol.jaxb.message;
+
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+import org.apache.nifi.cluster.protocol.NodeIdentifier;
+
+/**
+ * @author unattributed
+ */
+public class AdaptedNodeBulletins {
+    
+    private NodeIdentifier nodeIdentifier;
+    
+    private byte[] payload;
+    
+    public AdaptedNodeBulletins() {}
+
+    @XmlJavaTypeAdapter(NodeIdentifierAdapter.class)
+    public NodeIdentifier getNodeIdentifier() {
+        return nodeIdentifier;
+    }
+
+    public void setNodeIdentifier(NodeIdentifier nodeIdentifier) {
+        this.nodeIdentifier = nodeIdentifier;
+    }
+    
+    public byte[] getPayload() {
+        return payload;
+    }
+
+    public void setPayload(byte[] payload) {
+        this.payload = payload;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/AdaptedNodeIdentifier.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/AdaptedNodeIdentifier.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/AdaptedNodeIdentifier.java
new file mode 100644
index 0000000..8134ea3
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/AdaptedNodeIdentifier.java
@@ -0,0 +1,76 @@
+/*
+ * 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.nifi.cluster.protocol.jaxb.message;
+
+/**
+ * @author unattributed
+ */
+public class AdaptedNodeIdentifier {
+    
+    private String id;
+    
+    private String apiAddress;
+
+    private int apiPort;    
+
+    private String socketAddress;
+    
+    private int socketPort;
+    
+    public AdaptedNodeIdentifier() {}
+
+    public String getApiAddress() {
+        return apiAddress;
+    }
+
+    public void setApiAddress(String apiAddress) {
+        this.apiAddress = apiAddress;
+    }
+
+    public int getApiPort() {
+        return apiPort;
+    }
+
+    public void setApiPort(int apiPort) {
+        this.apiPort = apiPort;
+    }
+
+    public String getId() {
+        return id;
+    }
+
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    public String getSocketAddress() {
+        return socketAddress;
+    }
+
+    public void setSocketAddress(String socketAddress) {
+        this.socketAddress = socketAddress;
+    }
+
+    public int getSocketPort() {
+        return socketPort;
+    }
+
+    public void setSocketPort(int socketPort) {
+        this.socketPort = socketPort;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/ConnectionRequestAdapter.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/ConnectionRequestAdapter.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/ConnectionRequestAdapter.java
new file mode 100644
index 0000000..1f91cf1
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/ConnectionRequestAdapter.java
@@ -0,0 +1,41 @@
+/*
+ * 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.nifi.cluster.protocol.jaxb.message;
+
+import javax.xml.bind.annotation.adapters.XmlAdapter;
+import org.apache.nifi.cluster.protocol.ConnectionRequest;
+
+/**
+ * @author unattributed
+ */
+public class ConnectionRequestAdapter extends XmlAdapter<AdaptedConnectionRequest, ConnectionRequest> {
+
+    @Override
+    public AdaptedConnectionRequest marshal(final ConnectionRequest cr) {
+        final AdaptedConnectionRequest aCr = new AdaptedConnectionRequest();
+        if(cr != null) {
+            aCr.setNodeIdentifier(cr.getProposedNodeIdentifier());
+        }
+        return aCr;
+    }
+
+    @Override
+    public ConnectionRequest unmarshal(final AdaptedConnectionRequest aCr) {
+        return new ConnectionRequest(aCr.getNodeIdentifier());
+    }
+ 
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/ConnectionResponseAdapter.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/ConnectionResponseAdapter.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/ConnectionResponseAdapter.java
new file mode 100644
index 0000000..143bab0
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/ConnectionResponseAdapter.java
@@ -0,0 +1,55 @@
+/*
+ * 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.nifi.cluster.protocol.jaxb.message;
+
+import javax.xml.bind.annotation.adapters.XmlAdapter;
+import org.apache.nifi.cluster.protocol.ConnectionResponse;
+
+/**
+ * @author unattributed
+ */
+public class ConnectionResponseAdapter extends XmlAdapter<AdaptedConnectionResponse, ConnectionResponse> {
+
+    @Override
+    public AdaptedConnectionResponse marshal(final ConnectionResponse cr) {
+        final AdaptedConnectionResponse aCr = new AdaptedConnectionResponse();
+        if(cr != null) {
+            aCr.setDataFlow(cr.getDataFlow());
+            aCr.setNodeIdentifier(cr.getNodeIdentifier());
+            aCr.setTryLaterSeconds(cr.getTryLaterSeconds());
+            aCr.setBlockedByFirewall(cr.isBlockedByFirewall());
+            aCr.setPrimary(cr.isPrimary());
+            aCr.setManagerRemoteInputPort(cr.getManagerRemoteInputPort());
+            aCr.setManagerRemoteCommsSecure(cr.isManagerRemoteCommsSecure());
+            aCr.setInstanceId(cr.getInstanceId());
+        }
+        return aCr;
+    }
+
+    @Override
+    public ConnectionResponse unmarshal(final AdaptedConnectionResponse aCr) {
+        if(aCr.shouldTryLater()) {
+            return new ConnectionResponse(aCr.getTryLaterSeconds());
+        } else if(aCr.isBlockedByFirewall()) {
+            return ConnectionResponse.createBlockedByFirewallResponse();
+        } else {
+            return new ConnectionResponse(aCr.getNodeIdentifier(), aCr.getDataFlow(), aCr.isPrimary(), 
+                aCr.getManagerRemoteInputPort(), aCr.isManagerRemoteCommsSecure(), aCr.getInstanceId());
+        }
+    }
+ 
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/DataFlowAdapter.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/DataFlowAdapter.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/DataFlowAdapter.java
new file mode 100644
index 0000000..8d9467f
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/DataFlowAdapter.java
@@ -0,0 +1,50 @@
+/*
+ * 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.nifi.cluster.protocol.jaxb.message;
+
+import javax.xml.bind.annotation.adapters.XmlAdapter;
+
+import org.apache.nifi.cluster.protocol.StandardDataFlow;
+
+/**
+ * @author unattributed
+ */
+public class DataFlowAdapter extends XmlAdapter<AdaptedDataFlow, StandardDataFlow> {
+
+    @Override
+    public AdaptedDataFlow marshal(final StandardDataFlow df) {
+        
+        final AdaptedDataFlow aDf = new AdaptedDataFlow();
+        
+        if(df != null) {
+            aDf.setFlow(df.getFlow());
+            aDf.setTemplates(df.getTemplates());
+            aDf.setSnippets(df.getSnippets());
+            aDf.setAutoStartProcessors(df.isAutoStartProcessors());
+        }
+        
+        return aDf;
+    }
+
+    @Override
+    public StandardDataFlow unmarshal(final AdaptedDataFlow aDf) {
+        final StandardDataFlow dataFlow = new StandardDataFlow(aDf.getFlow(), aDf.getTemplates(), aDf.getSnippets());
+        dataFlow.setAutoStartProcessors(aDf.isAutoStartProcessors());
+        return dataFlow;
+    }
+ 
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/HeartbeatAdapter.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/HeartbeatAdapter.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/HeartbeatAdapter.java
new file mode 100644
index 0000000..0e073b6
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/HeartbeatAdapter.java
@@ -0,0 +1,54 @@
+/*
+ * 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.nifi.cluster.protocol.jaxb.message;
+
+import javax.xml.bind.annotation.adapters.XmlAdapter;
+import org.apache.nifi.cluster.protocol.Heartbeat;
+
+/**
+ * @author unattributed
+ */
+public class HeartbeatAdapter extends XmlAdapter<AdaptedHeartbeat, Heartbeat> {
+
+    @Override
+    public AdaptedHeartbeat marshal(final Heartbeat hb) {
+        
+        final AdaptedHeartbeat aHb = new AdaptedHeartbeat();
+        
+        if(hb != null) {
+            // set node identifier
+            aHb.setNodeIdentifier(hb.getNodeIdentifier());
+
+            // set payload
+            aHb.setPayload(hb.getPayload());
+            
+            // set leader flag
+            aHb.setPrimary(hb.isPrimary());
+            
+            // set connected flag
+            aHb.setConnected(hb.isConnected());
+        }
+        
+        return aHb;
+    }
+
+    @Override
+    public Heartbeat unmarshal(final AdaptedHeartbeat aHb) {
+        return new Heartbeat(aHb.getNodeIdentifier(), aHb.isPrimary(), aHb.isConnected(), aHb.getPayload());
+    }
+ 
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/JaxbProtocolUtils.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/JaxbProtocolUtils.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/JaxbProtocolUtils.java
new file mode 100644
index 0000000..c3a57f5
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/JaxbProtocolUtils.java
@@ -0,0 +1,42 @@
+/*
+ * 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.nifi.cluster.protocol.jaxb.message;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+
+/**
+ * @author unattributed
+ */
+public final class JaxbProtocolUtils {
+    
+    public static final String JAXB_CONTEXT_PATH = ObjectFactory.class.getPackage().getName();
+
+    public static final JAXBContext JAXB_CONTEXT = initializeJaxbContext();
+    
+    /**
+     * Load the JAXBContext version.
+     */
+    private static JAXBContext initializeJaxbContext() {
+        try {
+            return JAXBContext.newInstance(JAXB_CONTEXT_PATH);
+        } catch (JAXBException e) {
+            throw new RuntimeException("Unable to create JAXBContext.", e);
+        }
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/NodeBulletinsAdapter.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/NodeBulletinsAdapter.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/NodeBulletinsAdapter.java
new file mode 100644
index 0000000..1ae41f7
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/NodeBulletinsAdapter.java
@@ -0,0 +1,48 @@
+/*
+ * 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.nifi.cluster.protocol.jaxb.message;
+
+import javax.xml.bind.annotation.adapters.XmlAdapter;
+import org.apache.nifi.cluster.protocol.NodeBulletins;
+
+/**
+ * @author unattributed
+ */
+public class NodeBulletinsAdapter extends XmlAdapter<AdaptedNodeBulletins, NodeBulletins> {
+
+    @Override
+    public AdaptedNodeBulletins marshal(final NodeBulletins hb) {
+        
+        final AdaptedNodeBulletins adaptedBulletins = new AdaptedNodeBulletins();
+        
+        if(hb != null) {
+            // set node identifier
+            adaptedBulletins.setNodeIdentifier(hb.getNodeIdentifier());
+
+            // set payload
+            adaptedBulletins.setPayload(hb.getPayload());
+        }
+        
+        return adaptedBulletins;
+    }
+
+    @Override
+    public NodeBulletins unmarshal(final AdaptedNodeBulletins adaptedBulletins) {
+        return new NodeBulletins(adaptedBulletins.getNodeIdentifier(), adaptedBulletins.getPayload());
+    }
+ 
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/NodeIdentifierAdapter.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/NodeIdentifierAdapter.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/NodeIdentifierAdapter.java
new file mode 100644
index 0000000..fe2d8a4
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/NodeIdentifierAdapter.java
@@ -0,0 +1,51 @@
+/*
+ * 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.nifi.cluster.protocol.jaxb.message;
+
+import javax.xml.bind.annotation.adapters.XmlAdapter;
+import org.apache.nifi.cluster.protocol.NodeIdentifier;
+
+/**
+ * @author unattributed
+ */
+public class NodeIdentifierAdapter extends XmlAdapter<AdaptedNodeIdentifier, NodeIdentifier> {
+
+    @Override
+    public AdaptedNodeIdentifier marshal(final NodeIdentifier ni) {
+        if(ni == null) {
+            return null;
+        } else {
+            final AdaptedNodeIdentifier aNi = new AdaptedNodeIdentifier();
+            aNi.setId(ni.getId());
+            aNi.setApiAddress(ni.getApiAddress());
+            aNi.setApiPort(ni.getApiPort());
+            aNi.setSocketAddress(ni.getSocketAddress());
+            aNi.setSocketPort(ni.getSocketPort());
+            return aNi;
+        }
+    }
+
+    @Override
+    public NodeIdentifier unmarshal(final AdaptedNodeIdentifier aNi) {
+        if(aNi == null) {
+            return null;
+        } else {
+            return new NodeIdentifier(aNi.getId(), aNi.getApiAddress(), aNi.getApiPort(), aNi.getSocketAddress(), aNi.getSocketPort());
+        }
+    }
+ 
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/ObjectFactory.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/ObjectFactory.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/ObjectFactory.java
new file mode 100644
index 0000000..1613536
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/jaxb/message/ObjectFactory.java
@@ -0,0 +1,104 @@
+/*
+ * 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.nifi.cluster.protocol.jaxb.message;
+
+import javax.xml.bind.annotation.XmlRegistry;
+
+import org.apache.nifi.cluster.protocol.message.ConnectionRequestMessage;
+import org.apache.nifi.cluster.protocol.message.ConnectionResponseMessage;
+import org.apache.nifi.cluster.protocol.message.ControllerStartupFailureMessage;
+import org.apache.nifi.cluster.protocol.message.DisconnectMessage;
+import org.apache.nifi.cluster.protocol.message.FlowRequestMessage;
+import org.apache.nifi.cluster.protocol.message.FlowResponseMessage;
+import org.apache.nifi.cluster.protocol.message.HeartbeatMessage;
+import org.apache.nifi.cluster.protocol.message.MulticastProtocolMessage;
+import org.apache.nifi.cluster.protocol.message.NodeBulletinsMessage;
+import org.apache.nifi.cluster.protocol.message.PingMessage;
+import org.apache.nifi.cluster.protocol.message.PrimaryRoleAssignmentMessage;
+import org.apache.nifi.cluster.protocol.message.ReconnectionFailureMessage;
+import org.apache.nifi.cluster.protocol.message.ReconnectionRequestMessage;
+import org.apache.nifi.cluster.protocol.message.ReconnectionResponseMessage;
+import org.apache.nifi.cluster.protocol.message.ServiceBroadcastMessage;
+
+/**
+ * @author unattributed
+ */
+@XmlRegistry
+public class ObjectFactory {
+    
+    public ObjectFactory() {}
+    
+    public ReconnectionRequestMessage createReconnectionRequestMessage() {
+        return new ReconnectionRequestMessage();
+    }
+    
+    public ReconnectionFailureMessage createReconnectionFailureMessage() {
+        return new ReconnectionFailureMessage();
+    }
+    
+    public ReconnectionResponseMessage createReconnectionResponseMessage() {
+        return new ReconnectionResponseMessage();
+    }
+    
+    public DisconnectMessage createDisconnectionMessage() {
+        return new DisconnectMessage();
+    }
+    
+    public ConnectionRequestMessage createConnectionRequestMessage() {
+        return new ConnectionRequestMessage();
+    }
+    
+    public ConnectionResponseMessage createConnectionResponseMessage() {
+        return new ConnectionResponseMessage();
+    }
+    
+    public ServiceBroadcastMessage createServiceBroadcastMessage() {
+        return new ServiceBroadcastMessage();
+    }
+    
+    public HeartbeatMessage createHeartbeatMessage() {
+        return new HeartbeatMessage();
+    }
+    
+    public FlowRequestMessage createFlowRequestMessage() {
+        return new FlowRequestMessage();
+    }
+    
+    public FlowResponseMessage createFlowResponseMessage() {
+        return new FlowResponseMessage();
+    }
+    
+    public PingMessage createPingMessage() {
+        return new PingMessage();
+    }
+    
+    public MulticastProtocolMessage createMulticastProtocolMessage() {
+        return new MulticastProtocolMessage();
+    }
+    
+    public ControllerStartupFailureMessage createControllerStartupFailureMessage() {
+        return new ControllerStartupFailureMessage();
+    }
+    
+    public PrimaryRoleAssignmentMessage createPrimaryRoleAssignmentMessage() {
+        return new PrimaryRoleAssignmentMessage();
+    }
+    
+    public NodeBulletinsMessage createBulletinsMessage() {
+        return new NodeBulletinsMessage();
+    }
+}


[20/20] incubator-nifi git commit: NIFI-410 pushed RAT exclusions down to the relevant modules and stopped doing broad test resource exclusion - is now specific

Posted by jo...@apache.org.
NIFI-410 pushed RAT exclusions down to the relevant modules and stopped doing broad test resource exclusion - is now specific


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

Branch: refs/heads/develop
Commit: 761e64a410a837b4fd756fd730f07621fcea8b37
Parents: eb757a4
Author: joewitt <jo...@apache.org>
Authored: Mon Mar 16 22:48:14 2015 -0400
Committer: joewitt <jo...@apache.org>
Committed: Mon Mar 16 22:48:14 2015 -0400

----------------------------------------------------------------------
 .../nifi-cluster-protocol/.gitignore            |    1 -
 .../nifi-cluster-protocol/pom.xml               |   67 -
 .../protocol/ClusterManagerProtocolSender.java  |   69 -
 .../cluster/protocol/ConnectionRequest.java     |   44 -
 .../cluster/protocol/ConnectionResponse.java    |  141 -
 .../apache/nifi/cluster/protocol/Heartbeat.java |   68 -
 .../nifi/cluster/protocol/NodeBulletins.java    |   44 -
 .../nifi/cluster/protocol/NodeIdentifier.java   |  172 -
 .../cluster/protocol/NodeProtocolSender.java    |   73 -
 .../nifi/cluster/protocol/ProtocolContext.java  |   39 -
 .../cluster/protocol/ProtocolException.java     |   40 -
 .../nifi/cluster/protocol/ProtocolHandler.java  |   44 -
 .../nifi/cluster/protocol/ProtocolListener.java |   72 -
 .../protocol/ProtocolMessageMarshaller.java     |   38 -
 .../protocol/ProtocolMessageUnmarshaller.java   |   38 -
 .../nifi/cluster/protocol/StandardDataFlow.java |  105 -
 .../UnknownServiceAddressException.java         |   39 -
 .../impl/ClusterManagerProtocolSenderImpl.java  |  245 --
 .../ClusterManagerProtocolSenderListener.java   |  118 -
 .../protocol/impl/ClusterServiceDiscovery.java  |  181 -
 .../protocol/impl/ClusterServiceLocator.java    |  229 --
 .../impl/ClusterServicesBroadcaster.java        |  182 -
 .../protocol/impl/CopyingInputStream.java       |   77 -
 .../impl/MulticastProtocolListener.java         |  204 -
 .../protocol/impl/NodeProtocolSenderImpl.java   |  171 -
 .../impl/NodeProtocolSenderListener.java        |  115 -
 .../protocol/impl/SocketProtocolListener.java   |  205 -
 .../protocol/jaxb/JaxbProtocolContext.java      |  148 -
 .../jaxb/message/AdaptedConnectionRequest.java  |   40 -
 .../jaxb/message/AdaptedConnectionResponse.java |  109 -
 .../protocol/jaxb/message/AdaptedCounter.java   |   56 -
 .../protocol/jaxb/message/AdaptedDataFlow.java  |   64 -
 .../protocol/jaxb/message/AdaptedHeartbeat.java |   66 -
 .../jaxb/message/AdaptedNodeBulletins.java      |   50 -
 .../jaxb/message/AdaptedNodeIdentifier.java     |   76 -
 .../jaxb/message/ConnectionRequestAdapter.java  |   41 -
 .../jaxb/message/ConnectionResponseAdapter.java |   55 -
 .../protocol/jaxb/message/DataFlowAdapter.java  |   50 -
 .../protocol/jaxb/message/HeartbeatAdapter.java |   54 -
 .../jaxb/message/JaxbProtocolUtils.java         |   42 -
 .../jaxb/message/NodeBulletinsAdapter.java      |   48 -
 .../jaxb/message/NodeIdentifierAdapter.java     |   51 -
 .../protocol/jaxb/message/ObjectFactory.java    |  104 -
 .../message/ConnectionRequestMessage.java       |   46 -
 .../message/ConnectionResponseMessage.java      |   66 -
 .../ControllerStartupFailureMessage.java        |   49 -
 .../protocol/message/DisconnectMessage.java     |   55 -
 .../protocol/message/ExceptionMessage.java      |   44 -
 .../protocol/message/FlowRequestMessage.java    |   46 -
 .../protocol/message/FlowResponseMessage.java   |   44 -
 .../protocol/message/HeartbeatMessage.java      |   43 -
 .../message/MulticastProtocolMessage.java       |   66 -
 .../protocol/message/NodeBulletinsMessage.java  |   43 -
 .../cluster/protocol/message/PingMessage.java   |   55 -
 .../message/PrimaryRoleAssignmentMessage.java   |   56 -
 .../protocol/message/ProtocolMessage.java       |   61 -
 .../message/ReconnectionFailureMessage.java     |   45 -
 .../message/ReconnectionRequestMessage.java     |   94 -
 .../message/ReconnectionResponseMessage.java    |   32 -
 .../message/ServiceBroadcastMessage.java        |   64 -
 .../MulticastConfigurationFactoryBean.java      |   60 -
 .../ServerSocketConfigurationFactoryBean.java   |   65 -
 .../spring/SocketConfigurationFactoryBean.java  |   66 -
 .../resources/nifi-cluster-protocol-context.xml |  110 -
 .../ClusterManagerProtocolSenderImplTest.java   |  134 -
 .../impl/ClusterServiceDiscoveryTest.java       |  135 -
 .../impl/ClusterServiceLocatorTest.java         |  121 -
 .../impl/ClusterServicesBroadcasterTest.java    |  133 -
 .../impl/MulticastProtocolListenerTest.java     |  171 -
 .../impl/NodeProtocolSenderImplTest.java        |  203 -
 .../impl/testutils/DelayedProtocolHandler.java  |   57 -
 .../testutils/ReflexiveProtocolHandler.java     |   47 -
 .../nifi-framework/nifi-cluster-web/.gitignore  |    1 -
 .../nifi-framework/nifi-cluster-web/pom.xml     |   48 -
 .../nifi/cluster/context/ClusterContext.java    |   59 -
 .../cluster/context/ClusterContextImpl.java     |   69 -
 .../context/ClusterContextThreadLocal.java      |   47 -
 .../ClusterAwareOptimisticLockingManager.java   |   96 -
 .../nifi-framework/nifi-cluster/.gitignore      |    1 -
 .../nifi-framework/nifi-cluster/pom.xml         |  130 -
 .../cluster/client/MulticastTestClient.java     |  151 -
 .../org/apache/nifi/cluster/event/Event.java    |  122 -
 .../apache/nifi/cluster/event/EventManager.java |   65 -
 .../cluster/event/impl/EventManagerImpl.java    |  143 -
 .../cluster/firewall/ClusterNodeFirewall.java   |   35 -
 .../impl/FileBasedClusterNodeFirewall.java      |  207 -
 .../nifi/cluster/flow/ClusterDataFlow.java      |   45 -
 .../apache/nifi/cluster/flow/DaoException.java  |   40 -
 .../apache/nifi/cluster/flow/DataFlowDao.java   |   62 -
 .../cluster/flow/DataFlowManagementService.java |  115 -
 .../nifi/cluster/flow/PersistedFlowState.java   |   37 -
 .../nifi/cluster/flow/StaleFlowException.java   |   42 -
 .../nifi/cluster/flow/impl/DataFlowDaoImpl.java |  600 ---
 .../impl/DataFlowManagementServiceImpl.java     |  356 --
 .../nifi/cluster/manager/ClusterManager.java    |  225 --
 .../cluster/manager/HttpClusterManager.java     |  169 -
 .../cluster/manager/HttpRequestReplicator.java  |   99 -
 .../cluster/manager/HttpResponseMapper.java     |   42 -
 .../nifi/cluster/manager/NodeResponse.java      |  329 --
 .../exception/BlockedByFirewallException.java   |   60 -
 .../manager/exception/ClusterException.java     |   40 -
 .../ConnectingNodeMutableRequestException.java  |   41 -
 ...DisconnectedNodeMutableRequestException.java |   41 -
 .../exception/IllegalClusterStateException.java |   41 -
 .../exception/IllegalNodeDeletionException.java |   41 -
 .../IllegalNodeDisconnectionException.java      |   42 -
 .../IllegalNodeReconnectionException.java       |   41 -
 .../IneligiblePrimaryNodeException.java         |   41 -
 .../exception/MutableRequestException.java      |   42 -
 .../exception/NoConnectedNodesException.java    |   41 -
 .../exception/NoResponseFromNodesException.java |   42 -
 .../exception/NodeDisconnectionException.java   |   41 -
 .../exception/NodeReconnectionException.java    |   40 -
 .../PrimaryRoleAssignmentException.java         |   41 -
 .../SafeModeMutableRequestException.java        |   41 -
 .../manager/exception/UnknownNodeException.java |   41 -
 .../exception/UriConstructionException.java     |   42 -
 .../manager/impl/ClusteredEventAccess.java      |  135 -
 .../manager/impl/ClusteredReportingContext.java |  165 -
 .../manager/impl/HttpRequestReplicatorImpl.java |  531 ---
 .../manager/impl/HttpResponseMapperImpl.java    |   85 -
 .../cluster/manager/impl/WebClusterManager.java | 3628 ------------------
 .../java/org/apache/nifi/cluster/node/Node.java |  252 --
 ...anagerProtocolServiceLocatorFactoryBean.java |  116 -
 ...FileBasedClusterNodeFirewallFactoryBean.java |   58 -
 .../spring/WebClusterManagerFactoryBean.java    |  139 -
 .../reporting/ClusteredReportingTaskNode.java   |   49 -
 .../resources/nifi-cluster-manager-context.xml  |  124 -
 .../event/impl/EventManagerImplTest.java        |  119 -
 .../impl/FileBasedClusterNodeFirewallTest.java  |   98 -
 .../impl/DataFlowManagementServiceImplTest.java |  343 --
 .../impl/HttpRequestReplicatorImplTest.java     |  368 --
 .../impl/HttpResponseMapperImplTest.java        |  126 -
 .../manager/impl/TestWebClusterManager.java     |   54 -
 .../cluster/manager/testutils/HttpRequest.java  |  239 --
 .../cluster/manager/testutils/HttpResponse.java |   93 -
 .../manager/testutils/HttpResponseAction.java   |   60 -
 .../cluster/manager/testutils/HttpServer.java   |  240 --
 .../ClusterManagerProtocolSenderImplTest.java   |  133 -
 .../impl/ClusterServiceLocatorTest.java         |  119 -
 .../impl/ClusterServicesBroadcasterTest.java    |  131 -
 .../impl/MulticastProtocolListenerTest.java     |  171 -
 .../impl/NodeProtocolSenderImplTest.java        |  201 -
 .../impl/SocketProtocolListenerTest.java        |  132 -
 .../testutils/DelayedProtocolHandler.java       |   57 -
 .../testutils/ReflexiveProtocolHandler.java     |   47 -
 .../src/test/resources/logback-test.xml         |   48 -
 .../apache/nifi/cluster/firewall/impl/empty.txt |    0
 .../apache/nifi/cluster/firewall/impl/ips.txt   |   12 -
 .../nifi-framework-cluster-protocol/.gitignore  |    1 +
 .../nifi-framework-cluster-protocol/pom.xml     |   67 +
 .../protocol/ClusterManagerProtocolSender.java  |   69 +
 .../cluster/protocol/ConnectionRequest.java     |   44 +
 .../cluster/protocol/ConnectionResponse.java    |  141 +
 .../apache/nifi/cluster/protocol/Heartbeat.java |   68 +
 .../nifi/cluster/protocol/NodeBulletins.java    |   44 +
 .../nifi/cluster/protocol/NodeIdentifier.java   |  172 +
 .../cluster/protocol/NodeProtocolSender.java    |   73 +
 .../nifi/cluster/protocol/ProtocolContext.java  |   39 +
 .../cluster/protocol/ProtocolException.java     |   40 +
 .../nifi/cluster/protocol/ProtocolHandler.java  |   44 +
 .../nifi/cluster/protocol/ProtocolListener.java |   72 +
 .../protocol/ProtocolMessageMarshaller.java     |   38 +
 .../protocol/ProtocolMessageUnmarshaller.java   |   38 +
 .../nifi/cluster/protocol/StandardDataFlow.java |  105 +
 .../UnknownServiceAddressException.java         |   39 +
 .../impl/ClusterManagerProtocolSenderImpl.java  |  245 ++
 .../ClusterManagerProtocolSenderListener.java   |  118 +
 .../protocol/impl/ClusterServiceDiscovery.java  |  181 +
 .../protocol/impl/ClusterServiceLocator.java    |  229 ++
 .../impl/ClusterServicesBroadcaster.java        |  182 +
 .../protocol/impl/CopyingInputStream.java       |   77 +
 .../impl/MulticastProtocolListener.java         |  204 +
 .../protocol/impl/NodeProtocolSenderImpl.java   |  171 +
 .../impl/NodeProtocolSenderListener.java        |  115 +
 .../protocol/impl/SocketProtocolListener.java   |  205 +
 .../protocol/jaxb/JaxbProtocolContext.java      |  148 +
 .../jaxb/message/AdaptedConnectionRequest.java  |   40 +
 .../jaxb/message/AdaptedConnectionResponse.java |  109 +
 .../protocol/jaxb/message/AdaptedCounter.java   |   56 +
 .../protocol/jaxb/message/AdaptedDataFlow.java  |   64 +
 .../protocol/jaxb/message/AdaptedHeartbeat.java |   66 +
 .../jaxb/message/AdaptedNodeBulletins.java      |   50 +
 .../jaxb/message/AdaptedNodeIdentifier.java     |   76 +
 .../jaxb/message/ConnectionRequestAdapter.java  |   41 +
 .../jaxb/message/ConnectionResponseAdapter.java |   55 +
 .../protocol/jaxb/message/DataFlowAdapter.java  |   50 +
 .../protocol/jaxb/message/HeartbeatAdapter.java |   54 +
 .../jaxb/message/JaxbProtocolUtils.java         |   42 +
 .../jaxb/message/NodeBulletinsAdapter.java      |   48 +
 .../jaxb/message/NodeIdentifierAdapter.java     |   51 +
 .../protocol/jaxb/message/ObjectFactory.java    |  104 +
 .../message/ConnectionRequestMessage.java       |   46 +
 .../message/ConnectionResponseMessage.java      |   66 +
 .../ControllerStartupFailureMessage.java        |   49 +
 .../protocol/message/DisconnectMessage.java     |   55 +
 .../protocol/message/ExceptionMessage.java      |   44 +
 .../protocol/message/FlowRequestMessage.java    |   46 +
 .../protocol/message/FlowResponseMessage.java   |   44 +
 .../protocol/message/HeartbeatMessage.java      |   43 +
 .../message/MulticastProtocolMessage.java       |   66 +
 .../protocol/message/NodeBulletinsMessage.java  |   43 +
 .../cluster/protocol/message/PingMessage.java   |   55 +
 .../message/PrimaryRoleAssignmentMessage.java   |   56 +
 .../protocol/message/ProtocolMessage.java       |   61 +
 .../message/ReconnectionFailureMessage.java     |   45 +
 .../message/ReconnectionRequestMessage.java     |   94 +
 .../message/ReconnectionResponseMessage.java    |   32 +
 .../message/ServiceBroadcastMessage.java        |   64 +
 .../MulticastConfigurationFactoryBean.java      |   60 +
 .../ServerSocketConfigurationFactoryBean.java   |   65 +
 .../spring/SocketConfigurationFactoryBean.java  |   66 +
 .../resources/nifi-cluster-protocol-context.xml |  110 +
 .../ClusterManagerProtocolSenderImplTest.java   |  134 +
 .../impl/ClusterServiceDiscoveryTest.java       |  135 +
 .../impl/ClusterServiceLocatorTest.java         |  121 +
 .../impl/ClusterServicesBroadcasterTest.java    |  133 +
 .../impl/MulticastProtocolListenerTest.java     |  171 +
 .../impl/NodeProtocolSenderImplTest.java        |  203 +
 .../impl/testutils/DelayedProtocolHandler.java  |   57 +
 .../testutils/ReflexiveProtocolHandler.java     |   47 +
 .../nifi-framework-cluster-web/.gitignore       |    1 +
 .../nifi-framework-cluster-web/pom.xml          |   48 +
 .../nifi/cluster/context/ClusterContext.java    |   59 +
 .../cluster/context/ClusterContextImpl.java     |   69 +
 .../context/ClusterContextThreadLocal.java      |   47 +
 .../ClusterAwareOptimisticLockingManager.java   |   96 +
 .../nifi-framework-cluster/.gitignore           |    1 +
 .../nifi-framework-cluster/pom.xml              |  144 +
 .../cluster/client/MulticastTestClient.java     |  151 +
 .../org/apache/nifi/cluster/event/Event.java    |  122 +
 .../apache/nifi/cluster/event/EventManager.java |   65 +
 .../cluster/event/impl/EventManagerImpl.java    |  143 +
 .../cluster/firewall/ClusterNodeFirewall.java   |   35 +
 .../impl/FileBasedClusterNodeFirewall.java      |  207 +
 .../nifi/cluster/flow/ClusterDataFlow.java      |   45 +
 .../apache/nifi/cluster/flow/DaoException.java  |   40 +
 .../apache/nifi/cluster/flow/DataFlowDao.java   |   62 +
 .../cluster/flow/DataFlowManagementService.java |  115 +
 .../nifi/cluster/flow/PersistedFlowState.java   |   37 +
 .../nifi/cluster/flow/StaleFlowException.java   |   42 +
 .../nifi/cluster/flow/impl/DataFlowDaoImpl.java |  600 +++
 .../impl/DataFlowManagementServiceImpl.java     |  356 ++
 .../nifi/cluster/manager/ClusterManager.java    |  225 ++
 .../cluster/manager/HttpClusterManager.java     |  169 +
 .../cluster/manager/HttpRequestReplicator.java  |   99 +
 .../cluster/manager/HttpResponseMapper.java     |   42 +
 .../nifi/cluster/manager/NodeResponse.java      |  329 ++
 .../exception/BlockedByFirewallException.java   |   60 +
 .../manager/exception/ClusterException.java     |   40 +
 .../ConnectingNodeMutableRequestException.java  |   41 +
 ...DisconnectedNodeMutableRequestException.java |   41 +
 .../exception/IllegalClusterStateException.java |   41 +
 .../exception/IllegalNodeDeletionException.java |   41 +
 .../IllegalNodeDisconnectionException.java      |   42 +
 .../IllegalNodeReconnectionException.java       |   41 +
 .../IneligiblePrimaryNodeException.java         |   41 +
 .../exception/MutableRequestException.java      |   42 +
 .../exception/NoConnectedNodesException.java    |   41 +
 .../exception/NoResponseFromNodesException.java |   42 +
 .../exception/NodeDisconnectionException.java   |   41 +
 .../exception/NodeReconnectionException.java    |   40 +
 .../PrimaryRoleAssignmentException.java         |   41 +
 .../SafeModeMutableRequestException.java        |   41 +
 .../manager/exception/UnknownNodeException.java |   41 +
 .../exception/UriConstructionException.java     |   42 +
 .../manager/impl/ClusteredEventAccess.java      |  135 +
 .../manager/impl/ClusteredReportingContext.java |  165 +
 .../manager/impl/HttpRequestReplicatorImpl.java |  531 +++
 .../manager/impl/HttpResponseMapperImpl.java    |   85 +
 .../cluster/manager/impl/WebClusterManager.java | 3628 ++++++++++++++++++
 .../java/org/apache/nifi/cluster/node/Node.java |  252 ++
 ...anagerProtocolServiceLocatorFactoryBean.java |  116 +
 ...FileBasedClusterNodeFirewallFactoryBean.java |   58 +
 .../spring/WebClusterManagerFactoryBean.java    |  139 +
 .../reporting/ClusteredReportingTaskNode.java   |   49 +
 .../resources/nifi-cluster-manager-context.xml  |  124 +
 .../event/impl/EventManagerImplTest.java        |  119 +
 .../impl/FileBasedClusterNodeFirewallTest.java  |   98 +
 .../impl/DataFlowManagementServiceImplTest.java |  343 ++
 .../impl/HttpRequestReplicatorImplTest.java     |  368 ++
 .../impl/HttpResponseMapperImplTest.java        |  126 +
 .../manager/impl/TestWebClusterManager.java     |   54 +
 .../cluster/manager/testutils/HttpRequest.java  |  239 ++
 .../cluster/manager/testutils/HttpResponse.java |   93 +
 .../manager/testutils/HttpResponseAction.java   |   60 +
 .../cluster/manager/testutils/HttpServer.java   |  240 ++
 .../ClusterManagerProtocolSenderImplTest.java   |  133 +
 .../impl/ClusterServiceLocatorTest.java         |  119 +
 .../impl/ClusterServicesBroadcasterTest.java    |  131 +
 .../impl/MulticastProtocolListenerTest.java     |  171 +
 .../impl/NodeProtocolSenderImplTest.java        |  201 +
 .../impl/SocketProtocolListenerTest.java        |  132 +
 .../testutils/DelayedProtocolHandler.java       |   57 +
 .../testutils/ReflexiveProtocolHandler.java     |   47 +
 .../src/test/resources/logback-test.xml         |   48 +
 .../apache/nifi/cluster/firewall/impl/empty.txt |    0
 .../apache/nifi/cluster/firewall/impl/ips.txt   |   12 +
 .../nifi-framework/nifi-framework-core/pom.xml  |   19 +-
 .../nifi-framework/nifi-web/nifi-web-ui/pom.xml |   13 +
 .../nifi-framework/pom.xml                      |    6 +-
 .../nifi-standard-processors/pom.xml            |   86 +-
 nifi/pom.xml                                    |   36 +-
 303 files changed, 18400 insertions(+), 18280 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/.gitignore
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/.gitignore b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/.gitignore
deleted file mode 100755
index ea8c4bf..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-/target

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/pom.xml
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/pom.xml b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/pom.xml
deleted file mode 100644
index dc70905..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/pom.xml
+++ /dev/null
@@ -1,67 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-  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.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-    <modelVersion>4.0.0</modelVersion>
-    <parent>
-        <groupId>org.apache.nifi</groupId>
-        <artifactId>nifi-framework</artifactId>
-        <version>0.0.3-incubating-SNAPSHOT</version>
-    </parent>
-    <artifactId>nifi-framework-cluster-protocol</artifactId>
-    <packaging>jar</packaging>
-    <description>The messaging protocol for clustered NiFi</description>
-    <dependencies>
-        <!-- application dependencies -->
-        <dependency>
-            <groupId>org.apache.nifi</groupId>
-            <artifactId>nifi-api</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.nifi</groupId>
-            <artifactId>nifi-properties</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.nifi</groupId>
-            <artifactId>nifi-logging-utils</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.nifi</groupId>
-            <artifactId>nifi-socket-utils</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.nifi</groupId>
-            <artifactId>nifi-security</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.nifi</groupId>
-            <artifactId>nifi-framework-core-api</artifactId>
-        </dependency>
-        
-        <!-- spring dependencies -->
-        <dependency>
-            <groupId>org.springframework</groupId>
-            <artifactId>spring-core</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.springframework</groupId>
-            <artifactId>spring-beans</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.springframework</groupId>
-            <artifactId>spring-context</artifactId>
-        </dependency>
-    </dependencies>
-</project>

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ClusterManagerProtocolSender.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ClusterManagerProtocolSender.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ClusterManagerProtocolSender.java
deleted file mode 100644
index fa1547f..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ClusterManagerProtocolSender.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * 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.nifi.cluster.protocol;
-
-import org.apache.nifi.cluster.protocol.message.DisconnectMessage;
-import org.apache.nifi.cluster.protocol.message.FlowRequestMessage;
-import org.apache.nifi.cluster.protocol.message.FlowResponseMessage;
-import org.apache.nifi.cluster.protocol.message.PrimaryRoleAssignmentMessage;
-import org.apache.nifi.cluster.protocol.message.ReconnectionRequestMessage;
-import org.apache.nifi.cluster.protocol.message.ReconnectionResponseMessage;
-import org.apache.nifi.reporting.BulletinRepository;
-
-/**
- * An interface for sending protocol messages from the cluster manager to nodes.
- * 
- * @author unattributed
- */
-public interface ClusterManagerProtocolSender {
-    
-    /**
-     * Sends a "flow request" message to a node.
-     * @param msg a message
-     * @return the response
-     * @throws ProtocolException if communication failed 
-     */
-    FlowResponseMessage requestFlow(FlowRequestMessage msg) throws ProtocolException;
-
-    /**
-     * Sends a "reconnection request" message to a node.
-     * @param msg a message
-     * @return 
-     * @throws ProtocolException if communication failed
-     */
-    ReconnectionResponseMessage requestReconnection(ReconnectionRequestMessage msg) throws ProtocolException;
-    
-    /**
-     * Sends a "disconnection request" message to a node.
-     * @param msg a message
-     * @throws ProtocolException if communication failed
-     */
-    void disconnect(DisconnectMessage msg) throws ProtocolException;
-    
-    /**
-     * Sends an "assign primary role" message to a node.
-     * @param msg a message
-     * @throws ProtocolException if communication failed 
-     */
-    void assignPrimaryRole(PrimaryRoleAssignmentMessage msg) throws ProtocolException;
-
-    /**
-     * Sets the {@link BulletinRepository} that can be used to report bulletins
-     * @param bulletinRepository
-     */
-    void setBulletinRepository(final BulletinRepository bulletinRepository);
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ConnectionRequest.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ConnectionRequest.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ConnectionRequest.java
deleted file mode 100644
index 1b5d007..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ConnectionRequest.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * 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.nifi.cluster.protocol;
-
-import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
-import org.apache.nifi.cluster.protocol.jaxb.message.ConnectionRequestAdapter;
-
-/**
- * A node's request to connect to the cluster.  The request contains a proposed
- * identifier.
- * 
- * @author unattributed
- */
-@XmlJavaTypeAdapter(ConnectionRequestAdapter.class)
-public class ConnectionRequest {
-
-    private final NodeIdentifier proposedNodeIdentifier;
-
-    public ConnectionRequest(final NodeIdentifier proposedNodeIdentifier) {
-        if(proposedNodeIdentifier == null) {
-            throw new IllegalArgumentException("Proposed node identifier may not be null.");
-        }
-        this.proposedNodeIdentifier = proposedNodeIdentifier;
-    }
-
-    public NodeIdentifier getProposedNodeIdentifier() {
-        return proposedNodeIdentifier;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ConnectionResponse.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ConnectionResponse.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ConnectionResponse.java
deleted file mode 100644
index 7a5ff2b..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ConnectionResponse.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * 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.nifi.cluster.protocol;
-
-import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
-
-import org.apache.nifi.cluster.protocol.jaxb.message.ConnectionResponseAdapter;
-
-/**
- * The cluster manager's response to a node's connection request.  If the manager
- * has a current copy of the data flow, then it is returned with a node identifier
- * to the node.  Otherwise, the manager will provide a "try again in X seconds" 
- * response to the node in hopes that a current data flow will be available upon
- * subsequent requests.
- * 
- * @author unattributed
- */
-@XmlJavaTypeAdapter(ConnectionResponseAdapter.class)
-public class ConnectionResponse {
-
-    private final boolean blockedByFirewall;
-    private final int tryLaterSeconds;
-    private final NodeIdentifier nodeIdentifier;
-    private final StandardDataFlow dataFlow;
-    private final boolean primary;
-    private final Integer managerRemoteInputPort;
-    private final Boolean managerRemoteCommsSecure;
-    private final String instanceId;
-    
-    private volatile String clusterManagerDN;
-    
-    public ConnectionResponse(final NodeIdentifier nodeIdentifier, final StandardDataFlow dataFlow, final boolean primary, 
-        final Integer managerRemoteInputPort, final Boolean managerRemoteCommsSecure, final String instanceId) {
-        if(nodeIdentifier == null) {
-            throw new IllegalArgumentException("Node identifier may not be empty or null.");
-        } else if(dataFlow == null) {
-            throw new IllegalArgumentException("DataFlow may not be null.");
-        }
-        this.nodeIdentifier = nodeIdentifier;
-        this.dataFlow = dataFlow;
-        this.tryLaterSeconds = 0;
-        this.blockedByFirewall = false;
-        this.primary = primary;
-        this.managerRemoteInputPort = managerRemoteInputPort;
-        this.managerRemoteCommsSecure = managerRemoteCommsSecure;
-        this.instanceId = instanceId;
-    }
-    
-    public ConnectionResponse(final int tryLaterSeconds) {
-        if(tryLaterSeconds <= 0) {
-            throw new IllegalArgumentException("Try-Later seconds may not be nonnegative: " + tryLaterSeconds);
-        }
-        this.dataFlow = null;
-        this.nodeIdentifier = null;
-        this.tryLaterSeconds = tryLaterSeconds;
-        this.blockedByFirewall = false;
-        this.primary = false;
-        this.managerRemoteInputPort = null;
-        this.managerRemoteCommsSecure = null;
-        this.instanceId = null;
-    }
-
-    private ConnectionResponse() {
-        this.dataFlow = null;
-        this.nodeIdentifier = null;
-        this.tryLaterSeconds = 0;
-        this.blockedByFirewall = true;
-        this.primary = false;
-        this.managerRemoteInputPort = null;
-        this.managerRemoteCommsSecure = null;
-        this.instanceId = null;
-    }
-    
-    public static ConnectionResponse createBlockedByFirewallResponse() {
-        return new ConnectionResponse();
-    }
-    
-    public boolean isPrimary() {
-        return primary;
-    }
-    
-    public boolean shouldTryLater() {
-        return tryLaterSeconds > 0;
-    }
-    
-    public boolean isBlockedByFirewall() {
-        return blockedByFirewall;
-    }
-
-    public int getTryLaterSeconds() {
-        return tryLaterSeconds;
-    }
-    
-    public StandardDataFlow getDataFlow() {
-        return dataFlow;
-    }
-    
-    public NodeIdentifier getNodeIdentifier() {
-        return nodeIdentifier;
-    }
-
-    public Integer getManagerRemoteInputPort() {
-        return managerRemoteInputPort;
-    }
-    
-    public Boolean isManagerRemoteCommsSecure() {
-        return managerRemoteCommsSecure;
-    }
-    
-    public String getInstanceId() {
-        return instanceId;
-    }
-    
-    public void setClusterManagerDN(final String dn) {
-        this.clusterManagerDN = dn;
-    }
-    
-    /**
-     * Returns the DN of the NCM, if it is available or <code>null</code> otherwise.
-     * 
-     * @return
-     */
-    public String getClusterManagerDN() {
-        return clusterManagerDN;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/Heartbeat.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/Heartbeat.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/Heartbeat.java
deleted file mode 100644
index 67324a1..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/Heartbeat.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * 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.nifi.cluster.protocol;
-
-import java.util.Date;
-import javax.xml.bind.annotation.XmlTransient;
-import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
-import org.apache.nifi.cluster.protocol.jaxb.message.HeartbeatAdapter;
-
-/**
- * A heartbeat for indicating the status of a node to the cluster.
- * @author unattributed
- */
-@XmlJavaTypeAdapter(HeartbeatAdapter.class)
-public class Heartbeat {
-    
-    private final NodeIdentifier nodeIdentifier;
-    private final boolean primary;
-    private final boolean connected;
-    private final long createdTimestamp;
-    private final byte[] payload;
-    
-    public Heartbeat(final NodeIdentifier nodeIdentifier, final boolean primary, final boolean connected, final byte[] payload) {
-        if(nodeIdentifier == null) {
-            throw new IllegalArgumentException("Node Identifier may not be null.");
-        } 
-        this.nodeIdentifier = nodeIdentifier;
-        this.primary = primary;
-        this.connected = connected;
-        this.payload = payload;
-        this.createdTimestamp = new Date().getTime();
-    }
-    
-    public NodeIdentifier getNodeIdentifier() {
-        return nodeIdentifier;
-    }
-    
-    public byte[] getPayload() {
-        return payload;
-    }
-    
-    public boolean isPrimary() {
-        return primary;
-    }
-    
-    public boolean isConnected() {
-        return connected;
-    }
-    
-    @XmlTransient
-    public long getCreatedTimestamp() {
-        return createdTimestamp;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/NodeBulletins.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/NodeBulletins.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/NodeBulletins.java
deleted file mode 100644
index a120524..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/NodeBulletins.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * 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.nifi.cluster.protocol;
-
-import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
-import org.apache.nifi.cluster.protocol.jaxb.message.NodeBulletinsAdapter;
-
-/**
- *
- */
-@XmlJavaTypeAdapter(NodeBulletinsAdapter.class)
-public class NodeBulletins {
-
-    private final NodeIdentifier nodeIdentifier;
-    private final byte[] payload;
-
-    public NodeBulletins(NodeIdentifier nodeIdentifier, byte[] payload) {
-        this.nodeIdentifier = nodeIdentifier;
-        this.payload = payload;
-    }
-
-    public NodeIdentifier getNodeIdentifier() {
-        return nodeIdentifier;
-    }
-
-    public byte[] getPayload() {
-        return payload;
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/NodeIdentifier.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/NodeIdentifier.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/NodeIdentifier.java
deleted file mode 100644
index 1893186..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/NodeIdentifier.java
+++ /dev/null
@@ -1,172 +0,0 @@
-/*
- * 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.nifi.cluster.protocol;
-
-import org.apache.commons.lang3.StringUtils;
-
-/**
- * A node identifier denoting the coordinates of a flow controller that is connected 
- * to a cluster.  Nodes provide an external public API interface and an internal private
- * interface for communicating with the cluster.
- * 
- * The external API interface and internal protocol each require an IP or hostname 
- * as well as a port for communicating. 
- * 
- * This class overrides hashCode and equals and considers two instances to be
- * equal if they have the equal IDs.
- * 
- * @author unattributed
- * @Immutable
- * @Threadsafe
- */
-public class NodeIdentifier {
- 
-    /** the unique identifier for the node */
-    private final String id;
-    
-    /** the IP or hostname to use for sending requests to the node's external interface */
-    private final String apiAddress;
-    
-    /** the port to use use for sending requests to the node's external interface */
-    private final int apiPort;    
-    
-    /** the IP or hostname to use for sending requests to the node's internal interface */
-    private final String socketAddress;
-    
-    /** the port to use use for sending requests to the node's internal interface */
-    private final int socketPort;
-    
-    private final String nodeDn;
-
-    public NodeIdentifier(final String id, final String apiAddress, final int apiPort, final String socketAddress, final int socketPort) {
-        this(id, apiAddress, apiPort, socketAddress, socketPort, null);
-    }
-    
-    public NodeIdentifier(final String id, final String apiAddress, final int apiPort, final String socketAddress, final int socketPort, final String dn) {
-        
-        if(StringUtils.isBlank(id)) {
-            throw new IllegalArgumentException("Node ID may not be empty or null.");
-        } else if(StringUtils.isBlank(apiAddress)) {
-            throw new IllegalArgumentException("Node API address may not be empty or null.");
-        } else if(StringUtils.isBlank(socketAddress)) {
-            throw new IllegalArgumentException("Node socket address may not be empty or null.");
-        } 
-        
-        validatePort(apiPort);
-        validatePort(socketPort);
-        
-        this.id = id;
-        this.apiAddress = apiAddress;
-        this.apiPort = apiPort;
-        this.socketAddress = socketAddress;
-        this.socketPort = socketPort;
-        this.nodeDn = dn;
-    }
-
-    public String getId() {
-        return id;
-    }
-    
-    public String getDN() {
-        return nodeDn;
-    }
-    
-    public String getApiAddress() {
-        return apiAddress;
-    }
-
-    public int getApiPort() {
-        return apiPort;
-    }
-
-    public String getSocketAddress() {
-        return socketAddress;
-    }
-    
-    public int getSocketPort() {
-        return socketPort;
-    }
-    
-    private void validatePort(final int port) {
-        if(port < 1 || port > 65535) {
-            throw new IllegalArgumentException("Port must be inclusively in the range [1, 65535].  Port given: " + port);
-        }   
-    }
-    
-    /**
-     * Compares the id of two node identifiers for equality.
-     * 
-     * @param obj a node identifier
-     * 
-     * @return true if the id is equal; false otherwise
-     */
-    @Override
-    public boolean equals(Object obj) {
-        if (obj == null) {
-            return false;
-        }
-        if (getClass() != obj.getClass()) {
-            return false;
-        }
-        final NodeIdentifier other = (NodeIdentifier) obj;
-        if ((this.id == null) ? (other.id != null) : !this.id.equals(other.id)) {
-            return false;
-        }
-        return true;
-    }
-
-    /**
-     * Compares API address/port and socket address/port for equality.  The 
-     * id is not used for comparison.
-     * 
-     * @param other a node identifier
-     * 
-     * @return true if API address/port and socket address/port are equal; false
-     * otherwise
-     */
-    public boolean logicallyEquals(final NodeIdentifier other) {
-        if(other == null) {
-            return false;
-        }
-        if ((this.apiAddress == null) ? (other.apiAddress != null) : !this.apiAddress.equals(other.apiAddress)) {
-            return false;
-        }
-        if(this.apiPort != other.apiPort) {
-            return false;
-        }
-        if ((this.socketAddress == null) ? (other.socketAddress != null) : !this.socketAddress.equals(other.socketAddress)) {
-            return false;
-        }
-        if(this.socketPort != other.socketPort) {
-            return false;
-        }
-        return true;
-    }
-    
-    @Override
-    public int hashCode() {
-        int hash = 7;
-        hash = 31 * hash + (this.id != null ? this.id.hashCode() : 0);
-        return hash;
-    }
-
-    @Override
-    public String toString() {
-        return "[" + "id=" + id + ", apiAddress=" + apiAddress + ", apiPort=" + apiPort + ", socketAddress=" + socketAddress + ", socketPort=" + socketPort + ']';
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/NodeProtocolSender.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/NodeProtocolSender.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/NodeProtocolSender.java
deleted file mode 100644
index 1edcb91..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/NodeProtocolSender.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * 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.nifi.cluster.protocol;
-
-import org.apache.nifi.cluster.protocol.message.ConnectionRequestMessage;
-import org.apache.nifi.cluster.protocol.message.ConnectionResponseMessage;
-import org.apache.nifi.cluster.protocol.message.ControllerStartupFailureMessage;
-import org.apache.nifi.cluster.protocol.message.HeartbeatMessage;
-import org.apache.nifi.cluster.protocol.message.NodeBulletinsMessage;
-import org.apache.nifi.cluster.protocol.message.ReconnectionFailureMessage;
-
-/**
- * An interface for sending protocol messages from a node to the cluster manager.
- * @author unattributed
- */
-public interface NodeProtocolSender {
-    
-    /**
-     * Sends a "connection request" message to the cluster manager.
-     * @param msg a message
-     * @return the response
-     * @throws UnknownServiceAddressException if the cluster manager's address is not known
-     * @throws ProtocolException if communication failed
-     */
-    ConnectionResponseMessage requestConnection(ConnectionRequestMessage msg) throws ProtocolException, UnknownServiceAddressException;
-    
-    /**
-     * Sends a "heartbeat" message to the cluster manager.
-     * @param msg a message
-     * @throws UnknownServiceAddressException if the cluster manager's address is not known
-     * @throws ProtocolException if communication failed
-     */
-    void heartbeat(HeartbeatMessage msg) throws ProtocolException, UnknownServiceAddressException;
-    
-    /**
-     * Sends a bulletins message to the cluster manager.
-     * @param msg
-     * @throws ProtocolException
-     * @throws UnknownServiceAddressException 
-     */
-    void sendBulletins(NodeBulletinsMessage msg) throws ProtocolException, UnknownServiceAddressException;
-    
-    /**
-     * Sends a failure notification if the controller was unable start.
-     * @param msg a message
-     * @throws UnknownServiceAddressException if the cluster manager's address is not known
-     * @throws ProtocolException if communication failed
-     */
-    void notifyControllerStartupFailure(ControllerStartupFailureMessage msg) throws ProtocolException, UnknownServiceAddressException;
-    
-    /**
-     * Sends a failure notification if the node was unable to reconnect to the cluster
-     * @param msg a message
-     * @throws UnknownServiceAddressException if the cluster manager's address is not known
-     * @throws ProtocolException if communication failed
-     */
-    void notifyReconnectionFailure(ReconnectionFailureMessage msg) throws ProtocolException, UnknownServiceAddressException;
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ProtocolContext.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ProtocolContext.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ProtocolContext.java
deleted file mode 100644
index b614e76..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ProtocolContext.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * 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.nifi.cluster.protocol;
-
-/**
- * The context for communicating using the internal cluster protocol. 
- * 
- * @param <T> The type of protocol message.
- * 
- * @author unattributed
- */
-public interface ProtocolContext<T> {
- 
-    /**
-     * Creates a marshaller for serializing protocol messages.
-     * @return a marshaller
-     */
-    ProtocolMessageMarshaller<T> createMarshaller();
-    
-    /**
-     * Creates an unmarshaller for deserializing protocol messages.
-     * @return a unmarshaller
-     */
-    ProtocolMessageUnmarshaller<T> createUnmarshaller();
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ProtocolException.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ProtocolException.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ProtocolException.java
deleted file mode 100644
index f11ad84..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ProtocolException.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * 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.nifi.cluster.protocol;
-
-/**
- * The base exception for problems encountered while communicating within the
- * cluster.
- * @author unattributed
- */
-public class ProtocolException extends RuntimeException {
-    
-    public ProtocolException() {
-    }
-    
-    public ProtocolException(String msg) {
-        super(msg);
-    }
-    
-    public ProtocolException(Throwable cause) {
-        super(cause);
-    }
-    
-    public ProtocolException(String msg, Throwable cause) {
-        super(msg, cause);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ProtocolHandler.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ProtocolHandler.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ProtocolHandler.java
deleted file mode 100644
index 6de87db..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ProtocolHandler.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * 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.nifi.cluster.protocol;
-
-import org.apache.nifi.cluster.protocol.message.ProtocolMessage;
-
-/**
- * A handler for processing protocol messages.
- * @author unattributed
- */
-public interface ProtocolHandler {
-    
-    /**
-     * Handles the given protocol message or throws an exception if it cannot
-     * handle the message.  If no response is needed by the protocol, then null
-     * should be returned.
-     * 
-     * @param msg a message
-     * @return a response or null, if no response is necessary
-     * 
-     * @throws ProtocolException if the message could not be processed
-     */
-    ProtocolMessage handle(ProtocolMessage msg) throws ProtocolException;
-    
-    /**
-     * @param msg
-     * @return true if the handler can process the given message; false otherwise
-     */
-    boolean canHandle(ProtocolMessage msg);
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ProtocolListener.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ProtocolListener.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ProtocolListener.java
deleted file mode 100644
index 32f0f5d..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ProtocolListener.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * 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.nifi.cluster.protocol;
-
-import java.io.IOException;
-import java.util.Collection;
-
-import org.apache.nifi.reporting.BulletinRepository;
-
-/**
- * Defines the interface for a listener to process protocol messages.
- * @author unattributed
- */
-public interface ProtocolListener {
-    
-    /**
-     * Starts the instance for listening for messages.  Start may only be called
-     * if the instance is not running.
-     * @throws java.io.IOException
-     */
-    void start() throws IOException;
-    
-    /**
-     * Stops the instance from listening for messages.  Stop may only be called
-     * if the instance is running.
-     * @throws java.io.IOException
-     */
-    void stop() throws IOException;
-    
-    /**
-     * @return true if the instance is started; false otherwise.
-     */
-    boolean isRunning();
-    
-    /**
-     * @return the handlers registered with the listener
-     */
-    Collection<ProtocolHandler> getHandlers();
-    
-    /**
-     * Registers a handler with the listener.
-     * @param handler a handler
-     */
-    void addHandler(ProtocolHandler handler);
-    
-    /**
-     * Sets the BulletinRepository that can be used to report bulletins
-     * @param bulletinRepository
-     */
-    void setBulletinRepository(BulletinRepository bulletinRepository);
-    
-    /**
-     * Unregisters the handler with the listener.
-     * @param handler a handler
-     * @return true if the handler was removed; false otherwise
-     */
-    boolean removeHandler(ProtocolHandler handler);
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ProtocolMessageMarshaller.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ProtocolMessageMarshaller.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ProtocolMessageMarshaller.java
deleted file mode 100644
index bb436e0..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ProtocolMessageMarshaller.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * 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.nifi.cluster.protocol;
-
-import java.io.IOException;
-import java.io.OutputStream;
-
-/**
- * Defines a marshaller for serializing protocol messages.
- * 
- * @param <T> The type of protocol message.
- * 
- * @author unattributed
- */
-public interface ProtocolMessageMarshaller<T> {
-    
-    /**
-     * Serializes the given message to the given output stream.
-     * @param msg a message
-     * @param os an output stream
-     * @throws IOException if the message could not be serialized to the stream
-     */
-    void marshal(T msg, OutputStream os) throws IOException;
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ProtocolMessageUnmarshaller.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ProtocolMessageUnmarshaller.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ProtocolMessageUnmarshaller.java
deleted file mode 100644
index c690e7b..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/ProtocolMessageUnmarshaller.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * 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.nifi.cluster.protocol;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-/**
- * Defines an unmarshaller for deserializing protocol messages.
- * 
- * @param <T> The type of protocol message.
- * 
- * @author unattributed
- */
-public interface ProtocolMessageUnmarshaller<T> {
-    
-    /**
-     * Deserializes a message on the given input stream.
-     * @param is an input stream
-     * @return 
-     * @throws IOException if the message could not be deserialized from the stream
-     */
-    T unmarshal(InputStream is) throws IOException;
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/StandardDataFlow.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/StandardDataFlow.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/StandardDataFlow.java
deleted file mode 100644
index c2d16fc..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/StandardDataFlow.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * 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.nifi.cluster.protocol;
-
-import org.apache.nifi.cluster.protocol.DataFlow;
-import java.io.Serializable;
-import java.util.Arrays;
-
-import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
-
-import org.apache.nifi.cluster.protocol.jaxb.message.DataFlowAdapter;
-
-/**
- * Represents a dataflow, which includes the raw bytes of the flow.xml and 
- * whether processors should be started automatically at application startup.
- */
-@XmlJavaTypeAdapter(DataFlowAdapter.class)
-public class StandardDataFlow implements Serializable, DataFlow {
-    
-    private final byte[] flow;
-    private final byte[] templateBytes;
-    private final byte[] snippetBytes;
-
-    private boolean autoStartProcessors;
-    
-    /**
-     * Constructs an instance.  
-     * 
-     * @param flow a valid flow as bytes, which cannot be null
-     * @param templateBytes an XML representation of templates
-     * @param snippetBytes an XML representation of snippets
-     * 
-     * @throws NullPointerException if any argument is null
-     */
-    public StandardDataFlow(final byte[] flow, final byte[] templateBytes, final byte[] snippetBytes) {
-        this.flow = flow;
-        this.templateBytes = templateBytes;
-        this.snippetBytes = snippetBytes;
-    }
-    
-    public StandardDataFlow(final DataFlow toCopy) {
-        this.flow = copy(toCopy.getFlow());
-        this.templateBytes = copy(toCopy.getTemplates());
-        this.snippetBytes = copy(toCopy.getSnippets());
-        this.autoStartProcessors = toCopy.isAutoStartProcessors();
-    }
-    
-    private static byte[] copy(final byte[] bytes) {
-        return bytes == null ? null : Arrays.copyOf(bytes, bytes.length);
-    }
-    
-    /**
-     * @return the raw byte array of the flow 
-     */
-    public byte[] getFlow() {
-        return flow;
-    }
-
-    /**
-     * @return the raw byte array of the templates
-     */
-    public byte[] getTemplates() {
-        return templateBytes;
-    }
-    
-    /**
-     * @return the raw byte array of the snippets
-     */
-    public byte[] getSnippets() {
-        return snippetBytes;
-    }
-    
-    /**
-     * @return true if processors should be automatically started at application 
-     * startup; false otherwise 
-     */
-    public boolean isAutoStartProcessors() {
-        return autoStartProcessors;
-    }
-    
-    /**
-     * 
-     * Sets the flag to automatically start processors at application startup.
-     * 
-     * @param autoStartProcessors true if processors should be automatically
-     * started at application startup; false otherwise
-     */
-    public void setAutoStartProcessors(final boolean autoStartProcessors) {
-        this.autoStartProcessors = autoStartProcessors;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/UnknownServiceAddressException.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/UnknownServiceAddressException.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/UnknownServiceAddressException.java
deleted file mode 100644
index 41c74eb..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/UnknownServiceAddressException.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * 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.nifi.cluster.protocol;
-
-/**
- * Represents the exceptional case when a service's address is not known.
- * @author unattributed
- */
-public class UnknownServiceAddressException extends RuntimeException {
-    
-    public UnknownServiceAddressException() {
-    }
-    
-    public UnknownServiceAddressException(String msg) {
-        super(msg);
-    }
-    
-    public UnknownServiceAddressException(Throwable cause) {
-        super(cause);
-    }
-    
-    public UnknownServiceAddressException(String msg, Throwable cause) {
-        super(msg, cause);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/ClusterManagerProtocolSenderImpl.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/ClusterManagerProtocolSenderImpl.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/ClusterManagerProtocolSenderImpl.java
deleted file mode 100644
index ceb3fcb..0000000
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/ClusterManagerProtocolSenderImpl.java
+++ /dev/null
@@ -1,245 +0,0 @@
-/*
- * 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.nifi.cluster.protocol.impl;
-
-import java.io.IOException;
-import java.net.InetSocketAddress;
-import java.net.Socket;
-import java.net.SocketException;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.nifi.cluster.protocol.ClusterManagerProtocolSender;
-import org.apache.nifi.cluster.protocol.NodeIdentifier;
-import org.apache.nifi.cluster.protocol.ProtocolContext;
-import org.apache.nifi.cluster.protocol.ProtocolException;
-import org.apache.nifi.cluster.protocol.ProtocolMessageMarshaller;
-import org.apache.nifi.cluster.protocol.ProtocolMessageUnmarshaller;
-import org.apache.nifi.cluster.protocol.message.DisconnectMessage;
-import org.apache.nifi.cluster.protocol.message.FlowRequestMessage;
-import org.apache.nifi.cluster.protocol.message.FlowResponseMessage;
-import org.apache.nifi.cluster.protocol.message.PrimaryRoleAssignmentMessage;
-import org.apache.nifi.cluster.protocol.message.ProtocolMessage;
-import org.apache.nifi.cluster.protocol.message.ProtocolMessage.MessageType;
-import org.apache.nifi.cluster.protocol.message.ReconnectionRequestMessage;
-import org.apache.nifi.cluster.protocol.message.ReconnectionResponseMessage;
-import org.apache.nifi.io.socket.SocketConfiguration;
-import org.apache.nifi.io.socket.SocketUtils;
-import org.apache.nifi.reporting.BulletinRepository;
-import org.apache.nifi.util.FormatUtils;
-
-/**
- * A protocol sender for sending protocol messages from the cluster manager to
- * nodes.  
- * 
- * Connection-type requests (e.g., reconnection, disconnection) by nature of 
- * starting/stopping flow controllers take longer than other types of protocol 
- * messages.  Therefore, a handshake timeout may be specified to lengthen the 
- * allowable time for communication with the node.
- * 
- * @author unattributed
- */
-public class ClusterManagerProtocolSenderImpl implements ClusterManagerProtocolSender {
-
-    
-    private final ProtocolContext<ProtocolMessage> protocolContext;
-    private final SocketConfiguration socketConfiguration;
-    private int handshakeTimeoutSeconds;
-    private volatile BulletinRepository bulletinRepository;
-
-    public ClusterManagerProtocolSenderImpl(final SocketConfiguration socketConfiguration, final ProtocolContext<ProtocolMessage> protocolContext) {
-        if(socketConfiguration == null) {
-            throw new IllegalArgumentException("Socket configuration may not be null.");
-        } else if(protocolContext == null) {
-            throw new IllegalArgumentException("Protocol Context may not be null.");
-        }
-        this.socketConfiguration = socketConfiguration;
-        this.protocolContext = protocolContext;
-        this.handshakeTimeoutSeconds = -1;  // less than zero denotes variable not configured
-    }
-    
-    @Override
-    public void setBulletinRepository(final BulletinRepository bulletinRepository) {
-        this.bulletinRepository = bulletinRepository;
-    }
-
-    /**
-     * Requests the data flow from a node.
-     * @param msg a message
-     * @return the message response
-     * @throws @throws ProtocolException if the message failed to be sent or the response was malformed
-     */
-    @Override
-    public FlowResponseMessage requestFlow(final FlowRequestMessage msg) throws ProtocolException {
-        Socket socket = null;
-        try {
-        	socket = createSocket(msg.getNodeId(), false);
-            
-            try {
-                // marshal message to output stream
-                final ProtocolMessageMarshaller<ProtocolMessage> marshaller = protocolContext.createMarshaller();
-                marshaller.marshal(msg, socket.getOutputStream());
-            } catch(final IOException ioe) {
-                throw new ProtocolException("Failed marshalling '" + msg.getType() + "' protocol message due to: " + ioe, ioe);
-            }
-            
-            final ProtocolMessage response;
-            try {
-                // unmarshall response and return
-                final ProtocolMessageUnmarshaller<ProtocolMessage> unmarshaller = protocolContext.createUnmarshaller();
-                response = unmarshaller.unmarshal(socket.getInputStream());
-            } catch(final IOException ioe) {
-                throw new ProtocolException("Failed unmarshalling '" + MessageType.FLOW_RESPONSE + "' protocol message due to: " + ioe, ioe);
-            } 
-            
-            if(MessageType.FLOW_RESPONSE == response.getType()) {
-                return (FlowResponseMessage) response;
-            } else {
-                throw new ProtocolException("Expected message type '" + MessageType.FLOW_RESPONSE + "' but found '" + response.getType() + "'");
-            }
-            
-        } finally {
-            SocketUtils.closeQuietly(socket);
-        }
-    }
-
-    /**
-     * Requests a node to reconnect to the cluster.  The configured value for
-     * handshake timeout is applied to the socket before making the request.
-     * @param msg a message
-     * @return the response
-     * @throws ProtocolException if the message failed to be sent or the response was malformed
-     */
-    @Override
-    public ReconnectionResponseMessage requestReconnection(final ReconnectionRequestMessage msg) throws ProtocolException {
-        Socket socket = null;
-        try {
-        	socket = createSocket(msg.getNodeId(), true);
-
-            // marshal message to output stream
-            try {
-                final ProtocolMessageMarshaller<ProtocolMessage> marshaller = protocolContext.createMarshaller();
-                marshaller.marshal(msg, socket.getOutputStream());
-            } catch(final IOException ioe) {
-                throw new ProtocolException("Failed marshalling '" + msg.getType() + "' protocol message due to: " + ioe, ioe);
-            }
-            
-            
-            final ProtocolMessage response;
-            try {
-                // unmarshall response and return
-                final ProtocolMessageUnmarshaller<ProtocolMessage> unmarshaller = protocolContext.createUnmarshaller();
-                response = unmarshaller.unmarshal(socket.getInputStream());
-            } catch(final IOException ioe) {
-                throw new ProtocolException("Failed unmarshalling '" + MessageType.RECONNECTION_RESPONSE + "' protocol message due to: " + ioe, ioe);
-            } 
-            
-            if(MessageType.RECONNECTION_RESPONSE == response.getType()) {
-                return (ReconnectionResponseMessage) response;
-            } else {
-                throw new ProtocolException("Expected message type '" + MessageType.FLOW_RESPONSE + "' but found '" + response.getType() + "'");
-            }
-        } finally {
-            SocketUtils.closeQuietly(socket);
-        }
-    }
-    
-    /**
-     * Requests a node to disconnect from the cluster.  The configured value for
-     * handshake timeout is applied to the socket before making the request.
-     * @param msg a message
-     * @throws ProtocolException if the message failed to be sent
-     */
-    @Override
-    public void disconnect(final DisconnectMessage msg) throws ProtocolException {
-        Socket socket = null;
-        try {
-        	socket = createSocket(msg.getNodeId(), true);
-
-            // marshal message to output stream
-            try {
-                final ProtocolMessageMarshaller<ProtocolMessage> marshaller = protocolContext.createMarshaller();
-                marshaller.marshal(msg, socket.getOutputStream());
-            } catch(final IOException ioe) {
-                throw new ProtocolException("Failed marshalling '" + msg.getType() + "' protocol message due to: " + ioe, ioe);
-            }
-        } finally {
-            SocketUtils.closeQuietly(socket);
-        }
-    }
-
-    /**
-     * Assigns the primary role to a node.
-     * 
-     * @param msg a message
-     * 
-     * @throws ProtocolException if the message failed to be sent
-     */
-    @Override
-    public void assignPrimaryRole(final PrimaryRoleAssignmentMessage msg) throws ProtocolException {
-        Socket socket = null;
-        try {
-        	socket = createSocket(msg.getNodeId(), true);
-
-            try {
-                // marshal message to output stream
-                final ProtocolMessageMarshaller<ProtocolMessage> marshaller = protocolContext.createMarshaller();
-                marshaller.marshal(msg, socket.getOutputStream());
-            } catch(final IOException ioe) {
-                throw new ProtocolException("Failed marshalling '" + msg.getType() + "' protocol message due to: " + ioe, ioe);
-            }
-        } finally {
-            SocketUtils.closeQuietly(socket);
-        }
-    }
-    
-    
-    private void setConnectionHandshakeTimeoutOnSocket(final Socket socket) throws SocketException {
-        // update socket timeout, if handshake timeout was set; otherwise use socket's current timeout
-        if(handshakeTimeoutSeconds >= 0) {
-            socket.setSoTimeout(handshakeTimeoutSeconds * 1000);
-        }   
-    }
-    
-    public SocketConfiguration getSocketConfiguration() {
-        return socketConfiguration;
-    }
-
-    public int getHandshakeTimeoutSeconds() {
-        return handshakeTimeoutSeconds;
-    }
-
-    public void setHandshakeTimeout(final String handshakeTimeout) {
-        this.handshakeTimeoutSeconds = (int) FormatUtils.getTimeDuration(handshakeTimeout, TimeUnit.SECONDS);
-    }
-
-    private Socket createSocket(final NodeIdentifier nodeId, final boolean applyHandshakeTimeout) {
-    	return createSocket(nodeId.getSocketAddress(), nodeId.getSocketPort(), applyHandshakeTimeout);
-    }
-    
-    private Socket createSocket(final String host, final int port, final boolean applyHandshakeTimeout) {
-    	try {
-            // create a socket
-            final Socket socket = SocketUtils.createSocket(InetSocketAddress.createUnresolved(host, port), socketConfiguration);
-            if ( applyHandshakeTimeout ) {
-            	setConnectionHandshakeTimeoutOnSocket(socket);
-            }
-            return socket;
-        } catch(final IOException ioe) {
-            throw new ProtocolException("Failed to create socket due to: " + ioe, ioe);
-        }
-    }
-}


[05/20] incubator-nifi git commit: NIFI-410 pushed RAT exclusions down to the relevant modules and stopped doing broad test resource exclusion - is now specific

Posted by jo...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/BlockedByFirewallException.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/BlockedByFirewallException.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/BlockedByFirewallException.java
new file mode 100644
index 0000000..49bcd35
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/BlockedByFirewallException.java
@@ -0,0 +1,60 @@
+/*
+ * 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.nifi.cluster.manager.exception;
+
+import org.apache.nifi.cluster.protocol.NodeIdentifier;
+
+/**
+ *
+ */
+public class BlockedByFirewallException extends ClusterException {
+
+    private final NodeIdentifier nodeId;
+    private final boolean isExistingNode;
+
+    public BlockedByFirewallException(NodeIdentifier nodeId, boolean isExistingNode, String msg, Throwable cause) {
+        super(msg, cause);
+        this.nodeId = nodeId;
+        this.isExistingNode = isExistingNode;
+    }
+
+    public BlockedByFirewallException(NodeIdentifier nodeId, boolean isExistingNode, Throwable cause) {
+        super(cause);
+        this.nodeId = nodeId;
+        this.isExistingNode = isExistingNode;
+    }
+
+    public BlockedByFirewallException(NodeIdentifier nodeId, boolean isExistingNode, String msg) {
+        super(msg);
+        this.nodeId = nodeId;
+        this.isExistingNode = isExistingNode;
+    }
+
+    public BlockedByFirewallException(NodeIdentifier nodeId, boolean isExistingNode) {
+        this.nodeId = nodeId;
+        this.isExistingNode = isExistingNode;
+    }
+
+    public NodeIdentifier getNodeId() {
+        return nodeId;
+    }
+
+    public boolean isExistingNode() {
+        return isExistingNode;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/ClusterException.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/ClusterException.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/ClusterException.java
new file mode 100644
index 0000000..3bf9752
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/ClusterException.java
@@ -0,0 +1,40 @@
+/*
+ * 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.nifi.cluster.manager.exception;
+
+/**
+ * The base exception class for cluster related exceptions.
+ *
+ * @author unattributed
+ */
+public class ClusterException extends RuntimeException {
+
+    public ClusterException() {
+    }
+
+    public ClusterException(String msg) {
+        super(msg);
+    }
+
+    public ClusterException(Throwable cause) {
+        super(cause);
+    }
+
+    public ClusterException(String msg, Throwable cause) {
+        super(msg, cause);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/ConnectingNodeMutableRequestException.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/ConnectingNodeMutableRequestException.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/ConnectingNodeMutableRequestException.java
new file mode 100644
index 0000000..365b5f0
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/ConnectingNodeMutableRequestException.java
@@ -0,0 +1,41 @@
+/*
+ * 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.nifi.cluster.manager.exception;
+
+/**
+ * Represents the exceptional case when a HTTP request that may change a node's
+ * dataflow is to be replicated while a node is connecting to the cluster.
+ *
+ * @author unattributed
+ */
+public class ConnectingNodeMutableRequestException extends MutableRequestException {
+
+    public ConnectingNodeMutableRequestException() {
+    }
+
+    public ConnectingNodeMutableRequestException(String msg) {
+        super(msg);
+    }
+
+    public ConnectingNodeMutableRequestException(Throwable cause) {
+        super(cause);
+    }
+
+    public ConnectingNodeMutableRequestException(String msg, Throwable cause) {
+        super(msg, cause);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/DisconnectedNodeMutableRequestException.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/DisconnectedNodeMutableRequestException.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/DisconnectedNodeMutableRequestException.java
new file mode 100644
index 0000000..412a555
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/DisconnectedNodeMutableRequestException.java
@@ -0,0 +1,41 @@
+/*
+ * 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.nifi.cluster.manager.exception;
+
+/**
+ * Represents the exceptional case when a HTTP request that may change a node's
+ * dataflow is to be replicated while one or more nodes are disconnected.
+ *
+ * @author unattributed
+ */
+public class DisconnectedNodeMutableRequestException extends MutableRequestException {
+
+    public DisconnectedNodeMutableRequestException() {
+    }
+
+    public DisconnectedNodeMutableRequestException(String msg) {
+        super(msg);
+    }
+
+    public DisconnectedNodeMutableRequestException(Throwable cause) {
+        super(cause);
+    }
+
+    public DisconnectedNodeMutableRequestException(String msg, Throwable cause) {
+        super(msg, cause);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/IllegalClusterStateException.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/IllegalClusterStateException.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/IllegalClusterStateException.java
new file mode 100644
index 0000000..6c4e670
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/IllegalClusterStateException.java
@@ -0,0 +1,41 @@
+/*
+ * 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.nifi.cluster.manager.exception;
+
+/**
+ * Signals that an operation to be performed on a cluster has been invoked at an
+ * illegal or inappropriate time.
+ *
+ * @author unattributed
+ */
+public class IllegalClusterStateException extends ClusterException {
+
+    public IllegalClusterStateException() {
+    }
+
+    public IllegalClusterStateException(String msg) {
+        super(msg);
+    }
+
+    public IllegalClusterStateException(Throwable cause) {
+        super(cause);
+    }
+
+    public IllegalClusterStateException(String msg, Throwable cause) {
+        super(msg, cause);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/IllegalNodeDeletionException.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/IllegalNodeDeletionException.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/IllegalNodeDeletionException.java
new file mode 100644
index 0000000..adef62a
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/IllegalNodeDeletionException.java
@@ -0,0 +1,41 @@
+/*
+ * 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.nifi.cluster.manager.exception;
+
+/**
+ * Represents the exceptional case when a deletion request is issued to a node
+ * that cannot be deleted (e.g., the node is not disconnected).
+ *
+ * @author unattributed
+ */
+public class IllegalNodeDeletionException extends IllegalClusterStateException {
+
+    public IllegalNodeDeletionException() {
+    }
+
+    public IllegalNodeDeletionException(String msg) {
+        super(msg);
+    }
+
+    public IllegalNodeDeletionException(Throwable cause) {
+        super(cause);
+    }
+
+    public IllegalNodeDeletionException(String msg, Throwable cause) {
+        super(msg, cause);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/IllegalNodeDisconnectionException.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/IllegalNodeDisconnectionException.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/IllegalNodeDisconnectionException.java
new file mode 100644
index 0000000..7e61b24
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/IllegalNodeDisconnectionException.java
@@ -0,0 +1,42 @@
+/*
+ * 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.nifi.cluster.manager.exception;
+
+/**
+ * Represents the exceptional case when a disconnection request is issued to a
+ * node that cannot be disconnected (e.g., last node in cluster, node is primary
+ * node).
+ *
+ * @author unattributed
+ */
+public class IllegalNodeDisconnectionException extends IllegalClusterStateException {
+
+    public IllegalNodeDisconnectionException() {
+    }
+
+    public IllegalNodeDisconnectionException(String msg) {
+        super(msg);
+    }
+
+    public IllegalNodeDisconnectionException(Throwable cause) {
+        super(cause);
+    }
+
+    public IllegalNodeDisconnectionException(String msg, Throwable cause) {
+        super(msg, cause);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/IllegalNodeReconnectionException.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/IllegalNodeReconnectionException.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/IllegalNodeReconnectionException.java
new file mode 100644
index 0000000..96c76bc
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/IllegalNodeReconnectionException.java
@@ -0,0 +1,41 @@
+/*
+ * 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.nifi.cluster.manager.exception;
+
+/**
+ * Represents the exceptional case when a reconnection request is issued to a
+ * node that cannot be reconnected (e.g., the node is not disconnected).
+ *
+ * @author unattributed
+ */
+public class IllegalNodeReconnectionException extends IllegalClusterStateException {
+
+    public IllegalNodeReconnectionException() {
+    }
+
+    public IllegalNodeReconnectionException(String msg) {
+        super(msg);
+    }
+
+    public IllegalNodeReconnectionException(Throwable cause) {
+        super(cause);
+    }
+
+    public IllegalNodeReconnectionException(String msg, Throwable cause) {
+        super(msg, cause);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/IneligiblePrimaryNodeException.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/IneligiblePrimaryNodeException.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/IneligiblePrimaryNodeException.java
new file mode 100644
index 0000000..4b0097a
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/IneligiblePrimaryNodeException.java
@@ -0,0 +1,41 @@
+/*
+ * 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.nifi.cluster.manager.exception;
+
+/**
+ * Represents the exceptional case when the primary role cannot be assigned to a
+ * node because the node is ineligible for the role.
+ *
+ * @author unattributed
+ */
+public class IneligiblePrimaryNodeException extends IllegalClusterStateException {
+
+    public IneligiblePrimaryNodeException() {
+    }
+
+    public IneligiblePrimaryNodeException(String msg) {
+        super(msg);
+    }
+
+    public IneligiblePrimaryNodeException(Throwable cause) {
+        super(cause);
+    }
+
+    public IneligiblePrimaryNodeException(String msg, Throwable cause) {
+        super(msg, cause);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/MutableRequestException.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/MutableRequestException.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/MutableRequestException.java
new file mode 100644
index 0000000..d160587
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/MutableRequestException.java
@@ -0,0 +1,42 @@
+/*
+ * 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.nifi.cluster.manager.exception;
+
+/**
+ * Represents the exceptional case when a HTTP request that may change a node's
+ * state is to be replicated while the cluster or connected nodes are unable to
+ * change their state (e.g., a new node is connecting to the cluster).
+ *
+ * @author unattributed
+ */
+public class MutableRequestException extends IllegalClusterStateException {
+
+    public MutableRequestException() {
+    }
+
+    public MutableRequestException(String msg) {
+        super(msg);
+    }
+
+    public MutableRequestException(Throwable cause) {
+        super(cause);
+    }
+
+    public MutableRequestException(String msg, Throwable cause) {
+        super(msg, cause);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/NoConnectedNodesException.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/NoConnectedNodesException.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/NoConnectedNodesException.java
new file mode 100644
index 0000000..8d704b9
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/NoConnectedNodesException.java
@@ -0,0 +1,41 @@
+/*
+ * 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.nifi.cluster.manager.exception;
+
+/**
+ * Represents the exceptional case when the cluster is unable to service a
+ * request because no nodes are connected.
+ *
+ * @author unattributed
+ */
+public class NoConnectedNodesException extends ClusterException {
+
+    public NoConnectedNodesException() {
+    }
+
+    public NoConnectedNodesException(String msg) {
+        super(msg);
+    }
+
+    public NoConnectedNodesException(Throwable cause) {
+        super(cause);
+    }
+
+    public NoConnectedNodesException(String msg, Throwable cause) {
+        super(msg, cause);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/NoResponseFromNodesException.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/NoResponseFromNodesException.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/NoResponseFromNodesException.java
new file mode 100644
index 0000000..9e17a23
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/NoResponseFromNodesException.java
@@ -0,0 +1,42 @@
+/*
+ * 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.nifi.cluster.manager.exception;
+
+/**
+ * Represents the exceptional case when the cluster is unable to service a
+ * request because no nodes returned a response. When the given request is not
+ * mutable the nodes are left in their previous state.
+ *
+ * @author unattributed
+ */
+public class NoResponseFromNodesException extends ClusterException {
+
+    public NoResponseFromNodesException() {
+    }
+
+    public NoResponseFromNodesException(String msg) {
+        super(msg);
+    }
+
+    public NoResponseFromNodesException(Throwable cause) {
+        super(cause);
+    }
+
+    public NoResponseFromNodesException(String msg, Throwable cause) {
+        super(msg, cause);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/NodeDisconnectionException.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/NodeDisconnectionException.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/NodeDisconnectionException.java
new file mode 100644
index 0000000..3bd2f4b
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/NodeDisconnectionException.java
@@ -0,0 +1,41 @@
+/*
+ * 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.nifi.cluster.manager.exception;
+
+/**
+ * Represents the exceptional case when a disconnection request to a node
+ * failed.
+ *
+ * @author unattributed
+ */
+public class NodeDisconnectionException extends ClusterException {
+
+    public NodeDisconnectionException() {
+    }
+
+    public NodeDisconnectionException(String msg) {
+        super(msg);
+    }
+
+    public NodeDisconnectionException(Throwable cause) {
+        super(cause);
+    }
+
+    public NodeDisconnectionException(String msg, Throwable cause) {
+        super(msg, cause);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/NodeReconnectionException.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/NodeReconnectionException.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/NodeReconnectionException.java
new file mode 100644
index 0000000..8c40cef
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/NodeReconnectionException.java
@@ -0,0 +1,40 @@
+/*
+ * 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.nifi.cluster.manager.exception;
+
+/**
+ * Represents the exceptional case when a reconnection request to a node failed.
+ *
+ * @author unattributed
+ */
+public class NodeReconnectionException extends ClusterException {
+
+    public NodeReconnectionException() {
+    }
+
+    public NodeReconnectionException(String msg) {
+        super(msg);
+    }
+
+    public NodeReconnectionException(Throwable cause) {
+        super(cause);
+    }
+
+    public NodeReconnectionException(String msg, Throwable cause) {
+        super(msg, cause);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/PrimaryRoleAssignmentException.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/PrimaryRoleAssignmentException.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/PrimaryRoleAssignmentException.java
new file mode 100644
index 0000000..403f7a5
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/PrimaryRoleAssignmentException.java
@@ -0,0 +1,41 @@
+/*
+ * 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.nifi.cluster.manager.exception;
+
+/**
+ * Represents the exceptional case when the cluster is unable to update the
+ * primary role of a node.
+ *
+ * @author unattributed
+ */
+public class PrimaryRoleAssignmentException extends IllegalClusterStateException {
+
+    public PrimaryRoleAssignmentException() {
+    }
+
+    public PrimaryRoleAssignmentException(String msg) {
+        super(msg);
+    }
+
+    public PrimaryRoleAssignmentException(Throwable cause) {
+        super(cause);
+    }
+
+    public PrimaryRoleAssignmentException(String msg, Throwable cause) {
+        super(msg, cause);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/SafeModeMutableRequestException.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/SafeModeMutableRequestException.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/SafeModeMutableRequestException.java
new file mode 100644
index 0000000..f544f26
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/SafeModeMutableRequestException.java
@@ -0,0 +1,41 @@
+/*
+ * 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.nifi.cluster.manager.exception;
+
+/**
+ * Represents the exceptional case when a HTTP request that may change a node's
+ * dataflow is to be replicated while the cluster is in safe mode.
+ *
+ * @author unattributed
+ */
+public class SafeModeMutableRequestException extends MutableRequestException {
+
+    public SafeModeMutableRequestException() {
+    }
+
+    public SafeModeMutableRequestException(String msg) {
+        super(msg);
+    }
+
+    public SafeModeMutableRequestException(Throwable cause) {
+        super(cause);
+    }
+
+    public SafeModeMutableRequestException(String msg, Throwable cause) {
+        super(msg, cause);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/UnknownNodeException.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/UnknownNodeException.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/UnknownNodeException.java
new file mode 100644
index 0000000..914bb56
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/UnknownNodeException.java
@@ -0,0 +1,41 @@
+/*
+ * 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.nifi.cluster.manager.exception;
+
+/**
+ * Represents the exceptional case when a request is made for a node that does
+ * not exist.
+ *
+ * @author unattributed
+ */
+public class UnknownNodeException extends ClusterException {
+
+    public UnknownNodeException() {
+    }
+
+    public UnknownNodeException(String msg) {
+        super(msg);
+    }
+
+    public UnknownNodeException(Throwable cause) {
+        super(cause);
+    }
+
+    public UnknownNodeException(String msg, Throwable cause) {
+        super(msg, cause);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/UriConstructionException.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/UriConstructionException.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/UriConstructionException.java
new file mode 100644
index 0000000..773d7b5
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/exception/UriConstructionException.java
@@ -0,0 +1,42 @@
+/*
+ * 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.nifi.cluster.manager.exception;
+
+/**
+ * Represents the exceptional case when a URI cannot be constructed from the
+ * given information. This exception is similar to Java's URISyntaxException
+ * except that it extends RuntimeException.
+ *
+ * @author unattributed
+ */
+public class UriConstructionException extends RuntimeException {
+
+    public UriConstructionException() {
+    }
+
+    public UriConstructionException(String msg) {
+        super(msg);
+    }
+
+    public UriConstructionException(Throwable cause) {
+        super(cause);
+    }
+
+    public UriConstructionException(String msg, Throwable cause) {
+        super(msg, cause);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/impl/ClusteredEventAccess.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/impl/ClusteredEventAccess.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/impl/ClusteredEventAccess.java
new file mode 100644
index 0000000..2015530
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/impl/ClusteredEventAccess.java
@@ -0,0 +1,135 @@
+/*
+ * 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.nifi.cluster.manager.impl;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.nifi.controller.status.ProcessGroupStatus;
+import org.apache.nifi.events.EventReporter;
+import org.apache.nifi.provenance.ProvenanceEventBuilder;
+import org.apache.nifi.provenance.ProvenanceEventRecord;
+import org.apache.nifi.provenance.ProvenanceEventRepository;
+import org.apache.nifi.provenance.lineage.ComputeLineageSubmission;
+import org.apache.nifi.provenance.search.Query;
+import org.apache.nifi.provenance.search.QuerySubmission;
+import org.apache.nifi.provenance.search.SearchableField;
+import org.apache.nifi.reporting.EventAccess;
+
+public class ClusteredEventAccess implements EventAccess {
+
+    private final WebClusterManager clusterManager;
+
+    public ClusteredEventAccess(final WebClusterManager clusterManager) {
+        this.clusterManager = clusterManager;
+    }
+
+    @Override
+    public ProcessGroupStatus getControllerStatus() {
+        return clusterManager.getProcessGroupStatus(WebClusterManager.ROOT_GROUP_ID_ALIAS);
+    }
+
+    @Override
+    public List<ProvenanceEventRecord> getProvenanceEvents(long arg0, int arg1) throws IOException {
+        return new ArrayList<>();
+    }
+
+    @Override
+    public ProvenanceEventRepository getProvenanceRepository() {
+        // NCM doesn't have provenance events, because it doesn't process FlowFiles.
+        // So we just use a Provenance Event Repository that does nothing.
+        return new ProvenanceEventRepository() {
+            @Override
+            public void close() throws IOException {
+            }
+
+            @Override
+            public ProvenanceEventRecord getEvent(long eventId) throws IOException {
+                return null;
+            }
+
+            @Override
+            public List<ProvenanceEventRecord> getEvents(long startEventId, int maxEvents) throws IOException {
+                return new ArrayList<>();
+            }
+
+            @Override
+            public Long getMaxEventId() {
+                return null;
+            }
+
+            @Override
+            public List<SearchableField> getSearchableAttributes() {
+                return new ArrayList<>();
+            }
+
+            @Override
+            public List<SearchableField> getSearchableFields() {
+                return new ArrayList<>();
+            }
+
+            @Override
+            public void registerEvent(final ProvenanceEventRecord event) {
+            }
+
+            @Override
+            public void registerEvents(final Iterable<ProvenanceEventRecord> events) {
+            }
+
+            @Override
+            public ComputeLineageSubmission retrieveLineageSubmission(final String submissionId) {
+                return null;
+            }
+
+            @Override
+            public QuerySubmission retrieveQuerySubmission(final String submissionId) {
+                return null;
+            }
+
+            @Override
+            public ComputeLineageSubmission submitExpandChildren(final long eventId) {
+                return null;
+            }
+
+            @Override
+            public ComputeLineageSubmission submitExpandParents(final long eventId) {
+                return null;
+            }
+
+            @Override
+            public ComputeLineageSubmission submitLineageComputation(final String flowFileUuid) {
+                return null;
+            }
+
+            @Override
+            public QuerySubmission submitQuery(final Query query) {
+                return null;
+            }
+
+            @Override
+            public ProvenanceEventBuilder eventBuilder() {
+                return null;
+            }
+
+            @Override
+            public void initialize(EventReporter eventReporter) throws IOException {
+
+            }
+        };
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/impl/ClusteredReportingContext.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/impl/ClusteredReportingContext.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/impl/ClusteredReportingContext.java
new file mode 100644
index 0000000..e546f87
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/impl/ClusteredReportingContext.java
@@ -0,0 +1,165 @@
+/*
+ * 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.nifi.cluster.manager.impl;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.nifi.attribute.expression.language.PreparedQuery;
+import org.apache.nifi.attribute.expression.language.Query;
+import org.apache.nifi.components.PropertyDescriptor;
+import org.apache.nifi.components.PropertyValue;
+import org.apache.nifi.controller.ControllerServiceLookup;
+import org.apache.nifi.controller.service.ControllerServiceProvider;
+import org.apache.nifi.controller.status.PortStatus;
+import org.apache.nifi.controller.status.ProcessGroupStatus;
+import org.apache.nifi.controller.status.ProcessorStatus;
+import org.apache.nifi.events.BulletinFactory;
+import org.apache.nifi.processor.StandardPropertyValue;
+import org.apache.nifi.reporting.Bulletin;
+import org.apache.nifi.reporting.BulletinRepository;
+import org.apache.nifi.reporting.EventAccess;
+import org.apache.nifi.reporting.ReportingContext;
+import org.apache.nifi.reporting.Severity;
+
+public class ClusteredReportingContext implements ReportingContext {
+
+    private final EventAccess eventAccess;
+    private final BulletinRepository bulletinRepository;
+    private final ControllerServiceProvider serviceProvider;
+    private final Map<PropertyDescriptor, String> properties;
+    private final Map<PropertyDescriptor, PreparedQuery> preparedQueries;
+
+    public ClusteredReportingContext(final EventAccess eventAccess, final BulletinRepository bulletinRepository,
+            final Map<PropertyDescriptor, String> properties, final ControllerServiceProvider serviceProvider) {
+        this.eventAccess = eventAccess;
+        this.bulletinRepository = bulletinRepository;
+        this.properties = Collections.unmodifiableMap(properties);
+        this.serviceProvider = serviceProvider;
+
+        preparedQueries = new HashMap<>();
+        for (final Map.Entry<PropertyDescriptor, String> entry : properties.entrySet()) {
+            final PropertyDescriptor desc = entry.getKey();
+            String value = entry.getValue();
+            if (value == null) {
+                value = desc.getDefaultValue();
+            }
+
+            final PreparedQuery pq = Query.prepare(value);
+            preparedQueries.put(desc, pq);
+        }
+    }
+
+    @Override
+    public EventAccess getEventAccess() {
+        return eventAccess;
+    }
+
+    @Override
+    public BulletinRepository getBulletinRepository() {
+        return bulletinRepository;
+    }
+
+    @Override
+    public Bulletin createBulletin(final String category, final Severity severity, final String message) {
+        return BulletinFactory.createBulletin(category, severity.name(), message);
+    }
+
+    @Override
+    public Bulletin createBulletin(final String componentId, final String category, final Severity severity, final String message) {
+        final ProcessGroupStatus rootGroupStatus = eventAccess.getControllerStatus();
+        final String groupId = findGroupId(rootGroupStatus, componentId);
+        final String componentName = findComponentName(rootGroupStatus, componentId);
+
+        return BulletinFactory.createBulletin(groupId, componentId, componentName, category, severity.name(), message);
+    }
+
+    @Override
+    public Map<PropertyDescriptor, String> getProperties() {
+        return Collections.unmodifiableMap(properties);
+    }
+
+    @Override
+    public PropertyValue getProperty(final PropertyDescriptor property) {
+        final String configuredValue = properties.get(property);
+        return new StandardPropertyValue(configuredValue == null ? property.getDefaultValue() : configuredValue, serviceProvider, preparedQueries.get(property));
+    }
+
+    @Override
+    public ControllerServiceLookup getControllerServiceLookup() {
+        return serviceProvider;
+    }
+
+    String findGroupId(final ProcessGroupStatus groupStatus, final String componentId) {
+        for (final ProcessorStatus procStatus : groupStatus.getProcessorStatus()) {
+            if (procStatus.getId().equals(componentId)) {
+                return groupStatus.getId();
+            }
+        }
+
+        for (final PortStatus portStatus : groupStatus.getInputPortStatus()) {
+            if (portStatus.getId().equals(componentId)) {
+                return groupStatus.getId();
+            }
+        }
+
+        for (final PortStatus portStatus : groupStatus.getOutputPortStatus()) {
+            if (portStatus.getId().equals(componentId)) {
+                return groupStatus.getId();
+            }
+        }
+
+        for (final ProcessGroupStatus childGroup : groupStatus.getProcessGroupStatus()) {
+            final String groupId = findGroupId(childGroup, componentId);
+            if (groupId != null) {
+                return groupId;
+            }
+        }
+
+        return null;
+    }
+
+    private String findComponentName(final ProcessGroupStatus groupStatus, final String componentId) {
+        for (final ProcessorStatus procStatus : groupStatus.getProcessorStatus()) {
+            if (procStatus.getId().equals(componentId)) {
+                return procStatus.getName();
+            }
+        }
+
+        for (final PortStatus portStatus : groupStatus.getInputPortStatus()) {
+            if (portStatus.getId().equals(componentId)) {
+                return groupStatus.getName();
+            }
+        }
+
+        for (final PortStatus portStatus : groupStatus.getOutputPortStatus()) {
+            if (portStatus.getId().equals(componentId)) {
+                return groupStatus.getName();
+            }
+        }
+
+        for (final ProcessGroupStatus childGroup : groupStatus.getProcessGroupStatus()) {
+            final String componentName = findComponentName(childGroup, componentId);
+            if (componentName != null) {
+                return componentName;
+            }
+        }
+
+        return null;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/impl/HttpRequestReplicatorImpl.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/impl/HttpRequestReplicatorImpl.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/impl/HttpRequestReplicatorImpl.java
new file mode 100644
index 0000000..81bb7a7
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/impl/HttpRequestReplicatorImpl.java
@@ -0,0 +1,531 @@
+/*
+ * 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.nifi.cluster.manager.impl;
+
+import com.sun.jersey.api.client.Client;
+import com.sun.jersey.api.client.ClientResponse;
+import com.sun.jersey.api.client.UniformInterfaceException;
+import com.sun.jersey.api.client.WebResource;
+import com.sun.jersey.api.client.config.ClientConfig;
+import com.sun.jersey.api.client.filter.GZIPContentEncodingFilter;
+import com.sun.jersey.core.util.MultivaluedMapImpl;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
+import java.util.concurrent.Callable;
+import java.util.concurrent.CompletionService;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ExecutorCompletionService;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+
+import javax.ws.rs.HttpMethod;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+
+import org.apache.nifi.cluster.manager.HttpRequestReplicator;
+import org.apache.nifi.cluster.manager.NodeResponse;
+import org.apache.nifi.cluster.manager.exception.UriConstructionException;
+import org.apache.nifi.cluster.protocol.NodeIdentifier;
+import org.apache.nifi.logging.NiFiLog;
+import org.apache.nifi.util.FormatUtils;
+
+import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * An implementation of the <code>HttpRequestReplicator</code> interface. This
+ * implementation parallelizes the node HTTP requests using the given
+ * <code>ExecutorService</code> instance. Individual requests may have
+ * connection and read timeouts set, which may be set during instance
+ * construction. Otherwise, the default is not to timeout.
+ *
+ * If a node protocol scheme is provided during construction, then all requests
+ * will be replicated using the given scheme. If null is provided as the scheme
+ * (the default), then the requests will be replicated using the scheme of the
+ * original URI.
+ *
+ * Clients must call start() and stop() to initialize and shutdown the instance.
+ * The instance must be started before issuing any replication requests.
+ *
+ * @author unattributed
+ */
+public class HttpRequestReplicatorImpl implements HttpRequestReplicator {
+
+    // defaults
+    private static final int DEFAULT_SHUTDOWN_REPLICATOR_SECONDS = 30;
+
+    // logger
+    private static final Logger logger = new NiFiLog(LoggerFactory.getLogger(HttpRequestReplicatorImpl.class));
+
+    // final members
+    private final Client client;            // the client to use for issuing requests
+    private final int numThreads;           // number of threads to use for request replication
+    private final int connectionTimeoutMs;  // connection timeout per node request
+    private final int readTimeoutMs;        // read timeout per node request
+
+    // members
+    private ExecutorService executorService;
+    private int shutdownReplicatorSeconds = DEFAULT_SHUTDOWN_REPLICATOR_SECONDS;
+
+    // guarded by synchronized method access in support of multithreaded replication
+    private String nodeProtocolScheme = null;
+
+    /**
+     * Creates an instance. The connection timeout and read timeout will be
+     * infinite.
+     *
+     * @param numThreads the number of threads to use when parallelizing
+     * requests
+     * @param client a client for making requests
+     */
+    public HttpRequestReplicatorImpl(final int numThreads, final Client client) {
+        this(numThreads, client, "0 sec", "0 sec");
+    }
+
+    /**
+     * Creates an instance.
+     *
+     * @param numThreads the number of threads to use when parallelizing
+     * requests
+     * @param client a client for making requests
+     * @param connectionTimeoutMs the connection timeout specified in
+     * milliseconds
+     * @param readTimeoutMs the read timeout specified in milliseconds
+     */
+    public HttpRequestReplicatorImpl(final int numThreads, final Client client, final String connectionTimeout, final String readTimeout) {
+
+        if (numThreads <= 0) {
+            throw new IllegalArgumentException("The number of threads must be greater than zero.");
+        } else if (client == null) {
+            throw new IllegalArgumentException("Client may not be null.");
+        }
+
+        this.numThreads = numThreads;
+        this.client = client;
+        this.connectionTimeoutMs = (int) FormatUtils.getTimeDuration(connectionTimeout, TimeUnit.MILLISECONDS);
+        this.readTimeoutMs = (int) FormatUtils.getTimeDuration(readTimeout, TimeUnit.MILLISECONDS);
+
+        client.getProperties().put(ClientConfig.PROPERTY_CONNECT_TIMEOUT, connectionTimeoutMs);
+        client.getProperties().put(ClientConfig.PROPERTY_READ_TIMEOUT, readTimeoutMs);
+        client.getProperties().put(ClientConfig.PROPERTY_FOLLOW_REDIRECTS, Boolean.TRUE);
+    }
+
+    @Override
+    public void start() {
+        if (isRunning()) {
+            throw new IllegalStateException("Instance is already started.");
+        }
+        executorService = Executors.newFixedThreadPool(numThreads);
+    }
+
+    @Override
+    public boolean isRunning() {
+        return executorService != null && !executorService.isShutdown();
+    }
+
+    @Override
+    public void stop() {
+
+        if (!isRunning()) {
+            throw new IllegalStateException("Instance is already stopped.");
+        }
+
+        // shutdown executor service
+        try {
+            if (getShutdownReplicatorSeconds() <= 0) {
+                executorService.shutdownNow();
+            } else {
+                executorService.shutdown();
+            }
+            executorService.awaitTermination(getShutdownReplicatorSeconds(), TimeUnit.SECONDS);
+        } catch (final InterruptedException ex) {
+            Thread.currentThread().interrupt();
+        } finally {
+            if (executorService.isTerminated()) {
+                logger.info("HTTP Request Replicator has been terminated successfully.");
+            } else {
+                logger.warn("HTTP Request Replicator has not terminated properly.  There exists an uninterruptable thread that will take an indeterminate amount of time to stop.");
+            }
+        }
+    }
+
+    /**
+     * Sets the protocol scheme to use when issuing requests to nodes.
+     *
+     * @param nodeProtocolScheme the scheme. Valid values are "http", "https",
+     * or null. If null is specified, then the scheme of the originating request
+     * is used when replicating that request.
+     */
+    public synchronized void setNodeProtocolScheme(final String nodeProtocolScheme) {
+        if (StringUtils.isNotBlank(nodeProtocolScheme)) {
+            if (!"http".equalsIgnoreCase(nodeProtocolScheme) && !"https".equalsIgnoreCase(nodeProtocolScheme)) {
+                throw new IllegalArgumentException("Node Protocol Scheme must be either HTTP or HTTPS");
+            }
+        }
+        this.nodeProtocolScheme = nodeProtocolScheme;
+    }
+
+    public synchronized String getNodeProtocolScheme() {
+        return nodeProtocolScheme;
+    }
+
+    private synchronized String getNodeProtocolScheme(final URI uri) {
+        // if we are not configured to use a protocol scheme, then use the uri's scheme
+        if (StringUtils.isBlank(nodeProtocolScheme)) {
+            return uri.getScheme();
+        }
+        return nodeProtocolScheme;
+    }
+
+    public int getConnectionTimeoutMs() {
+        return connectionTimeoutMs;
+    }
+
+    public int getReadTimeoutMs() {
+        return readTimeoutMs;
+    }
+
+    public int getShutdownReplicatorSeconds() {
+        return shutdownReplicatorSeconds;
+    }
+
+    public void setShutdownReplicatorSeconds(int shutdownReplicatorSeconds) {
+        this.shutdownReplicatorSeconds = shutdownReplicatorSeconds;
+    }
+
+    @Override
+    public Set<NodeResponse> replicate(final Set<NodeIdentifier> nodeIds, final String method,
+            final URI uri, final Map<String, List<String>> parameters, final Map<String, String> headers)
+            throws UriConstructionException {
+        if (nodeIds == null) {
+            throw new IllegalArgumentException("Node IDs may not be null.");
+        } else if (method == null) {
+            throw new IllegalArgumentException("HTTP method may not be null.");
+        } else if (uri == null) {
+            throw new IllegalArgumentException("URI may not be null.");
+        } else if (parameters == null) {
+            throw new IllegalArgumentException("Parameters may not be null.");
+        } else if (headers == null) {
+            throw new IllegalArgumentException("HTTP headers map may not be null.");
+        }
+        return replicateHelper(nodeIds, method, getNodeProtocolScheme(uri), uri.getPath(), parameters, /* entity */ null, headers);
+    }
+
+    @Override
+    public Set<NodeResponse> replicate(final Set<NodeIdentifier> nodeIds, final String method, final URI uri,
+            final Object entity, final Map<String, String> headers) throws UriConstructionException {
+        if (nodeIds == null) {
+            throw new IllegalArgumentException("Node IDs may not be null.");
+        } else if (method == null) {
+            throw new IllegalArgumentException("HTTP method may not be null.");
+        } else if (method.equalsIgnoreCase(HttpMethod.DELETE) || method.equalsIgnoreCase(HttpMethod.GET) || method.equalsIgnoreCase(HttpMethod.HEAD) || method.equalsIgnoreCase(HttpMethod.OPTIONS)) {
+            throw new IllegalArgumentException("HTTP (DELETE | GET | HEAD | OPTIONS) requests cannot have a body containing an entity.");
+        } else if (uri == null) {
+            throw new IllegalArgumentException("URI may not be null.");
+        } else if (entity == null) {
+            throw new IllegalArgumentException("Entity may not be null.");
+        } else if (headers == null) {
+            throw new IllegalArgumentException("HTTP headers map may not be null.");
+        }
+        return replicateHelper(nodeIds, method, getNodeProtocolScheme(uri), uri.getPath(), /* parameters */ null, entity, headers);
+    }
+
+    private Set<NodeResponse> replicateHelper(final Set<NodeIdentifier> nodeIds, final String method, final String scheme,
+            final String path, final Map<String, List<String>> parameters, final Object entity, final Map<String, String> headers)
+            throws UriConstructionException {
+
+        if (nodeIds.isEmpty()) {
+            return new HashSet<>(); // return quickly for trivial case
+        }
+
+        final CompletionService<NodeResponse> completionService = new ExecutorCompletionService<>(executorService);
+
+        // keeps track of future requests so that failed requests can be tied back to the failing node
+        final Collection<NodeHttpRequestFutureWrapper> futureNodeHttpRequests = new ArrayList<>();
+
+        // construct the URIs for the nodes
+        final Map<NodeIdentifier, URI> uriMap = new HashMap<>();
+        try {
+            for (final NodeIdentifier nodeId : nodeIds) {
+                final URI nodeUri = new URI(scheme, null, nodeId.getApiAddress(), nodeId.getApiPort(), path, /* query */ null, /* fragment */ null);
+                uriMap.put(nodeId, nodeUri);
+            }
+        } catch (final URISyntaxException use) {
+            throw new UriConstructionException(use);
+        }
+
+        // submit the requests to the nodes
+        final String requestId = UUID.randomUUID().toString();
+        headers.put(WebClusterManager.REQUEST_ID_HEADER, requestId);
+        for (final Map.Entry<NodeIdentifier, URI> entry : uriMap.entrySet()) {
+            final NodeIdentifier nodeId = entry.getKey();
+            final URI nodeUri = entry.getValue();
+            final NodeHttpRequestCallable callable = (entity == null)
+                    ? new NodeHttpRequestCallable(nodeId, method, nodeUri, parameters, headers)
+                    : new NodeHttpRequestCallable(nodeId, method, nodeUri, entity, headers);
+            futureNodeHttpRequests.add(new NodeHttpRequestFutureWrapper(nodeId, method, nodeUri, completionService.submit(callable)));
+        }
+
+        // get the node responses
+        final Set<NodeResponse> result = new HashSet<>();
+        for (int i = 0; i < nodeIds.size(); i++) {
+
+            // keeps track of the original request information in case we receive an exception
+            NodeHttpRequestFutureWrapper futureNodeHttpRequest = null;
+            try {
+
+                // get the future resource response for the node
+                final Future<NodeResponse> futureNodeResourceResponse = completionService.take();
+
+                // find the original request by comparing the submitted future with the future returned by the completion service
+                for (final NodeHttpRequestFutureWrapper futureNodeHttpRequestElem : futureNodeHttpRequests) {
+                    if (futureNodeHttpRequestElem.getFuture() == futureNodeResourceResponse) {
+                        futureNodeHttpRequest = futureNodeHttpRequestElem;
+                    }
+                }
+
+                // try to retrieve the node response and add to result
+                final NodeResponse nodeResponse = futureNodeResourceResponse.get();
+                result.add(nodeResponse);
+
+            } catch (final InterruptedException | ExecutionException ex) {
+
+                logger.warn("Node request for " + futureNodeHttpRequest.getNodeId() + " encountered exception: " + ex, ex);
+
+                // create node response with the thrown exception and add to result
+                final NodeResponse nodeResponse = new NodeResponse(
+                        futureNodeHttpRequest.getNodeId(), futureNodeHttpRequest.getHttpMethod(), futureNodeHttpRequest.getRequestUri(), ex);
+                result.add(nodeResponse);
+
+            }
+        }
+
+        if (logger.isDebugEnabled()) {
+            NodeResponse min = null;
+            NodeResponse max = null;
+            long nanosSum = 0L;
+            int nanosAdded = 0;
+
+            for (final NodeResponse response : result) {
+                final long requestNanos = response.getRequestDuration(TimeUnit.NANOSECONDS);
+                final long minNanos = (min == null) ? -1 : min.getRequestDuration(TimeUnit.NANOSECONDS);
+                final long maxNanos = (max == null) ? -1 : max.getRequestDuration(TimeUnit.NANOSECONDS);
+
+                if (requestNanos < minNanos || minNanos < 0L) {
+                    min = response;
+                }
+
+                if (requestNanos > maxNanos || maxNanos < 0L) {
+                    max = response;
+                }
+
+                if (requestNanos >= 0L) {
+                    nanosSum += requestNanos;
+                    nanosAdded++;
+                }
+            }
+
+            final StringBuilder sb = new StringBuilder();
+            sb.append("Node Responses for ").append(method).append(" ").append(path).append(" (Request ID ").append(requestId).append("):\n");
+            for (final NodeResponse response : result) {
+                sb.append(response).append("\n");
+            }
+
+            final long averageNanos = (nanosAdded == 0) ? -1L : nanosSum / nanosAdded;
+            final long averageMillis = (averageNanos < 0) ? averageNanos : TimeUnit.MILLISECONDS.convert(averageNanos, TimeUnit.NANOSECONDS);
+            logger.debug("For {} {} (Request ID {}), minimum response time = {}, max = {}, average = {} ms",
+                    method, path, requestId, min, max, averageMillis);
+            logger.debug(sb.toString());
+        }
+
+        return result;
+    }
+
+    /**
+     * Wraps a future node response with info from originating request. This
+     * coupling allows for futures that encountered exceptions to be linked back
+     * to the failing node and better reported.
+     */
+    private class NodeHttpRequestFutureWrapper {
+
+        private final NodeIdentifier nodeId;
+
+        private final String httpMethod;
+
+        private final URI requestUri;
+
+        private final Future<NodeResponse> future;
+
+        public NodeHttpRequestFutureWrapper(final NodeIdentifier nodeId, final String httpMethod,
+                final URI requestUri, final Future<NodeResponse> future) {
+            if (nodeId == null) {
+                throw new IllegalArgumentException("Node ID may not be null.");
+            } else if (StringUtils.isBlank(httpMethod)) {
+                throw new IllegalArgumentException("Http method may not be null or empty.");
+            } else if (requestUri == null) {
+                throw new IllegalArgumentException("Request URI may not be null.");
+            } else if (future == null) {
+                throw new IllegalArgumentException("Future may not be null.");
+            }
+            this.nodeId = nodeId;
+            this.httpMethod = httpMethod;
+            this.requestUri = requestUri;
+            this.future = future;
+        }
+
+        public NodeIdentifier getNodeId() {
+            return nodeId;
+        }
+
+        public String getHttpMethod() {
+            return httpMethod;
+        }
+
+        public URI getRequestUri() {
+            return requestUri;
+        }
+
+        public Future<NodeResponse> getFuture() {
+            return future;
+        }
+    }
+
+    /**
+     * A Callable for making an HTTP request to a single node and returning its
+     * response.
+     */
+    private class NodeHttpRequestCallable implements Callable<NodeResponse> {
+
+        private final NodeIdentifier nodeId;
+        private final String method;
+        private final URI uri;
+        private final Object entity;
+        private final Map<String, List<String>> parameters = new HashMap<>();
+        private final Map<String, String> headers = new HashMap<>();
+
+        private NodeHttpRequestCallable(final NodeIdentifier nodeId, final String method,
+                final URI uri, final Object entity, final Map<String, String> headers) {
+            this.nodeId = nodeId;
+            this.method = method;
+            this.uri = uri;
+            this.entity = entity;
+            this.headers.putAll(headers);
+        }
+
+        private NodeHttpRequestCallable(final NodeIdentifier nodeId, final String method,
+                final URI uri, final Map<String, List<String>> parameters, final Map<String, String> headers) {
+            this.nodeId = nodeId;
+            this.method = method;
+            this.uri = uri;
+            this.entity = null;
+            this.parameters.putAll(parameters);
+            this.headers.putAll(headers);
+        }
+
+        @Override
+        public NodeResponse call() {
+
+            try {
+                // create and send the request
+                final WebResource.Builder resourceBuilder = getResourceBuilder();
+                final String requestId = headers.get("x-nifi-request-id");
+
+                final long startNanos = System.nanoTime();
+                final ClientResponse clientResponse;
+                if (HttpMethod.DELETE.equalsIgnoreCase(method)) {
+                    clientResponse = resourceBuilder.delete(ClientResponse.class);
+                } else if (HttpMethod.GET.equalsIgnoreCase(method)) {
+                    clientResponse = resourceBuilder.get(ClientResponse.class);
+                } else if (HttpMethod.HEAD.equalsIgnoreCase(method)) {
+                    clientResponse = resourceBuilder.head();
+                } else if (HttpMethod.OPTIONS.equalsIgnoreCase(method)) {
+                    clientResponse = resourceBuilder.options(ClientResponse.class);
+                } else if (HttpMethod.POST.equalsIgnoreCase(method)) {
+                    clientResponse = resourceBuilder.post(ClientResponse.class);
+                } else if (HttpMethod.PUT.equalsIgnoreCase(method)) {
+                    clientResponse = resourceBuilder.put(ClientResponse.class);
+                } else {
+                    throw new IllegalArgumentException("HTTP Method '" + method + "' not supported for request replication.");
+                }
+
+                // create and return the response
+                return new NodeResponse(nodeId, method, uri, clientResponse, System.nanoTime() - startNanos, requestId);
+
+            } catch (final UniformInterfaceException | IllegalArgumentException t) {
+                return new NodeResponse(nodeId, method, uri, t);
+            }
+
+        }
+
+        private WebResource.Builder getResourceBuilder() {
+
+            // convert parameters to a more convenient data structure
+            final MultivaluedMap<String, String> map = new MultivaluedMapImpl();
+            map.putAll(parameters);
+
+            // create the resource
+            WebResource resource = client.resource(uri);
+
+            if (WebClusterManager.isResponseInterpreted(uri, method)) {
+                resource.addFilter(new GZIPContentEncodingFilter(false));
+            }
+
+            // set the parameters as either query parameters or as request body
+            final WebResource.Builder builder;
+            if (HttpMethod.DELETE.equalsIgnoreCase(method) || HttpMethod.HEAD.equalsIgnoreCase(method) || HttpMethod.GET.equalsIgnoreCase(method) || HttpMethod.OPTIONS.equalsIgnoreCase(method)) {
+                resource = resource.queryParams(map);
+                builder = resource.getRequestBuilder();
+            } else {
+                if (entity == null) {
+                    builder = resource.entity(map);
+                } else {
+                    builder = resource.entity(entity);
+                }
+            }
+
+            // set headers
+            boolean foundContentType = false;
+            for (final Map.Entry<String, String> entry : headers.entrySet()) {
+                builder.header(entry.getKey(), entry.getValue());
+                if (entry.getKey().equalsIgnoreCase("content-type")) {
+                    foundContentType = true;
+                }
+            }
+
+            // set default content type
+            if (!foundContentType) {
+                // set default content type
+                builder.type(MediaType.APPLICATION_FORM_URLENCODED);
+            }
+
+            return builder;
+        }
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/impl/HttpResponseMapperImpl.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/impl/HttpResponseMapperImpl.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/impl/HttpResponseMapperImpl.java
new file mode 100644
index 0000000..afade7e
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/impl/HttpResponseMapperImpl.java
@@ -0,0 +1,85 @@
+/*
+ * 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.nifi.cluster.manager.impl;
+
+import java.net.URI;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+import org.apache.nifi.cluster.manager.HttpResponseMapper;
+import org.apache.nifi.cluster.manager.NodeResponse;
+import org.apache.nifi.cluster.node.Node;
+import org.apache.nifi.cluster.node.Node.Status;
+import org.apache.nifi.logging.NiFiLog;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Determines the status of nodes based on their HTTP response codes.
+ *
+ * The algorithm is as follows.
+ *
+ * If any HTTP responses were 2XX, then disconnect non-2XX responses. This is
+ * because 2XX may have changed a node's flow.
+ *
+ * If no 2XX responses were received, then the node's flow has not changed.
+ * Instead of disconnecting everything, we only disconnect the nodes with
+ * internal errors, i.e., 5XX responses.
+ *
+ * @author unattributed
+ */
+public class HttpResponseMapperImpl implements HttpResponseMapper {
+
+    private static final Logger logger = new NiFiLog(LoggerFactory.getLogger(HttpResponseMapperImpl.class));
+
+    @Override
+    public Map<NodeResponse, Status> map(final URI requestURI, final Set<NodeResponse> nodeResponses) {
+
+        final Map<NodeResponse, Status> result = new HashMap<>();
+
+        // check if any responses were 2XX
+        boolean found2xx = false;
+        for (final NodeResponse nodeResponse : nodeResponses) {
+            if (nodeResponse.is2xx()) {
+                found2xx = true;
+                break;
+            }
+        }
+
+        // determine the status of each node 
+        for (final NodeResponse nodeResponse : nodeResponses) {
+
+            final Node.Status status;
+            if (found2xx) {
+                // disconnect nodes with non-2XX responses
+                status = nodeResponse.is2xx()
+                        ? Node.Status.CONNECTED
+                        : Node.Status.DISCONNECTED;
+            } else {
+                // disconnect nodes with 5XX responses or exception
+                status = nodeResponse.is5xx()
+                        ? Node.Status.DISCONNECTED
+                        : Node.Status.CONNECTED;
+            }
+
+            result.put(nodeResponse, status);
+        }
+
+        return result;
+    }
+
+}


[02/20] incubator-nifi git commit: NIFI-410 pushed RAT exclusions down to the relevant modules and stopped doing broad test resource exclusion - is now specific

Posted by jo...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/manager/testutils/HttpRequest.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/manager/testutils/HttpRequest.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/manager/testutils/HttpRequest.java
new file mode 100644
index 0000000..35380dd
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/manager/testutils/HttpRequest.java
@@ -0,0 +1,239 @@
+/*
+ * 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.nifi.cluster.manager.testutils;
+
+import java.io.IOException;
+import java.io.Reader;
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import javax.ws.rs.HttpMethod;
+import javax.ws.rs.core.MediaType;
+import org.apache.commons.lang3.StringUtils;
+
+/**
+ * Encapsulates an HTTP request. The toString method returns the
+ * specification-compliant request.
+ *
+ * @author unattributed
+ */
+public class HttpRequest {
+
+    private String method;
+    private String uri;
+    private String rawUri;
+    private String version;
+    private String body;
+    private String rawRequest;
+    private Map<String, String> headers = new HashMap<>();
+    private Map<String, List<String>> parameters = new HashMap<>();
+
+    public static HttpRequestBuilder createFromRequestLine(final String requestLine) {
+        return new HttpRequestBuilder(requestLine);
+    }
+
+    public String getBody() {
+        return body;
+    }
+
+    public Map<String, String> getHeaders() {
+        return Collections.unmodifiableMap(headers);
+    }
+
+    public String getHeaderValue(final String header) {
+        for (final Map.Entry<String, String> entry : getHeaders().entrySet()) {
+            if (entry.getKey().equalsIgnoreCase(header)) {
+                return entry.getValue();
+            }
+        }
+        return null;
+    }
+
+    public String getMethod() {
+        return method;
+    }
+
+    public Map<String, List<String>> getParameters() {
+        final Map<String, List<String>> result = new HashMap<>();
+        for (final Map.Entry<String, List<String>> entry : parameters.entrySet()) {
+            result.put(entry.getKey(), Collections.unmodifiableList(entry.getValue()));
+        }
+        return Collections.unmodifiableMap(result);
+    }
+
+    public String getUri() {
+        return uri;
+    }
+
+    public String getRawUri() {
+        return rawUri;
+    }
+
+    public String getVersion() {
+        return version;
+    }
+
+    @Override
+    public String toString() {
+        return rawRequest;
+    }
+
+    /**
+     * A builder for constructing basic HTTP requests. It handles only enough of
+     * the HTTP specification to support basic unit testing, and it should not
+     * be used otherwise.
+     */
+    public static class HttpRequestBuilder {
+
+        private String method;
+        private String uri;
+        private String rawUri;
+        private String version;
+        private Map<String, String> headers = new HashMap<>();
+        private Map<String, List<String>> parameters = new HashMap<>();
+        private int contentLength = 0;
+        private String contentType;
+        private String body = "";
+        private StringBuilder rawRequest = new StringBuilder();
+
+        private HttpRequestBuilder(final String requestLine) {
+
+            final String[] tokens = requestLine.split(" ");
+            if (tokens.length != 3) {
+                throw new IllegalArgumentException("Invalid HTTP Request Line: " + requestLine);
+            }
+
+            method = tokens[0];
+            if (HttpMethod.GET.equalsIgnoreCase(method) || HttpMethod.HEAD.equalsIgnoreCase(method) || HttpMethod.DELETE.equalsIgnoreCase(method) || HttpMethod.OPTIONS.equalsIgnoreCase(method)) {
+                final int queryIndex = tokens[1].indexOf("?");
+                if (queryIndex > -1) {
+                    uri = tokens[1].substring(0, queryIndex);
+                    addParameters(tokens[1].substring(queryIndex + 1));
+                } else {
+                    uri = tokens[1];
+                }
+            }
+            rawUri = tokens[1];
+            version = tokens[2];
+            rawRequest.append(requestLine).append("\n");
+        }
+
+        private void addHeader(final String key, final String value) {
+            if (key.contains(" ")) {
+                throw new IllegalArgumentException("Header key may not contain spaces.");
+            } else if ("content-length".equalsIgnoreCase(key)) {
+                contentLength = (StringUtils.isBlank(value.trim())) ? 0 : Integer.parseInt(value.trim());
+            } else if ("content-type".equalsIgnoreCase(key)) {
+                contentType = value.trim();
+            }
+            headers.put(key, value);
+        }
+
+        public void addHeader(final String header) {
+            final int firstColonIndex = header.indexOf(":");
+            if (firstColonIndex < 0) {
+                throw new IllegalArgumentException("Invalid HTTP Header line: " + header);
+            }
+            addHeader(header.substring(0, firstColonIndex), header.substring(firstColonIndex + 1));
+            rawRequest.append(header).append("\n");
+        }
+
+        // final because constructor calls it
+        public final void addParameters(final String queryString) {
+
+            if (StringUtils.isBlank(queryString)) {
+                return;
+            }
+
+            final String normQueryString;
+            if (queryString.startsWith("?")) {
+                normQueryString = queryString.substring(1);
+            } else {
+                normQueryString = queryString;
+            }
+            final String[] keyValuePairs = normQueryString.split("&");
+            for (final String keyValuePair : keyValuePairs) {
+                final String[] keyValueTokens = keyValuePair.split("=");
+                try {
+                    addParameter(
+                            URLDecoder.decode(keyValueTokens[0], "utf-8"),
+                            URLDecoder.decode(keyValueTokens[1], "utf-8")
+                    );
+                } catch (UnsupportedEncodingException use) {
+                    throw new RuntimeException(use);
+                }
+            }
+        }
+
+        public void addParameter(final String key, final String value) {
+
+            if (key.contains(" ")) {
+                throw new IllegalArgumentException("Parameter key may not contain spaces: " + key);
+            }
+
+            final List<String> values;
+            if (parameters.containsKey(key)) {
+                values = parameters.get(key);
+            } else {
+                values = new ArrayList<>();
+                parameters.put(key, values);
+            }
+            values.add(value);
+        }
+
+        public void addBody(final Reader reader) throws IOException {
+
+            if (contentLength <= 0) {
+                return;
+            }
+
+            final char[] buf = new char[contentLength];
+            int offset = 0;
+            int numRead = 0;
+            while (offset < buf.length && (numRead = reader.read(buf, offset, buf.length - offset)) >= 0) {
+                offset += numRead;
+            }
+            body = new String(buf);
+            rawRequest.append("\n");
+            rawRequest.append(body);
+        }
+
+        public HttpRequest build() throws UnsupportedEncodingException {
+
+            if (HttpMethod.GET.equalsIgnoreCase(method) == false && HttpMethod.HEAD.equalsIgnoreCase(method) == false && contentType.equalsIgnoreCase(MediaType.APPLICATION_FORM_URLENCODED)) {
+                addParameters(body);
+            }
+
+            final HttpRequest request = new HttpRequest();
+            request.method = this.method;
+            request.uri = this.uri;
+            request.rawUri = this.rawUri;
+            request.version = this.version;
+            request.headers.putAll(this.headers);
+            request.parameters.putAll(this.parameters);
+            request.body = this.body;
+            request.rawRequest = this.rawRequest.toString();
+
+            return request;
+        }
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/manager/testutils/HttpResponse.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/manager/testutils/HttpResponse.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/manager/testutils/HttpResponse.java
new file mode 100644
index 0000000..3aa2931
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/manager/testutils/HttpResponse.java
@@ -0,0 +1,93 @@
+/*
+ * 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.nifi.cluster.manager.testutils;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import javax.ws.rs.core.Response.Status;
+
+/**
+ * Encapsulates an HTTP response. The toString method returns the
+ * specification-compliant response.
+ *
+ * @author unattributed
+ */
+public class HttpResponse {
+
+    private final Status status;
+    private final String entity;
+    private final Map<String, String> headers = new HashMap<>();
+
+    public HttpResponse(final Status status, final String entity) {
+        this.status = status;
+        this.entity = entity;
+        headers.put("content-length", String.valueOf(entity.getBytes().length));
+    }
+
+    public String getEntity() {
+        return entity;
+    }
+
+    public Status getStatus() {
+        return status;
+    }
+
+    public Map<String, String> getHeaders() {
+        return Collections.unmodifiableMap(headers);
+    }
+
+    public void addHeader(final String key, final String value) {
+        if (key.contains(" ")) {
+            throw new IllegalArgumentException("Header key may not contain spaces.");
+        } else if ("content-length".equalsIgnoreCase(key)) {
+            throw new IllegalArgumentException("Content-Length header is set automatically based on length of content.");
+        }
+        headers.put(key, value);
+    }
+
+    public void addHeaders(final Map<String, String> headers) {
+        for (final Map.Entry<String, String> entry : headers.entrySet()) {
+            addHeader(entry.getKey(), entry.getValue());
+        }
+    }
+
+    @Override
+    public String toString() {
+
+        final StringBuilder strb = new StringBuilder();
+
+        // response line
+        strb.append("HTTP/1.1 ")
+                .append(status.getStatusCode())
+                .append(" ")
+                .append(status.getReasonPhrase())
+                .append("\n");
+
+        // headers
+        for (final Map.Entry<String, String> entry : headers.entrySet()) {
+            strb.append(entry.getKey()).append(": ").append(entry.getValue()).append("\n");
+        }
+
+        strb.append("\n");
+
+        // body
+        strb.append(entity);
+
+        return strb.toString();
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/manager/testutils/HttpResponseAction.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/manager/testutils/HttpResponseAction.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/manager/testutils/HttpResponseAction.java
new file mode 100644
index 0000000..28615d0
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/manager/testutils/HttpResponseAction.java
@@ -0,0 +1,60 @@
+/*
+ * 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.nifi.cluster.manager.testutils;
+
+/**
+ * Wraps a HttpResponse with a time-delay. When the action is applied, the
+ * currently executing thread sleeps for the given delay before returning the
+ * response to the caller.
+ *
+ * This class is good for simulating network latency.
+ *
+ * @author unattributed
+ */
+public class HttpResponseAction {
+
+    private final HttpResponse response;
+
+    private final int waitTimeMs;
+
+    public HttpResponseAction(final HttpResponse response) {
+        this(response, 0);
+    }
+
+    public HttpResponseAction(final HttpResponse response, final int waitTimeMs) {
+        this.response = response;
+        this.waitTimeMs = waitTimeMs;
+    }
+
+    public HttpResponse apply() {
+        try {
+            Thread.sleep(waitTimeMs);
+        } catch (final InterruptedException ie) {
+            throw new RuntimeException(ie);
+        }
+
+        return response;
+    }
+
+    public HttpResponse getResponse() {
+        return response;
+    }
+
+    public int getWaitTimeMs() {
+        return waitTimeMs;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/manager/testutils/HttpServer.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/manager/testutils/HttpServer.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/manager/testutils/HttpServer.java
new file mode 100644
index 0000000..f17a66c
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/manager/testutils/HttpServer.java
@@ -0,0 +1,240 @@
+/*
+ * 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.nifi.cluster.manager.testutils;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.PrintWriter;
+import java.io.Reader;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.net.SocketException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Queue;
+import java.util.concurrent.ConcurrentLinkedQueue;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
+import org.apache.nifi.cluster.manager.testutils.HttpRequest.HttpRequestBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * A simple HTTP web server that allows clients to register canned-responses to
+ * respond to received requests.
+ *
+ * @author unattributed
+ */
+public class HttpServer {
+
+    private static final Logger logger = LoggerFactory.getLogger(HttpServer.class);
+
+    private final ExecutorService executorService;
+    private final ServerSocket serverSocket;
+    private final Queue<HttpResponseAction> responseQueue = new ConcurrentLinkedQueue<>();
+    private final Map<String, String> checkedHeaders = new HashMap<>();
+    private final Map<String, List<String>> checkedParameters = new HashMap<>();
+    private final int port;
+
+    public HttpServer(int numThreads, int port) throws IOException {
+        this.port = port;
+        executorService = Executors.newFixedThreadPool(numThreads);
+        serverSocket = new ServerSocket(port);
+    }
+
+    public void start() {
+
+        new Thread() {
+            @Override
+            public void run() {
+                while (isRunning()) {
+                    try {
+                        final Socket conn = serverSocket.accept();
+                        executorService.execute(new Runnable() {
+                            @Override
+                            public void run() {
+                                handleRequest(conn);
+                                if (conn.isClosed() == false) {
+                                    try {
+                                        conn.close();
+                                    } catch (IOException ioe) {
+                                    }
+                                }
+                            }
+                        });
+                    } catch (final SocketException se) {
+                        /* ignored */
+                    } catch (final IOException ioe) {
+                        if (logger.isDebugEnabled()) {
+                            logger.warn("", ioe);
+                        }
+                    }
+                }
+            }
+        ;
+    }
+
+    .start();
+    }
+
+    public boolean isRunning() {
+        return executorService.isShutdown() == false;
+    }
+
+    public void stop() {
+        // shutdown server socket
+        try {
+            if (serverSocket.isClosed() == false) {
+                serverSocket.close();
+            }
+        } catch (final Exception ex) {
+            throw new RuntimeException(ex);
+        }
+
+        // shutdown executor service
+        try {
+            executorService.shutdown();
+            executorService.awaitTermination(3, TimeUnit.SECONDS);
+        } catch (final Exception ex) {
+            throw new RuntimeException(ex);
+        }
+    }
+
+    public int getPort() {
+        if (isRunning()) {
+            return serverSocket.getLocalPort();
+        } else {
+            return port;
+        }
+    }
+
+    public Queue<HttpResponseAction> addResponseAction(final HttpResponseAction response) {
+        responseQueue.add(response);
+        return responseQueue;
+    }
+
+    public void addCheckedHeaders(final Map<String, String> headers) {
+        checkedHeaders.putAll(headers);
+    }
+
+    public void addCheckedParameters(final Map<String, List<String>> parameters) {
+        checkedParameters.putAll(parameters);
+    }
+
+    private void handleRequest(final Socket conn) {
+        try {
+
+            final HttpRequest httpRequest = buildRequest(conn.getInputStream());
+
+            if (logger.isDebugEnabled()) {
+                logger.debug("\n" + httpRequest);
+            }
+
+            // check headers
+            final Map<String, String> reqHeaders = httpRequest.getHeaders();
+            for (final Map.Entry<String, String> entry : checkedHeaders.entrySet()) {
+                if (reqHeaders.containsKey(entry.getKey())) {
+                    if (entry.getValue().equals(reqHeaders.get(entry.getKey()))) {
+                        logger.error("Incorrect HTTP request header value received for checked header: " + entry.getKey());
+                        conn.close();
+                        return;
+                    }
+                } else {
+                    logger.error("Missing checked header: " + entry.getKey());
+                    conn.close();
+                    return;
+                }
+            }
+
+            // check parameters
+            final Map<String, List<String>> reqParams = httpRequest.getParameters();
+            for (final Map.Entry<String, List<String>> entry : checkedParameters.entrySet()) {
+                if (reqParams.containsKey(entry.getKey())) {
+                    if (entry.getValue().equals(reqParams.get(entry.getKey())) == false) {
+                        logger.error("Incorrect HTTP request parameter values received for checked parameter: " + entry.getKey());
+                        conn.close();
+                        return;
+                    }
+                } else {
+                    logger.error("Missing checked parameter: " + entry.getKey());
+                    conn.close();
+                    return;
+                }
+            }
+
+            // apply the next response
+            final HttpResponseAction response = responseQueue.remove();
+            response.apply();
+
+            // send the response to client
+            final PrintWriter pw = new PrintWriter(conn.getOutputStream(), true);
+
+            if (logger.isDebugEnabled()) {
+                logger.debug("\n" + response.getResponse());
+            }
+
+            pw.print(response.getResponse());
+            pw.flush();
+
+        } catch (IOException ioe) { /* ignored */ }
+    }
+
+    private HttpRequest buildRequest(final InputStream requestIs) throws IOException {
+        return new HttpRequestReader().read(new InputStreamReader(requestIs));
+    }
+
+    // reads an HTTP request from the given reader
+    private class HttpRequestReader {
+
+        public HttpRequest read(final Reader reader) throws IOException {
+
+            HttpRequestBuilder builder = null;
+            String line = "";
+            boolean isRequestLine = true;
+            while ((line = readLine(reader)).isEmpty() == false) {
+                if (isRequestLine) {
+                    builder = HttpRequest.createFromRequestLine(line);
+                    isRequestLine = false;
+                } else {
+                    builder.addHeader(line);
+                }
+            }
+
+            if (builder != null) {
+                builder.addBody(reader);
+            }
+
+            return builder.build();
+        }
+
+        private String readLine(final Reader reader) throws IOException {
+
+            /* read character at time to prevent blocking */
+            final StringBuilder strb = new StringBuilder();
+            char c;
+            while ((c = (char) reader.read()) != '\n') {
+                if (c != '\r') {
+                    strb.append(c);
+                }
+            }
+            return strb.toString();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/protocol/impl/ClusterManagerProtocolSenderImplTest.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/protocol/impl/ClusterManagerProtocolSenderImplTest.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/protocol/impl/ClusterManagerProtocolSenderImplTest.java
new file mode 100644
index 0000000..96943c2
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/protocol/impl/ClusterManagerProtocolSenderImplTest.java
@@ -0,0 +1,133 @@
+/*
+ * 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.nifi.cluster.protocol.impl;
+
+import java.io.IOException;
+import java.net.InetAddress;
+import org.apache.nifi.cluster.protocol.NodeIdentifier;
+import org.apache.nifi.cluster.protocol.ProtocolContext;
+import org.apache.nifi.cluster.protocol.ProtocolException;
+import org.apache.nifi.cluster.protocol.ProtocolHandler;
+import org.apache.nifi.cluster.protocol.jaxb.JaxbProtocolContext;
+import org.apache.nifi.cluster.protocol.jaxb.message.JaxbProtocolUtils;
+import org.apache.nifi.cluster.protocol.message.FlowRequestMessage;
+import org.apache.nifi.cluster.protocol.message.FlowResponseMessage;
+import org.apache.nifi.cluster.protocol.message.PingMessage;
+import org.apache.nifi.cluster.protocol.message.ProtocolMessage;
+import org.apache.nifi.io.socket.ServerSocketConfiguration;
+import org.apache.nifi.io.socket.SocketConfiguration;
+import org.junit.After;
+import static org.junit.Assert.*;
+import org.junit.Before;
+import org.junit.Test;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.*;
+import org.mockito.invocation.InvocationOnMock;
+import org.mockito.stubbing.Answer;
+
+/**
+ * @author unattributed
+ */
+public class ClusterManagerProtocolSenderImplTest {
+
+    private InetAddress address;
+
+    private int port;
+
+    private SocketProtocolListener listener;
+
+    private ClusterManagerProtocolSenderImpl sender;
+
+    private ProtocolHandler mockHandler;
+
+    @Before
+    public void setup() throws IOException {
+
+        address = InetAddress.getLocalHost();
+        ServerSocketConfiguration serverSocketConfiguration = new ServerSocketConfiguration();
+
+        mockHandler = mock(ProtocolHandler.class);
+
+        ProtocolContext protocolContext = new JaxbProtocolContext(JaxbProtocolUtils.JAXB_CONTEXT);
+
+        listener = new SocketProtocolListener(5, 0, serverSocketConfiguration, protocolContext);
+        listener.addHandler(mockHandler);
+        listener.start();
+
+        port = listener.getPort();
+
+        SocketConfiguration socketConfiguration = new SocketConfiguration();
+        sender = new ClusterManagerProtocolSenderImpl(socketConfiguration, protocolContext);
+    }
+
+    @After
+    public void teardown() throws IOException {
+        if (listener.isRunning()) {
+            listener.stop();
+        }
+    }
+
+    @Test
+    public void testRequestFlow() throws Exception {
+
+        when(mockHandler.canHandle(any(ProtocolMessage.class))).thenReturn(Boolean.TRUE);
+        when(mockHandler.handle(any(ProtocolMessage.class))).thenReturn(new FlowResponseMessage());
+        FlowRequestMessage request = new FlowRequestMessage();
+        request.setNodeId(new NodeIdentifier("id", "api-address", 1, address.getHostAddress(), port));
+        FlowResponseMessage response = sender.requestFlow(request);
+        assertNotNull(response);
+    }
+
+    @Test
+    public void testRequestFlowWithBadResponseMessage() throws Exception {
+
+        when(mockHandler.canHandle(any(ProtocolMessage.class))).thenReturn(Boolean.TRUE);
+        when(mockHandler.handle(any(ProtocolMessage.class))).thenReturn(new PingMessage());
+        FlowRequestMessage request = new FlowRequestMessage();
+        request.setNodeId(new NodeIdentifier("id", "api-address", 1, address.getHostAddress(), port));
+        try {
+            sender.requestFlow(request);
+            fail("failed to throw exception");
+        } catch (ProtocolException pe) {
+        }
+
+    }
+
+    @Test
+    public void testRequestFlowDelayedResponse() throws Exception {
+
+        final int time = 250;
+        sender.getSocketConfiguration().setSocketTimeout(time);
+
+        when(mockHandler.canHandle(any(ProtocolMessage.class))).thenReturn(Boolean.TRUE);
+        when(mockHandler.handle(any(ProtocolMessage.class))).thenAnswer(new Answer<FlowResponseMessage>() {
+            @Override
+            public FlowResponseMessage answer(InvocationOnMock invocation) throws Throwable {
+                Thread.sleep(time * 3);
+                return new FlowResponseMessage();
+            }
+        });
+        FlowRequestMessage request = new FlowRequestMessage();
+        request.setNodeId(new NodeIdentifier("id", "api-address", 1, address.getHostAddress(), port));
+        try {
+            sender.requestFlow(request);
+            fail("failed to throw exception");
+        } catch (ProtocolException pe) {
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/protocol/impl/ClusterServiceLocatorTest.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/protocol/impl/ClusterServiceLocatorTest.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/protocol/impl/ClusterServiceLocatorTest.java
new file mode 100644
index 0000000..4a69571
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/protocol/impl/ClusterServiceLocatorTest.java
@@ -0,0 +1,119 @@
+/*
+ * 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.nifi.cluster.protocol.impl;
+
+import java.net.InetSocketAddress;
+import java.util.concurrent.TimeUnit;
+import org.apache.nifi.io.socket.multicast.DiscoverableService;
+import org.apache.nifi.io.socket.multicast.DiscoverableServiceImpl;
+import static org.junit.Assert.*;
+import org.junit.Before;
+import org.junit.Test;
+import static org.mockito.Mockito.*;
+import org.mockito.stubbing.OngoingStubbing;
+
+public class ClusterServiceLocatorTest {
+
+    private ClusterServiceDiscovery mockServiceDiscovery;
+
+    private int fixedPort;
+
+    private DiscoverableService fixedService;
+
+    private ClusterServiceLocator serviceDiscoveryLocator;
+
+    private ClusterServiceLocator serviceDiscoveryFixedPortLocator;
+
+    private ClusterServiceLocator fixedServiceLocator;
+
+    @Before
+    public void setup() throws Exception {
+
+        fixedPort = 1;
+        mockServiceDiscovery = mock(ClusterServiceDiscovery.class);
+        fixedService = new DiscoverableServiceImpl("some-service", InetSocketAddress.createUnresolved("some-host", 20));
+
+        serviceDiscoveryLocator = new ClusterServiceLocator(mockServiceDiscovery);
+        serviceDiscoveryFixedPortLocator = new ClusterServiceLocator(mockServiceDiscovery, fixedPort);
+        fixedServiceLocator = new ClusterServiceLocator(fixedService);
+
+    }
+
+    @Test
+    public void getServiceWhenServiceDiscoveryNotStarted() {
+        assertNull(serviceDiscoveryLocator.getService());
+    }
+
+    @Test
+    public void getServiceWhenServiceDiscoveryFixedPortNotStarted() {
+        assertNull(serviceDiscoveryLocator.getService());
+    }
+
+    @Test
+    public void getServiceWhenFixedServiceNotStarted() {
+        assertEquals(fixedService, fixedServiceLocator.getService());
+    }
+
+    @Test
+    public void getServiceNotOnFirstAttempt() {
+
+        ClusterServiceLocator.AttemptsConfig config = new ClusterServiceLocator.AttemptsConfig();
+        config.setNumAttempts(2);
+        config.setTimeBetweenAttempsUnit(TimeUnit.SECONDS);
+        config.setTimeBetweenAttempts(1);
+
+        serviceDiscoveryLocator.setAttemptsConfig(config);
+
+        OngoingStubbing<DiscoverableService> stubbing = null;
+        for (int i = 0; i < config.getNumAttempts() - 1; i++) {
+            if (stubbing == null) {
+                stubbing = when(mockServiceDiscovery.getService()).thenReturn(null);
+            } else {
+                stubbing.thenReturn(null);
+            }
+        }
+        stubbing.thenReturn(fixedService);
+
+        assertEquals(fixedService, serviceDiscoveryLocator.getService());
+
+    }
+
+    @Test
+    public void getServiceNotOnFirstAttemptWithFixedPort() {
+
+        ClusterServiceLocator.AttemptsConfig config = new ClusterServiceLocator.AttemptsConfig();
+        config.setNumAttempts(2);
+        config.setTimeBetweenAttempsUnit(TimeUnit.SECONDS);
+        config.setTimeBetweenAttempts(1);
+
+        serviceDiscoveryFixedPortLocator.setAttemptsConfig(config);
+
+        OngoingStubbing<DiscoverableService> stubbing = null;
+        for (int i = 0; i < config.getNumAttempts() - 1; i++) {
+            if (stubbing == null) {
+                stubbing = when(mockServiceDiscovery.getService()).thenReturn(null);
+            } else {
+                stubbing.thenReturn(null);
+            }
+        }
+        stubbing.thenReturn(fixedService);
+
+        InetSocketAddress resultAddress = InetSocketAddress.createUnresolved(fixedService.getServiceAddress().getHostName(), fixedPort);
+        DiscoverableService resultService = new DiscoverableServiceImpl(fixedService.getServiceName(), resultAddress);
+        assertEquals(resultService, serviceDiscoveryFixedPortLocator.getService());
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/protocol/impl/ClusterServicesBroadcasterTest.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/protocol/impl/ClusterServicesBroadcasterTest.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/protocol/impl/ClusterServicesBroadcasterTest.java
new file mode 100644
index 0000000..4d85d1a
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/protocol/impl/ClusterServicesBroadcasterTest.java
@@ -0,0 +1,131 @@
+/*
+ * 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.nifi.cluster.protocol.impl;
+
+import java.net.InetSocketAddress;
+import org.apache.nifi.cluster.protocol.ProtocolContext;
+import org.apache.nifi.cluster.protocol.ProtocolException;
+import org.apache.nifi.cluster.protocol.ProtocolHandler;
+import org.apache.nifi.cluster.protocol.jaxb.JaxbProtocolContext;
+import org.apache.nifi.cluster.protocol.jaxb.message.JaxbProtocolUtils;
+import org.apache.nifi.cluster.protocol.message.ProtocolMessage;
+import org.apache.nifi.cluster.protocol.message.ServiceBroadcastMessage;
+import org.apache.nifi.io.socket.multicast.DiscoverableService;
+import org.apache.nifi.io.socket.multicast.DiscoverableServiceImpl;
+import org.apache.nifi.io.socket.multicast.MulticastConfiguration;
+import org.junit.After;
+import static org.junit.Assert.*;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ * @author unattributed
+ */
+public class ClusterServicesBroadcasterTest {
+
+    private ClusterServicesBroadcaster broadcaster;
+
+    private MulticastProtocolListener listener;
+
+    private DummyProtocolHandler handler;
+
+    private InetSocketAddress multicastAddress;
+
+    private DiscoverableService broadcastedService;
+
+    private ProtocolContext protocolContext;
+
+    private MulticastConfiguration configuration;
+
+    @Before
+    public void setup() throws Exception {
+
+        broadcastedService = new DiscoverableServiceImpl("some-service", new InetSocketAddress("localhost", 11111));
+
+        multicastAddress = new InetSocketAddress("225.1.1.1", 22222);
+
+        configuration = new MulticastConfiguration();
+
+        protocolContext = new JaxbProtocolContext(JaxbProtocolUtils.JAXB_CONTEXT);
+
+        broadcaster = new ClusterServicesBroadcaster(multicastAddress, configuration, protocolContext, "500 ms");
+        broadcaster.addService(broadcastedService);
+
+        handler = new DummyProtocolHandler();
+        listener = new MulticastProtocolListener(5, multicastAddress, configuration, protocolContext);
+        listener.addHandler(handler);
+    }
+
+    @After
+    public void teardown() {
+
+        if (broadcaster.isRunning()) {
+            broadcaster.stop();
+        }
+
+        try {
+            if (listener.isRunning()) {
+                listener.stop();
+            }
+        } catch (Exception ex) {
+            ex.printStackTrace(System.out);
+        }
+
+    }
+
+    @Test
+    @Ignore
+    public void testBroadcastReceived() throws Exception {
+
+        broadcaster.start();
+        listener.start();
+
+        Thread.sleep(1000);
+
+        listener.stop();
+
+        assertNotNull(handler.getProtocolMessage());
+        assertEquals(ProtocolMessage.MessageType.SERVICE_BROADCAST, handler.getProtocolMessage().getType());
+        final ServiceBroadcastMessage msg = (ServiceBroadcastMessage) handler.getProtocolMessage();
+        assertEquals(broadcastedService.getServiceName(), msg.getServiceName());
+        assertEquals(broadcastedService.getServiceAddress().getHostName(), msg.getAddress());
+        assertEquals(broadcastedService.getServiceAddress().getPort(), msg.getPort());
+    }
+
+    private class DummyProtocolHandler implements ProtocolHandler {
+
+        private ProtocolMessage protocolMessage;
+
+        @Override
+        public boolean canHandle(ProtocolMessage msg) {
+            return true;
+        }
+
+        @Override
+        public ProtocolMessage handle(ProtocolMessage msg) throws ProtocolException {
+            this.protocolMessage = msg;
+            return null;
+        }
+
+        public ProtocolMessage getProtocolMessage() {
+            return protocolMessage;
+        }
+
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/protocol/impl/MulticastProtocolListenerTest.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/protocol/impl/MulticastProtocolListenerTest.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/protocol/impl/MulticastProtocolListenerTest.java
new file mode 100644
index 0000000..6c79b90
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/protocol/impl/MulticastProtocolListenerTest.java
@@ -0,0 +1,171 @@
+/*
+ * 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.nifi.cluster.protocol.impl;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.net.DatagramPacket;
+import java.net.InetSocketAddress;
+import java.net.MulticastSocket;
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.nifi.cluster.protocol.ProtocolContext;
+import org.apache.nifi.cluster.protocol.ProtocolException;
+import org.apache.nifi.cluster.protocol.ProtocolHandler;
+import org.apache.nifi.cluster.protocol.ProtocolMessageMarshaller;
+import org.apache.nifi.cluster.protocol.jaxb.JaxbProtocolContext;
+import org.apache.nifi.cluster.protocol.jaxb.message.JaxbProtocolUtils;
+import org.apache.nifi.cluster.protocol.message.MulticastProtocolMessage;
+import org.apache.nifi.cluster.protocol.message.PingMessage;
+import org.apache.nifi.cluster.protocol.message.ProtocolMessage;
+import org.apache.nifi.io.socket.multicast.MulticastConfiguration;
+import org.apache.nifi.io.socket.multicast.MulticastUtils;
+import org.junit.After;
+import static org.junit.Assert.*;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ * @author unattributed
+ */
+public class MulticastProtocolListenerTest {
+
+    private MulticastProtocolListener listener;
+
+    private MulticastSocket socket;
+
+    private InetSocketAddress address;
+
+    private MulticastConfiguration configuration;
+
+    private ProtocolContext protocolContext;
+
+    @Before
+    public void setup() throws Exception {
+
+        address = new InetSocketAddress("226.1.1.1", 60000);
+        configuration = new MulticastConfiguration();
+
+        protocolContext = new JaxbProtocolContext(JaxbProtocolUtils.JAXB_CONTEXT);
+
+        listener = new MulticastProtocolListener(5, address, configuration, protocolContext);
+        listener.start();
+
+        socket = MulticastUtils.createMulticastSocket(address.getPort(), configuration);
+    }
+
+    @After
+    public void teardown() throws IOException {
+        try {
+            if (listener.isRunning()) {
+                listener.stop();
+            }
+        } finally {
+            MulticastUtils.closeQuietly(socket);
+        }
+    }
+
+    @Ignore("This test must be reworked.  Requires an active network connection")
+    @Test
+    public void testBadRequest() throws Exception {
+        DelayedProtocolHandler handler = new DelayedProtocolHandler(0);
+        listener.addHandler(handler);
+        DatagramPacket packet = new DatagramPacket(new byte[]{5}, 1, address);
+        socket.send(packet);
+        Thread.sleep(250);
+        assertEquals(0, handler.getMessages().size());
+    }
+
+    @Test
+    @Ignore
+    public void testRequest() throws Exception {
+
+        ReflexiveProtocolHandler handler = new ReflexiveProtocolHandler();
+        listener.addHandler(handler);
+
+        ProtocolMessage msg = new PingMessage();
+        MulticastProtocolMessage multicastMsg = new MulticastProtocolMessage("some-id", msg);
+
+        // marshal message to output stream
+        ProtocolMessageMarshaller marshaller = protocolContext.createMarshaller();
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        marshaller.marshal(multicastMsg, baos);
+        byte[] requestPacketBytes = baos.toByteArray();
+        DatagramPacket packet = new DatagramPacket(requestPacketBytes, requestPacketBytes.length, address);
+        socket.send(packet);
+
+        Thread.sleep(250);
+        assertEquals(1, handler.getMessages().size());
+        assertEquals(msg.getType(), handler.getMessages().get(0).getType());
+
+    }
+
+    private class ReflexiveProtocolHandler implements ProtocolHandler {
+
+        private List<ProtocolMessage> messages = new ArrayList<>();
+
+        @Override
+        public ProtocolMessage handle(ProtocolMessage msg) throws ProtocolException {
+            messages.add(msg);
+            return msg;
+        }
+
+        @Override
+        public boolean canHandle(ProtocolMessage msg) {
+            return true;
+        }
+
+        public List<ProtocolMessage> getMessages() {
+            return messages;
+        }
+
+    }
+
+    private class DelayedProtocolHandler implements ProtocolHandler {
+
+        private int delay = 0;
+
+        private List<ProtocolMessage> messages = new ArrayList<>();
+
+        public DelayedProtocolHandler(int delay) {
+            this.delay = delay;
+        }
+
+        @Override
+        public ProtocolMessage handle(ProtocolMessage msg) throws ProtocolException {
+            try {
+                messages.add(msg);
+                Thread.sleep(delay);
+                return null;
+            } catch (final InterruptedException ie) {
+                throw new ProtocolException(ie);
+            }
+
+        }
+
+        @Override
+        public boolean canHandle(ProtocolMessage msg) {
+            return true;
+        }
+
+        public List<ProtocolMessage> getMessages() {
+            return messages;
+        }
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/protocol/impl/NodeProtocolSenderImplTest.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/protocol/impl/NodeProtocolSenderImplTest.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/protocol/impl/NodeProtocolSenderImplTest.java
new file mode 100644
index 0000000..7c62d2f
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/protocol/impl/NodeProtocolSenderImplTest.java
@@ -0,0 +1,201 @@
+/*
+ * 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.nifi.cluster.protocol.impl;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.util.UUID;
+
+import org.apache.nifi.cluster.HeartbeatPayload;
+import org.apache.nifi.cluster.protocol.ConnectionRequest;
+import org.apache.nifi.cluster.protocol.ConnectionResponse;
+import org.apache.nifi.cluster.protocol.Heartbeat;
+import org.apache.nifi.cluster.protocol.NodeIdentifier;
+import org.apache.nifi.cluster.protocol.ProtocolContext;
+import org.apache.nifi.cluster.protocol.ProtocolException;
+import org.apache.nifi.cluster.protocol.ProtocolHandler;
+import org.apache.nifi.cluster.protocol.StandardDataFlow;
+import org.apache.nifi.cluster.protocol.UnknownServiceAddressException;
+import org.apache.nifi.cluster.protocol.jaxb.JaxbProtocolContext;
+import org.apache.nifi.cluster.protocol.jaxb.message.JaxbProtocolUtils;
+import org.apache.nifi.cluster.protocol.message.ConnectionRequestMessage;
+import org.apache.nifi.cluster.protocol.message.ConnectionResponseMessage;
+import org.apache.nifi.cluster.protocol.message.ControllerStartupFailureMessage;
+import org.apache.nifi.cluster.protocol.message.HeartbeatMessage;
+import org.apache.nifi.cluster.protocol.message.PingMessage;
+import org.apache.nifi.cluster.protocol.message.ProtocolMessage;
+import org.apache.nifi.io.socket.ServerSocketConfiguration;
+import org.apache.nifi.io.socket.SocketConfiguration;
+import org.apache.nifi.io.socket.multicast.DiscoverableService;
+import org.apache.nifi.io.socket.multicast.DiscoverableServiceImpl;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.invocation.InvocationOnMock;
+import org.mockito.stubbing.Answer;
+
+/**
+ * @author unattributed
+ */
+public class NodeProtocolSenderImplTest {
+
+    private SocketProtocolListener listener;
+
+    private NodeProtocolSenderImpl sender;
+
+    private DiscoverableService service;
+
+    private ServerSocketConfiguration serverSocketConfiguration;
+
+    private ClusterServiceLocator mockServiceLocator;
+
+    private ProtocolHandler mockHandler;
+
+    private NodeIdentifier nodeIdentifier;
+
+    @Before
+    public void setup() throws IOException {
+
+        serverSocketConfiguration = new ServerSocketConfiguration();
+
+        mockServiceLocator = mock(ClusterServiceLocator.class);
+        mockHandler = mock(ProtocolHandler.class);
+
+        nodeIdentifier = new NodeIdentifier("1", "localhost", 1234, "localhost", 5678);
+
+        ProtocolContext protocolContext = new JaxbProtocolContext(JaxbProtocolUtils.JAXB_CONTEXT);
+
+        listener = new SocketProtocolListener(5, 0, serverSocketConfiguration, protocolContext);
+        listener.setShutdownListenerSeconds(3);
+        listener.addHandler(mockHandler);
+        listener.start();
+
+        service = new DiscoverableServiceImpl("some-service", new InetSocketAddress("localhost", listener.getPort()));
+
+        SocketConfiguration socketConfiguration = new SocketConfiguration();
+        socketConfiguration.setReuseAddress(true);
+        sender = new NodeProtocolSenderImpl(mockServiceLocator, socketConfiguration, protocolContext);
+    }
+
+    @After
+    public void teardown() throws IOException {
+        if (listener.isRunning()) {
+            listener.stop();
+        }
+    }
+
+    @Test
+    public void testConnect() throws Exception {
+
+        when(mockServiceLocator.getService()).thenReturn(service);
+        when(mockHandler.canHandle(any(ProtocolMessage.class))).thenReturn(Boolean.TRUE);
+        ConnectionResponseMessage mockMessage = new ConnectionResponseMessage();
+        mockMessage.setConnectionResponse(new ConnectionResponse(nodeIdentifier, new StandardDataFlow("flow".getBytes("UTF-8"), new byte[0], new byte[0]), false, null, null, UUID.randomUUID().toString()));
+        when(mockHandler.handle(any(ProtocolMessage.class))).thenReturn(mockMessage);
+
+        ConnectionRequestMessage request = new ConnectionRequestMessage();
+        request.setConnectionRequest(new ConnectionRequest(nodeIdentifier));
+        ConnectionResponseMessage response = sender.requestConnection(request);
+        assertNotNull(response);
+    }
+
+    @Test(expected = UnknownServiceAddressException.class)
+    public void testConnectNoClusterManagerAddress() throws Exception {
+
+        when(mockServiceLocator.getService()).thenReturn(null);
+        when(mockHandler.canHandle(any(ProtocolMessage.class))).thenReturn(Boolean.TRUE);
+        when(mockHandler.handle(any(ProtocolMessage.class))).thenReturn(new ConnectionResponseMessage());
+
+        ConnectionRequestMessage request = new ConnectionRequestMessage();
+        request.setConnectionRequest(new ConnectionRequest(nodeIdentifier));
+
+        sender.requestConnection(request);
+        fail("failed to throw exception");
+    }
+
+    @Test(expected = ProtocolException.class)
+    public void testConnectBadResponse() throws Exception {
+
+        when(mockServiceLocator.getService()).thenReturn(service);
+        when(mockHandler.canHandle(any(ProtocolMessage.class))).thenReturn(Boolean.TRUE);
+        when(mockHandler.handle(any(ProtocolMessage.class))).thenReturn(new PingMessage());
+
+        ConnectionRequestMessage request = new ConnectionRequestMessage();
+        request.setConnectionRequest(new ConnectionRequest(nodeIdentifier));
+
+        sender.requestConnection(request);
+        fail("failed to throw exception");
+
+    }
+
+    @Test(expected = ProtocolException.class)
+    public void testConnectDelayedResponse() throws Exception {
+
+        final int time = 250;
+        sender.getSocketConfiguration().setSocketTimeout(time);
+        when(mockServiceLocator.getService()).thenReturn(service);
+        when(mockHandler.canHandle(any(ProtocolMessage.class))).thenReturn(Boolean.TRUE);
+        when(mockHandler.handle(any(ProtocolMessage.class))).thenAnswer(new Answer<ConnectionResponseMessage>() {
+            @Override
+            public ConnectionResponseMessage answer(InvocationOnMock invocation) throws Throwable {
+                Thread.sleep(time * 3);
+                return new ConnectionResponseMessage();
+            }
+        });
+        ConnectionRequestMessage request = new ConnectionRequestMessage();
+        request.setConnectionRequest(new ConnectionRequest(nodeIdentifier));
+
+        sender.requestConnection(request);
+        fail("failed to throw exception");
+
+    }
+
+    @Test
+    public void testHeartbeat() throws Exception {
+
+        when(mockServiceLocator.getService()).thenReturn(service);
+        when(mockHandler.canHandle(any(ProtocolMessage.class))).thenReturn(Boolean.TRUE);
+        when(mockHandler.handle(any(ProtocolMessage.class))).thenReturn(null);
+
+        HeartbeatMessage msg = new HeartbeatMessage();
+        HeartbeatPayload hbPayload = new HeartbeatPayload();
+        Heartbeat hb = new Heartbeat(new NodeIdentifier("id", "localhost", 3, "localhost", 4), false, false, hbPayload.marshal());
+        msg.setHeartbeat(hb);
+        sender.heartbeat(msg);
+    }
+
+    @Test
+    public void testNotifyControllerStartupFailure() throws Exception {
+
+        when(mockServiceLocator.getService()).thenReturn(service);
+        when(mockHandler.canHandle(any(ProtocolMessage.class))).thenReturn(Boolean.TRUE);
+        when(mockHandler.handle(any(ProtocolMessage.class))).thenReturn(null);
+
+        ControllerStartupFailureMessage msg = new ControllerStartupFailureMessage();
+        msg.setNodeId(new NodeIdentifier("some-id", "some-addr", 1, "some-addr", 1));
+        msg.setExceptionMessage("some exception");
+        sender.notifyControllerStartupFailure(msg);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/protocol/impl/SocketProtocolListenerTest.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/protocol/impl/SocketProtocolListenerTest.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/protocol/impl/SocketProtocolListenerTest.java
new file mode 100644
index 0000000..92a7d2a
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/protocol/impl/SocketProtocolListenerTest.java
@@ -0,0 +1,132 @@
+/*
+ * 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.nifi.cluster.protocol.impl;
+
+import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.net.Socket;
+import java.net.SocketTimeoutException;
+import org.apache.nifi.cluster.protocol.ProtocolContext;
+import org.apache.nifi.cluster.protocol.ProtocolMessageMarshaller;
+import org.apache.nifi.cluster.protocol.ProtocolMessageUnmarshaller;
+import org.apache.nifi.cluster.protocol.jaxb.JaxbProtocolContext;
+import org.apache.nifi.cluster.protocol.jaxb.message.JaxbProtocolUtils;
+import org.apache.nifi.cluster.protocol.message.PingMessage;
+import org.apache.nifi.cluster.protocol.message.ProtocolMessage;
+import org.apache.nifi.cluster.protocol.testutils.DelayedProtocolHandler;
+import org.apache.nifi.cluster.protocol.testutils.ReflexiveProtocolHandler;
+import org.apache.nifi.io.socket.ServerSocketConfiguration;
+import org.apache.nifi.io.socket.SocketConfiguration;
+import org.apache.nifi.io.socket.SocketUtils;
+import org.junit.After;
+import static org.junit.Assert.*;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * @author unattributed
+ */
+public class SocketProtocolListenerTest {
+
+    private SocketProtocolListener listener;
+
+    private Socket socket;
+
+    private ProtocolMessageMarshaller<ProtocolMessage> marshaller;
+
+    private ProtocolMessageUnmarshaller<ProtocolMessage> unmarshaller;
+
+    @Before
+    public void setup() throws Exception {
+
+        final ProtocolContext protocolContext = new JaxbProtocolContext(JaxbProtocolUtils.JAXB_CONTEXT);
+        marshaller = protocolContext.createMarshaller();
+        unmarshaller = protocolContext.createUnmarshaller();
+
+        ServerSocketConfiguration configuration = new ServerSocketConfiguration();
+        configuration.setSocketTimeout(1000);
+
+        listener = new SocketProtocolListener(5, 0, configuration, protocolContext);
+        listener.start();
+
+        int port = listener.getPort();
+
+        SocketConfiguration config = new SocketConfiguration();
+        config.setReuseAddress(true);
+        config.setSocketTimeout(1000);
+        socket = SocketUtils.createSocket(new InetSocketAddress("localhost", port), config);
+    }
+
+    @After
+    public void teardown() throws IOException {
+        try {
+            if (listener.isRunning()) {
+                listener.stop();
+            }
+        } finally {
+            SocketUtils.closeQuietly(socket);
+        }
+    }
+
+    @Test
+    public void testBadRequest() throws Exception {
+        DelayedProtocolHandler handler = new DelayedProtocolHandler(0);
+        listener.addHandler(handler);
+        socket.getOutputStream().write(5);
+        Thread.sleep(250);
+        assertEquals(0, handler.getMessages().size());
+    }
+
+    @Test
+    public void testRequest() throws Exception {
+        ProtocolMessage msg = new PingMessage();
+
+        ReflexiveProtocolHandler handler = new ReflexiveProtocolHandler();
+        listener.addHandler(handler);
+
+        // marshal message to output stream
+        marshaller.marshal(msg, socket.getOutputStream());
+
+        // unmarshall response and return
+        ProtocolMessage response = unmarshaller.unmarshal(socket.getInputStream());
+        assertEquals(msg.getType(), response.getType());
+
+        assertEquals(1, handler.getMessages().size());
+        assertEquals(msg.getType(), handler.getMessages().get(0).getType());
+    }
+
+    @Test
+    public void testDelayedRequest() throws Exception {
+        ProtocolMessage msg = new PingMessage();
+
+        DelayedProtocolHandler handler = new DelayedProtocolHandler(2000);
+        listener.addHandler(handler);
+
+        // marshal message to output stream
+        marshaller.marshal(msg, socket.getOutputStream());
+
+        try {
+            socket.getInputStream().read();
+            fail("Socket timeout not received.");
+        } catch (SocketTimeoutException ste) {
+        }
+
+        assertEquals(1, handler.getMessages().size());
+        assertEquals(msg.getType(), handler.getMessages().get(0).getType());
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/protocol/testutils/DelayedProtocolHandler.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/protocol/testutils/DelayedProtocolHandler.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/protocol/testutils/DelayedProtocolHandler.java
new file mode 100644
index 0000000..2f16777
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/protocol/testutils/DelayedProtocolHandler.java
@@ -0,0 +1,57 @@
+/*
+ * 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.nifi.cluster.protocol.testutils;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.nifi.cluster.protocol.ProtocolException;
+import org.apache.nifi.cluster.protocol.ProtocolHandler;
+import org.apache.nifi.cluster.protocol.message.ProtocolMessage;
+
+/**
+ * @author unattributed
+ */
+public class DelayedProtocolHandler implements ProtocolHandler {
+
+    private int delay = 0;
+    private List<ProtocolMessage> messages = new ArrayList<>();
+
+    public DelayedProtocolHandler(int delay) {
+        this.delay = delay;
+    }
+
+    @Override
+    public ProtocolMessage handle(ProtocolMessage msg) throws ProtocolException {
+        try {
+            messages.add(msg);
+            Thread.sleep(delay);
+            return null;
+        } catch (final InterruptedException ie) {
+            throw new ProtocolException(ie);
+        }
+
+    }
+
+    @Override
+    public boolean canHandle(ProtocolMessage msg) {
+        return true;
+    }
+
+    public List<ProtocolMessage> getMessages() {
+        return messages;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/protocol/testutils/ReflexiveProtocolHandler.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/protocol/testutils/ReflexiveProtocolHandler.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/protocol/testutils/ReflexiveProtocolHandler.java
new file mode 100644
index 0000000..e80f52c
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/protocol/testutils/ReflexiveProtocolHandler.java
@@ -0,0 +1,47 @@
+/*
+ * 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.nifi.cluster.protocol.testutils;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.nifi.cluster.protocol.ProtocolException;
+import org.apache.nifi.cluster.protocol.ProtocolHandler;
+import org.apache.nifi.cluster.protocol.message.ProtocolMessage;
+
+/**
+ * @author unattributed
+ */
+public class ReflexiveProtocolHandler implements ProtocolHandler {
+
+    private List<ProtocolMessage> messages = new ArrayList<>();
+
+    @Override
+    public ProtocolMessage handle(ProtocolMessage msg) throws ProtocolException {
+        messages.add(msg);
+        return msg;
+    }
+
+    @Override
+    public boolean canHandle(ProtocolMessage msg) {
+        return true;
+    }
+
+    public List<ProtocolMessage> getMessages() {
+        return messages;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/resources/logback-test.xml
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/resources/logback-test.xml b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/resources/logback-test.xml
new file mode 100644
index 0000000..92eb78c
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/resources/logback-test.xml
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+
+<configuration scan="true" scanPeriod="30 seconds">
+    <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
+        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
+            <pattern>%-4r [%t] %-5p %c - %m%n</pattern>
+        </encoder>
+    </appender>
+    
+    <!-- valid logging levels: TRACE, DEBUG, INFO, WARN, ERROR -->
+    <logger name="org.apache.nifi" level="INFO"/>
+    
+    <!-- Logger for managing logging statements for nifi clusters. -->
+    <logger name="org.apache.nifi.cluster" level="INFO"/>
+
+    <!-- 
+        Logger for logging HTTP requests received by the web server.  Setting
+        log level to 'debug' activates HTTP request logging.
+    -->
+    <logger name="org.apache.nifi.server.JettyServer" level="INFO"/>
+
+    <!-- Logger for managing logging statements for jetty -->
+    <logger name="org.mortbay" level="INFO"/>
+
+    <!-- Suppress non-error messages due to excessive logging by class -->
+    <logger name="com.sun.jersey.spi.container.servlet.WebComponent" level="ERROR"/>
+
+    <logger name="org.apache.nifi.processors.standard" level="DEBUG"/>
+
+    <root level="INFO">
+        <appender-ref ref="CONSOLE"/>
+    </root>
+    
+</configuration>

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/resources/org/apache/nifi/cluster/firewall/impl/empty.txt
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/resources/org/apache/nifi/cluster/firewall/impl/empty.txt b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/resources/org/apache/nifi/cluster/firewall/impl/empty.txt
new file mode 100755
index 0000000..e69de29

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/resources/org/apache/nifi/cluster/firewall/impl/ips.txt
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/resources/org/apache/nifi/cluster/firewall/impl/ips.txt b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/resources/org/apache/nifi/cluster/firewall/impl/ips.txt
new file mode 100755
index 0000000..e8e4c2b
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/resources/org/apache/nifi/cluster/firewall/impl/ips.txt
@@ -0,0 +1,12 @@
+
+bad data should be skipped
+
+# this is a comment
+  2.2.2.2  # this is another comment ####
+3.3.3.3/8
+
+4.4.4.4/24
+
+5.5.5.255/31
+
+more bad data
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/pom.xml
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/pom.xml b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/pom.xml
index bb53aff..f2bf6c9 100644
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/pom.xml
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/pom.xml
@@ -64,8 +64,8 @@
             <artifactId>nifi-client-dto</artifactId>
         </dependency>
         <dependency>
-        	<groupId>org.apache.nifi</groupId>
-        	<artifactId>nifi-site-to-site-client</artifactId>
+            <groupId>org.apache.nifi</groupId>
+            <artifactId>nifi-site-to-site-client</artifactId>
         </dependency>
         <dependency>
             <groupId>org.quartz-scheduler</groupId>
@@ -121,4 +121,19 @@
             <scope>test</scope>
         </dependency>
     </dependencies>
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.rat</groupId>
+                <artifactId>apache-rat-plugin</artifactId>
+                <configuration>
+                    <excludes>
+                        <exclude>src/test/resources/conf/0bytes.xml</exclude>
+                        <exclude>src/test/resources/conf/termination-only.xml</exclude>
+                        <exclude>src/test/resources/hello.txt</exclude>
+                    </excludes>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
 </project>

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/pom.xml
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/pom.xml b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/pom.xml
index 60eda8a..6b587fd 100644
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/pom.xml
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/pom.xml
@@ -588,6 +588,19 @@
                             </packagingIncludes>
                         </configuration>
                     </plugin>
+                    <plugin>
+                        <groupId>org.apache.rat</groupId>
+                        <artifactId>apache-rat-plugin</artifactId>
+                        <configuration>
+                            <excludes>
+                                <exclude>src/main/webapp/js/json2.js</exclude>
+                                <exclude>src/main/webapp/js/jquery/</exclude>
+                                <exclude>src/main/webapp/js/d3/d3.min.js</exclude>
+                                <exclude>src/main/webapp/js/codemirror/</exclude>
+                                <exclude>src/main/webapp/css/reset.css</exclude>
+                            </excludes>
+                        </configuration>
+                    </plugin>
                 </plugins>
             </build>
         </profile>

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/pom.xml
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/pom.xml b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/pom.xml
index 544dd77..2aaa045 100644
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/pom.xml
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/pom.xml
@@ -30,9 +30,9 @@
         <module>nifi-security</module>
         <module>nifi-site-to-site</module>
         <module>nifi-framework-core</module>
-        <module>nifi-cluster-protocol</module>
-        <module>nifi-cluster-web</module>
-        <module>nifi-cluster</module>
+        <module>nifi-framework-cluster-protocol</module>
+        <module>nifi-framework-cluster-web</module>
+        <module>nifi-framework-cluster</module>
         <module>nifi-file-authorization-provider</module>
         <module>nifi-cluster-authorization-provider</module>
         <module>nifi-user-actions</module>

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/761e64a4/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/pom.xml
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/pom.xml b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/pom.xml
index 2043a0d..170a95e 100644
--- a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/pom.xml
+++ b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/pom.xml
@@ -48,7 +48,7 @@
             <groupId>org.apache.nifi</groupId>
             <artifactId>nifi-distributed-cache-client-service-api</artifactId>
         </dependency>
-		<dependency>
+        <dependency>
             <groupId>org.apache.nifi</groupId>
             <artifactId>nifi-http-context-map-api</artifactId>
         </dependency>
@@ -169,4 +169,88 @@
             <version>1.7</version>
         </dependency>
     </dependencies>
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.rat</groupId>
+                <artifactId>apache-rat-plugin</artifactId>
+                <configuration>
+                    <excludes>
+                        <exclude>src/test/resources/hello.txt</exclude>
+                        <exclude>src/test/resources/CharacterSetConversionSamples/Converted.txt</exclude>
+                        <exclude>src/test/resources/CharacterSetConversionSamples/Original.txt</exclude>
+                        <exclude>src/test/resources/CompressedData/SampleFile.txt</exclude>
+                        <exclude>src/test/resources/CompressedData/SampleFileConcat.txt</exclude>
+                        <exclude>src/test/resources/ExecuteCommand/1000bytes.txt</exclude>
+                        <exclude>src/test/resources/ExecuteCommand/test.txt</exclude>
+                        <exclude>src/test/resources/ScanAttribute/dictionary-with-empty-new-lines</exclude>
+                        <exclude>src/test/resources/ScanAttribute/dictionary-with-extra-info</exclude>
+                        <exclude>src/test/resources/ScanAttribute/dictionary1</exclude>
+                        <exclude>src/test/resources/TestIdentifyMimeType/1.txt</exclude>
+                        <exclude>src/test/resources/TestJson/json-sample.json</exclude>
+                        <exclude>src/test/resources/TestMergeContent/demarcate</exclude>
+                        <exclude>src/test/resources/TestMergeContent/foot</exclude>
+                        <exclude>src/test/resources/TestMergeContent/head</exclude>
+                        <exclude>src/test/resources/TestModifyBytes/noFooter.txt</exclude>
+                        <exclude>src/test/resources/TestModifyBytes/noFooter_noHeader.txt</exclude>
+                        <exclude>src/test/resources/TestModifyBytes/noHeader.txt</exclude>
+                        <exclude>src/test/resources/TestModifyBytes/testFile.txt</exclude>
+                        <exclude>src/test/resources/TestReplaceTextLineByLine/$1$1.txt</exclude>
+                        <exclude>src/test/resources/TestReplaceTextLineByLine/BRue_cRue_RiRey.txt</exclude>
+                        <exclude>src/test/resources/TestReplaceTextLineByLine/Blu$2e_clu$2e.txt</exclude>
+                        <exclude>src/test/resources/TestReplaceTextLineByLine/D$d_h$d.txt</exclude>
+                        <exclude>src/test/resources/TestReplaceTextLineByLine/Good.txt</exclude>
+                        <exclude>src/test/resources/TestReplaceTextLineByLine/Spider.txt</exclude>
+                        <exclude>src/test/resources/TestReplaceTextLineByLine/[DODO].txt</exclude>
+                        <exclude>src/test/resources/TestReplaceTextLineByLine/cu[$1]_Po[$1].txt</exclude>
+                        <exclude>src/test/resources/TestReplaceTextLineByLine/cu_Po.txt</exclude>
+                        <exclude>src/test/resources/TestReplaceTextLineByLine/food.txt</exclude>
+                        <exclude>src/test/resources/TestReplaceTextLineByLine/testFile.txt</exclude>
+                        <exclude>src/test/resources/TestReplaceTextWithMapping/color-fruit-backreference-mapping.txt</exclude>
+                        <exclude>src/test/resources/TestReplaceTextWithMapping/color-fruit-blank-mapping.txt</exclude>
+                        <exclude>src/test/resources/TestReplaceTextWithMapping/color-fruit-escaped-dollar-mapping.txt</exclude>
+                        <exclude>src/test/resources/TestReplaceTextWithMapping/color-fruit-excessive-backreference-mapping-simple.txt</exclude>
+                        <exclude>src/test/resources/TestReplaceTextWithMapping/color-fruit-excessive-backreference-mapping.txt</exclude>
+                        <exclude>src/test/resources/TestReplaceTextWithMapping/color-fruit-invalid-backreference-mapping.txt</exclude>
+                        <exclude>src/test/resources/TestReplaceTextWithMapping/color-fruit-mapping.txt</exclude>
+                        <exclude>src/test/resources/TestReplaceTextWithMapping/color-fruit-no-match-mapping.txt</exclude>
+                        <exclude>src/test/resources/TestReplaceTextWithMapping/color-fruit-space-mapping.txt</exclude>
+                        <exclude>src/test/resources/TestReplaceTextWithMapping/colors-without-dashes.txt</exclude>
+                        <exclude>src/test/resources/TestReplaceTextWithMapping/colors.txt</exclude>
+                        <exclude>src/test/resources/TestScanContent/helloWorld</exclude>
+                        <exclude>src/test/resources/TestScanContent/wellthengood-bye</exclude>
+                        <exclude>src/test/resources/TestSplitText/1.txt</exclude>
+                        <exclude>src/test/resources/TestSplitText/2.txt</exclude>
+                        <exclude>src/test/resources/TestSplitText/3.txt</exclude>
+                        <exclude>src/test/resources/TestSplitText/4.txt</exclude>
+                        <exclude>src/test/resources/TestSplitText/5.txt</exclude>
+                        <exclude>src/test/resources/TestSplitText/6.txt</exclude>
+                        <exclude>src/test/resources/TestSplitText/original.txt</exclude>
+                        <exclude>src/test/resources/TestTransformXml/math.html</exclude>
+                        <exclude>src/test/resources/TestTransformXml/tokens.csv</exclude>
+                        <exclude>src/test/resources/TestTransformXml/tokens.xml</exclude>
+                        <exclude>src/test/resources/TestUnpackContent/folder/cal.txt</exclude>
+                        <exclude>src/test/resources/TestUnpackContent/folder/date.txt</exclude>
+                        <exclude>src/test/resources/TestXml/xml-bundle-1</exclude>
+                        <exclude>src/test/resources/CompressedData/SampleFile.txt.bz2</exclude>
+                        <exclude>src/test/resources/CompressedData/SampleFile.txt.gz</exclude>
+                        <exclude>src/test/resources/CompressedData/SampleFile1.txt.bz2</exclude>
+                        <exclude>src/test/resources/CompressedData/SampleFile1.txt.gz</exclude>
+                        <exclude>src/test/resources/CompressedData/SampleFileConcat.txt.bz2</exclude>
+                        <exclude>src/test/resources/ExecuteCommand/TestIngestAndUpdate.jar</exclude>
+                        <exclude>src/test/resources/ExecuteCommand/TestSuccess.jar</exclude>
+                        <exclude>src/test/resources/TestIdentifyMimeType/1.jar</exclude>
+                        <exclude>src/test/resources/TestIdentifyMimeType/1.tar</exclude>
+                        <exclude>src/test/resources/TestIdentifyMimeType/1.tar.gz</exclude>
+                        <exclude>src/test/resources/TestIdentifyMimeType/1.txt.bz2</exclude>
+                        <exclude>src/test/resources/TestIdentifyMimeType/1.txt.gz</exclude>
+                        <exclude>src/test/resources/TestIdentifyMimeType/1.zip</exclude>
+                        <exclude>src/test/resources/TestIdentifyMimeType/flowfilev1.tar</exclude>
+                        <exclude>src/test/resources/TestUnpackContent/data.tar</exclude>
+                        <exclude>src/test/resources/TestUnpackContent/data.zip</exclude>
+                    </excludes>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>    
 </project>