本文整理汇总了Java中com.github.dockerjava.api.command.InspectContainerResponse.getState方法的典型用法代码示例。如果您正苦于以下问题:Java InspectContainerResponse.getState方法的具体用法?Java InspectContainerResponse.getState怎么用?Java InspectContainerResponse.getState使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.github.dockerjava.api.command.InspectContainerResponse
的用法示例。
在下文中一共展示了InspectContainerResponse.getState方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDockerEvent
import com.github.dockerjava.api.command.InspectContainerResponse; //导入方法依赖的package包/类
private DockerEvent getDockerEvent(String containerId){
DockerEvent result = null;
try{
InspectContainerResponse inspectResponse = dockerClient.inspectContainerCmd(containerId).exec();
ContainerConfig config = inspectResponse.getConfig();
Map<String,String> labels = config.getLabels();
String taskId = labels.get(TASK_ID);
if(this.taskId.getValue().equals(taskId)){
ContainerState state = inspectResponse.getState();
String name = inspectResponse.getName();
int exitCode = state.getExitCode();
int pid = state.getPid();
result= new DockerEvent(containerId, name, pid, exitCode);
}
}catch(NotFoundException exception){
log.debug("tried to debug non-existent containerId",exception);
}
return result;
}
示例2: inspect
import com.github.dockerjava.api.command.InspectContainerResponse; //导入方法依赖的package包/类
@Override
public KieContainerDetails inspect(String containerId) {
Timer timer = new Timer();
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Start inspecting container with id = " + containerId);
timer.start();
}
final DockerClient dockerClient = getClient();
final InspectContainerResponse response = dockerClient.inspectContainerCmd(containerId).exec();
final NetworkSettings networkSettings = response.getNetworkSettings();
final ContainerConfig config = response.getConfig();
final String[] envVars = config.getEnv();
final InspectContainerResponse.ContainerState state = response.getState();
final String ipAddress = networkSettings.getIpAddress();
final int containerPid = state.getPid();
final String containerStartedAt = state.getStartedAt();
final String containerFinishedAt = state.getFinishedAt();
final Map<String, Map<String, String>> portMappings = networkSettings.getPortMapping();
final String[] containerArgs = response.getArgs();
final KieContainerDetails details = new KieContainerDetails();
details.setIpAddress(ipAddress);
details.setContainerPid(containerPid);
details.setContainerStartedAt(containerStartedAt);
details.setContainerFinishedAt(containerFinishedAt);
details.setPortMappings(portMappings);
details.setContainerArgs(containerArgs);
details.setEnvVars(escapeEnvVars(envVars));
if (LOGGER.isDebugEnabled()) {
timer.end();
LOGGER.debug("container with id = " + containerId + " inspected. Elapsed time = " + timer.getTotalTime());
}
return details;
}
示例3: getContainerState
import com.github.dockerjava.api.command.InspectContainerResponse; //导入方法依赖的package包/类
/**
* Gets the state of a container.
* @param containerId the container ID
* @param dockerClient the Docker client
* @return a container state, or null if the container was not found
*/
public static ContainerState getContainerState( String containerId, DockerClient dockerClient ) {
ContainerState result = null;
try {
InspectContainerResponse resp = dockerClient.inspectContainerCmd( containerId ).exec();
if( resp != null )
result = resp.getState();
} catch( Exception e ) {
// nothing
}
return result;
}
示例4: areRunning
import com.github.dockerjava.api.command.InspectContainerResponse; //导入方法依赖的package包/类
public ContainersAssert areRunning() {
for (InspectContainerResponse container : this.actual) {
ContainerStateAssert stateAssert = new ContainerStateAssert(container.getState());
stateAssert.isNotNull();
if (!container.getState().getRunning()) {
failWithMessage("Container %s is not running", container.getName());
}
}
return this;
}