NIFI-6653 Change bootstrap port command handling

This closes #3722.

Signed-off-by: Andy LoPresto <alopresto@apache.org>
This commit is contained in:
Kevin Doran 2019-09-11 15:40:40 -04:00 committed by Andy LoPresto
parent 171e37ddda
commit 3686ee2a16
No known key found for this signature in database
GPG Key ID: 6EC293152D90B61D

View File

@ -116,8 +116,10 @@ public class RunNiFi {
public static final String DUMP_CMD = "DUMP"; public static final String DUMP_CMD = "DUMP";
public static final String DIAGNOSTICS_CMD = "DIAGNOSTICS"; public static final String DIAGNOSTICS_CMD = "DIAGNOSTICS";
private static final int UNINITIALIZED_CC_PORT = -1;
private volatile boolean autoRestartNiFi = true; private volatile boolean autoRestartNiFi = true;
private volatile int ccPort = -1; private volatile int ccPort = UNINITIALIZED_CC_PORT;
private volatile long nifiPid = -1L; private volatile long nifiPid = -1L;
private volatile String secretKey; private volatile String secretKey;
private volatile ShutdownHook shutdownHook; private volatile ShutdownHook shutdownHook;
@ -1376,6 +1378,12 @@ public class RunNiFi {
} }
void setNiFiCommandControlPort(final int port, final String secretKey) throws IOException { void setNiFiCommandControlPort(final int port, final String secretKey) throws IOException {
if (this.secretKey != null && this.ccPort != UNINITIALIZED_CC_PORT) {
defaultLogger.warn("Blocking attempt to change NiFi command port and secret after they have already been initialized. requestedPort={}", port);
return;
}
this.ccPort = port; this.ccPort = port;
this.secretKey = secretKey; this.secretKey = secretKey;