Skip to content

Commit

Permalink
chnage to configurable pool size
Browse files Browse the repository at this point in the history
  • Loading branch information
codingPF committed Nov 8, 2023
1 parent 90c3862 commit 3d9c03f
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/main/java/de/mediathekview/mlib/tool/FileSizeDeterminer.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package de.mediathekview.mlib.tool;

import okhttp3.ConnectionPool;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
Expand All @@ -8,6 +9,7 @@
import org.jetbrains.annotations.NotNull;

import java.io.IOException;
import java.util.concurrent.TimeUnit;

import static jakarta.ws.rs.core.HttpHeaders.CONTENT_LENGTH;
import static jakarta.ws.rs.core.HttpHeaders.CONTENT_TYPE;
Expand All @@ -19,17 +21,18 @@ public class FileSizeDeterminer {


public FileSizeDeterminer() {
this(30L,30L);
this(30L, 30L, 10);
}

public FileSizeDeterminer(
final long connectTimeoutInSeconds, final long readTimeoutInSeconds) {
client =
new OkHttpClientBuilder()
.withConnectTimeout(connectTimeoutInSeconds)
.withReadTimeout(readTimeoutInSeconds)
.build();
final long connectTimeoutInSeconds, final long readTimeoutInSeconds, final int threadPoolSize) {
OkHttpClient.Builder b = new OkHttpClient.Builder();
b.readTimeout(readTimeoutInSeconds,TimeUnit.SECONDS);
b.connectTimeout(connectTimeoutInSeconds,TimeUnit.SECONDS);
b.connectionPool(new ConnectionPool(threadPoolSize, 5L, TimeUnit.MINUTES));
client = b.build();
}

public RespoonseInfo getRequestInfo(final String url) {
return getRequestInfo(url, RequestType.HEAD);
}
Expand Down

0 comments on commit 3d9c03f

Please sign in to comment.