• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java WaitContainerResultCallback类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.github.dockerjava.core.command.WaitContainerResultCallback的典型用法代码示例。如果您正苦于以下问题:Java WaitContainerResultCallback类的具体用法?Java WaitContainerResultCallback怎么用?Java WaitContainerResultCallback使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



WaitContainerResultCallback类属于com.github.dockerjava.core.command包,在下文中一共展示了WaitContainerResultCallback类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: stopAndRemoveContainer

import com.github.dockerjava.core.command.WaitContainerResultCallback; //导入依赖的package包/类
private void stopAndRemoveContainer(@NonNull final DockerClient _dockerClient,
                                    @NonNull final CreateContainerResponse _container) {
    _dockerClient
            .stopContainerCmd(_container.getId())
            .withTimeout(0)
            .exec();

    try {
        _dockerClient
                .waitContainerCmd(_container.getId())
                .exec(new WaitContainerResultCallback())
                .awaitCompletion();
    } catch (InterruptedException e) {
        // ignore
    }

    _dockerClient
            .removeContainerCmd(_container.getId())
            .exec();
}
 
开发者ID:jonfryd,项目名称:tifoon,代码行数:21,代码来源:DockerExecutorPlugin.java


示例2: testWaitContainerTimeout

import com.github.dockerjava.core.command.WaitContainerResultCallback; //导入依赖的package包/类
@Test
public void testWaitContainerTimeout() throws Exception {

    CreateContainerResponse container = dockerRule.getClient().createContainerCmd("busybox").withCmd("sleep", "10").exec();

    LOG.info("Created container: {}", container.toString());
    assertThat(container.getId(), not(isEmptyString()));

    dockerRule.getClient().startContainerCmd(container.getId()).exec();

    WaitContainerResultCallback callback = dockerRule.getClient().waitContainerCmd(container.getId()).exec(
            new WaitContainerResultCallback());
    try {
        callback.awaitStatusCode(100, TimeUnit.MILLISECONDS);
        throw new AssertionError("Should throw exception on timeout.");
    } catch (DockerClientException e) {
        LOG.info(e.getMessage());
    }
}
 
开发者ID:docker-java,项目名称:docker-java,代码行数:20,代码来源:WaitContainerCmdIT.java


示例3: testContainerDiff

import com.github.dockerjava.core.command.WaitContainerResultCallback; //导入依赖的package包/类
@Test
public void testContainerDiff() throws DockerException {
    CreateContainerResponse container = dockerRule.getClient().createContainerCmd(DEFAULT_IMAGE).withCmd("touch", "/test").exec();
    LOG.info("Created container: {}", container.toString());
    assertThat(container.getId(), not(isEmptyString()));
    dockerRule.getClient().startContainerCmd(container.getId()).exec();

    int exitCode = dockerRule.getClient().waitContainerCmd(container.getId()).exec(new WaitContainerResultCallback())
            .awaitStatusCode();
    assertThat(exitCode, equalTo(0));

    List<ChangeLog> filesystemDiff = dockerRule.getClient().containerDiffCmd(container.getId()).exec();
    LOG.info("Container DIFF: {}", filesystemDiff.toString());

    assertThat(filesystemDiff.size(), equalTo(1));
    ChangeLog testChangeLog = selectUnique(filesystemDiff, hasField("path", equalTo("/test")));

    assertThat(testChangeLog, hasField("path", equalTo("/test")));
    assertThat(testChangeLog, hasField("kind", equalTo(1)));
}
 
开发者ID:docker-java,项目名称:docker-java,代码行数:21,代码来源:ContainerDiffCmdIT.java


示例4: setUp

import com.github.dockerjava.core.command.WaitContainerResultCallback; //导入依赖的package包/类
@Before
public void setUp()
throws Exception {
	super.setUp();
	initTestContainer();
	dockerClient.startContainerCmd(testContainerId).exec();
	dockerClient
		.waitContainerCmd(testContainerId)
		.exec(new WaitContainerResultCallback())
		.awaitStatusCode(1000, TimeUnit.SECONDS);
	stdOutput = stdOutBuff.toString();
}
 
