Repository: nifi
Updated Branches:
  refs/heads/master e345218ea -> 8ebf1f03c


NIFI-868 Configure advertised host name of Remote Process Group Input Port

Before this change, the host given out to clients to connect to a Remote
Process Group Input Port is the host where the NiFi instance runs.
However, sometimes the binding host is different from the host that
clients connect to. For example, when a NiFi instance runs inside a
Docker container, a client on a separate machine must connect to the
Docker host which forwards the connection to the container.

Add a configuration property to specify the host name to give out to
clients to connect to a Remote Process Group Input Port. If the property
is not configured, then give out the name of host running the NiFi
instance.


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

Branch: refs/heads/master
Commit: 8f98f8093868e0ed2fb1dfbe3947f1afc1bdd10b
Parents: 8e53471
Author: Chin Huang <[email protected]>
Authored: Tue Aug 18 19:35:25 2015 -0700
Committer: Chin Huang <[email protected]>
Committed: Tue Aug 18 21:35:28 2015 -0700

----------------------------------------------------------------------
 .../main/java/org/apache/nifi/util/NiFiProperties.java   | 11 +++++++++++
 nifi-docs/src/main/asciidoc/administration-guide.adoc    |  1 +
 .../src/main/resources/conf/nifi.properties              |  1 +
 .../protocol/socket/SocketFlowFileServerProtocol.java    |  8 +++++++-
 .../src/test/resources/access-control/nifi.properties    |  1 +
 5 files changed, 21 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/nifi/blob/8f98f809/nifi-commons/nifi-properties/src/main/java/org/apache/nifi/util/NiFiProperties.java
----------------------------------------------------------------------
diff --git 
a/nifi-commons/nifi-properties/src/main/java/org/apache/nifi/util/NiFiProperties.java
 
