本文整理汇总了Java中com.spotify.docker.client.messages.ContainerInfo.state方法的典型用法代码示例。如果您正苦于以下问题:Java ContainerInfo.state方法的具体用法?Java ContainerInfo.state怎么用?Java ContainerInfo.state使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.spotify.docker.client.messages.ContainerInfo
的用法示例。
在下文中一共展示了ContainerInfo.state方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: refresh
import com.spotify.docker.client.messages.ContainerInfo; //导入方法依赖的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);
}
}