File tree Expand file tree Collapse file tree
java/org/togetherjava/jshellapi Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -11,7 +11,9 @@ public record Config(
1111 long maxAliveSessions ,
1212 int dockerMaxRamMegaBytes ,
1313 double dockerCPUsUsage ,
14- long schedulerSessionKillScanRateSeconds ) {
14+ long schedulerSessionKillScanRateSeconds ,
15+ long dockerResponseTimeout ,
16+ long dockerConnectionTimeout ) {
1517 public Config {
1618 if (regularSessionTimeoutSeconds <= 0 ) throw new RuntimeException ("Invalid value " + regularSessionTimeoutSeconds );
1719 if (oneTimeSessionTimeoutSeconds <= 0 ) throw new RuntimeException ("Invalid value " + oneTimeSessionTimeoutSeconds );
@@ -21,5 +23,7 @@ public record Config(
2123 if (dockerMaxRamMegaBytes <= 0 ) throw new RuntimeException ("Invalid value " + dockerMaxRamMegaBytes );
2224 if (dockerCPUsUsage <= 0 ) throw new RuntimeException ("Invalid value " + dockerCPUsUsage );
2325 if (schedulerSessionKillScanRateSeconds <= 0 ) throw new RuntimeException ("Invalid value " + schedulerSessionKillScanRateSeconds );
26+ if (dockerResponseTimeout <= 0 ) throw new RuntimeException ("Invalid value " + dockerResponseTimeout );
27+ if (dockerConnectionTimeout <= 0 ) throw new RuntimeException ("Invalid value " + dockerConnectionTimeout );
2428 }
2529}
Original file line number Diff line number Diff line change 1010import org .slf4j .Logger ;
1111import org .slf4j .LoggerFactory ;
1212import org .springframework .beans .factory .DisposableBean ;
13+ import org .springframework .beans .factory .annotation .Autowired ;
1314import org .springframework .stereotype .Service ;
15+ import org .togetherjava .jshellapi .Config ;
1416
1517import java .io .*;
1618import java .nio .charset .StandardCharsets ;
2426@ Service
2527public class DockerService implements DisposableBean {
2628 private static final Logger LOGGER = LoggerFactory .getLogger (DockerService .class );
27-
2829 private static final String WORKER_LABEL = "jshell-api-worker" ;
2930 private static final UUID WORKER_UNIQUE_ID = UUID .randomUUID ();
3031
3132 private final DockerClient client ;
3233
33- public DockerService () {
34+ public DockerService (Config config ) {
3435 DefaultDockerClientConfig clientConfig = DefaultDockerClientConfig .createDefaultConfigBuilder ().build ();
3536 ApacheDockerHttpClient httpClient = new ApacheDockerHttpClient .Builder ()
3637 .dockerHost (clientConfig .getDockerHost ())
3738 .sslConfig (clientConfig .getSSLConfig ())
38- .responseTimeout (Duration .ofSeconds (60 ))
39- .connectionTimeout (Duration .ofSeconds (60 ))
39+ .responseTimeout (Duration .ofSeconds (config . dockerResponseTimeout () ))
40+ .connectionTimeout (Duration .ofSeconds (config . dockerConnectionTimeout () ))
4041 .build ();
4142 this .client = DockerClientImpl .getInstance (clientConfig , httpClient );
4243
Original file line number Diff line number Diff line change @@ -11,4 +11,8 @@ jshellapi.dockerMaxRamMegaBytes=100
1111jshellapi.dockerCPUsUsage =0.5
1212
1313# Internal config
14- jshellapi.schedulerSessionKillScanRateSeconds =60
14+ jshellapi.schedulerSessionKillScanRateSeconds =60
15+
16+ # Docker service config
17+ jshellapi.dockerResponseTimeout =60
18+ jshellapi.dockerConnectionTimeout =60
You can’t perform that action at this time.
0 commit comments