You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by GitBox <gi...@apache.org> on 2022/08/29 00:40:51 UTC

[GitHub] [nifi] gresockj opened a new pull request, #6341: NIFI-10401: Adding FlowSynchronizationCallback to synchronizer

gresockj opened a new pull request, #6341:
URL: https://github.com/apache/nifi/pull/6341

   
   # Summary
   
   [NIFI-10401](https://issues.apache.org/jira/browse/NIFI-10401)
   
   This adds a callback to the `FlowSynchronizationOptions` that will allow client framework code to receive notification of any automatic component scheduled state updates.
   
   # Tracking
   
   Please complete the following tracking steps prior to pull request creation.
   
   ### Issue Tracking
   
   - [ ] [Apache NiFi Jira](https://issues.apache.org/jira/browse/NIFI) issue created
   
   ### Pull Request Tracking
   
   - [ ] Pull Request title starts with Apache NiFi Jira issue number, such as `NIFI-00000`
   - [ ] Pull Request commit message starts with Apache NiFi Jira issue number, as such `NIFI-00000`
   
   ### Pull Request Formatting
   
   - [ ] Pull Request based on current revision of the `main` branch
   - [ ] Pull Request refers to a feature branch with one commit containing changes
   
   # Verification
   
   Please indicate the verification steps performed prior to pull request creation.
   
   ### Build
   
   - [ ] Build completed using `mvn clean install -P contrib-check`
     - [ ] JDK 8
     - [ ] JDK 11
     - [ ] JDK 17
   
   ### Licensing
   
   - [ ] New dependencies are compatible with the [Apache License 2.0](https://apache.org/licenses/LICENSE-2.0) according to the [License Policy](https://www.apache.org/legal/resolved.html)
   - [ ] New dependencies are documented in applicable `LICENSE` and `NOTICE` files
   
   ### Documentation
   
   - [ ] Documentation formatting appears as expected in rendered files
   


-- 
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: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nifi] markap14 merged pull request #6341: NIFI-10401: Adding FlowSynchronizationCallback to synchronizer

Posted by GitBox <gi...@apache.org>.
markap14 merged PR #6341:
URL: https://github.com/apache/nifi/pull/6341


-- 
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: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nifi] markap14 commented on a diff in pull request #6341: NIFI-10401: Adding FlowSynchronizationCallback to synchronizer

Posted by GitBox <gi...@apache.org>.
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: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nifi] gresockj commented on pull request #6341: NIFI-10401: Adding FlowSynchronizationCallback to synchronizer

Posted by GitBox <gi...@apache.org>.
gresockj commented on PR #6341:
URL: https://github.com/apache/nifi/pull/6341#issuecomment-1247356721

   Ok @markap14, I believe I've addressed your feedback in the latest commit


-- 
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: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nifi] greyp9 commented on a diff in pull request #6341: NIFI-10401: Adding FlowSynchronizationCallback to synchronizer

Posted by GitBox <gi...@apache.org>.
greyp9 commented on code in PR #6341:
URL: https://github.com/apache/nifi/pull/6341#discussion_r957836684


##########
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/groups/FlowSynchronizationCallback.java:
##########
@@ -0,0 +1,56 @@
+/*
+ * 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.ScheduledState;
+import org.apache.nifi.controller.service.ControllerServiceNode;
+
+public interface FlowSynchronizationCallback {
+    void onScheduledStateChange(ProcessorNode processor);
+
+    void onScheduledStateChange(Port port);
+
+    void onScheduledStateChange(ControllerServiceNode controllerService);
+
+    void onScheduledStateChange(ReportingTaskNode reportingTask);
+
+    FlowSynchronizationCallback EMPTY = new FlowSynchronizationCallback() {
+        @Override
+        public void onScheduledStateChange(ProcessorNode processor) {
+

Review Comment:
   Might be nice for these to have log trace statements, so that the default runtime behavior could be verified.



##########
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/groups/FlowSynchronizationCallback.java:
##########
@@ -0,0 +1,56 @@
+/*
+ * 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.ScheduledState;
+import org.apache.nifi.controller.service.ControllerServiceNode;
+
+public interface FlowSynchronizationCallback {
+    void onScheduledStateChange(ProcessorNode processor);
+
+    void onScheduledStateChange(Port port);
+
+    void onScheduledStateChange(ControllerServiceNode controllerService);
+
+    void onScheduledStateChange(ReportingTaskNode reportingTask);

Review Comment:
   Don't see this used anywhere; should there be a reference in `notifyScheduledStateChange(final ComponentNode component, ...)`?



-- 
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: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nifi] markap14 commented on pull request #6341: NIFI-10401: Adding FlowSynchronizationCallback to synchronizer

Posted by GitBox <gi...@apache.org>.
markap14 commented on PR #6341:
URL: https://github.com/apache/nifi/pull/6341#issuecomment-1248086635

   Thanks for updating @gresockj. All looks good to me now as well. +1 will merge to main.


-- 
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: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nifi] gresockj commented on a diff in pull request #6341: NIFI-10401: Adding FlowSynchronizationCallback to synchronizer

Posted by GitBox <gi...@apache.org>.
gresockj commented on code in PR #6341:
URL: https://github.com/apache/nifi/pull/6341#discussion_r971146423


##########
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/groups/FlowSynchronizationCallback.java:
##########
@@ -0,0 +1,56 @@
+/*
+ * 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.ScheduledState;
+import org.apache.nifi.controller.service.ControllerServiceNode;
+
+public interface FlowSynchronizationCallback {
+    void onScheduledStateChange(ProcessorNode processor);
+
+    void onScheduledStateChange(Port port);
+
+    void onScheduledStateChange(ControllerServiceNode controllerService);
+
+    void onScheduledStateChange(ReportingTaskNode reportingTask);

Review Comment:
   Yes, good catch!



-- 
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: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nifi] gresockj commented on a diff in pull request #6341: NIFI-10401: Adding FlowSynchronizationCallback to synchronizer

Posted by GitBox <gi...@apache.org>.
gresockj commented on code in PR #6341:
URL: https://github.com/apache/nifi/pull/6341#discussion_r971146837


##########
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:
   Good call -- I'll go with `ScheduleStateChangeListener`



-- 
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: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org