本文整理汇总了Java中com.spotify.docker.client.messages.ContainerState类的典型用法代码示例。如果您正苦于以下问题:Java ContainerState类的具体用法?Java ContainerState怎么用?Java ContainerState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ContainerState类属于com.spotify.docker.client.messages包,在下文中一共展示了ContainerState类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:ProgramLeague,项目名称:Avalon-Executive,代码行数:23,代码来源:Runner.java
示例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;
}
开发者ID:carlpett,项目名称:teamcity-container-cloud,代码行数:23,代码来源:DockerSocketContainerProvider.java
示例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);
}
}
开发者ID:tdomzal,项目名称:junit-docker-rule,代码行数:31,代码来源:DockerRule.java
示例4: createContainerInfo
import com.spotify.docker.client.messages.ContainerState; //导入依赖的package包/类
private ContainerInfo createContainerInfo(String isPublic, String owner) {
final Map<String, String> labels = new HashMap<>();
labels.put(MccyConstants.MCCY_LABEL, "true");
labels.put(MccyConstants.MCCY_LABEL_PUBLIC, isPublic);
labels.put(MccyConstants.MCCY_LABEL_OWNER, owner);
labels.put(MccyConstants.MCCY_LABEL_NAME, "container_name");
ContainerInfo containerInfo = new ContainerInfo();
setField(containerInfo, "config",
ContainerConfig.builder()
.labels(labels)
.build());
setField(containerInfo, "networkSettings",
NetworkSettings.builder()
.build());
setField(containerInfo, "state",
new ContainerState());
setField(containerInfo, "name", "container_name");
return containerInfo;
}
开发者ID:moorkop,项目名称:mccy-engine,代码行数:21,代码来源:ContainersServiceTest.java
示例5: exitCodeWhenStopped
import com.spotify.docker.client.messages.ContainerState; //导入依赖的package包/类
/**
* Docker returns its exit code if it is stopped.
*/
@Test
public void exitCodeWhenStopped() {
final ContainerState state = Mockito.mock(ContainerState.class);
Mockito.when(state.exitCode()).thenReturn(127);
final ContainerInfo info = Mockito.mock(ContainerInfo.class);
Mockito.when(info.state()).thenReturn(state);
final DockerHost host = Mockito.mock(DockerHost.class);
Mockito.when(host.inspect("id456")).thenReturn(info);
final Container docker = new Docker("id456", host);
MatcherAssert.assertThat(docker.exitCode(), Matchers.is(127));
}
开发者ID:amihaiemil,项目名称:comdor,代码行数:18,代码来源:DockerTestCase.java
示例6: startObserving
import com.spotify.docker.client.messages.ContainerState; //导入依赖的package包/类
@Override
public void startObserving() {
timer.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
String containerIds[] = null;
// copy the list of containers so that we don't have to care for
// access conflicts with other threads after this point
synchronized (monitoredContainers) {
containerIds = monitoredContainers.toArray(new String[monitoredContainers.size()]);
}
ContainerInfo info;
for (String id : containerIds) {
info = manager.getContainerInfo(id);
if (info != null) {
ContainerState state = info.state();
if (!(state.running() || state.restarting() || state.paused())) {
// get exit code
int exitStatus = info.state().exitCode();
// notify all callbacks
for (ContainerTerminationCallback cb : terminationCallbacks) {
try {
cb.notifyTermination(id, exitStatus);
} catch (Throwable e) {
LOGGER.error("Error while calling container termination callback.", e);
}
}
}
} else {
LOGGER.error("Couldn't get the status of container " + id
+ ". It will be ignored during this run but will be checked again during the next run.");
}
}
}
}, repeatInterval, repeatInterval);
}
开发者ID:hobbit-project,项目名称:platform,代码行数:37,代码来源:ContainerStateObserverImpl.java
示例7: 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;
}
}
开发者ID:meridor,项目名称:perspective-backend,代码行数:14,代码来源:ListInstancesOperation.java
示例8: 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);
}
}
开发者ID:kiegroup,项目名称:kie-wb-common,代码行数:34,代码来源:DockerRuntimeManager.java
示例9: inspectContainer
import com.spotify.docker.client.messages.ContainerState; //导入依赖的package包/类
public ContainerState inspectContainer(String containerId) throws DockerException, InterruptedException {
return client.inspectContainer(containerId).state();
}
开发者ID:ProgramLeague,项目名称:Avalon-Executive,代码行数:4,代码来源:DockerOperator.java
注:本文中的com.spotify.docker.client.messages.ContainerState类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论