exceptionfactory commented on code in PR #11100:
URL: https://github.com/apache/nifi/pull/11100#discussion_r3029837995
##########
nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/components/connector/secrets/ParameterProviderSecretsManager.java:
##########
@@ -33,16 +35,30 @@
import java.util.Map;
import java.util.Optional;
import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.TimeUnit;
import java.util.function.Function;
import java.util.stream.Collectors;
public class ParameterProviderSecretsManager implements SecretsManager {
private static final Logger logger =
LoggerFactory.getLogger(ParameterProviderSecretsManager.class);
+ private static final String DEFAULT_CACHE_TTL = "5 mins";
+
private FlowManager flowManager;
+ private long cacheTtlNanos;
Review Comment:
Recommend using `java.time.Duration` for clarity instead of using the
`Nanos` naming.
##########
nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/components/connector/secrets/ParameterProviderSecretsManager.java:
##########
@@ -33,16 +35,30 @@
import java.util.Map;
import java.util.Optional;
import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.TimeUnit;
import java.util.function.Function;
import java.util.stream.Collectors;
public class ParameterProviderSecretsManager implements SecretsManager {
private static final Logger logger =
LoggerFactory.getLogger(ParameterProviderSecretsManager.class);
+ private static final String DEFAULT_CACHE_TTL = "5 mins";
+
private FlowManager flowManager;
+ private long cacheTtlNanos;
+ private final Map<String, CachedSecret> secretCache = new
ConcurrentHashMap<>();
+
+ private record CachedSecret(Secret secret, long timestampNanos) {
+ }
@Override
public void initialize(final SecretsManagerInitializationContext
initializationContext) {
this.flowManager = initializationContext.getFlowManager();
+
+ final String cacheTtlValue =
initializationContext.getProperty(NiFiProperties.SECRETS_MANAGER_CACHE_TTL);
+ final String effectiveTtl = cacheTtlValue != null ? cacheTtlValue :
DEFAULT_CACHE_TTL;
+ this.cacheTtlNanos = FormatUtils.getTimeDuration(effectiveTtl.trim(),
TimeUnit.NANOSECONDS);
+ logger.info("Secret cache TTL configured to {}", effectiveTtl);
Review Comment:
Logging the value seems unnecessary in general, and uncommon for other
configuration properties, is there a reason for logging it here?
--
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]