mcgilman commented on code in PR #10748:
URL: https://github.com/apache/nifi/pull/10748#discussion_r2682404774
##########
nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/components/connector/StandardConnectorNode.java:
##########
@@ -866,6 +867,191 @@ public void discardWorkingConfiguration() {
recreateWorkingFlowContext();
}
+ @Override
+ public List<ConnectorAction> getAvailableActions() {
+ final List<ConnectorAction> actions = new ArrayList<>();
+ final ConnectorState currentState = getCurrentState();
+ final boolean dataQueued =
activeFlowContext.getManagedProcessGroup().isDataQueued();
+ final boolean stopped = isStopped();
+
+ actions.add(createStartAction(currentState, stopped));
+ actions.add(createStopAction(currentState));
+ actions.add(createConfigureAction());
+ actions.add(createDiscardWorkingConfigAction());
+ actions.add(createPurgeFlowFilesAction(stopped, dataQueued));
+ actions.add(createDrainFlowFilesAction(stopped, dataQueued));
+ actions.add(createApplyUpdatesAction(currentState));
+ actions.add(createDeleteAction(stopped, dataQueued));
+
+ return actions;
+ }
+
+ private boolean isStopped() {
+ final ConnectorState currentState = getCurrentState();
+ if (currentState == ConnectorState.STOPPED) {
+ return true;
+ }
+ if (currentState == ConnectorState.UPDATED || currentState ==
ConnectorState.UPDATE_FAILED) {
+ return
!isActiveThread(getActiveFlowContext().getManagedProcessGroup());
+ }
+ return false;
+ }
+
+ private boolean isActiveThread(final ProcessGroup processGroup) {
+ for (final ProcessorNode processor : processGroup.getProcessors()) {
+ if (processor.getActiveThreadCount() > 0) {
+ return true;
+ }
+ }
+
+ for (final ProcessGroup childGroup : processGroup.getProcessGroups()) {
+ if (isActiveThread(childGroup)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ private ConnectorAction createStartAction(final ConnectorState
currentState, final boolean stopped) {
Review Comment:
`currentState` is unused and could be removed.
##########
nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/components/connector/StandardConnectorNode.java:
##########
@@ -866,6 +867,191 @@ public void discardWorkingConfiguration() {
recreateWorkingFlowContext();
}
+ @Override
+ public List<ConnectorAction> getAvailableActions() {
+ final List<ConnectorAction> actions = new ArrayList<>();
+ final ConnectorState currentState = getCurrentState();
+ final boolean dataQueued =
activeFlowContext.getManagedProcessGroup().isDataQueued();
+ final boolean stopped = isStopped();
+
+ actions.add(createStartAction(currentState, stopped));
+ actions.add(createStopAction(currentState));
+ actions.add(createConfigureAction());
+ actions.add(createDiscardWorkingConfigAction());
+ actions.add(createPurgeFlowFilesAction(stopped, dataQueued));
+ actions.add(createDrainFlowFilesAction(stopped, dataQueued));
+ actions.add(createApplyUpdatesAction(currentState));
+ actions.add(createDeleteAction(stopped, dataQueued));
+
+ return actions;
+ }
+
+ private boolean isStopped() {
+ final ConnectorState currentState = getCurrentState();
+ if (currentState == ConnectorState.STOPPED) {
+ return true;
+ }
+ if (currentState == ConnectorState.UPDATED || currentState ==
ConnectorState.UPDATE_FAILED) {
+ return
!isActiveThread(getActiveFlowContext().getManagedProcessGroup());
+ }
+ return false;
+ }
+
+ private boolean isActiveThread(final ProcessGroup processGroup) {
+ for (final ProcessorNode processor : processGroup.getProcessors()) {
+ if (processor.getActiveThreadCount() > 0) {
+ return true;
+ }
+ }
+
+ for (final ProcessGroup childGroup : processGroup.getProcessGroups()) {
+ if (isActiveThread(childGroup)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
Review Comment:
There already is a `hasActiveThread` method with the same implementation.
--
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]