本文整理汇总了Java中com.github.dockerjava.api.model.PullResponseItem类的典型用法代码示例。如果您正苦于以下问题:Java PullResponseItem类的具体用法?Java PullResponseItem怎么用?Java PullResponseItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PullResponseItem类属于com.github.dockerjava.api.model包,在下文中一共展示了PullResponseItem类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: call
import com.github.dockerjava.api.model.PullResponseItem; //导入依赖的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
示例2: onNext
import com.github.dockerjava.api.model.PullResponseItem; //导入依赖的package包/类
@Override
public void onNext ( PullResponseItem item ) {
logger.debug( "response: {} ", item );
String progress = item.getStatus();
if ( item.getErrorDetail() != null ) {
progress = item.getErrorDetail().getMessage();
setFoundPullError( true );
} else if ( item.getProgressDetail() != null && item.getProgressDetail().getCurrent() != null ) {
progress += "..." + Math.round( item.getProgressDetail().getCurrent() * 100 / item.getProgressDetail().getTotal() ) + "%";
}
if ( get_pullOutputManager() != null ) {
get_pullOutputManager().print( progress );
}
if ( lastResults.length() < MAX_PROGRESS ) {
// System.out.println( progress );
lastResults.append( "\n" + progress );
} else {
logger.warn( "MAX progress messages exceeded: {}", MAX_PROGRESS );
}
}
开发者ID:csap-platform,项目名称:csap-core,代码行数:27,代码来源:DockerHelper.java
示例3: onNext
import com.github.dockerjava.api.model.PullResponseItem; //导入依赖的package包/类
@Override
public void onNext ( PullResponseItem item ) {
logger.debug( "response: {} ", item );
String progress = item.getStatus();
if ( item.getProgressDetail() != null && item.getProgressDetail().getCurrent() != null ) {
progress += "..." + Math.round( item.getProgressDetail().getCurrent() * 100 / item.getProgressDetail().getTotal() ) + "%";
}
if ( item.getErrorDetail() != null ) {
System.err.println( item.getErrorDetail().getMessage() );
} else {
System.out.println( progress );
}
}
开发者ID:csap-platform,项目名称:csap-core,代码行数:19,代码来源:Docker_Java.java
示例4: ensureImage
import com.github.dockerjava.api.model.PullResponseItem; //导入依赖的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
示例5: pull
import com.github.dockerjava.api.model.PullResponseItem; //导入依赖的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
示例6: callbackNotifier
import com.github.dockerjava.api.model.PullResponseItem; //导入依赖的package包/类
@Override
protected AbstractCallbackNotifier<PullResponseItem> callbackNotifier(PullImageCmd command,
ResultCallback<PullResponseItem> resultCallback) {
WebTarget webResource = getBaseResource().path("/images/create").queryParam("tag", command.getTag())
.queryParam("fromImage", command.getRepository()).queryParam("registry", command.getRegistry());
LOGGER.trace("POST: {}", webResource);
Builder builder = resourceWithOptionalAuthConfig(command.getAuthConfig(), webResource.request()).accept(
MediaType.APPLICATION_OCTET_STREAM_TYPE);
return new POSTCallbackNotifier<PullResponseItem>(new JsonStreamProcessor<PullResponseItem>(
PullResponseItem.class), resultCallback, builder, entity(null, MediaType.APPLICATION_JSON));
}
开发者ID:docker-java,项目名称:docker-java,代码行数:15,代码来源:PullImageCmdExec.java
示例7: execute0
import com.github.dockerjava.api.model.PullResponseItem; //导入依赖的package包/类
@Override
protected Void execute0(PullImageCmd command, ResultCallback<PullResponseItem> resultCallback) {
WebTarget webResource = getBaseResource().path("/images/create").queryParam("tag", command.getTag())
.queryParam("fromImage", command.getRepository()).queryParam("registry", command.getRegistry());
LOGGER.trace("POST: {}", webResource);
resourceWithOptionalAuthConfig(command.getAuthConfig(), webResource.request()).accept(MediaType.APPLICATION_OCTET_STREAM).post(
null, new TypeReference<PullResponseItem>() {
}, resultCallback);
return null;
}
开发者ID:docker-java,项目名称:docker-java,代码行数:14,代码来源:PullImageCmdExec.java
示例8: checkDockerSwarmPullSuccessful
import com.github.dockerjava.api.model.PullResponseItem; //导入依赖的package包/类
private void checkDockerSwarmPullSuccessful() {
if (results.isEmpty()) {
throw new DockerClientException("Could not pull image through Docker Swarm");
} else {
boolean pullFailed = false;
StringBuilder sb = new StringBuilder();
for (PullResponseItem pullResponseItem : results.values()) {
if (!pullResponseItem.isPullSuccessIndicated()) {
pullFailed = true;
sb.append("[" + pullResponseItem.getId() + ":" + messageFromPullResult(pullResponseItem) + "]");
}
}
if (pullFailed) {
throw new DockerClientException("Could not pull image: " + sb.toString());
}
}
}
开发者ID:docker-java,项目名称:docker-java,代码行数:20,代码来源:PullImageResultCallback.java
示例9: pullImage
import com.github.dockerjava.api.model.PullResponseItem; //导入依赖的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
示例10: createContainer
import com.github.dockerjava.api.model.PullResponseItem; //导入依赖的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
示例11: onNext
import com.github.dockerjava.api.model.PullResponseItem; //导入依赖的package包/类
@Override
public void onNext(PullResponseItem item) {
// only do it once
if (results == null && latestItem == null) {
checkForDockerSwarmResponse(item);
}
if (isSwarm) {
handleDockerSwarmResponse(item);
} else {
handleDockerClientResponse(item);
}
LOGGER.debug(item.toString());
}
开发者ID:docker-java,项目名称:docker-java,代码行数:16,代码来源:PullImageResultCallback.java
示例12: handleDockerSwarmResponse
import com.github.dockerjava.api.model.PullResponseItem; //导入依赖的package包/类
private void handleDockerSwarmResponse(final PullResponseItem item) {
if (results == null) {
results = new HashMap<>();
}
// Swarm terminates a pull sometimes with an empty line.
// Therefore keep first success message
PullResponseItem currentItem = results.get(item.getId());
if (currentItem == null || !currentItem.isPullSuccessIndicated()) {
results.put(item.getId(), item);
}
}
开发者ID:docker-java,项目名称:docker-java,代码行数:13,代码来源:PullImageResultCallback.java
示例13: processEmptyJson
import com.github.dockerjava.api.model.PullResponseItem; //导入依赖的package包/类
@Test
public void processEmptyJson() throws Exception {
InputStream response = new ByteArrayInputStream("{}".getBytes());
JsonStreamProcessor<PullResponseItem> jsonStreamProcessor = new JsonStreamProcessor<PullResponseItem>(PullResponseItem.class);
final List<Boolean> completed = new ArrayList<Boolean>();
jsonStreamProcessor.processResponseStream(response, new ResultCallback<PullResponseItem>() {
@Override
public void close() throws IOException {
}
@Override
public void onStart(Closeable closeable) {
}
@Override
public void onNext(PullResponseItem object) {
assertFalse("onNext called for empty json", true);
}
@Override
public void onError(Throwable throwable) {
}
@Override
public void onComplete() {
completed.add(true);
}
});
assertFalse("Stream processing not completed", completed.isEmpty());
}
开发者ID:docker-java,项目名称:docker-java,代码行数:37,代码来源:JsonStreamProcessorTest.java
示例14: onNext
import com.github.dockerjava.api.model.PullResponseItem; //导入依赖的package包/类
@Override
public void onNext(PullResponseItem item) {
this.latestItem = item;
LOGGER.debug(item.toString());
}
开发者ID:fabzo,项目名称:kraken,代码行数:6,代码来源:NoLogPullImageResultCallback.java
示例15: checkForDockerSwarmResponse
import com.github.dockerjava.api.model.PullResponseItem; //导入依赖的package包/类
private void checkForDockerSwarmResponse(PullResponseItem item) {
if (item.getStatus().matches("Pulling\\s.+\\.{3}$")) {
isSwarm = true;
LOGGER.debug("Communicating with Docker Swarm.");
}
}
开发者ID:docker-java,项目名称:docker-java,代码行数:7,代码来源:PullImageResultCallback.java
示例16: handleDockerClientResponse
import com.github.dockerjava.api.model.PullResponseItem; //导入依赖的package包/类
private void handleDockerClientResponse(PullResponseItem item) {
latestItem = item;
}
开发者ID:docker-java,项目名称:docker-java,代码行数:4,代码来源:PullImageResultCallback.java
示例17: messageFromPullResult
import com.github.dockerjava.api.model.PullResponseItem; //导入依赖的package包/类
private String messageFromPullResult(PullResponseItem pullResponseItem) {
return (pullResponseItem.getError() != null) ? pullResponseItem.getError() : pullResponseItem.getStatus();
}
开发者ID:docker-java,项目名称:docker-java,代码行数:4,代码来源:PullImageResultCallback.java
示例18: exec
import com.github.dockerjava.api.model.PullResponseItem; //导入依赖的package包/类
public Void exec(PullImageCmd command, ResultCallback<PullResponseItem> resultCallback) {
return null;
}
开发者ID:docker-java,项目名称:docker-java,代码行数:4,代码来源:PullImageCmdIT.java
注:本文中的com.github.dockerjava.api.model.PullResponseItem类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论