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


Java PullImageResultCallback类代码示例

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


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

示例1: pullImage

import com.github.dockerjava.core.command.PullImageResultCallback; //导入依赖的package包/类
/**
 * pulls {@link Image} from {@link Registry}
 * 	
 * @param imageName - imageName of {@link Element}
 * @throws Exception
 */
public void pullImage(String imageName) throws Exception {
	String tag = null;
	String registry = imageName;
	if (registry.contains(":")) {
		String[] sp = registry.split(":");
		registry = sp[0];
		tag = sp[1];
	}
	PullImageCmd req = dockerClient.pullImageCmd(registry).withAuthConfig(dockerClient.authConfig());
	if (tag != null)
		req.withTag(tag);
	PullImageResultCallback res = new PullImageResultCallback();
	res = req.exec(res);
	res.awaitSuccess();
}
 
开发者ID:iotracks,项目名称:iofabric,代码行数:22,代码来源:DockerUtil.java

示例2: call

import com.github.dockerjava.core.command.PullImageResultCallback; //导入依赖的package包/类
public Void call() throws Exception {
    final ConsoleLogger console = new ConsoleLogger(listener);
    DockerClient client = DockerCommand.getClient(descriptor, cfgData.dockerUrlRes, cfgData.dockerVersionRes, cfgData.dockerCertPathRes, authConfig);

    PullImageCmd pullImageCmd = client.pullImageCmd(fromImageRes);
    PullImageResultCallback callback = new PullImageResultCallback() {
        @Override
        public void onNext(PullResponseItem item) {
            console.logInfo(item.toString());
            super.onNext(item);
        }

        @Override
        public void onError(Throwable throwable) {
            console.logError("Failed to exec start:" + throwable.getMessage());
            super.onError(throwable);
        }
    };
    pullImageCmd.exec(callback).awaitSuccess();
    
    return null;
}
 
开发者ID:jenkinsci,项目名称:docker-build-step-plugin,代码行数:23,代码来源:PullImageRemoteCallable.java

示例3: pullImage

import com.github.dockerjava.core.command.PullImageResultCallback; //导入依赖的package包/类
public void pullImage(String imageName) {

        this.readWriteLock.readLock().lock();

        try {
            final Image image = Image.valueOf(imageName);

            PullImageCmd pullImageCmd = this.dockerClient.pullImageCmd(image.getName());

            String tag = image.getTag();
            if (tag != null && !"".equals(tag)) {
                pullImageCmd.withTag(tag);
            } else {
                pullImageCmd.withTag("latest");
            }

            pullImageCmd.exec(new PullImageResultCallback()).awaitSuccess();
        } finally {
            this.readWriteLock.readLock().unlock();
        }
    }
 
开发者ID:arquillian,项目名称:arquillian-cube,代码行数:22,代码来源:DockerClientExecutor.java

示例4: loadImage

import com.github.dockerjava.core.command.PullImageResultCallback; //导入依赖的package包/类
private void loadImage ( String imageName )
		throws InterruptedException {
	MyHandler handler = new MyHandler();

	// AuthConfig authConfig = new AuthConfig()
	// .withUsername( "peterdnight" )
	// .withPassword( "pet6er82" )
	// .withEmail( "[email protected]" )
	// .withRegistryAddress( registryName );
	// authConfig.wi

	PullImageResultCallback cb = dockerClient
		.pullImageCmd( imageName )
		.withTag( "latest" )
		// .withAuthConfig( authConfig )
		.exec( handler ).awaitCompletion();
}
 
开发者ID:csap-platform,项目名称:csap-core,代码行数:18,代码来源:Docker_Java.java

示例5: pullImage

import com.github.dockerjava.core.command.PullImageResultCallback; //导入依赖的package包/类
private static String pullImage(String registryHost, String imageName, String tag) {
  checkArgument(!Strings.isNullOrEmpty(registryHost));
  checkArgument(!Strings.isNullOrEmpty(imageName));

  String tag1 = Strings.isNullOrEmpty(tag) ? "latest" : tag;
  String fullQualifiedImageName = String.format("%s/%s:%s", registryHost, imageName, tag1);
  dockerClient
      .pullImageCmd(fullQualifiedImageName)
      .exec(new PullImageResultCallback())
      .awaitSuccess();

  String fullQualifiedImageId =
      dockerClient.inspectImageCmd(fullQualifiedImageName).exec().getId();
  fullQualifiedImageId = fullQualifiedImageId.substring(fullQualifiedImageId.indexOf(":") + 1);
  return fullQualifiedImageId.substring(0, IMAGE_ID_LENGTH);
}
 
