markap14 commented on code in PR #6341: URL: https://github.com/apache/nifi/pull/6341#discussion_r971095945
########## nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/groups/FlowSynchronizationCallback.java: ########## @@ -0,0 +1,55 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.nifi.groups; + +import org.apache.nifi.connectable.Port; +import org.apache.nifi.controller.ProcessorNode; +import org.apache.nifi.controller.ReportingTaskNode; +import org.apache.nifi.controller.service.ControllerServiceNode; + +public interface FlowSynchronizationCallback { Review Comment: I'm OK with the concept of listening for these events. But I'm not sure that `FlowSynchronizationCallback` is the right abstraction here - er, rather, the right name. When you call it a callback, it gives the impression that it's some action that needs to be taken after a flow is synchronized. Here, there's no action that needs to be taken in order to complete the synchronization. Instead, it's more of an event listener. And the methods have nothing to do with Flow Synchronization but rather a change of components' scheduled states. Perhaps it makes more sense to refer to this as a ScheduleStateChangeListener or something like that? ########## nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/flow/synchronization/StandardVersionedComponentSynchronizer.java: ########## @@ -2429,6 +2440,24 @@ private <T extends Connectable> Set<T> stopOrTerminate(final Set<T> components, return stoppedComponents; } + private void notifyScheduledStateChange(final Connectable component, final FlowSynchronizationOptions synchronizationOptions) { + if (component instanceof ProcessorNode) { + synchronizationOptions.getCallback().onScheduledStateChange((ProcessorNode) component); + } else if (component instanceof Port) { + synchronizationOptions.getCallback().onScheduledStateChange((Port) component); + } + } + + private void notifyScheduledStateChange(final ComponentNode component, final FlowSynchronizationOptions synchronizationOptions) { + if (component instanceof ProcessorNode) { + synchronizationOptions.getCallback().onScheduledStateChange((ProcessorNode) component); + } else if (component instanceof Port) { + synchronizationOptions.getCallback().onScheduledStateChange((Port) component); + } else if (component instanceof ControllerServiceNode) { + synchronizationOptions.getCallback().onScheduledStateChange((Port) component); Review Comment: This is not the correct type cast. If component instanceof ControllerServiceNode, you're casting to Port. ########## nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/groups/FlowSynchronizationOptions.java: ########## @@ -247,6 +254,15 @@ public Builder componentStopTimeoutAction(final ComponentStopTimeoutAction actio return this; } + /** + * Specifies a callback whose methods will be called when various updates are made to the flow + * @param callback the FlowSynchronizationCallback to use + * @return the builder + */ + public Builder callback(final FlowSynchronizationCallback callback) { Review Comment: As noted above, as this is designed & used, I think this is more of a listener that can be provided, than a callback that should be required. This should be optionally provided. -- 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. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
