mirror of https://github.com/apache/nifi.git
NIFI-8040: When changing version of a flow, stop processors that have a state of Starting in addition to those with a state of Running
Signed-off-by: Pierre Villard <pierre.villard.fr@gmail.com> This closes #5718.
This commit is contained in:
parent
0eff249870
commit
3ea9faccc6
|
@ -5056,7 +5056,7 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (localComponent.getComponentType() == org.apache.nifi.flow.ComponentType.CONTROLLER_SERVICE) {
|
if (localComponent.getComponentType() == org.apache.nifi.flow.ComponentType.CONTROLLER_SERVICE) {
|
||||||
final String serviceId = ((InstantiatedVersionedControllerService) localComponent).getInstanceIdentifier();
|
final String serviceId = localComponent.getInstanceIdentifier();
|
||||||
final ControllerServiceNode serviceNode = controllerServiceDAO.getControllerService(serviceId);
|
final ControllerServiceNode serviceNode = controllerServiceDAO.getControllerService(serviceId);
|
||||||
|
|
||||||
final List<ControllerServiceNode> referencingServices = serviceNode.getReferences().findRecursiveReferences(ControllerServiceNode.class);
|
final List<ControllerServiceNode> referencingServices = serviceNode.getReferences().findRecursiveReferences(ControllerServiceNode.class);
|
||||||
|
@ -5171,6 +5171,7 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade {
|
||||||
dto.setId(connectable.getIdentifier());
|
dto.setId(connectable.getIdentifier());
|
||||||
dto.setReferenceType(connectable.getConnectableType().name());
|
dto.setReferenceType(connectable.getConnectableType().name());
|
||||||
dto.setState(connectable.getScheduledState().name());
|
dto.setState(connectable.getScheduledState().name());
|
||||||
|
dto.setName(connectable.getName());
|
||||||
|
|
||||||
final String groupId = connectable instanceof RemoteGroupPort ? ((RemoteGroupPort) connectable).getRemoteProcessGroup().getIdentifier() : connectable.getProcessGroupIdentifier();
|
final String groupId = connectable instanceof RemoteGroupPort ? ((RemoteGroupPort) connectable).getRemoteProcessGroup().getIdentifier() : connectable.getProcessGroupIdentifier();
|
||||||
dto.setProcessGroupId(groupId);
|
dto.setProcessGroupId(groupId);
|
||||||
|
|
|
@ -299,6 +299,20 @@ public abstract class FlowUpdateResource<T extends ProcessGroupDescriptorEntity,
|
||||||
return createUpdateRequestResponse(requestType, requestId, request, false);
|
return createUpdateRequestResponse(requestType, requestId, request, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isActive(final AffectedComponentDTO affectedComponentDto) {
|
||||||
|
final String state = affectedComponentDto.getState();
|
||||||
|
if ("Running".equalsIgnoreCase(state) || "Starting".equalsIgnoreCase(state)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
final Integer threadCount = affectedComponentDto.getActiveThreadCount();
|
||||||
|
if (threadCount != null && threadCount > 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Perform the specified flow update
|
* Perform the specified flow update
|
||||||
*/
|
*/
|
||||||
|
@ -318,8 +332,8 @@ public abstract class FlowUpdateResource<T extends ProcessGroupDescriptorEntity,
|
||||||
stoppableReferenceTypes.add(AffectedComponentDTO.COMPONENT_TYPE_OUTPUT_PORT);
|
stoppableReferenceTypes.add(AffectedComponentDTO.COMPONENT_TYPE_OUTPUT_PORT);
|
||||||
|
|
||||||
final Set<AffectedComponentEntity> runningComponents = affectedComponents.stream()
|
final Set<AffectedComponentEntity> runningComponents = affectedComponents.stream()
|
||||||
.filter(dto -> stoppableReferenceTypes.contains(dto.getComponent().getReferenceType()))
|
.filter(entity -> stoppableReferenceTypes.contains(entity.getComponent().getReferenceType()))
|
||||||
.filter(dto -> "Running".equalsIgnoreCase(dto.getComponent().getState()))
|
.filter(entity -> isActive(entity.getComponent()))
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
logger.info("Stopping {} Processors", runningComponents.size());
|
logger.info("Stopping {} Processors", runningComponents.size());
|
||||||
|
|
Loading…
Reference in New Issue