开发者ID:emc-mongoose,项目名称:mongoose-base,代码行数:13,代码来源:GroovyParallelShellCommandsTest.java


示例5: setUp

import com.github.dockerjava.core.command.WaitContainerResultCallback; //导入依赖的package包/类
@Before
public void setUp()
throws Exception {
	configArgs.add("--storage-net-http-namespace=ns1");
	configArgs.add("--storage-mock-capacity=10000000");
	super.setUp();
	if(storageType.equals(StorageType.FS)) {
		itemOutputPath = Paths.get(
			Paths.get(PathUtil.getBaseDir()).getParent().toString(), stepId
		).toString();
		EnvUtil.set("ITEM_OUTPUT_PATH", itemOutputPath);
	} else {
		itemOutputPath = "/default";
		EnvUtil.set("ITEM_OUTPUT_PATH", stepId);
	}
	configArgs.add("--item-output-path=" + itemOutputPath);

	initTestContainer();
	duration = System.currentTimeMillis();
	dockerClient.startContainerCmd(testContainerId).exec();
	containerExitCode = dockerClient
		.waitContainerCmd(testContainerId)
		.exec(new WaitContainerResultCallback())
		.awaitStatusCode(2, TimeUnit.MINUTES);
	duration = System.currentTimeMillis() - duration;
	stdOutput = stdOutBuff.toString();
}
 
开发者ID:emc-mongoose,项目名称:mongoose-base,代码行数:28,代码来源:PyWeightedLoadTest.java


示例6: setUp

import com.github.dockerjava.core.command.WaitContainerResultCallback; //导入依赖的package包/类
@Before
public void setUp()
throws Exception {
	configArgs.add("--test-step-limit-count=" + COUNT_LIMIT);
	super.setUp();
	switch(storageType) {
		case FS:
			itemOutputPath = Paths.get(
				Paths.get(PathUtil.getBaseDir()).getParent().toString(), stepId
			).toString();
			configArgs.add("--item-output-path=" + itemOutputPath);
			break;
		case SWIFT:
			configArgs.add("--storage-net-http-namespace=ns1");
			break;
	}
	initTestContainer();

	duration = System.currentTimeMillis();
	dockerClient.startContainerCmd(testContainerId).exec();
	containerExitCode = dockerClient
		.waitContainerCmd(testContainerId)
		.exec(new WaitContainerResultCallback())
		.awaitStatusCode(1000, TimeUnit.SECONDS);
	duration = System.currentTimeMillis() - duration;
	stdOutput = stdOutBuff.toString();
}
 
开发者ID:emc-mongoose,项目名称:mongoose-base,代码行数:28,代码来源:JsChainLoadStepTest.java


示例7: setUp

import com.github.dockerjava.core.command.WaitContainerResultCallback; //导入依赖的package包/类
@Before @Override
public void setUp()
throws Exception {

	super.setUp();

	switch(storageType) {
		case FS:
			final Path containerItemOutputPath = Paths.get(CONTAINER_SHARE_PATH, stepId);
			configArgs.add("--item-output-path=" + containerItemOutputPath.toString());
			break;
		case SWIFT:
			configArgs.add("--storage-net-http-namespace=ns1");
			break;
	}

	EnvUtil.set("ITEMS_FILE_0", stepId + "_0.csv");
	EnvUtil.set("ITEMS_FILE_1", stepId + "_1.csv");
	EnvUtil.set("ITEMS_FILE_2", stepId + "_2.csv");
	EnvUtil.set("FIRST_STEP_DURATION_LIMIT", Integer.toString(FIRST_STEP_DURATION_LIMIT));
	EnvUtil.set("UPDATE_RANDOM_RANGES_COUNT", Integer.toString(UPDATE_RANDOM_RANGES_COUNT));

	initTestContainer();
	dockerClient.startContainerCmd(testContainerId).exec();
	containerExitCode = dockerClient
		.waitContainerCmd(testContainerId)
		.exec(new WaitContainerResultCallback())
		.awaitStatusCode(300, TimeUnit.SECONDS);
	stdOutput = stdOutBuff.toString();
}
 