开发者ID:scalecube,项目名称:docker-utils,代码行数:17,代码来源:Containers.java

示例6: init

import com.github.dockerjava.core.command.PullImageResultCallback; //导入依赖的package包/类
public static void init() {
  DefaultDockerClientConfig conf = DefaultDockerClientConfig
      .createDefaultConfigBuilder()
      .withRegistryUrl("https://index.docker.io/v1/").build();

  dockerClient =
      DockerClientBuilder.getInstance(conf).withDockerCmdExecFactory(new NettyDockerCmdExecFactory()).build();
  try {
    dockerClient.inspectImageCmd("busybox").exec();
  } catch (Exception e) {
    LOGGER.info("Pulling image 'busybox'");
    // need to block until image is pulled completely
    dockerClient.pullImageCmd("busybox").withTag("latest").exec(new PullImageResultCallback()).awaitSuccess();
  }

  String logRecord = "This is magic string keyToFind=42 and some text at the end";
  container = dockerClient.createContainerCmd("busybox")
      .withCmd("/bin/sh", "-c", "while true; do echo " + logRecord + "; sleep 1; done")
      .withTty(true)
      .exec();

  dockerClient.startContainerCmd(container.getId()).exec();
}
 
开发者ID:scalecube,项目名称:docker-utils,代码行数:24,代码来源:LogParsingTest.java

示例7: ensureImage

import com.github.dockerjava.core.command.PullImageResultCallback; //导入依赖的package包/类
public static void ensureImage(String imageName) {
    List<Image> images = dockerClient.listImagesCmd().withImageNameFilter(imageName).exec();
    if (images.isEmpty()){
        logger.info("Pulling docker image from Docker Hub ...");
        // FIXME: Figure out how image tags should work
        dockerClient.pullImageCmd(imageName).withTag("latest")
                .exec(new PullImageResultCallback(){
                    @Override
                    public void onNext(PullResponseItem item) {
                        super.onNext(item);
                        logger.debug(item.toString());
                    }
                })
                .awaitSuccess();
        logger.info("Finished pulling docker image.");
    }
}
 
开发者ID:b-long,项目名称:jedi,代码行数:18,代码来源:ContainerUtils.java

示例8: pull

import com.github.dockerjava.core.command.PullImageResultCallback; //导入依赖的package包/类
public void pull(InstanceStartRequest request, InstanceStartResponse response) {
    try {
        dockerClient.pullImageCmd(request.getRepository()).exec(new PullImageResultCallback() {
            @Override
            public void onNext(PullResponseItem item) {
                super.onNext(item);
                if (logger.isDebugEnabled()) {
                    logger.debug(item);
                }
            }
        }).awaitSuccess();
        response.success();
    } catch (Exception e) {
        response.fail(e.toString());
        logger.error(String.format("error pullImage: %s", request), e);
    }
}
 
开发者ID:dianping,项目名称:Dolphin,代码行数:18,代码来源:DockerImageServiceImpl.java

示例9: before

import com.github.dockerjava.core.command.PullImageResultCallback; //导入依赖的package包/类
@Override
    protected void before() throws Throwable {
//        LOG.info("======================= BEFORETEST =======================");
        LOG.debug("Connecting to Docker server");


        try {
            getClient().inspectImageCmd(DEFAULT_IMAGE).exec();
        } catch (NotFoundException e) {
            LOG.info("Pulling image 'busybox'");
            // need to block until image is pulled completely
            getClient().pullImageCmd("busybox")
                    .withTag("latest")
                    .exec(new PullImageResultCallback())
                    .awaitSuccess();
        }

//        assertThat(getClient(), notNullValue());
//        LOG.info("======================= END OF BEFORETEST =======================\n\n");
    }
 
开发者ID:docker-java,项目名称:docker-java,代码行数:21,代码来源:DockerRule.java

示例10: generateEvents

