Search in sources :

Example 11 with NonSwarmNodeException

use of com.spotify.docker.client.exceptions.NonSwarmNodeException in project docker-client by spotify.

the class DefaultDockerClient method updateNode.

@Override
public void updateNode(final String nodeId, final Long version, final NodeSpec nodeSpec) throws DockerException, InterruptedException {
    assertApiVersionIsAbove("1.24");
    WebTarget resource = resource().path("nodes").path(nodeId).path("update").queryParam("version", version);
    try {
        request(POST, String.class, resource, resource.request(APPLICATION_JSON_TYPE), Entity.json(nodeSpec));
    } catch (DockerRequestException e) {
        switch(e.status()) {
            case 404:
                throw new NodeNotFoundException(nodeId);
            case 503:
                throw new NonSwarmNodeException("Node " + nodeId + " is not a swarm node", e);
            default:
                throw e;
        }
    }
}
Also used : NodeNotFoundException(com.spotify.docker.client.exceptions.NodeNotFoundException) DockerRequestException(com.spotify.docker.client.exceptions.DockerRequestException) WebTarget(javax.ws.rs.client.WebTarget) NonSwarmNodeException(com.spotify.docker.client.exceptions.NonSwarmNodeException)

Aggregations

DockerRequestException (com.spotify.docker.client.exceptions.DockerRequestException)11 NonSwarmNodeException (com.spotify.docker.client.exceptions.NonSwarmNodeException)11 WebTarget (javax.ws.rs.client.WebTarget)11 NodeNotFoundException (com.spotify.docker.client.exceptions.NodeNotFoundException)7 ContainerNotFoundException (com.spotify.docker.client.exceptions.ContainerNotFoundException)4 ExecNotFoundException (com.spotify.docker.client.exceptions.ExecNotFoundException)4 ImageNotFoundException (com.spotify.docker.client.exceptions.ImageNotFoundException)4 NetworkNotFoundException (com.spotify.docker.client.exceptions.NetworkNotFoundException)4 NotFoundException (com.spotify.docker.client.exceptions.NotFoundException)4 ServiceNotFoundException (com.spotify.docker.client.exceptions.ServiceNotFoundException)4 TaskNotFoundException (com.spotify.docker.client.exceptions.TaskNotFoundException)4 VolumeNotFoundException (com.spotify.docker.client.exceptions.VolumeNotFoundException)4 ConflictException (com.spotify.docker.client.exceptions.ConflictException)2 ContainerRenameConflictException (com.spotify.docker.client.exceptions.ContainerRenameConflictException)2 ExecCreateConflictException (com.spotify.docker.client.exceptions.ExecCreateConflictException)2 ExecStartConflictException (com.spotify.docker.client.exceptions.ExecStartConflictException)2 Maps.newHashMap (com.google.common.collect.Maps.newHashMap)1 VolumeList (com.spotify.docker.client.messages.VolumeList)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1