Search in sources :

Example 6 with DockerException

use of com.spotify.docker.client.exceptions.DockerException in project opennms by OpenNMS.

the class SyslogKafkaElasticsearch5OutageIT method getEs5Address.

protected InetSocketAddress getEs5Address() {
    try {
        // Fetch an up-to-date ContainerInfo for the ELASTICSEARCH_5 container
        final DockerClient docker = ((AbstractTestEnvironment) testEnvironment).getDockerClient();
        final String id = testEnvironment.getContainerInfo(ContainerAlias.ELASTICSEARCH_5).id();
        ContainerInfo info = docker.inspectContainer(id);
        return testEnvironment.getServiceAddress(info, 9200, "tcp");
    } catch (DockerException | InterruptedException e) {
        LOG.error("Unexpected exception trying to fetch Elassticsearch port", e);
        return null;
    }
}
Also used : DockerException(com.spotify.docker.client.exceptions.DockerException) DockerClient(com.spotify.docker.client.DockerClient) AbstractTestEnvironment(org.opennms.test.system.api.AbstractTestEnvironment) ContainerInfo(com.spotify.docker.client.messages.ContainerInfo)

Example 7 with DockerException

use of com.spotify.docker.client.exceptions.DockerException in project opennms by OpenNMS.

the class SyslogKafkaElasticsearchBufferingIT method stopContainer.

private void stopContainer(ContainerAlias alias) {
    final DockerClient docker = ((AbstractTestEnvironment) testEnvironment).getDockerClient();
    final String id = testEnvironment.getContainerInfo(alias).id();
    try {
        LOG.info("Stopping container: {} -> {}", alias, id);
        docker.stopContainer(id, 60);
        LOG.info("Container stopped: {} -> {}", alias, id);
    } catch (DockerException | InterruptedException e) {
        LOG.warn("Unexpected exception while stopping container {}", id, e);
    }
}
Also used : DockerException(com.spotify.docker.client.exceptions.DockerException) DockerClient(com.spotify.docker.client.DockerClient) AbstractTestEnvironment(org.opennms.test.system.api.AbstractTestEnvironment)

Example 8 with DockerException

use of com.spotify.docker.client.exceptions.DockerException in project opennms by OpenNMS.

the class SyslogKafkaElasticsearchBufferingIT method startContainer.

private void startContainer(ContainerAlias alias) {
    final DockerClient docker = ((AbstractTestEnvironment) testEnvironment).getDockerClient();
    final String id = testEnvironment.getContainerInfo(alias).id();
    try {
        LOG.info("Starting container: {} -> {}", alias, id);
        docker.startContainer(id);
        LOG.info("Container started: {} -> {}", alias, id);
    } catch (DockerException | InterruptedException e) {
        LOG.warn("Unexpected exception while starting container {}", id, e);
    }
}
Also used : DockerException(com.spotify.docker.client.exceptions.DockerException) DockerClient(com.spotify.docker.client.DockerClient) AbstractTestEnvironment(org.opennms.test.system.api.AbstractTestEnvironment)

Example 9 with DockerException

use of com.spotify.docker.client.exceptions.DockerException in project opennms by OpenNMS.

the class SyslogKafkaElasticsearchBufferingIT method getServiceAddress.

protected static InetSocketAddress getServiceAddress(AbstractTestEnvironment env, ContainerAlias alias, int port, String protocol) {
    try {
        // Fetch an up-to-date ContainerInfo for the ELASTICSEARCH_5 container
        final DockerClient docker = env.getDockerClient();
        final String id = env.getContainerInfo(alias).id();
        ContainerInfo info = docker.inspectContainer(id);
        return env.getServiceAddress(info, port, protocol);
    } catch (DockerException | InterruptedException e) {
        LOG.error("Unexpected exception trying to fetch Elassticsearch port", e);
        return null;
    }
}
Also used : DockerException(com.spotify.docker.client.exceptions.DockerException) DockerClient(com.spotify.docker.client.DockerClient) ContainerInfo(com.spotify.docker.client.messages.ContainerInfo)

Aggregations

DockerException (com.spotify.docker.client.exceptions.DockerException)9 DockerClient (com.spotify.docker.client.DockerClient)6 AbstractTestEnvironment (org.opennms.test.system.api.AbstractTestEnvironment)4 ImageNotFoundException (com.spotify.docker.client.exceptions.ImageNotFoundException)2 ContainerConfig (com.spotify.docker.client.messages.ContainerConfig)2 ContainerCreation (com.spotify.docker.client.messages.ContainerCreation)2 ContainerInfo (com.spotify.docker.client.messages.ContainerInfo)2 HostConfig (com.spotify.docker.client.messages.HostConfig)2 Stopwatch (com.google.common.base.Stopwatch)1 ImmutableList (com.google.common.collect.ImmutableList)1 Service (com.google.common.util.concurrent.Service)1 DefaultDockerClient (com.spotify.docker.client.DefaultDockerClient)1 ContainerNotFoundException (com.spotify.docker.client.exceptions.ContainerNotFoundException)1 DockerRequestException (com.spotify.docker.client.exceptions.DockerRequestException)1 DockerTimeoutException (com.spotify.docker.client.exceptions.DockerTimeoutException)1 ImagePullFailedException (com.spotify.docker.client.exceptions.ImagePullFailedException)1 Container (com.spotify.docker.client.messages.Container)1 ContainerExit (com.spotify.docker.client.messages.ContainerExit)1 HeliosClient (com.spotify.helios.client.HeliosClient)1 IOException (java.io.IOException)1