Github user mcgilman commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/2051#discussion_r131985519
  
    --- Diff: 
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/impl/StandardProcessGroupDAO.java
 ---
    @@ -99,29 +116,69 @@ public void verifyScheduleComponents(final String 
groupId, final ScheduledState
         }
     
         @Override
    -    public void scheduleComponents(final String groupId, final 
ScheduledState state, final Set<String> componentIds) {
    +    public void verifyActivateControllerServices(final String groupId, 
final ControllerServiceState state, final Set<String> serviceIds) {
    +        final ProcessGroup group = locateProcessGroup(flowController, 
groupId);
    +
    +        group.findAllControllerServices().stream()
    +            .filter(service -> 
serviceIds.contains(service.getIdentifier()))
    +            .forEach(service -> {
    +                if (state == ControllerServiceState.ENABLED) {
    +                    service.verifyCanEnable();
    +                } else {
    +                    service.verifyCanDisable();
    +                }
    +            });
    +    }
    +
    +    @Override
    +    public CompletableFuture<Void> scheduleComponents(final String 
groupId, final ScheduledState state, final Set<String> componentIds) {
             final ProcessGroup group = locateProcessGroup(flowController, 
groupId);
     
    +        CompletableFuture<Void> future = 
CompletableFuture.completedFuture(null);
    +
             for (final String componentId : componentIds) {
                 final Connectable connectable = 
group.findLocalConnectable(componentId);
                 if (ScheduledState.RUNNING.equals(state)) {
                     if 
(ConnectableType.PROCESSOR.equals(connectable.getConnectableType())) {
    -                    
connectable.getProcessGroup().startProcessor((ProcessorNode) connectable);
    +                    final CompletableFuture<?> processorFuture = 
connectable.getProcessGroup().startProcessor((ProcessorNode) connectable);
    +                    future = CompletableFuture.allOf(future, 
processorFuture);
                     } else if 
(ConnectableType.INPUT_PORT.equals(connectable.getConnectableType())) {
                         connectable.getProcessGroup().startInputPort((Port) 
connectable);
                     } else if 
(ConnectableType.OUTPUT_PORT.equals(connectable.getConnectableType())) {
                         connectable.getProcessGroup().startOutputPort((Port) 
connectable);
                     }
                 } else {
                     if 
(ConnectableType.PROCESSOR.equals(connectable.getConnectableType())) {
    -                    
connectable.getProcessGroup().stopProcessor((ProcessorNode) connectable);
    +                    final CompletableFuture<?> processorFuture = 
connectable.getProcessGroup().stopProcessor((ProcessorNode) connectable);
    +                    future = CompletableFuture.allOf(future, 
processorFuture);
                     } else if 
(ConnectableType.INPUT_PORT.equals(connectable.getConnectableType())) {
                         connectable.getProcessGroup().stopInputPort((Port) 
connectable);
                     } else if 
(ConnectableType.OUTPUT_PORT.equals(connectable.getConnectableType())) {
                         connectable.getProcessGroup().stopOutputPort((Port) 
connectable);
                     }
                 }
             }
    +
    +        return future;
    +    }
    +
    +    @Override
    +    public Future<Void> activateControllerServices(final String groupId, 
final ControllerServiceState state, final Set<String> serviceIds) {
    --- End diff --
    
    Assuming this action needs to be recorded in the Flow History, the 
`ProcessGroupAuditor` will need to account for this method invocation.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to