forked from docker-java/docker-java
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathStopContainerCmdImpl.java
More file actions
68 lines (57 loc) · 2 KB
/
Copy pathStopContainerCmdImpl.java
File metadata and controls
68 lines (57 loc) · 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package com.github.dockerjava.core.command;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import com.github.dockerjava.api.command.StopContainerCmd;
import com.github.dockerjava.api.command.StopContainerSpec;
import com.github.dockerjava.api.exception.NotFoundException;
import com.github.dockerjava.api.exception.NotModifiedException;
/**
* Stop a running container.
*
* @param containerId
* - Id of the container
* @param timeout
* - Timeout in seconds before killing the container. Defaults to 10 seconds.
*
*/
public class StopContainerCmdImpl extends AbstrDockerCmd<StopContainerCmd, Void> implements StopContainerCmd {
private StopContainerSpec spec;
public StopContainerCmdImpl(StopContainerCmd.Exec exec, String containerId) {
this(exec, StopContainerSpec.of(containerId));
}
StopContainerCmdImpl(StopContainerCmd.Exec exec, StopContainerSpec spec) {
super(exec);
this.spec = spec;
}
@Override
public String getContainerId() {
return spec.getContainerId();
}
@Override
public Integer getTimeout() {
return spec.getTimeout();
}
@Override
public StopContainerCmd withContainerId(String containerId) {
checkNotNull(containerId, "containerId was not specified");
this.spec = spec.withContainerId(containerId);
return this;
}
@Override
public StopContainerCmd withTimeout(Integer timeout) {
checkNotNull(timeout, "timeout was not specified");
checkArgument(timeout >= 0, "timeout must be greater or equal 0");
this.spec = spec.withTimeout(timeout);
return this;
}
/**
* @throws NotFoundException
* No such container
* @throws NotModifiedException
* Container already stopped
*/
@Override
public Void exec() throws NotFoundException, NotModifiedException {
return super.exec();
}
}