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
|
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.dockerapi;
import com.yahoo.config.provision.DockerImage;
import java.util.Objects;
/**
* @author stiankri
*/
public class Container {
public final String hostname;
public final DockerImage image;
public final ContainerResources resources;
public final ContainerName name;
public final State state;
public final int pid;
public Container(
final String hostname,
final DockerImage image,
final ContainerResources resources,
final ContainerName containerName,
final State state,
final int pid) {
this.hostname = hostname;
this.image = image;
this.resources = resources;
this.name = containerName;
this.state = state;
this.pid = pid;
}
@Override
public boolean equals(final Object obj) {
if (!(obj instanceof Container)) {
return false;
}
final Container other = (Container) obj;
return Objects.equals(hostname, other.hostname)
&& Objects.equals(image, other.image)
&& Objects.equals(resources, other.resources)
&& Objects.equals(name, other.name)
&& Objects.equals(pid, other.pid);
}
@Override
public int hashCode() {
return Objects.hash(hostname, image, resources, name, pid);
}
@Override
public String toString() {
return "Container {"
+ " hostname=" + hostname
+ " image=" + image
+ " resources=" + resources
+ " name=" + name
+ " state=" + state
+ " pid=" + pid
+ "}";
}
public enum State {
CREATED, RESTARTING, RUNNING, REMOVING, PAUSED, EXITED, DEAD;
public boolean isRunning() {
return this == RUNNING;
}
}
}
|