开发者ID:emc-mongoose,项目名称:mongoose-base,代码行数:31,代码来源:GroovyLoadTypeStepsTest.java


示例8: setUp

import com.github.dockerjava.core.command.WaitContainerResultCallback; //导入依赖的package包/类
@Before @Override
public void setUp()
throws Exception {

	super.setUp();

	switch(storageType) {
		case FS:
			final Path containerItemOutputPath = Paths.get(CONTAINER_SHARE_PATH, stepId);
			configArgs.add("--item-output-path=" + containerItemOutputPath.toString());
			break;
		case SWIFT:
			configArgs.add("--storage-net-http-namespace=ns1");
			break;
	}

	EnvUtil.set("ITEMS_FILE_0", stepId + "_0.csv");
	EnvUtil.set("ITEMS_FILE_1", stepId + "_1.csv");
	EnvUtil.set("FIRST_STEP_COUNT_LIMIT", Integer.toString(FIRST_STEP_COUNT_LIMIT));

	initTestContainer();
	dockerClient.startContainerCmd(testContainerId).exec();
	containerExitCode = dockerClient
		.waitContainerCmd(testContainerId)
		.exec(new WaitContainerResultCallback())
		.awaitStatusCode(300, TimeUnit.SECONDS);
	stdOutput = stdOutBuff.toString();
}
 
开发者ID:emc-mongoose,项目名称:mongoose-base,代码行数:29,代码来源:JsUpdateAndReadVariantsTest.java


示例9: DockerizedProcess

import com.github.dockerjava.core.command.WaitContainerResultCallback; //导入依赖的package包/类
public DockerizedProcess(final DockerClient dockerClient, final String containerId, final Closure afterContainerStop) throws Exception
{
    this.dockerClient = dockerClient;
    this.containerId = containerId;
    this.afterContainerStop = afterContainerStop;
    attachStreams();
    dockerClient.waitContainerCmd(containerId).exec(new WaitContainerResultCallback() {
        @Override public void onNext(WaitResponse waitResponse)
        {
            exitCode.set(waitResponse.getStatusCode());
            try
            {
                attachContainerResultCallback.close();
                attachContainerResultCallback.awaitCompletion();
                stdOutWriteStream.close();
                stdErrWriteStream.close();
            } catch (Exception e) {
                LOGGER.debug("Error by detaching streams", e);
            } finally
            {
                finished.countDown();
                invokeIfNotNull(afterContainerStop, containerId, dockerClient);
            }


        }
    });
}
 
开发者ID:pedjak,项目名称:gradle-dockerized-test-plugin,代码行数:29,代码来源:DockerizedExecHandle.java


示例10: testWaitNonExistingContainer

import com.github.dockerjava.core.command.WaitContainerResultCallback; //导入依赖的package包/类
@Test(expected = NotFoundException.class)
public void testWaitNonExistingContainer() throws DockerException {

    WaitContainerResultCallback callback = new WaitContainerResultCallback() {
        public void onNext(WaitResponse waitResponse) {
            throw new AssertionError("expected NotFoundException");
        }
    };

    dockerRule.getClient().waitContainerCmd("non-existing").exec(callback).awaitStatusCode();
}
 
开发者ID:docker-java,项目名称:docker-java,代码行数:12,代码来源:WaitContainerCmdIT.java


示例11: copyFileWithExecutePermission

