Skip to content

Commit

Permalink
NIFI-13570 Use NiFiProperties isHTTPSConfigured to determine if NAR M…
Browse files Browse the repository at this point in the history
…anager should use https

This closes #9100

Signed-off-by: Joseph Witt <joewitt@apache.org>
  • Loading branch information
bbende authored and joewitt committed Jul 22, 2024
1 parent bacc30b commit 79ac0c2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ public NarManager narManager(@Autowired final NarPersistenceProvider narPersiste
narComponentManager(),
narLoader(),
webClientService(),
sslContext
properties
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@

package org.apache.nifi.nar;

import org.apache.commons.lang3.exception.ExceptionUtils;
import org.apache.nifi.bundle.Bundle;
import org.apache.nifi.bundle.BundleCoordinate;
import org.apache.nifi.cluster.coordination.ClusterCoordinator;
import org.apache.nifi.cluster.protocol.NodeIdentifier;
import org.apache.nifi.controller.FlowController;
import org.apache.nifi.controller.service.ControllerServiceProvider;
import org.apache.nifi.util.NiFiProperties;
import org.apache.nifi.web.ResourceNotFoundException;
import org.apache.nifi.web.api.dto.NarSummaryDTO;
import org.apache.nifi.web.api.entity.NarSummariesEntity;
Expand All @@ -32,7 +34,6 @@
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.InitializingBean;

import javax.net.ssl.SSLContext;
import java.io.Closeable;
import java.io.File;
import java.io.FileNotFoundException;
Expand Down Expand Up @@ -71,7 +72,7 @@ public class StandardNarManager implements NarManager, InitializingBean, Closeab
private final NarComponentManager narComponentManager;
private final NarLoader narLoader;
private final WebClientService webClientService;
private final SSLContext sslContext;
private final NiFiProperties properties;

private final Map<String, NarNode> narNodesById = new ConcurrentHashMap<>();
private final Map<String, Future<?>> installFuturesById = new ConcurrentHashMap<>();
Expand All @@ -84,15 +85,15 @@ public StandardNarManager(final FlowController flowController,
final NarComponentManager narComponentManager,
final NarLoader narLoader,
final WebClientService webClientService,
final SSLContext sslContext) {
final NiFiProperties properties) {
this.clusterCoordinator = clusterCoordinator;
this.extensionManager = flowController.getExtensionManager();
this.controllerServiceProvider = flowController.getControllerServiceProvider();
this.persistenceProvider = narPersistenceProvider;
this.narComponentManager = narComponentManager;
this.narLoader = narLoader;
this.webClientService = webClientService;
this.sslContext = sslContext;
this.properties = properties;
this.installExecutorService = Executors.newSingleThreadExecutor();
this.deleteExecutorService = Executors.newSingleThreadExecutor();
}
Expand Down Expand Up @@ -245,7 +246,7 @@ public synchronized void syncWithClusterCoordinator() {
logger.info("Synchronizing NARs with cluster coordinator");
final String coordinatorAddress = coordinatorNodeId.getApiAddress();
final int coordinatorPort = coordinatorNodeId.getApiPort();
final NarRestApiClient narRestApiClient = new NarRestApiClient(webClientService, coordinatorAddress, coordinatorPort, sslContext != null);
final NarRestApiClient narRestApiClient = new NarRestApiClient(webClientService, coordinatorAddress, coordinatorPort, properties.isHTTPSConfigured());

final int localNarCountBeforeSync = narNodesById.size();
try {
Expand Down Expand Up @@ -315,7 +316,8 @@ private NarSummariesEntity listNarSummaries(final NarRestApiClient narRestApiCli
try {
return narRestApiClient.listNarSummaries();
} catch (final NarRestApiRetryableException e) {
logger.warn("{}: retrying", e.getMessage());
final Throwable rootCause = ExceptionUtils.getRootCause(e);
logger.warn("{}, root cause [{}]: retrying", e.getMessage(), rootCause.getMessage());
return null;
}
}
Expand Down

0 comments on commit 79ac0c2

Please sign in to comment.