thenatog commented on a change in pull request #4613:
URL: https://github.com/apache/nifi/pull/4613#discussion_r516986718
##########
File path:
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/state/providers/zookeeper/ZooKeeperStateProvider.java
##########
@@ -133,20 +146,54 @@ public ZooKeeperStateProvider() {
return properties;
}
-
@Override
public synchronized void init(final StateProviderInitializationContext
context) {
connectionString = context.getProperty(CONNECTION_STRING).getValue();
rootNode = context.getProperty(ROOT_NODE).getValue();
timeoutMillis =
context.getProperty(SESSION_TIMEOUT).asTimePeriod(TimeUnit.MILLISECONDS).intValue();
+ final Properties stateProviderProperties = new Properties();
+
stateProviderProperties.setProperty(NiFiProperties.ZOOKEEPER_SESSION_TIMEOUT,
String.valueOf(timeoutMillis));
+
stateProviderProperties.setProperty(NiFiProperties.ZOOKEEPER_CONNECT_TIMEOUT,
String.valueOf(timeoutMillis));
+
stateProviderProperties.setProperty(NiFiProperties.ZOOKEEPER_ROOT_NODE,
rootNode);
+
stateProviderProperties.setProperty(NiFiProperties.ZOOKEEPER_CONNECT_STRING,
connectionString);
+
+ zooKeeperClientConfig =
ZooKeeperClientConfig.createConfig(combineProperties(nifiProperties,
stateProviderProperties));
if
(context.getProperty(ACCESS_CONTROL).getValue().equalsIgnoreCase(CREATOR_ONLY.getValue()))
{
acl = Ids.CREATOR_ALL_ACL;
} else {
acl = Ids.OPEN_ACL_UNSAFE;
}
}
+ /**
+ * Combine properties from NiFiProperties and additional properties,
allowing these additional properties to override settings
+ * in the given NiFiProperties.
+ * @param nifiProps A NiFiProperties to be combined with some additional
properties
+ * @param additionalProperties Additional properties that can be used to
override properties in the given NiFiProperties
+ * @return NiFiProperties containing the combined properties
+ */
+ static NiFiProperties combineProperties(NiFiProperties nifiProps,
Properties additionalProperties) {
+ return new NiFiProperties() {
+ @Override
+ public String getProperty(String key) {
+ String property = additionalProperties.getProperty(key);
+ if(nifiProps != null) {
+ return property != null ? property :
nifiProps.getProperty(key);
+ } else {
+ return null;
+ }
+ }
Review comment:
You're right, I think this is wrong. I wrote it like this to solve an
issue I was having with tests but it wasn't the best way to handle it. Will fix.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]