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


Java DockerException类代码示例

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


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

示例1: setUp

import com.spotify.docker.client.DockerException; //导入依赖的package包/类
@Before
public void setUp() throws com.spotify.docker.client.DockerException, InterruptedException,
    DockerCertificateException {

    dockerClient = mock(DockerClient.class);

    writer = new ByteBufferLogSteamWriter();

    streamer = new DockerStreamer(writer, dockerClient);

    testLogStream = new TestableLogStream();

    when(dockerClient
        .exec(SOME_CONTAINER_ID, "sh", "-c", streamer.getMonitorCmd(
            SOME_LOG_LOCATION))).thenReturn(
        testLogStream);
}
 
开发者ID:triforkse,项目名称:logstash-mesos,代码行数:18,代码来源:DockerStreamerTest.java

示例2: call

import com.spotify.docker.client.DockerException; //导入依赖的package包/类
@Override
public ProcessBuilder call() throws Exception {
  if (task.getTaskInfo().hasContainer() && task.getTaskInfo().getContainer().hasDocker()) {
    executorUtils.sendStatusUpdate(task.getDriver(), task.getTaskInfo(), TaskState.TASK_STARTING, String.format("Pulling image... (executor pid: %s)", executorPid), task.getLog());
    try {
      dockerUtils.pull(task.getTaskInfo().getContainer().getDocker().getImage());
    } catch (DockerException e) {
      throw new ProcessFailedException("Could not pull docker image", e);
    }
  }

  executorUtils.sendStatusUpdate(task.getDriver(), task.getTaskInfo(), TaskState.TASK_STARTING, String.format("Staging files... (executor pid: %s)", executorPid), task.getLog());

  taskArtifactFetcher = Optional.of(artifactFetcher.buildTaskFetcher(executorData, task));
  taskArtifactFetcher.get().fetchFiles();

  task.getArtifactVerifier().checkSignatures();

  ProcessBuilder processBuilder = buildProcessBuilder(task.getTaskInfo(), executorData);

  task.getTaskLogManager().setup();

  return processBuilder;
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:25,代码来源:SingularityExecutorTaskProcessBuilder.java

示例3: getInstance

import com.spotify.docker.client.DockerException; //导入依赖的package包/类
static public Dockerus getInstance() {
    if (DockerusAuto.instance == null) {
        try {
            DockerusAuto.instance = Dockerus.getInstance();
            DockerusAuto.instance.me();
        } catch (DockerCertificateException | InterruptedException | DockerException e) {
            try {
                DockerusAuto.instance = DockerusDummy.getInstance();
            } catch (DockerCertificateException e1) {
                System.err.println("LOL THIS SHOULDN'T FAIL BECAUSE FAILING IS NOT IMPLEMENTED!!!111");
                e1.printStackTrace();
            }
        }
    }
    return DockerusAuto.instance;
}
 
开发者ID:KathrynJaneway,项目名称:PBFT-JAVA,代码行数:17,代码来源:DockerusAuto.java

示例4: normalFunction

import com.spotify.docker.client.DockerException; //导入依赖的package包/类
/**
 * The row 15 to 27 from the algorithm.
 * @throws DockerException
 * @throws InterruptedException
 * @throws UnsupportedEncodingException
 * @throws DockerCertificateException
 */
public void normalFunction() throws DockerException, InterruptedException, UnsupportedEncodingException, DockerCertificateException {
    Sender sender = new Sender();
    initStore = new ArrayList();

    sender.sendMessage(new InitMessage(((int) System.currentTimeMillis()/sequencelength), DockerusAuto.getInstance().getNumber(), ToDO.getSensorValue()));  //UNixtimestampe

    if(this.leader == DockerusAuto.getInstance().getNumber()){
        if(this.initStore.size() >= DockerusAuto.getInstance().getHostnames(true).size() - (1/3)){  //TODO: (int) 1/3 == 0
            float median = (float) Median.calculateMedian(this.initStore);
            sender.sendMessage(
                    new ProposeMessage(
                            (int) System.currentTimeMillis()/sequencelength,
                            DockerusAuto.getInstance().getNumber(),
                            DockerusAuto.getInstance().getNumber(),
                            median,
                            initStore
                    )
            );
        }
        //notify soll auf timeout oder genügend nachrichten warten

    }
}
 
开发者ID:KathrynJaneway,项目名称:PBFT-JAVA,代码行数:31,代码来源:NormalCase.java

示例5: broadcast

import com.spotify.docker.client.DockerException; //导入依赖的package包/类
/**
 * Send broadcast messages in the network of registered nodes.
 * @param message String with the specific message (init, void...).
 * @throws UnsupportedEncodingException
 * @throws DockerCertificateException
 * @throws DockerException
 * @throws InterruptedException
 */
public void broadcast(String message) throws UnsupportedEncodingException, DockerCertificateException, DockerException, InterruptedException {
    List<String> otherHostnames = DockerusAuto.getInstance().getHostnames(true);
    message += "\n";
    msg = "ANSWER " + message.length() + "\n" + message;
    byte[] msgBytes = msg.getBytes("UTF-8");
    for (String nodeHost: otherHostnames){
        Boolean sent = false;
        while(!sent){
            try {
                Socket socket = new Socket(nodeHost, 4458);  //open a socket port 4458, and the nodeHost names of the other hosts
                DataOutputStream dataStream = new DataOutputStream(socket.getOutputStream()); //to send messages
                dataStream.write(msgBytes); //write the messages at the datastream
                sent = true;
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
 
开发者ID:KathrynJaneway,项目名称:PBFT-JAVA,代码行数:28,代码来源:Sender.java

示例6: test

import com.spotify.docker.client.DockerException; //导入依赖的package包/类
@Test
public void test() throws DockerCertificateException, DockerException, InterruptedException, IOException {
	String dockerHost = "https://192.168.59.103:2376";
	String certPath = "/Users/cleutonsampaio/.boot2docker/certs/boot2docker-vm";
	DockerWrapper dw = new DockerWrapper(dockerHost, certPath, "i");
	ServerAddress sa = new ServerAddress("localhost", 3001);
	Instance si = dw.up(sa,3000,
			"/Users/cleutonsampaio/Documents/projetos/dockertest",
			"signatureimage",
			"signatureserver");
	assertTrue(si != null);
	assertTrue(si.isRunning());
	assertTrue(si.getId() != null);
	boolean retorno = dw.delete(si);
	assertTrue(retorno);
	assertFalse(si.isRunning());
	assertTrue(si.getId() == null);
}
 
开发者ID:cleuton,项目名称:servkeeper,代码行数:19,代码来源:TestDockerWrapperCreateDelete.java

示例7: runContainer

import com.spotify.docker.client.DockerException; //导入依赖的package包/类
public String runContainer(ContainerConfig.Builder containerConfigBuilder, String containerName) throws DockerException {
    try {
        final ContainerConfig containerConfig = containerConfigBuilder.build();
        final ContainerCreation creation;

        creation = dockerClient.createContainer(containerConfig, containerName);

        final String id = creation.id();
        dockerClient.startContainer(id);
        return id;
    } catch (InterruptedException e) {
        logger.error("", e);
    }

    return null;
}
 
开发者ID:simpleci,项目名称:simpleci,代码行数:17,代码来源:DockerContainerManager.java

示例8: getServiceOfferings

import com.spotify.docker.client.DockerException; //导入依赖的package包/类
public List<DockerContainerElement> getServiceOfferings(IProgressMonitor monitor) throws CoreException {
	return new BehaviourRequest<List<DockerContainerElement>>("Getting available service options") { //$NON-NLS-1$
		@Override
		protected List<DockerContainerElement> doRun(DockerClient client, SubMonitor progress) throws CoreException {
			// return client.getServiceOfferings();
			try {
				List<Container> containers = client.listContainers();
				return DomainHelper.convert(containers);					
			}
			catch (DockerException | InterruptedException e) {
				e.printStackTrace();
			}
			return null;
		}
	}.run(monitor);
}
 
开发者ID:osswangxining,项目名称:dockerfoundry,代码行数:17,代码来源:DockerFoundryServerBehaviour.java

示例9: updateContainerState

import com.spotify.docker.client.DockerException; //导入依赖的package包/类
void updateContainerState() {

        // TODO: Handle state properly.

        try {
            List<Container> latestRunningContainers = getContainers();

            LOGGER.info(
                String.format("Found %d running containers", latestRunningContainers.size()));

            Map<String, String> latestRunningContainerIdAndNames = getContainerIdAndNames(
                latestRunningContainers);

            if (!latestRunningContainerIdAndNames.keySet()
                .equals(this.runningContainers.keySet())) {
                LOGGER.info("Container list changed!");

                this.runningContainers = latestRunningContainerIdAndNames;

                notifyFrameworkListener();
            }
        } catch (DockerException | InterruptedException e) {
            throw new IllegalStateException("Failed to onNewConfigsFromScheduler container states", e);
        }
    }
 
开发者ID:triforkse,项目名称:logstash-mesos,代码行数:26,代码来源:DockerClient.java

示例10: filesAreStreamedToTheExecutor

import com.spotify.docker.client.DockerException; //导入依赖的package包/类
@Test
public void filesAreStreamedToTheExecutor()
    throws DockerException, InterruptedException, IOException {

    LogStream logStream = null;

    try {

        logStream = streamer
            .startStreaming(new DockerLogPath(SOME_CONTAINER_ID, "busybox", SOME_LOG_LOCATION));

        testLogStream.outputStream.write("Hello\n".getBytes("UTF-8"));

        assertEquals(testLogStream, logStream);
        assertEquals("Hello\n", writer.getStdOutContent());
    } finally {
        if (logStream != null)
            logStream.close();
    }
}
 
开发者ID:triforkse,项目名称:logstash-mesos,代码行数:21,代码来源:DockerStreamerTest.java

示例11: listImageTags

import com.spotify.docker.client.DockerException; //导入依赖的package包/类
@Override
public Set<String> listImageTags() throws IOException {

  final Set<String> result = new HashSet<>();

  try {

    for (Image image : CollectionUtils
        .nullToEmpty(this.client.listImages())) {
      for (String tag : CollectionUtils.nullToEmpty(image.repoTags())) {
        if (tag != null) {
          result.add(tag);
        }
      }
    }
  } catch (DockerException | InterruptedException e) {
    throw new IOException(e);
  }

  return result;
}
 
开发者ID:GenomicParisCentre,项目名称:eoulsan,代码行数:22,代码来源:SpotifyDockerClient.java

示例12: pullImageIfNotExists

import com.spotify.docker.client.DockerException; //导入依赖的package包/类
@Override
public void pullImageIfNotExists() throws IOException {

  try {

    for (Image image : nullToEmpty(this.dockerClient.listImages())) {
      for (String tag : nullToEmpty(image.repoTags())) {
        if (this.dockerImage.equals(tag)) {
          return;
        }
      }
    }

    getLogger().fine("Pull Docker image: " + this.dockerImage);
    this.dockerClient.pull(this.dockerImage);
  } catch (InterruptedException | DockerException e) {
    throw new IOException(e);
  }
}
 
开发者ID:GenomicParisCentre,项目名称:eoulsan,代码行数:20,代码来源:SpotifyDockerImageInstance.java

示例13: trigger

import com.spotify.docker.client.DockerException; //导入依赖的package包/类
@Input
public void trigger() {
    if (dockerClient != null) {
        try {
            final Optional<Container> container = dockerKiller.randomlyPickOneMatchingElement(dockerClient, key, value);
            if(container.isPresent()) {
                final String containerId = container.get().id();
                dockerClient.stopContainer(containerId, secondsToWaitBeforeKilling);
                killedContainer.send(containerId);
            }
        } catch (DockerException | InterruptedException e) {
            Log.error(e.getMessage());
        }
    } else {
        Log.info("No action because of null docker client");
    }
}
 
开发者ID:kevoree,项目名称:kevoree-library,代码行数:18,代码来源:DockerKiller.java

示例14: randomlyPickOneMatchingElement

import com.spotify.docker.client.DockerException; //导入依赖的package包/类
public Optional<Container> randomlyPickOneMatchingElement(final DefaultDockerClient dockerClient, final String key, final String value) throws DockerException, InterruptedException {
    final List<Container> containers = dockerClient.listContainers();

    final List<Container> collect = new ArrayList<>();
    for (Container container : containers) {
        final ContainerInfo containerInfo = dockerClient.inspectContainer(container.id());
        boolean res;
        res = containsKeyAndValue(containerInfo.config().env(), key, value);
        if (res) {
            collect.add(container);
        }

    }
    final Optional<Container> ret;
    if (collect.isEmpty()) {
        ret = Optional.empty();
    } else {
        ret = Optional.of(collect.get(random.nextInt(collect.size())));
    }
    return ret;
}
 
开发者ID:kevoree,项目名称:kevoree-library,代码行数:22,代码来源:DockerKillerService.java

示例15: destroy

import com.spotify.docker.client.DockerException; //导入依赖的package包/类
@Override
public void destroy(final RuntimeId runtimeId) {
    try {
        LOG.info("Killing Container: " + runtimeId.getId());
        docker.getDockerClient(runtimeId.getProviderId()).killContainer(runtimeId.getId());
        LOG.info("Removing Container: " + runtimeId.getId());
        docker.getDockerClient(runtimeId.getProviderId()).removeContainer(runtimeId.getId());
        runtimeRegistry.deregisterRuntime(runtimeId);
    } catch (DockerException | InterruptedException ex) {
        LOG.debug(ex.getMessage(),
                  ex);
        try {
            // Trying to remove the container if it cannot be killed
            LOG.info("Attempting to Remove Container without Killing: " + runtimeId.getId());
            docker.getDockerClient(runtimeId.getProviderId()).removeContainer(runtimeId.getId());
            runtimeRegistry.deregisterRuntime(runtimeId);
        } catch (DockerException | InterruptedException ex2) {
            LOG.error(ex.getMessage(),
                      ex2);
            throw new ProvisioningException("Error destroying Docker Runtime: " + ex.getMessage(),
                                            ex2);
        }
    }
}
 
开发者ID:kiegroup,项目名称:kie-wb-common,代码行数:25,代码来源:DockerRuntimeExecExecutor.java


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