import com.github.dockerjava.core.command.WaitContainerResultCallback; //导入依赖的package包/类
@Test
public void copyFileWithExecutePermission() throws Exception {
    // create script file, add permission to execute
    Path scriptPath = Files.createTempFile("run", ".sh");
    boolean executable = scriptPath.toFile().setExecutable(true, false);
    if (!executable){
        throw new Exception("Execute permission on file not set!");
    }
    String snippet = "Running script with execute permission.";
    String scriptTextStr = "#!/bin/sh\necho \"" + snippet + "\"";
    // write content for created script
    Files.write(scriptPath, scriptTextStr.getBytes());
    // create a test container which starts and waits 3 seconds for the
    // script to be copied to the container's home dir and then executes it
    String containerCmd = "sleep 3; /home/" + scriptPath.getFileName().toString();
    CreateContainerResponse container = dockerRule.getClient().createContainerCmd("busybox")
            .withName("copyFileWithExecutivePerm" + dockerRule.getKind())
            .withCmd("/bin/sh", "-c", containerCmd)
            .exec();
    // start the container
    dockerRule.getClient().startContainerCmd(container.getId()).exec();
    // copy script to container home dir
    dockerRule.getClient().copyArchiveToContainerCmd(container.getId())
            .withRemotePath("/home")
            .withHostResource(scriptPath.toString())
            .exec();
    // await exid code
    int exitCode = dockerRule.getClient().waitContainerCmd(container.getId())
            .exec(new WaitContainerResultCallback())
            .awaitStatusCode();
    // check result
    assertThat(exitCode, equalTo(0));
}
 
开发者ID:docker-java,项目名称:docker-java,代码行数:34,代码来源:CopyArchiveToContainerCmdIT.java


示例12: commitWithLabels

import com.github.dockerjava.core.command.WaitContainerResultCallback; //导入依赖的package包/类
@Test
public void commitWithLabels() throws DockerException {

    CreateContainerResponse container = dockerRule.getClient().createContainerCmd("busybox")
            .withCmd("touch", "/test")
            .exec();

    LOG.info("Created container: {}", container.toString());
    assertThat(container.getId(), not(isEmptyString()));
    dockerRule.getClient().startContainerCmd(container.getId()).exec();

    Integer status = dockerRule.getClient().waitContainerCmd(container.getId())
            .exec(new WaitContainerResultCallback())
            .awaitStatusCode();

    assertThat(status, is(0));

    LOG.info("Committing container: {}", container.toString());
    Map<String, String> labels = ImmutableMap.of("label1", "abc", "label2", "123");
    String imageId = dockerRule.getClient().commitCmd(container.getId())
            .withLabels(labels)
            .exec();

    InspectImageResponse inspectImageResponse = dockerRule.getClient().inspectImageCmd(imageId).exec();
    LOG.info("Image Inspect: {}", inspectImageResponse.toString());

    //use config here since containerConfig contains the configuration of the container which was
    //committed to the container
    //https://stackoverflow.com/questions/36216220/what-is-different-of-config-and-containerconfig-of-docker-inspect
    Map<String, String> responseLabels = inspectImageResponse.getConfig().getLabels();
    //swarm will attach additional labels here
    assertThat(responseLabels.size(), greaterThanOrEqualTo(2));
    assertThat(responseLabels.get("label1"), equalTo("abc"));
    assertThat(responseLabels.get("label2"), equalTo("123"));
}
 
开发者ID:docker-java,项目名称:docker-java,代码行数:36,代码来源:CommitCmdIT.java


示例13: asyncLogContainerWithSince

