You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by pv...@apache.org on 2021/03/10 16:13:55 UTC
[nifi] branch main updated: NIFI-8307: When
StandardControllerServiceProvider.enableControllerServiceAndDependencies is
called,
ensure that it recursively calls itself for any dependent controller
services. Updated toString() of ControllerServiceNode and passed itself to
the ServiceStateTransition in order to facilitate better logging
This is an automated email from the ASF dual-hosted git repository.
pvillard pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi.git
The following commit(s) were added to refs/heads/main by this push:
new a9b435e NIFI-8307: When StandardControllerServiceProvider.enableControllerServiceAndDependencies is called, ensure that it recursively calls itself for any dependent controller services. Updated toString() of ControllerServiceNode and passed itself to the ServiceStateTransition in order to facilitate better logging
a9b435e is described below
commit a9b435e8d393611455ad1b7d6b835998f7d73ba3
Author: Mark Payne <ma...@hotmail.com>
AuthorDate: Wed Mar 10 10:06:46 2021 -0500
NIFI-8307: When StandardControllerServiceProvider.enableControllerServiceAndDependencies is called, ensure that it recursively calls itself for any dependent controller services. Updated toString() of ControllerServiceNode and passed itself to the ServiceStateTransition in order to facilitate better logging
Signed-off-by: Pierre Villard <pi...@gmail.com>
This closes #4882.
---
.../nifi/controller/service/ServiceStateTransition.java | 14 ++++++++++++++
.../controller/service/StandardControllerServiceNode.java | 9 +++------
.../service/StandardControllerServiceProvider.java | 1 +
3 files changed, 18 insertions(+), 6 deletions(-)
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/controller/service/ServiceStateTransition.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/controller/service/ServiceStateTransition.java
index 2971764..ae19388 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/controller/service/ServiceStateTransition.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/controller/service/ServiceStateTransition.java
@@ -36,12 +36,17 @@ public class ServiceStateTransition {
private ControllerServiceState state = ControllerServiceState.DISABLED;
private final List<CompletableFuture<?>> enabledFutures = new ArrayList<>();
private final List<CompletableFuture<?>> disabledFutures = new ArrayList<>();
+ private final ControllerServiceNode controllerServiceNode;
private final ReadWriteLock rwLock = new ReentrantReadWriteLock();
private final Lock writeLock = rwLock.writeLock();
private final Lock readLock = rwLock.readLock();
private final Condition stateChangeCondition = writeLock.newCondition();
+ public ServiceStateTransition(final ControllerServiceNode controllerServiceNode) {
+ this.controllerServiceNode = controllerServiceNode;
+ }
+
public boolean transitionToEnabling(final ControllerServiceState expectedState, final CompletableFuture<?> enabledFuture) {
writeLock.lock();
try {
@@ -50,6 +55,8 @@ public class ServiceStateTransition {
}
state = ControllerServiceState.ENABLING;
+ logger.debug("{} transitioned to ENABLING", controllerServiceNode);
+
stateChangeCondition.signalAll();
enabledFutures.add(enabledFuture);
return true;
@@ -62,10 +69,12 @@ public class ServiceStateTransition {
writeLock.lock();
try {
if (state != ControllerServiceState.ENABLING) {
+ logger.debug("{} cannot be transitioned to enabled because it's not currently ENABLING but rather {}", controllerServiceNode, state);
return false;
}
state = ControllerServiceState.ENABLED;
+ logger.debug("{} transitioned to ENABLED", controllerServiceNode);
enabledFutures.forEach(future -> future.complete(null));
@@ -86,6 +95,7 @@ public class ServiceStateTransition {
writeLock.lock();
try {
if (expectedState != state) {
+ logger.debug("{} cannot be transitioned to DISABLING because its state is {}, not the expected {}", controllerServiceNode, state, expectedState);
return false;
}
@@ -102,6 +112,8 @@ public class ServiceStateTransition {
writeLock.lock();
try {
state = ControllerServiceState.DISABLED;
+ logger.debug("{} transitioned to DISABLED", controllerServiceNode);
+
stateChangeCondition.signalAll();
disabledFutures.forEach(future -> future.complete(null));
} finally {
@@ -130,6 +142,8 @@ public class ServiceStateTransition {
return false;
}
+ logger.debug("State of {} is currently {}. Will wait up to {} milliseconds for state to transition to {}", controllerServiceNode, state, millisLeft, desiredState);
+
stateChangeCondition.await(millisLeft, TimeUnit.MILLISECONDS);
}
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/controller/service/StandardControllerServiceNode.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/controller/service/StandardControllerServiceNode.java
index 6167a5e..17e97ec 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/controller/service/StandardControllerServiceNode.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/controller/service/StandardControllerServiceNode.java
@@ -112,7 +112,7 @@ public class StandardControllerServiceNode extends AbstractComponentNode impleme
this.serviceProvider = serviceProvider;
this.active = new AtomicBoolean();
setControllerServiceAndProxy(implementation, proxiedControllerService, invocationHandler);
- stateTransition = new ServiceStateTransition();
+ stateTransition = new ServiceStateTransition(this);
}
@Override
@@ -594,14 +594,11 @@ public class StandardControllerServiceNode extends AbstractComponentNode impleme
@Override
public String toString() {
- final ControllerServiceDetails details = controllerServiceHolder.get();
- final String bundleCoordinate = details == null ? "null" : String.valueOf(details.getBundleCoordinate());
return "StandardControllerServiceNode[" +
"service=" + super.toString() +
- ", versionedComponentId=" + versionedComponentId +
- ", processGroup=" + processGroup +
+ ", name=" + getName() +
", active=" + active +
- ']';
+ "]";
}
@Override
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/controller/service/StandardControllerServiceProvider.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/controller/service/StandardControllerServiceProvider.java
index 4e17aab..baccdfd 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/controller/service/StandardControllerServiceProvider.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/controller/service/StandardControllerServiceProvider.java
@@ -295,6 +295,7 @@ public class StandardControllerServiceProvider implements ControllerServiceProvi
for (final ControllerServiceNode depNode : dependentServices) {
if (!depNode.isActive()) {
logger.debug("Before enabling {}, will enable dependent Controller Service {}", serviceNode, depNode);
+ enableControllerServiceAndDependencies(depNode);
}
}