|
@@ -12,6 +12,7 @@ import org.elasticsearch.common.settings.Setting;
|
|
|
import org.elasticsearch.common.settings.Settings;
|
|
|
import org.elasticsearch.common.unit.ByteSizeUnit;
|
|
|
import org.elasticsearch.common.unit.ByteSizeValue;
|
|
|
+import org.elasticsearch.core.TimeValue;
|
|
|
|
|
|
import java.util.List;
|
|
|
import java.util.Objects;
|
|
@@ -27,12 +28,21 @@ public class HttpSettings {
|
|
|
Setting.Property.Dynamic
|
|
|
);
|
|
|
|
|
|
+ // The time we wait for a connection to establish
|
|
|
+ public static final Setting<TimeValue> CONNECTION_TIMEOUT = Setting.timeSetting(
|
|
|
+ "xpack.inference.http.connect_timeout",
|
|
|
+ TimeValue.timeValueSeconds(5),
|
|
|
+ Setting.Property.NodeScope
|
|
|
+ );
|
|
|
+
|
|
|
private volatile ByteSizeValue maxResponseSize;
|
|
|
+ private final int connectionTimeout;
|
|
|
|
|
|
public HttpSettings(Settings settings, ClusterService clusterService) {
|
|
|
Objects.requireNonNull(clusterService);
|
|
|
Objects.requireNonNull(settings);
|
|
|
maxResponseSize = MAX_HTTP_RESPONSE_SIZE.get(settings);
|
|
|
+ connectionTimeout = Math.toIntExact(CONNECTION_TIMEOUT.get(settings).getMillis());
|
|
|
|
|
|
clusterService.getClusterSettings().addSettingsUpdateConsumer(MAX_HTTP_RESPONSE_SIZE, this::setMaxResponseSize);
|
|
|
}
|
|
@@ -41,11 +51,15 @@ public class HttpSettings {
|
|
|
return maxResponseSize;
|
|
|
}
|
|
|
|
|
|
+ public int connectionTimeout() {
|
|
|
+ return connectionTimeout;
|
|
|
+ }
|
|
|
+
|
|
|
private void setMaxResponseSize(ByteSizeValue maxResponseSize) {
|
|
|
this.maxResponseSize = maxResponseSize;
|
|
|
}
|
|
|
|
|
|
public static List<Setting<?>> getSettingsDefinitions() {
|
|
|
- return List.of(MAX_HTTP_RESPONSE_SIZE);
|
|
|
+ return List.of(MAX_HTTP_RESPONSE_SIZE, CONNECTION_TIMEOUT);
|
|
|
}
|
|
|
}
|