本文整理汇总了Java中com.github.dockerjava.api.model.PullResponseItem类的典型用法代码示例。如果您正苦于以下问题:Java PullResponseItem类的具体用法?Java PullResponseItem怎么用?Java PullResponseItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PullResponseItem类属于com.github.dockerjava.api.model包,在下文中一共展示了PullResponseItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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 );
}
}
示例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 );
}
}
示例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.");
}
}
示例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);
}
}
示例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));
}
示例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;
}
示例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());
}
}
}
示例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);
}
}
示例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();
}
示例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());
}
示例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);
}
}
示例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());
}
示例14: onNext
import com.github.dockerjava.api.model.PullResponseItem; //导入依赖的package包/类
@Override
public void onNext(PullResponseItem item) {
this.latestItem = item;
LOGGER.debug(item.toString());
}
示例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.");
}
}