markap14 commented on code in PR #11231:
URL: https://github.com/apache/nifi/pull/11231#discussion_r3222284167
##########
nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/components/connector/StandardConnectorRepository.java:
##########
@@ -459,19 +459,21 @@ private void purgeConnectorAndAwait(final ConnectorNode
connector) {
}
@Override
- public ConnectorNode getConnector(final String identifier) {
+ public ConnectorNode getConnector(final String identifier, final
ConnectorSyncMode syncMode) {
final ConnectorNode connector = connectors.get(identifier);
- if (connector != null) {
+ if (connector != null && syncMode ==
ConnectorSyncMode.SYNC_WITH_PROVIDER) {
syncFromProvider(connector);
}
return connector;
}
@Override
- public List<ConnectorNode> getConnectors() {
+ public List<ConnectorNode> getConnectors(final ConnectorSyncMode syncMode)
{
final List<ConnectorNode> connectorList =
List.copyOf(connectors.values());
- for (final ConnectorNode connector : connectorList) {
- syncFromProvider(connector);
+ if (syncMode == ConnectorSyncMode.SYNC_WITH_PROVIDER) {
Review Comment:
Good call — added `Objects.requireNonNull(syncMode, "syncMode is required")`
to both `getConnector(String, ConnectorSyncMode)` and
`getConnectors(ConnectorSyncMode)` so a missing mode now fails fast instead of
silently behaving as `LOCAL_ONLY`.
##########
nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/FlowController.java:
##########
@@ -2414,6 +2416,8 @@ public void startConnector(final ConnectorNode
connectorNode) {
writeLock.lock();
try {
if (initialized.get()) {
+ // The connector is about to begin running; ensure it starts
with the latest provider configuration.
+
connectorRepository.getConnector(connectorNode.getIdentifier(),
ConnectorSyncMode.SYNC_WITH_PROVIDER);
connectorRepository.startConnector(connectorNode);
Review Comment:
Confirmed. `startConnector(ConnectorNode)` only relies on the active flow
context, which the provider doesn't manage, so the pre-start `getConnector(...,
SYNC_WITH_PROVIDER)` was pure overhead. Removed it; now this path just calls
`connectorRepository.startConnector(connectorNode)` directly when the
controller is initialized.
--
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]