import com.github.dockerjava.core.command.PullImageResultCallback; //导入依赖的package包/类
/**
 * This method generates some events and returns the number of events being generated
 */
private int generateEvents() throws Exception {
    String testImage = "busybox:latest";

    dockerRule.getClient().pullImageCmd(testImage).exec(new PullImageResultCallback()).awaitSuccess();
    CreateContainerResponse container = dockerRule.getClient().createContainerCmd(testImage).withCmd("sleep", "9999").exec();
    dockerRule.getClient().startContainerCmd(container.getId()).exec();
    dockerRule.getClient().stopContainerCmd(container.getId()).withTimeout(1).exec();

    // generates 5 events with remote api 1.24:

    // Event[status=pull,id=busybox:latest,from=<null>,node=<null>,type=IMAGE,action=pull,[email protected][id=busybox:latest,attributes={name=busybox}],time=1473455186,timeNano=1473455186436681587]
    // Event[status=create,id=6ec10182cde227040bfead8547b63105e6bbc4e94b99f6098bfad6e158ce0d3c,from=busybox:latest,node=<null>,type=CONTAINER,action=create,[email protected][id=6ec10182cde227040bfead8547b63105e6bbc4e94b99f6098bfad6e158ce0d3c,attributes={image=busybox:latest, name=sick_lamport}],time=1473455186,timeNano=1473455186470713257]
    // Event[status=<null>,id=<null>,from=<null>,node=<null>,type=NETWORK,action=connect,[email protected][id=10870ceb13abb7cf841ea68868472da881b33c8ed08d2cde7dbb39d7c24d1d27,attributes={container=6ec10182cde227040bfead8547b63105e6bbc4e94b99f6098bfad6e158ce0d3c, name=bridge, type=bridge}],time=1473455186,timeNano=1473455186544318466]
    // Event[status=start,id=6ec10182cde227040bfead8547b63105e6bbc4e94b99f6098bfad6e158ce0d3c,from=busybox:latest,node=<null>,type=CONTAINER,action=start,[email protected][id=6ec10182cde227040bfead8547b63105e6bbc4e94b99f6098bfad6e158ce0d3c,attributes={image=busybox:latest, name=sick_lamport}],time=1473455186,timeNano=1473455186786163819]
    // Event[status=kill,id=6ec10182cde227040bfead8547b63105e6bbc4e94b99f6098bfad6e158ce0d3c,from=busybox:latest,node=<null>,type=CONTAINER,action=kill,[email protected][id=6ec10182cde227040bfead8547b63105e6bbc4e94b99f6098bfad6e158ce0d3c,attributes={image=busybox:latest, name=sick_lamport, signal=15}],time=1473455186,timeNano=1473455186792963392]

    return 5;
}
 
开发者ID:docker-java,项目名称:docker-java,代码行数:22,代码来源:EventsCmdIT.java

示例11: testPullImageWithNoAuth

import com.github.dockerjava.core.command.PullImageResultCallback; //导入依赖的package包/类
@Test
public void testPullImageWithNoAuth() throws Exception {
    RegistryUtils.runPrivateRegistry(dockerRule.getClient());

    String imgName = RegistryUtils.createPrivateImage(dockerRule, "pull-image-with-no-auth");

    if (isNotSwarm(dockerRule.getClient()) && getVersion(dockerRule.getClient())
            .isGreaterOrEqual(RemoteApiVersion.VERSION_1_30)) {
        exception.expect(InternalServerErrorException.class);
    } else {
        exception.expect(DockerClientException.class);
    }

    // stream needs to be fully read in order to close the underlying connection
    dockerRule.getClient().pullImageCmd(imgName)
            .exec(new PullImageResultCallback())
            .awaitCompletion(30, TimeUnit.SECONDS);
}
 
开发者ID:docker-java,项目名称:docker-java,代码行数:19,代码来源:PullImageCmdIT.java

示例12: testPullImageWithInvalidAuth

