kevdoran commented on code in PR #11079:
URL: https://github.com/apache/nifi/pull/11079#discussion_r3025752702


##########
nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/components/connector/StandardConnectorRepository.java:
##########
@@ -91,6 +107,288 @@ public void restoreConnector(final ConnectorNode 
connector) {
         logger.debug("Successfully restored {}", connector);
     }
 
+    @Override
+    public ConnectorSyncResult syncConnector(final VersionedConnector 
versionedConnector) {
+        final String connectorId = versionedConnector.getInstanceIdentifier();
+        final ScheduledState proposedScheduledState = 
versionedConnector.getScheduledState();
+        logger.debug("syncConnector called for connector [{}]", connectorId);
+
+        // Consult the provider for external state checks and working config
+        final ConnectorSyncDirective directive;
+        if (configurationProvider != null) {
+            try {
+                directive = configurationProvider.verifySyncable(connectorId, 
proposedScheduledState);
+            } catch (final Exception e) {
+                logger.error("Configuration provider threw exception during 
verifySyncable for connector [{}]: {}", connectorId, e.getMessage(), e);
+                final ConnectorNode existingNode = 
ensureConnectorNodeExists(versionedConnector);
+                existingNode.markInvalid("Flow Synchronization Failure",
+                        "Configuration provider error during synchronization: 
" + e.getMessage());
+                return ConnectorSyncResult.FAILED;
+            }
+        } else {
+            directive = ConnectorSyncDirective.allow();
+        }
+
+        logger.debug("Connector [{}] sync directive: {}", connectorId, 
directive);
+
+        // Handle REMOVE: connector should not exist on this node
+        if (directive.getAction() == ConnectorSyncDirective.Action.REMOVE) {
+            final ConnectorNode existingNode = connectors.remove(connectorId);

Review Comment:
   Yeah I think I addressed most of this in my last commit, but let me check 
that we are also purging data.



##########
nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/components/connector/ConnectorSyncResult.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.components.connector;
+
+/**
+ * Result of a connector synchronization attempt during flow inheritance.
+ */
+public enum ConnectorSyncResult {
+
+    /**
+     * Configuration was applied and the connector's run state was updated
+     * to match the proposed ScheduledState.
+     */
+    SYNCED,
+
+    /**
+     * Configuration was already up to date; the connector's run state was
+     * updated if it differed from the proposed ScheduledState.
+     */
+    SYNCED_NO_CHANGES,

Review Comment:
   Yep



-- 
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]

Reply via email to