You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by se...@apache.org on 2020/02/14 17:31:14 UTC
[flink-statefun] 09/11: [FLINK-15956] Use maxRequestDuration of
HttpFunctionSpec
This is an automated email from the ASF dual-hosted git repository.
sewen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink-statefun.git
commit 9505ceed6d9b0a1b3b06f3ee4a012a83ff663808
Author: Igal Shilman <ig...@gmail.com>
AuthorDate: Thu Feb 13 15:42:40 2020 +0100
[FLINK-15956] Use maxRequestDuration of HttpFunctionSpec
---
.../flink/statefun/flink/core/httpfn/HttpFunctionProvider.java | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/statefun-flink/statefun-flink-core/src/main/java/org/apache/flink/statefun/flink/core/httpfn/HttpFunctionProvider.java b/statefun-flink/statefun-flink-core/src/main/java/org/apache/flink/statefun/flink/core/httpfn/HttpFunctionProvider.java
index 3d94109..43da918 100644
--- a/statefun-flink/statefun-flink-core/src/main/java/org/apache/flink/statefun/flink/core/httpfn/HttpFunctionProvider.java
+++ b/statefun-flink/statefun-flink-core/src/main/java/org/apache/flink/statefun/flink/core/httpfn/HttpFunctionProvider.java
@@ -25,11 +25,11 @@ import org.apache.flink.statefun.sdk.StatefulFunctionProvider;
public class HttpFunctionProvider implements StatefulFunctionProvider {
private final Map<FunctionType, HttpFunctionSpec> supportedTypes;
- private final OkHttpClient client;
+ private final OkHttpClient sharedClient;
public HttpFunctionProvider(Map<FunctionType, HttpFunctionSpec> supportedTypes) {
this.supportedTypes = supportedTypes;
- this.client = OkHttpUtils.newClient();
+ this.sharedClient = OkHttpUtils.newClient();
}
@Override
@@ -38,6 +38,10 @@ public class HttpFunctionProvider implements StatefulFunctionProvider {
if (spec == null) {
throw new IllegalArgumentException("Unsupported type " + type);
}
- return new HttpFunction(spec, client);
+ // specific client reuses the same the connection pool and thread pool
+ // as the sharedClient.
+ OkHttpClient specificClient =
+ sharedClient.newBuilder().callTimeout(spec.maxRequestDuration()).build();
+ return new HttpFunction(spec, specificClient);
}
}