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