b/nifi-commons/nifi-properties/src/main/java/org/apache/nifi/util/NiFiProperties.java
index e25f5d6..40b0f28 100644
--- 
a/nifi-commons/nifi-properties/src/main/java/org/apache/nifi/util/NiFiProperties.java
+++ 
b/nifi-commons/nifi-properties/src/main/java/org/apache/nifi/util/NiFiProperties.java
@@ -59,6 +59,7 @@ public class NiFiProperties extends Properties {
     public static final String SENSITIVE_PROPS_ALGORITHM = 
"nifi.sensitive.props.algorithm";
     public static final String SENSITIVE_PROPS_PROVIDER = 
"nifi.sensitive.props.provider";
     public static final String H2_URL_APPEND = "nifi.h2.url.append";
+    public static final String REMOTE_INPUT_HOST = 
"nifi.remote.input.socket.host";
     public static final String REMOTE_INPUT_PORT = 
"nifi.remote.input.socket.port";
     public static final String SITE_TO_SITE_SECURE = 
"nifi.remote.input.secure";
     public static final String TEMPLATE_DIRECTORY = "nifi.templates.directory";
@@ -367,6 +368,16 @@ public class NiFiProperties extends Properties {
     }
 
     /**
+     * The host name that will be given out to clients to connect to the 
Remote Input Port.
+     *
+     * @return the remote input host name or null if not configured
+     */
+    public String getRemoteInputHost() {
+        final String value = getProperty(REMOTE_INPUT_HOST);
+        return StringUtils.isBlank(value) ? null : value;
+    }
+
+    /**
      * The socket port to listen on for a Remote Input Port.
      *
      * @return the remote input port

http://git-wip-us.apache.org/repos/asf/nifi/blob/8f98f809/nifi-docs/src/main/asciidoc/administration-guide.adoc
----------------------------------------------------------------------
diff --git a/nifi-docs/src/main/asciidoc/administration-guide.adoc 
b/nifi-docs/src/main/asciidoc/administration-guide.adoc
index 7724713..4c8a4dd 100644
--- a/nifi-docs/src/main/asciidoc/administration-guide.adoc
+++ b/nifi-docs/src/main/asciidoc/administration-guide.adoc
@@ -549,6 +549,7 @@ These properties govern how this instance of NiFi 
communicates with remote insta
 
 |====
 |*Property*|*Description*
+|nifi.remote.input.socket.host|The host name that will be given out to clients 
to connect to this NiFi instance for Site-to-Site communication. By default, it 
is the value from InetAddress.getLocalHost().getHostName(). On UNIX-like 
operating systems, this is typically the output from the `hostname` command.
 |nifi.remote.input.socket.port|The remote input socket port for Site-to-Site 
communication. By default, it is blank, but it must have a value in order to 
use Remote Process Groups.
 |nifi.remote.input.secure|This indicates whether communication between this 
instance of NiFi and remote NiFi instances should be secure. By default, it is 
set to _true_. In order for secure site-to-site to work, many Security 
Properties (below) must also be configured.
 |====

http://git-wip-us.apache.org/repos/asf/nifi/blob/8f98f809/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-resources/src/main/resources/conf/nifi.properties
----------------------------------------------------------------------
diff --git 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-resources/src/main/resources/conf/nifi.properties
 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-resources/src/main/resources/conf/nifi.properties
index 4043076..42476cc 100644
--- 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-resources/src/main/resources/conf/nifi.properties
+++ 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-resources/src/main/resources/conf/nifi.properties
@@ -95,6 +95,7 @@ 
nifi.components.status.repository.buffer.size=${nifi.components.status.repositor
 
nifi.components.status.snapshot.frequency=${nifi.components.status.snapshot.frequency}
 
 # Site to Site properties
+nifi.remote.input.socket.host=
 nifi.remote.input.socket.port=
 nifi.remote.input.secure=true
 

http://git-wip-us.apache.org/repos/asf/nifi/blob/8f98f809/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-site-to-site/src/main/java/org/apache/nifi/remote/protocol/socket/SocketFlowFileServerProtocol.java
----------------------------------------------------------------------
diff --git 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-site-to-site/src/main/java/org/apache/nifi/remote/protocol/socket/SocketFlowFileServerProtocol.java
 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-site-to-site/src/main/java/org/apache/nifi/remote/protocol/socket/SocketFlowFileServerProtocol.java
index b931e26..22ca29f 100644
--- 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-site-to-site/src/main/java/org/apache/nifi/remote/protocol/socket/SocketFlowFileServerProtocol.java
+++ 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-site-to-site/src/main/java/org/apache/nifi/remote/protocol/socket/SocketFlowFileServerProtocol.java
@@ -612,9 +612,15 @@ public class SocketFlowFileServerProtocol implements 
ServerProtocol {
 
         final NiFiProperties properties = NiFiProperties.getInstance();
 
+        String remoteInputHost = properties.getRemoteInputHost();
+        if (remoteInputHost == null) {
+            remoteInputHost = InetAddress.getLocalHost().getHostName();
+        }
+        logger.debug("{} Advertising Remote Input host name {}", this, peer);
+
         // we have only 1 peer: ourselves.
         dos.writeInt(1);
-        dos.writeUTF(InetAddress.getLocalHost().getHostName());
+        dos.writeUTF(remoteInputHost);
         dos.writeInt(properties.getRemoteInputPort());
         dos.writeBoolean(properties.isSiteToSiteSecure());
         dos.writeInt(0);    // doesn't matter how many FlowFiles we have, 
because we're the only host.

http://git-wip-us.apache.org/repos/asf/nifi/blob/8f98f809/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/resources/access-control/nifi.properties
----------------------------------------------------------------------
diff --git 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/resources/access-control/nifi.properties
 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/resources/access-control/nifi.properties
index 3393605..0aa5a14 100644
--- 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/resources/access-control/nifi.properties
+++ 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/resources/access-control/nifi.properties
@@ -67,6 +67,7 @@ nifi.components.status.snapshot.frequency=10 secs
 
 # Site to Site properties
 #For testing purposes. Default value should actually be empty!
+nifi.remote.input.socket.host=
 nifi.remote.input.socket.port=
 nifi.remote.input.secure=false
 

Reply via email to