import com.github.dockerjava.core.command.WaitContainerResultCallback; //导入依赖的package包/类
@Test
public void asyncLogContainerWithSince() throws Exception {
    String snippet = "hello world";

    CreateContainerResponse container = dockerRule.getClient().createContainerCmd("busybox")
            .withCmd("/bin/echo", snippet)
            .exec();

    LOG.info("Created container: {}", container.toString());
    assertThat(container.getId(), not(isEmptyString()));

    int timestamp = (int) (System.currentTimeMillis() / 1000);

    dockerRule.getClient().startContainerCmd(container.getId()).exec();

    int exitCode = dockerRule.getClient().waitContainerCmd(container.getId())
            .exec(new WaitContainerResultCallback())
            .awaitStatusCode();

    assertThat(exitCode, equalTo(0));

    LogContainerTestCallback loggingCallback = new LogContainerTestCallback();

    dockerRule.getClient().logContainerCmd(container.getId())
            .withStdErr(true)
            .withStdOut(true)
            .withSince(timestamp)
            .exec(loggingCallback);

    loggingCallback.awaitCompletion();

    assertThat(loggingCallback.toString(), containsString(snippet));
}
 
开发者ID:docker-java,项目名称:docker-java,代码行数:34,代码来源:LogContainerCmdIT.java


示例14: testExitedFilter

import com.github.dockerjava.core.command.WaitContainerResultCallback; //导入依赖的package包/类
@Test
public void testExitedFilter() throws Exception {
    dockerRule.getClient().createContainerCmd(DEFAULT_IMAGE)
            .withLabels(testLabel)
            .exec();

    String id = dockerRule.getClient().createContainerCmd(DEFAULT_IMAGE)
            .withLabels(testLabel)
            .withCmd("sh", "-c", "exit 42")
            .exec()
            .getId();

    dockerRule.getClient().startContainerCmd(id).exec();

    Integer status = dockerRule.getClient().waitContainerCmd(id).exec(new WaitContainerResultCallback())
            .awaitStatusCode();

    assertThat(status, is(42));

    List<Container> filteredContainers = dockerRule.getClient().listContainersCmd()
            .withLabelFilter(testLabel)
            .withShowAll(true)
            .withExitedFilter(42)
            .exec();

    assertThat(filteredContainers.size(), is(1));
    assertThat(filteredContainers.get(0).getId(), is(id));
}
 
开发者ID:docker-java,项目名称:docker-java,代码行数:29,代码来源:ListContainersCmdIT.java


示例15: execBuild

import com.github.dockerjava.core.command.WaitContainerResultCallback; //导入依赖的package包/类
private String execBuild(BuildImageCmd buildImageCmd) throws Exception {
    String imageId = buildImageCmd.withNoCache(true).exec(new BuildImageResultCallback()).awaitImageId();

    // Create container based on image
    CreateContainerResponse container = dockerRule.getClient().createContainerCmd(imageId).exec();

    LOG.info("Created container: {}", container.toString());
    assertThat(container.getId(), not(isEmptyString()));

    dockerRule.getClient().startContainerCmd(container.getId()).exec();
    dockerRule.getClient().waitContainerCmd(container.getId()).exec(new WaitContainerResultCallback()).awaitStatusCode();

    return dockerRule.containerLog(container.getId());
}
 
开发者ID:docker-java,项目名称:docker-java,代码行数:15,代码来源:BuildImageCmdIT.java


示例16: waitContainer

import com.github.dockerjava.core.command.WaitContainerResultCallback; //导入依赖的package包/类
public int waitContainer(String containerId) {
    this.readWriteLock.readLock().lock();
    try {
        return this.dockerClient.waitContainerCmd(containerId)
            .exec(new WaitContainerResultCallback())
            .awaitStatusCode();
    } finally {
        this.readWriteLock.readLock().unlock();
    }
}
 
开发者ID:arquillian,项目名称:arquillian-cube,代码行数:11,代码来源:DockerClientExecutor.java


示例17: verify_csap_base

