Skip to content

Commit 94ffa88

Browse files
Fix conflicts and successfully rebase with upstream develop.
1 parent 7d21142 commit 94ffa88

File tree

1 file changed

+24
-24
lines changed

1 file changed

+24
-24
lines changed

JShellAPI/src/main/java/org/togetherjava/jshellapi/service/DockerService.java

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ public class DockerService implements DisposableBean {
2727
private static final Logger LOGGER = LoggerFactory.getLogger(DockerService.class);
2828
private static final String WORKER_LABEL = "jshell-api-worker";
2929
private static final UUID WORKER_UNIQUE_ID = UUID.randomUUID();
30-
private static final String IMAGE_NAME = "togetherjava.org:5001/togetherjava/jshellwrapper";
31-
private static final String IMAGE_TAG = "master";
3230

3331
private final DockerClient client;
3432
private final Config config;
@@ -39,7 +37,8 @@ public class DockerService implements DisposableBean {
3937

4038
private final String jshellWrapperBaseImageName;
4139

42-
public DockerService(Config config, StartupScriptsService startupScriptsService) throws InterruptedException, IOException {
40+
public DockerService(Config config, StartupScriptsService startupScriptsService)
41+
throws InterruptedException, IOException {
4342
this.startupScriptsService = startupScriptsService;
4443
DefaultDockerClientConfig clientConfig =
4544
DefaultDockerClientConfig.createDefaultConfigBuilder().build();
@@ -83,11 +82,11 @@ private void cleanupLeftovers(UUID currentId) {
8382
*/
8483
private boolean isImagePresentLocally() {
8584
return client.listImagesCmd()
86-
.withFilter("reference", List.of(jshellWrapperBaseImageName))
87-
.exec()
88-
.stream()
89-
.flatMap(it -> Arrays.stream(it.getRepoTags()))
90-
.anyMatch(it -> it.endsWith(Config.JSHELL_WRAPPER_IMAGE_NAME_TAG));
85+
.withFilter("reference", List.of(jshellWrapperBaseImageName))
86+
.exec()
87+
.stream()
88+
.flatMap(it -> Arrays.stream(it.getRepoTags()))
89+
.anyMatch(it -> it.endsWith(Config.JSHELL_WRAPPER_IMAGE_NAME_TAG));
9190
}
9291

9392
/**
@@ -96,9 +95,9 @@ private boolean isImagePresentLocally() {
9695
private void pullImage() throws InterruptedException {
9796
if (!isImagePresentLocally()) {
9897
client.pullImageCmd(jshellWrapperBaseImageName)
99-
.withTag(IMAGE_TAG)
100-
.exec(new PullImageResultCallback())
101-
.awaitCompletion(5, TimeUnit.MINUTES);
98+
.withTag("master")
99+
.exec(new PullImageResultCallback())
100+
.awaitCompletion(5, TimeUnit.MINUTES);
102101
}
103102
}
104103

@@ -120,18 +119,19 @@ public String createContainer(String name) {
120119
.withCpuCount((long) Math.ceil(config.dockerCPUsUsage()))
121120
.withCpusetCpus(config.dockerCPUSetCPUs());
122121

123-
return client.createContainerCmd(jshellWrapperBaseImageName + Config.JSHELL_WRAPPER_IMAGE_NAME_TAG)
124-
.withHostConfig(hostConfig)
125-
.withStdinOpen(true)
126-
.withAttachStdin(true)
127-
.withAttachStderr(true)
128-
.withAttachStdout(true)
129-
.withEnv("evalTimeoutSeconds=" + config.evalTimeoutSeconds(),
130-
"sysOutCharLimit=" + config.sysOutCharLimit())
131-
.withLabels(Map.of(WORKER_LABEL, WORKER_UNIQUE_ID.toString()))
132-
.withName(name)
133-
.exec()
134-
.getId();
122+
return client
123+
.createContainerCmd(jshellWrapperBaseImageName + Config.JSHELL_WRAPPER_IMAGE_NAME_TAG)
124+
.withHostConfig(hostConfig)
125+
.withStdinOpen(true)
126+
.withAttachStdin(true)
127+
.withAttachStderr(true)
128+
.withAttachStdout(true)
129+
.withEnv("evalTimeoutSeconds=" + config.evalTimeoutSeconds(),
130+
"sysOutCharLimit=" + config.sysOutCharLimit())
131+
.withLabels(Map.of(WORKER_LABEL, WORKER_UNIQUE_ID.toString()))
132+
.withName(name)
133+
.exec()
134+
.getId();
135135
}
136136

137137
/**
@@ -143,7 +143,7 @@ public String createContainer(String name) {
143143
*/
144144
public ContainerState initializeContainer(String name, StartupScriptId startupScriptId)
145145
throws IOException {
146-
if (cachedContainers.isEmpty() || !cachedContainers.containsKey(startupScriptId)) {
146+
if (startupScriptId == null || cachedContainers.isEmpty() || !cachedContainers.containsKey(startupScriptId)) {
147147
String containerId = createContainer(name);
148148
return setupContainerWithScript(containerId, true, startupScriptId);
149149
}

0 commit comments

Comments
 (0)