import com.github.dockerjava.core.command.PullImageResultCallback; //导入依赖的package包/类
@Test
public void testPullImageWithInvalidAuth() throws Exception {
    AuthConfig validAuthConfig = RegistryUtils.runPrivateRegistry(dockerRule.getClient());

    AuthConfig authConfig = new AuthConfig()
            .withUsername("testuser")
            .withPassword("testwrongpassword")
            .withEmail("[email protected]")
            .withRegistryAddress(validAuthConfig.getRegistryAddress());

    String imgName = RegistryUtils.createPrivateImage(dockerRule, "pull-image-with-invalid-auth");

    if (isNotSwarm(dockerRule.getClient()) && getVersion(dockerRule.getClient())
            .isGreaterOrEqual(RemoteApiVersion.VERSION_1_30)) {
        exception.expect(InternalServerErrorException.class);
    } else {
        exception.expect(DockerClientException.class);
    }

    // stream needs to be fully read in order to close the underlying connection
    dockerRule.getClient().pullImageCmd(imgName)
            .withAuthConfig(authConfig)
            .exec(new PullImageResultCallback())
            .awaitCompletion(30, TimeUnit.SECONDS);
}
 
开发者ID:docker-java,项目名称:docker-java,代码行数:26,代码来源:PullImageCmdIT.java

示例13: pullImage

import com.github.dockerjava.core.command.PullImageResultCallback; //导入依赖的package包/类
void pullImage(DockerAPI api, TaskListener listener) throws IOException, InterruptedException {

        String image = getFullImageId();
        final DockerClient client = api.getClient();

        if (pullStrategy.shouldPullImage(client, image)) {
            // TODO create a FlyWeightTask so end-user get visibility on pull operation progress
            LOGGER.info("Pulling image '{}'. This may take awhile...", image);

            long startTime = System.currentTimeMillis();

            PullImageCmd cmd =  client.pullImageCmd(image);
            final DockerRegistryEndpoint registry = getRegistry();
            DockerCloud.setRegistryAuthentication(cmd, registry, Jenkins.getInstance());
            cmd.exec(new PullImageResultCallback() {
                @Override
                public void onNext(PullResponseItem item) {
                    listener.getLogger().println(item.getStatus());
                }
            }).awaitCompletion();

            try {
                client.inspectImageCmd(image).exec();
            } catch (NotFoundException e) {
                throw new DockerClientException("Could not pull image: " + image, e);
            }

            long pullTime = System.currentTimeMillis() - startTime;
            LOGGER.info("Finished pulling image '{}', took {} ms", image, pullTime);
        }

    }
 
开发者ID:jenkinsci,项目名称:docker-plugin,代码行数:33,代码来源:DockerTemplate.java

示例14: createContainer

import com.github.dockerjava.core.command.PullImageResultCallback; //导入依赖的package包/类
private CreateContainerResponse createContainer(@NonNull final DockerClient _dockerClient,
                                                @NonNull final String _dispatcher) {
    synchronized(this) {
        if (_dockerClient.listImagesCmd().withImageNameFilter(_dispatcher).exec().isEmpty()) {
            log.info("Image '" + _dispatcher + "' not found. Please wait while pulling from main repository...");

            boolean success = false;

            try {
                success = _dockerClient.pullImageCmd(_dispatcher)
                        .exec(new PullImageResultCallback() {
                            @Override
                            public void onNext(PullResponseItem item) {
                                //System.out.println("" + item);
                                super.onNext(item);
                            }
                        })
                        .awaitCompletion(5, TimeUnit.MINUTES);
            } catch (InterruptedException _e) {
                // ignore
            }

            if (!success) {
                throw new RuntimeException("Unable to retrieve image:" + _dispatcher);
            }
        } else {
            log.debug("Image found.");
        }
    }

    return _dockerClient
            .createContainerCmd(_dispatcher)
            .withEntrypoint("/bin/sh")
            .withTty(true)
            .exec();
}
 
开发者ID:jonfryd,项目名称:tifoon,代码行数:37,代码来源:DockerExecutorPlugin.java

示例15: pullImageIfNecessary

import com.github.dockerjava.core.command.PullImageResultCallback; //导入依赖的package包/类
public void pullImageIfNecessary(String imageId) {
    if (!existsImage(imageId)) {
        log.info("Pulling Docker image {} ... please wait", imageId);
        dockerClient.pullImageCmd(imageId)
                .exec(new PullImageResultCallback()).awaitSuccess();
        log.trace("Docker image {} downloaded", imageId);
    }
}
 
开发者ID:bonigarcia,项目名称:selenium-jupiter,代码行数:9,代码来源:DockerService.java


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