import com.github.dockerjava.core.command.WaitContainerResultCallback; //导入依赖的package包/类
@Ignore
@Test
public void verify_csap_base ()
		throws Exception {

	// ref. https://github.com/docker-java/docker-java/wiki

	String containerName = "/junit-csapbase-"
			+ LocalDateTime.now().format( DateTimeFormatter.ofPattern( "MMM.d-HH.mm.ss" ) );

	String imageName = CSAP_DOCKER_REPOSITORY +"/csap-base";
	// imageName = "centos";
	loadImageIfNeeded( imageName );

	CreateContainerResponse containerResponse = dockerClient.createContainerCmd( imageName )
		.withName( containerName )
		.withWorkingDir( "/" )
		.exec();

	dockerClient
		.startContainerCmd( containerResponse.getId() )
		.exec();

	// Thread.sleep( 3000 );
	int exitCode = dockerClient.waitContainerCmd( containerResponse.getId() )
		.exec( new WaitContainerResultCallback() )
		.awaitStatusCode( 5, TimeUnit.SECONDS );

	logger.info( "Container exited with: {}", exitCode );

	LogContainerTestCallback loggingCallback = new LogContainerTestCallback( false );
	dockerClient
		.logContainerCmd( containerResponse.getId() )
		.withStdErr( true )
		.withStdOut( true )
		.withTailAll()
		.exec( loggingCallback );

	loggingCallback.awaitCompletion( 3, TimeUnit.SECONDS );

	logger.info( "logs: \n {} ", loggingCallback.toString() );

	loggingCallback.close();

	assertThat( loggingCallback.toString() )
		.as( "csap-base logs" )
		.contains( "Java HotSpot(TM) 64-Bit Server VM" );

	dockerClient
		.removeContainerCmd( containerResponse.getId() )
		.withForce( true )
		.exec();
}
 
开发者ID:csap-platform,项目名称:csap-core,代码行数:54,代码来源:Docker_Java.java


示例18: verify_container_logs

import com.github.dockerjava.core.command.WaitContainerResultCallback; //导入依赖的package包/类
@Test
public void verify_container_logs ()
		throws Exception {

	String imageName = "hello-world";
	loadImageIfNeeded( imageName );
	String containerName = "/junit-logtest-"
			+ LocalDateTime.now().format( DateTimeFormatter.ofPattern( "MMM.d-HH.mm.ss" ) );

	CreateContainerResponse createResponse = dockerClient
		.createContainerCmd( imageName )
		.withName( containerName )
		.withCmd( "/hello" )
		.withTty( true )
		.exec();

	// CreateContainerResponse createResponse =
	// dockerClient.createContainerCmd( "busybox" )
	// .withCmd( "/bin/ls" )
	// .withName( containerName )
	// .exec();

	logger.info( "Create: {}", createResponse );

	dockerClient
		.startContainerCmd( createResponse.getId() )
		.exec();

	int exitCode = dockerClient.waitContainerCmd( createResponse.getId() )
		.exec( new WaitContainerResultCallback() )
		.awaitStatusCode( 5, TimeUnit.SECONDS );

	LogContainerTestCallback loggingCallback = new LogContainerTestCallback( false );

	dockerClient
		.logContainerCmd( createResponse.getId() )
		.withStdErr( true )
		.withStdOut( true )
		.withTailAll()
		.exec( loggingCallback );
	//
	loggingCallback.awaitCompletion( 3, TimeUnit.SECONDS );

	logger.info( "{} logs: \n {} ", containerName, loggingCallback.toString() );

	loggingCallback.close();

	assertThat( loggingCallback.toString() )
		.as( "HelloWorld logs" )
		.contains( "Hello from Docker!" );

	dockerClient
		.removeContainerCmd( createResponse.getId() )
		.withRemoveVolumes( true )
		.withForce( true )
		.exec();

	logger.info( "Container removed: {}", createResponse.getId() );

}
 
开发者ID:csap-platform,项目名称:csap-core,代码行数:61,代码来源:Docker_Java.java


示例19: verify_container_logs_stream

