本文整理汇总了Java中com.spotify.docker.client.messages.ContainerState.running方法的典型用法代码示例。如果您正苦于以下问题:Java ContainerState.running方法的具体用法?Java ContainerState.running怎么用?Java ContainerState.running使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.spotify.docker.client.messages.ContainerState
的用法示例。
在下文中一共展示了ContainerState.running方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: run
import com.spotify.docker.client.messages.ContainerState; //导入方法依赖的package包/类
public static ExecPair run(Language language, Submission submission)
throws DockerException, InterruptedException, RunErrorException, IOException {
String containerId = RunContainerPool.instance().getContainerId(language);
ExecPair state = instance().exec(containerId, language.getRunCmd().replace("_file", String.valueOf(submission.getSubmitTime())));
Thread.sleep(_TIME_LIMIT_MILLISECONDS);
ExecInfoSimple info = instance().inspectExec(state.getExecId());
if (info.isRunning())
throw new RunErrorException("<out of time>");
ContainerState containerState = instance().inspectContainer(containerId);
if (containerState == null)
throw new RuntimeException();
Boolean oomKilled = containerState.oomKilled();
if (oomKilled != null && oomKilled)
throw new RunErrorException("<out of resources>");
if (!containerState.running())
throw new RunErrorException("<unknown error>");
return state;
}
示例2: getStatus
import com.spotify.docker.client.messages.ContainerState; //导入方法依赖的package包/类
@Override
public InstanceStatus getStatus(String instanceId) {
ContainerState state;
try {
state = dockerClient.inspectContainer(instanceId).state();
} catch (Exception e) {
LOG.error("Cannot get state of container " + instanceId, e);
return InstanceStatus.UNKNOWN;
}
if (state.running())
return InstanceStatus.RUNNING;
if (state.restarting())
return InstanceStatus.RESTARTING;
if (state.oomKilled() || StringUtil.isNotEmpty(state.error()))
return InstanceStatus.ERROR;
if (state.finishedAt() != null)
return InstanceStatus.STOPPED;
LOG.warn("Could not map state '" + state.toString() + "' to InstanceStatus");
return InstanceStatus.UNKNOWN;
}
示例3: after
import com.spotify.docker.client.messages.ContainerState; //导入方法依赖的package包/类
/**
* Stop and remove container.<br/>
* This is {@link ExternalResource#before()} made available as public - it may be helpful in scenarios
* when you want to use {@link DockerRule} and operate it manually.
*/
@Override
public final void after() {
log.debug("after {}", containerShortId);
try {
dockerLogs.close();
ContainerState state = dockerClient.inspectContainer(container.id()).state();
log.debug("{} state {}", containerShortId, state);
if (state.running()) {
if (builder.stopOptions().contains(StopOption.KILL)) {
dockerClient.killContainer(container.id());
log.info("{} killed", containerShortId);
} else {
dockerClient.stopContainer(container.id(), STOP_TIMEOUT);
log.info("{} stopped", containerShortId);
}
}
if (builder.stopOptions().contains(StopOption.REMOVE)) {
dockerClient.removeContainer(container.id(), DockerClient.RemoveContainerParam.removeVolumes());
log.info("{} deleted", containerShortId);
container = null;
}
} catch (DockerException | InterruptedException e) {
throw new IllegalStateException(e);
}
}
示例4: createState
import com.spotify.docker.client.messages.ContainerState; //导入方法依赖的package包/类
private static InstanceState createState(ContainerState state) {
if (state.running()) {
return InstanceState.LAUNCHED;
} else if (state.oomKilled() || (state.error() != null && !state.error().isEmpty())) {
return InstanceState.ERROR;
} else if (state.paused()) {
return InstanceState.PAUSED;
} else if (state.restarting()) {
return InstanceState.REBOOTING;
} else {
return InstanceState.SHUTOFF;
}
}
示例5: refresh
import com.spotify.docker.client.messages.ContainerState; //导入方法依赖的package包/类
@Override
public void refresh(RuntimeId runtimeId) throws RuntimeOperationException {
DockerRuntime runtime = (DockerRuntime) runtimeRegistry.getRuntimeById(runtimeId.getId());
try {
ContainerInfo containerInfo = docker.getDockerClient(runtime.getProviderId()).inspectContainer(runtime.getId());
ContainerState state = containerInfo.state();
String stateString = STOPPED;
if (state.running() && !state.paused()) {
stateString = RUNNING;
} else if (state.paused()) {
stateString = "Paused";
} else if (state.restarting()) {
stateString = "Restarting";
} else if (state.oomKilled()) {
stateString = "Killed";
}
DockerRuntime newRuntime = new DockerRuntime(runtime.getId(),
runtime.getName(),
runtime.getConfig(),
runtime.getProviderId(),
runtime.getEndpoint(),
runtime.getInfo(),
new DockerRuntimeState(stateString,
state.startedAt().toString()));
runtimeRegistry.registerRuntime(newRuntime);
} catch (DockerException | InterruptedException ex) {
LOG.error("Error Refreshing container: " + runtimeId.getId(),
ex);
throw new RuntimeOperationException("Error Refreshing container: " + runtimeId.getId(),
ex);
}
}