本文整理汇总了Java中com.github.dockerjava.api.exception.NotFoundException类的典型用法代码示例。如果您正苦于以下问题:Java NotFoundException类的具体用法?Java NotFoundException怎么用?Java NotFoundException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NotFoundException类属于com.github.dockerjava.api.exception包,在下文中一共展示了NotFoundException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: destroyInstance
import com.github.dockerjava.api.exception.NotFoundException; //导入依赖的package包/类
private ServiceInstance destroyInstance(ServiceInstance i, DockerClient client) {
if(i.getContainerId() != null) {
RemoveContainerCmd cmd = client.removeContainerCmd(i.getContainerId()).withForce(true);
try {
cmd.exec();
return i.withStatus(Status.TERMINATED);
} catch (NotFoundException e) {
logger.warning("No container with id " + i.getContainerId() + " found");
return i.withStatus(Status.TERMINATION_FAILED)
.withStatusDetails(e.getMessage());
}
} else {
return i.withStatus(Status.TERMINATION_FAILED)
.withStatusDetails("No container id found.");
}
}
开发者ID:qzagarese,项目名称:dockerunit,代码行数:18,代码来源:DefaultServiceBuilder.java
示例2: deleteContainer
import com.github.dockerjava.api.exception.NotFoundException; //导入依赖的package包/类
@Override
public void deleteContainer(ContainerName containerName) {
try {
dockerImageGC.ifPresent(imageGC -> {
Optional<InspectContainerResponse> inspectResponse = inspectContainerCmd(containerName.asString());
inspectResponse.ifPresent(response -> imageGC.updateLastUsedTimeFor(response.getImageId()));
});
dockerClient.removeContainerCmd(containerName.asString()).exec();
} catch (NotFoundException ignored) {
// If container doesn't exist ignore
} catch (RuntimeException e) {
numberOfDockerDaemonFails.add();
throw new DockerException("Failed to delete container '" + containerName.asString() + "'", e);
}
}
开发者ID:vespa-engine,项目名称:vespa,代码行数:17,代码来源:DockerImpl.java
示例3: pullImageAsyncIfNeededSuccessfully
import com.github.dockerjava.api.exception.NotFoundException; //导入依赖的package包/类
@Test
@SuppressWarnings({"unchecked", "rawtypes"})
public void pullImageAsyncIfNeededSuccessfully() {
final DockerImage image = new DockerImage("test:1.2.3");
InspectImageResponse inspectImageResponse = mock(InspectImageResponse.class);
when(inspectImageResponse.getId()).thenReturn(image.asString());
InspectImageCmd imageInspectCmd = mock(InspectImageCmd.class);
when(imageInspectCmd.exec())
.thenThrow(new NotFoundException("Image not found"))
.thenReturn(inspectImageResponse);
// Array to make it final
ArgumentCaptor<ResultCallback> resultCallback = ArgumentCaptor.forClass(ResultCallback.class);
PullImageCmd pullImageCmd = mock(PullImageCmd.class);
when(pullImageCmd.exec(resultCallback.capture())).thenReturn(null);
final DockerClient dockerClient = mock(DockerClient.class);
when(dockerClient.inspectImageCmd(image.asString())).thenReturn(imageInspectCmd);
when(dockerClient.pullImageCmd(eq(image.asString()))).thenReturn(pullImageCmd);
final DockerImpl docker = new DockerImpl(dockerClient);
docker.setMetrics(new MetricReceiverWrapper(MetricReceiver.nullImplementation));
assertTrue("Should return true, we just scheduled the pull", docker.pullImageAsyncIfNeeded(image));
assertTrue("Should return true, the pull i still ongoing", docker.pullImageAsyncIfNeeded(image));
assertTrue(docker.imageIsDownloaded(image));
resultCallback.getValue().onComplete();
assertFalse(docker.pullImageAsyncIfNeeded(image));
}
开发者ID:vespa-engine,项目名称:vespa,代码行数:32,代码来源:DockerImplTest.java
示例4: pullImageAsyncIfNeededWithError
import com.github.dockerjava.api.exception.NotFoundException; //导入依赖的package包/类
@Test
@SuppressWarnings({"unchecked", "rawtypes"})
public void pullImageAsyncIfNeededWithError() {
final DockerImage image = new DockerImage("test:1.2.3");
InspectImageCmd imageInspectCmd = mock(InspectImageCmd.class);
when(imageInspectCmd.exec()).thenThrow(new NotFoundException("Image not found"));
// Array to make it final
ArgumentCaptor<ResultCallback> resultCallback = ArgumentCaptor.forClass(ResultCallback.class);
PullImageCmd pullImageCmd = mock(PullImageCmd.class);
when(pullImageCmd.exec(resultCallback.capture())).thenReturn(null);
final DockerClient dockerClient = mock(DockerClient.class);
when(dockerClient.inspectImageCmd(image.asString())).thenReturn(imageInspectCmd);
when(dockerClient.pullImageCmd(eq(image.asString()))).thenReturn(pullImageCmd);
final DockerImpl docker = new DockerImpl(dockerClient);
docker.setMetrics(new MetricReceiverWrapper(MetricReceiver.nullImplementation));
assertTrue("Should return true, we just scheduled the pull", docker.pullImageAsyncIfNeeded(image));
assertTrue("Should return true, the pull i still ongoing", docker.pullImageAsyncIfNeeded(image));
try {
resultCallback.getValue().onComplete();
} catch (Exception ignored) { }
assertFalse(docker.imageIsDownloaded(image));
assertTrue("Should return true, new pull scheduled", docker.pullImageAsyncIfNeeded(image));
}
开发者ID:vespa-engine,项目名称:vespa,代码行数:30,代码来源:DockerImplTest.java
示例5: runInsideDocker
import com.github.dockerjava.api.exception.NotFoundException; //导入依赖的package包/类
private <T> T runInsideDocker(DockerClient client, Consumer<CreateContainerCmd> createContainerCmdConsumer, BiFunction<DockerClient, String, T> block) {
checkAndPullImage(client, TINY_IMAGE);
CreateContainerCmd createContainerCmd = client.createContainerCmd(TINY_IMAGE);
createContainerCmdConsumer.accept(createContainerCmd);
String id = createContainerCmd.exec().getId();
try {
client.startContainerCmd(id).exec();
return block.apply(client, id);
} finally {
try {
client.removeContainerCmd(id).withRemoveVolumes(true).withForce(true).exec();
} catch (NotFoundException | InternalServerErrorException ignored) {
log.debug("", ignored);
}
}
}
开发者ID:testcontainers,项目名称:testcontainers-java,代码行数:18,代码来源:DockerClientFactory.java
示例6: filter
import com.github.dockerjava.api.exception.NotFoundException; //导入依赖的package包/类
@Override
public void filter(ClientRequestContext requestContext, ClientResponseContext responseContext) throws IOException {
int status = responseContext.getStatus();
switch (status) {
case 200:
case 201:
case 204:
return;
case 304:
throw new NotModifiedException(getBodyAsMessage(responseContext));
case 400:
throw new BadRequestException(getBodyAsMessage(responseContext));
case 401:
throw new UnauthorizedException(getBodyAsMessage(responseContext));
case 404:
throw new NotFoundException(getBodyAsMessage(responseContext));
case 406:
throw new NotAcceptableException(getBodyAsMessage(responseContext));
case 409:
throw new ConflictException(getBodyAsMessage(responseContext));
case 500:
throw new InternalServerErrorException(getBodyAsMessage(responseContext));
default:
throw new DockerException(getBodyAsMessage(responseContext), status);
}
}
开发者ID:docker-java,项目名称:docker-java,代码行数:27,代码来源:ResponseStatusExceptionFilter.java
示例7: before
import com.github.dockerjava.api.exception.NotFoundException; //导入依赖的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
示例8: removeVolume
import com.github.dockerjava.api.exception.NotFoundException; //导入依赖的package包/类
@Test(expected = NotFoundException.class)
public void removeVolume() throws DockerException {
String volumeName = "volume1" + dockerRule.getKind();
CreateVolumeResponse createVolumeResponse = dockerRule.getClient().createVolumeCmd()
.withName(volumeName)
.withDriver("local").exec();
assertThat(createVolumeResponse.getName(), equalTo(volumeName));
assertThat(createVolumeResponse.getDriver(), equalTo("local"));
assertThat(createVolumeResponse.getMountpoint(), containsString(volumeName));
dockerRule.getClient().removeVolumeCmd(volumeName).exec();
dockerRule.getClient().inspectVolumeCmd(volumeName).exec();
}
开发者ID:docker-java,项目名称:docker-java,代码行数:18,代码来源:RemoveVolumeCmdIT.java
示例9: execStartWithNonExistentUser
import com.github.dockerjava.api.exception.NotFoundException; //导入依赖的package包/类
@Test(expected = NotFoundException.class)
public void execStartWithNonExistentUser() throws Exception {
String containerName = "generated_" + new SecureRandom().nextInt();
CreateContainerResponse container = dockerRule.getClient().createContainerCmd("busybox").withCmd("sleep", "9999")
.withName(containerName).exec();
LOG.info("Created container {}", container.toString());
assertThat(container.getId(), not(isEmptyString()));
dockerRule.getClient().startContainerCmd(container.getId()).exec();
ExecCreateCmdResponse execCreateCmdResponse = dockerRule.getClient().execCreateCmd(container.getId())
.withAttachStdout(true).withCmd("touch", "/execStartTest.log").withUser("NonExistentUser").exec();
dockerRule.getClient().execStartCmd(execCreateCmdResponse.getId()).withDetach(false).withTty(true)
.exec(new ExecStartResultCallback(System.out, System.err)).awaitCompletion();
dockerRule.getClient().copyArchiveFromContainerCmd(container.getId(), "/execStartTest.log").exec();
}
开发者ID:docker-java,项目名称:docker-java,代码行数:19,代码来源:ExecStartCmdIT.java
示例10: close
import com.github.dockerjava.api.exception.NotFoundException; //导入依赖的package包/类
@Override
public void close() throws Exception {
if (containerId != null) {
LOGGER.info("removing container {}", containerId);
try {
client.removeContainerCmd(containerId).withForce(true) // stop too
.exec();
} catch (NotFoundException | InternalServerErrorException ignored) {
LOGGER.info("ignoring {}", ignored.getMessage());
}
containerId = null;
}
if (repository != null) {
LOGGER.info("removing repository {}", repository);
try {
client.removeImageCmd(repository).withForce(true).exec();
} catch (NotFoundException | InternalServerErrorException e) {
LOGGER.info("ignoring {}", e.getMessage());
}
repository = null;
}
}
开发者ID:docker-java,项目名称:docker-java,代码行数:25,代码来源:DockerfileFixture.java
示例11: pullImage
import com.github.dockerjava.api.exception.NotFoundException; //导入依赖的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
示例12: isRunning
import com.github.dockerjava.api.exception.NotFoundException; //导入依赖的package包/类
public static boolean isRunning(DockerClient docker, Instance instance) {
Value id = instance.findMetaDataByID(ModelHelper.DOCKER_ID);
if (id != null) {
try {
InspectContainerResponse containerRes = docker.inspectContainerCmd(id.getValue()).exec();
return containerRes.getState().getRunning();
} catch (NotFoundException ignore) {
return false;
}
} else {
return docker.listContainersCmd().exec()
.stream()
.filter(container -> container.getNames()[0].equals("/"+instance.getName()))
.findFirst()
.map(container -> container.getStatus().toLowerCase().startsWith("up"))
.orElse(false);
}
}
开发者ID:kevoree,项目名称:kevoree-library,代码行数:19,代码来源:ModelHelper.java
示例13: existsImage
import com.github.dockerjava.api.exception.NotFoundException; //导入依赖的package包/类
public boolean existsImage(String imageId) {
boolean exists = true;
try {
dockerClient.inspectImageCmd(imageId).exec();
log.trace("Docker image {} already exists", imageId);
} catch (NotFoundException e) {
log.trace("Image {} does not exist", imageId);
exists = false;
}
return exists;
}
开发者ID:bonigarcia,项目名称:selenium-jupiter,代码行数:13,代码来源:DockerService.java
示例14: existsContainer
import com.github.dockerjava.api.exception.NotFoundException; //导入依赖的package包/类
public boolean existsContainer(String containerName) {
boolean exists = true;
try {
dockerClient.inspectContainerCmd(containerName).exec();
log.trace("Container {} already exist", containerName);
} catch (NotFoundException e) {
log.trace("Container {} does not exist", containerName);
exists = false;
}
return exists;
}
开发者ID:bonigarcia,项目名称:selenium-jupiter,代码行数:13,代码来源:DockerService.java
示例15: pullImageIfRequired
import com.github.dockerjava.api.exception.NotFoundException; //导入依赖的package包/类
private void pullImageIfRequired(final DockerComponent dockerC) {
val image = dockerC.image();
val tag = dockerC.tag();
if (dockerC.isForcePull() || dockerCommands.isImageAvailable(image, tag)) {
log.info("Pulling image {}:{}", image, tag);
try {
dockerCommands.pullImage(image, tag);
} catch (final NotFoundException e) {
log.warn("Cannot pull image: {}", e.getMessage());
}
}
}
开发者ID:fabzo,项目名称:kraken,代码行数:14,代码来源:DockerLifecycleHandler.java
示例16: ensureImageExists
import com.github.dockerjava.api.exception.NotFoundException; //导入依赖的package包/类
private void ensureImageExists(String wantedImage) {
try {
dockerClient.inspectImageCmd(wantedImage).exec();
} catch (NotFoundException e) {
dockerClient.pullImageCmd(wantedImage).exec(new PullImageResultCallback()).awaitSuccess();
}
}
开发者ID:FaustXVI,项目名称:junit5-docker,代码行数:8,代码来源:DefaultDockerClient.java
示例17: ensureContainerIsNotPresent
import com.github.dockerjava.api.exception.NotFoundException; //导入依赖的package包/类
@BeforeEach
public void ensureContainerIsNotPresent() {
try {
String imageToRemove = dockerClient.inspectImageCmd(WANTED_IMAGE).exec().getId();
dockerClient.removeImageCmd(imageToRemove).exec();
} catch (NotFoundException e) {
// not found, no problems
}
}
开发者ID:FaustXVI,项目名称:junit5-docker,代码行数:10,代码来源:DefaultDockerClientIT.java
示例18: shouldRemoveTheContainer
import com.github.dockerjava.api.exception.NotFoundException; //导入依赖的package包/类
@Test
@DisplayName("should remove the container")
public void shouldRemoveTheContainer() {
defaultDockerClient.stopAndRemoveContainer(containerId);
assertThat(dockerClient.listContainersCmd().exec()).hasSize(existingContainers.size());
assertThatExceptionOfType(NotFoundException.class)
.isThrownBy(() -> dockerClient.inspectContainerCmd(containerId).exec());
}
开发者ID:FaustXVI,项目名称:junit5-docker,代码行数:9,代码来源:DefaultDockerClientIT.java
示例19: inspectContainerCmd
import com.github.dockerjava.api.exception.NotFoundException; //导入依赖的package包/类
private Optional<InspectContainerResponse> inspectContainerCmd(String container) {
try {
return Optional.of(dockerClient.inspectContainerCmd(container).exec());
} catch (NotFoundException ignored) {
return Optional.empty();
} catch (RuntimeException e) {
numberOfDockerDaemonFails.add();
throw new DockerException("Failed to get info for container '" + container + "'", e);
}
}
开发者ID:vespa-engine,项目名称:vespa,代码行数:11,代码来源:DockerImpl.java
示例20: getContainerStats
import com.github.dockerjava.api.exception.NotFoundException; //导入依赖的package包/类
@Override
public Optional<ContainerStats> getContainerStats(ContainerName containerName) {
try {
DockerStatsCallback statsCallback = dockerClient.statsCmd(containerName.asString()).exec(new DockerStatsCallback());
statsCallback.awaitCompletion(5, TimeUnit.SECONDS);
return statsCallback.stats.map(stats -> new ContainerStatsImpl(
stats.getNetworks(), stats.getCpuStats(), stats.getMemoryStats(), stats.getBlkioStats()));
} catch (NotFoundException ignored) {
return Optional.empty();
} catch (RuntimeException | InterruptedException e) {
numberOfDockerDaemonFails.add();
throw new DockerException("Failed to get stats for container '" + containerName.asString() + "'", e);
}
}
开发者ID:vespa-engine,项目名称:vespa,代码行数:16,代码来源:DockerImpl.java
注:本文中的com.github.dockerjava.api.exception.NotFoundException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论