This is an automated email from the ASF dual-hosted git repository.
bbende pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nifi.git
The following commit(s) were added to refs/heads/master by this push:
new bf7e70e NIFI-6194: Fixed verification logic to determine whether or
not a variable's value can be changed. Previously, the logic had a bug that
resulted in a failure if any child group contained a running processor that
references an overridden variable and the user attempts to change the
overridden variable at the higher level. We should not include any components
of descendent groups if the descendent group overrides the variable.
bf7e70e is described below
commit bf7e70e4c3a30bec5121333faa6ebfe8d054c180
Author: Mark Payne <[email protected]>
AuthorDate: Tue Apr 9 09:44:22 2019 -0400
NIFI-6194: Fixed verification logic to determine whether or not a
variable's value can be changed. Previously, the logic had a bug that resulted
in a failure if any child group contained a running processor that references
an overridden variable and the user attempts to change the overridden variable
at the higher level. We should not include any components of descendent groups
if the descendent group overrides the variable.
This closes #3420.
Signed-off-by: Bryan Bende <[email protected]>
---
.../apache/nifi/groups/StandardProcessGroup.java | 36 +++++++++++++++++-----
1 file changed, 28 insertions(+), 8 deletions(-)
diff --git
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/groups/StandardProcessGroup.java
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/groups/StandardProcessGroup.java
index c1a241b..1bc06a1 100644
---
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/groups/StandardProcessGroup.java
+++
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/groups/StandardProcessGroup.java
@@ -2849,13 +2849,14 @@ public final class StandardProcessGroup implements
ProcessGroup {
return;
}
- for (final ProcessorNode processor : findAllProcessors()) {
+ // Determine any Processors that references the variable
+ for (final ProcessorNode processor : getProcessors()) {
if (!processor.isRunning()) {
continue;
}
- for (final String variableName : updatedVariableNames) {
- for (final VariableImpact impact :
getVariableImpact(processor)) {
+ for (final VariableImpact impact :
getVariableImpact(processor)) {
+ for (final String variableName : updatedVariableNames) {
if (impact.isImpacted(variableName)) {
throw new IllegalStateException("Cannot update
variable '" + variableName + "' because it is referenced by " + processor + ",
which is currently running");
}
@@ -2863,19 +2864,38 @@ public final class StandardProcessGroup implements
ProcessGroup {
}
}
- for (final ControllerServiceNode service :
findAllControllerServices()) {
+ // Determine any Controller Service that references the variable.
+ for (final ControllerServiceNode service :
getControllerServices(false)) {
if (!service.isActive()) {
continue;
}
- for (final String variableName : updatedVariableNames) {
- for (final VariableImpact impact :
getVariableImpact(service)) {
+ for (final VariableImpact impact : getVariableImpact(service))
{
+ for (final String variableName : updatedVariableNames) {
if (impact.isImpacted(variableName)) {
throw new IllegalStateException("Cannot update
variable '" + variableName + "' because it is referenced by " + service + ",
which is currently running");
}
}
}
}
+
+ // For any child Process Group that does not override the
variable, also include its references.
+ // If a child group has a value for the same variable, though,
then that means that the child group
+ // is overriding the variable and its components are actually
referencing a different variable.
+ for (final ProcessGroup childGroup : getProcessGroups()) {
+ for (final String variableName : updatedVariableNames) {
+ final ComponentVariableRegistry childRegistry =
childGroup.getVariableRegistry();
+ final VariableDescriptor descriptor =
childRegistry.getVariableKey(variableName);
+ final boolean overridden =
childRegistry.getVariableMap().containsKey(descriptor);
+ if (!overridden) {
+ final Set<ComponentNode> affectedComponents =
childGroup.getComponentsAffectedByVariable(variableName);
+ if (!affectedComponents.isEmpty()) {
+ throw new IllegalStateException("Cannot update
variable '" + variableName + "' because it is referenced by " +
affectedComponents.size() + " components that are " +
+ "currently running.");
+ }
+ }
+ }
+ }
} finally {
readLock.unlock();
}
@@ -2987,8 +3007,8 @@ public final class StandardProcessGroup implements
ProcessGroup {
}
final Map<VariableDescriptor, String> variableMap = new
HashMap<>();
- variables.entrySet() // cannot use Collectors.toMap because value
may be null
- .forEach(entry -> variableMap.put(new
VariableDescriptor(entry.getKey()), entry.getValue()));
+ // cannot use Collectors.toMap because value may be null
+ variables.forEach((key, value) -> variableMap.put(new
VariableDescriptor(key), value));
variableRegistry.setVariables(variableMap);
} finally {