import com.github.dockerjava.core.command.WaitContainerResultCallback; //导入依赖的package包/类
@Test
public void verify_container_logs_stream ()
		throws Exception {

	String imageName = "hello-world";
	loadImageIfNeeded( imageName );
	String containerName = "/junit-logtest-"
			+ LocalDateTime.now().format( DateTimeFormatter.ofPattern( "MMM.d-HH.mm.ss" ) );

	CreateContainerResponse createResponse = dockerClient
		.createContainerCmd( imageName )
		.withName( containerName )
		.withCmd( "/hello" )
		.withTty( true )
		.exec();

	// CreateContainerResponse createResponse =
	// dockerClient.createContainerCmd( "busybox" )
	// .withCmd( "/bin/ls" )
	// .withName( containerName )
	// .exec();

	logger.info( "Create: {}", createResponse );

	dockerClient
		.startContainerCmd( createResponse.getId() )
		.exec();

	int exitCode = dockerClient.waitContainerCmd( createResponse.getId() )
		.exec( new WaitContainerResultCallback() )
		.awaitStatusCode( 5, TimeUnit.SECONDS );

	StringWriter sw = new StringWriter();
	LogContainerTestCallback loggingCallback = new LogContainerTestCallback( sw );

	dockerClient
		.logContainerCmd( createResponse.getId() )
		.withStdErr( true )
		.withStdOut( true )
		.withTailAll()
		.exec( loggingCallback );
	//
	loggingCallback.awaitCompletion( 3, TimeUnit.SECONDS );

	sw.flush();
	logger.info( "{} logs from stream: \n {} ", containerName, sw.toString() );

	loggingCallback.close();

	assertThat( sw.toString() )
		.as( "HelloWorld logs" )
		.contains( "Hello from Docker!" );

	dockerClient
		.removeContainerCmd( createResponse.getId() )
		.withRemoveVolumes( true )
		.withForce( true )
		.exec();

	logger.info( "Container removed: {}", createResponse.getId() );

	loggingCallback.close();

}
 
开发者ID:csap-platform,项目名称:csap-core,代码行数:65,代码来源:Docker_Java.java


示例20: runBuild

import com.github.dockerjava.core.command.WaitContainerResultCallback; //导入依赖的package包/类
public void runBuild(String image, String cmd, Path repoPath) {

        LOGGER.info("Run Build Start");
        String fileName = repoPath.getFileName().toString();
        Volume volume = new Volume(File.separator + fileName);

        // mvn cache
        Volume mvnVolume = new Volume(DOCKER_MVN_CACHE_FOLDER);

        LOGGER.info("Run Build Start - " + Paths.get(repoPath.getParent().toString(), REPOSITORY).toString());

        CreateContainerResponse container = docker
            .createContainerCmd(image)
            .withBinds(new Bind(repoPath.toString(), volume),
                new Bind(Paths.get(repoPath.getParent().toString(), REPOSITORY).toString(), mvnVolume))
            .withWorkingDir(File.separator + fileName)
            .withCmd(BASH, "-c", cmd)
            .withTty(true)
            .exec();

        docker.startContainerCmd(container.getId()).exec();

        BuildProcess loggingCallback = new
            BuildProcess();

        try {
            docker
                .logContainerCmd(container.getId())
                .withStdErr(true)
                .withStdOut(true)
                .withFollowStream(true)
                .withTailAll()
                .exec(loggingCallback)
                .awaitStarted();

            loggingCallback.awaitCompletion();

            int exitCode = docker
                .waitContainerCmd(container.getId())
                .exec(new WaitContainerResultCallback())
                .awaitStatusCode();

            docker.removeContainerCmd(container.getId()).exec();
            if (exitCode != 0) {
                throw new PluginException("Build Project Error ExitCode: " + exitCode);
            }

        } catch (Throwable e) {
            docker.removeContainerCmd(container.getId());
            LOGGER.error("Docker build error ", e);
            throw new PluginException("Docker build error " + e.getMessage());
        }
        LOGGER.info("Run Build Finish");
    }
 
开发者ID:FlowCI,项目名称:flow-platform,代码行数:55,代码来源:Docker.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java XSComponent类代码示例发布时间:2022-05-23
下一篇:
Java TypedXmlWriter类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap