This is an automated email from the ASF dual-hosted git repository.
mthomsen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nifi.git
The following commit(s) were added to refs/heads/master by this push:
new ad63678 NIFI-6928 - add connect/read timeout to RestLookupService
ad63678 is described below
commit ad636789f0213fb13f108277ba2bca6b15889ecd
Author: Pierre Villard <[email protected]>
AuthorDate: Fri Dec 6 06:45:32 2019 +0100
NIFI-6928 - add connect/read timeout to RestLookupService
This closes #3920
Signed-off-by: Mike Thomsen <[email protected]>
---
.../org/apache/nifi/lookup/RestLookupService.java | 29 +++++++++++++++++++++-
1 file changed, 28 insertions(+), 1 deletion(-)
diff --git
a/nifi-nar-bundles/nifi-standard-services/nifi-lookup-services-bundle/nifi-lookup-services/src/main/java/org/apache/nifi/lookup/RestLookupService.java
b/nifi-nar-bundles/nifi-standard-services/nifi-lookup-services-bundle/nifi-lookup-services/src/main/java/org/apache/nifi/lookup/RestLookupService.java
index ed8fc50..6ecc95d 100644
---
a/nifi-nar-bundles/nifi-standard-services/nifi-lookup-services-bundle/nifi-lookup-services/src/main/java/org/apache/nifi/lookup/RestLookupService.java
+++
b/nifi-nar-bundles/nifi-standard-services/nifi-lookup-services-bundle/nifi-lookup-services/src/main/java/org/apache/nifi/lookup/RestLookupService.java
@@ -71,6 +71,7 @@ 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.regex.Pattern;
import java.util.stream.Collectors;
@@ -120,6 +121,7 @@ public class RestLookupService extends
AbstractControllerService implements Reco
.required(false)
.identifiesControllerService(SSLContextService.class)
.build();
+
public static final PropertyDescriptor PROP_BASIC_AUTH_USERNAME = new
PropertyDescriptor.Builder()
.name("rest-lookup-basic-auth-username")
.displayName("Basic Authentication Username")
@@ -138,6 +140,7 @@ public class RestLookupService extends
AbstractControllerService implements Reco
.expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY)
.addValidator(StandardValidators.createRegexMatchingValidator(Pattern.compile("^[\\x20-\\x7e\\x80-\\xff]+$")))
.build();
+
public static final PropertyDescriptor PROP_DIGEST_AUTH = new
PropertyDescriptor.Builder()
.name("rest-lookup-digest-auth")
.displayName("Use Digest Authentication")
@@ -148,6 +151,24 @@ public class RestLookupService extends
AbstractControllerService implements Reco
.allowableValues("true", "false")
.build();
+ public static final PropertyDescriptor PROP_CONNECT_TIMEOUT = new
PropertyDescriptor.Builder()
+ .name("rest-lookup-connection-timeout")
+ .displayName("Connection Timeout")
+ .description("Max wait time for connection to remote service.")
+ .required(true)
+ .defaultValue("5 secs")
+ .addValidator(StandardValidators.TIME_PERIOD_VALIDATOR)
+ .build();
+
+ public static final PropertyDescriptor PROP_READ_TIMEOUT = new
PropertyDescriptor.Builder()
+ .name("rest-lookup-read-timeout")
+ .displayName("Read Timeout")
+ .description("Max wait time for response from remote service.")
+ .required(true)
+ .defaultValue("15 secs")
+ .addValidator(StandardValidators.TIME_PERIOD_VALIDATOR)
+ .build();
+
private static final ProxySpec[] PROXY_SPECS = {ProxySpec.HTTP_AUTH,
ProxySpec.SOCKS};
public static final PropertyDescriptor PROXY_CONFIGURATION_SERVICE
= ProxyConfiguration.createProxyConfigPropertyDescriptor(true,
PROXY_SPECS);
@@ -170,7 +191,9 @@ public class RestLookupService extends
AbstractControllerService implements Reco
PROXY_CONFIGURATION_SERVICE,
PROP_BASIC_AUTH_USERNAME,
PROP_BASIC_AUTH_PASSWORD,
- PROP_DIGEST_AUTH
+ PROP_DIGEST_AUTH,
+ PROP_CONNECT_TIMEOUT,
+ PROP_READ_TIMEOUT
));
KEYS = Collections.emptySet();
}
@@ -199,6 +222,10 @@ public class RestLookupService extends
AbstractControllerService implements Reco
setAuthenticator(builder, context);
+ // Set timeouts
+
builder.connectTimeout((context.getProperty(PROP_CONNECT_TIMEOUT).asTimePeriod(TimeUnit.MILLISECONDS).intValue()),
TimeUnit.MILLISECONDS);
+
builder.readTimeout(context.getProperty(PROP_READ_TIMEOUT).asTimePeriod(TimeUnit.MILLISECONDS).intValue(),
TimeUnit.MILLISECONDS);
+
if (proxyConfigurationService != null) {
setProxy(builder);
}