forked from docker-java/docker-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRestartContainerCmdImpl.java
More file actions
79 lines (63 loc) · 2.08 KB
/
Copy pathRestartContainerCmdImpl.java
File metadata and controls
79 lines (63 loc) · 2.08 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
69
70
71
72
73
74
75
76
77
78
79
package com.github.dockerjava.core.command;
import static com.google.common.base.Preconditions.checkArgument;
import java.util.Objects;
import com.github.dockerjava.api.command.RestartContainerCmd;
import com.github.dockerjava.api.exception.NotFoundException;
import javax.annotation.CheckForNull;
/**
* Restart a running container.
*
* @param signal - Signal to send to the container as an integer or string (e.g. SIGINT).
* @param timeout - Timeout in seconds before killing the container. Defaults to 10 seconds.
*/
public class RestartContainerCmdImpl extends AbstrDockerCmd<RestartContainerCmd, Void> implements RestartContainerCmd {
private String containerId;
private Integer timeout = 10;
private String signal;
public RestartContainerCmdImpl(RestartContainerCmd.Exec exec, String containerId) {
super(exec);
withContainerId(containerId);
}
@Override
public String getContainerId() {
return containerId;
}
@Override
public Integer getTimeout() {
return timeout;
}
/**
* @since {@link com.github.dockerjava.core.RemoteApiVersion#VERSION_1_42}
*/
@CheckForNull
@Override
public String getSignal() {
return signal;
}
@Override
public RestartContainerCmd withContainerId(String containerId) {
Objects.requireNonNull(containerId, "containerId was not specified");
this.containerId = containerId;
return this;
}
@Override
public RestartContainerCmd withTimeout(Integer timeout) {
Objects.requireNonNull(timeout, "timeout was not specified");
checkArgument(timeout >= 0, "timeout must be greater or equal 0");
this.timeout = timeout;
return this;
}
@Override
public RestartContainerCmd withSignal(String signal) {
Objects.requireNonNull(signal, "signal was not specified");
this.signal = signal;
return this;
}
/**
* @throws NotFoundException No such container
*/
@Override
public Void exec() throws NotFoundException {
return super.exec();
}
}