当前位置: 首页>>代码示例>>Java>>正文


Java InspectContainerResponse.getState方法代码示例

本文整理汇总了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;
}
 
开发者ID:mohitsoni,项目名称:compose-executor,代码行数:20,代码来源:DockerEventObserver.java

示例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;
}
 
开发者ID:kiegroup,项目名称:kie-docker-ci,代码行数:39,代码来源:DockerServiceImpl.java

示例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;
}
 
开发者ID:roboconf,项目名称:roboconf-platform,代码行数:21,代码来源:DockerUtils.java

示例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;
}
 
开发者ID:arquillian,项目名称:arquillian-cube,代码行数:13,代码来源:ContainersAssert.java


注:本文中的com.github.dockerjava.api.command.InspectContainerResponse.getState方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。