Skip to content

Commit 53a184e

Browse files
author
Marcus Linke
committed
Merge branch 'KostyaSha-since't push origin master
2 parents 05c4b25 + 0972b1a commit 53a184e

4 files changed

Lines changed: 98 additions & 5 deletions

File tree

src/main/java/com/github/dockerjava/api/command/CreateContainerCmd.java

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,26 @@ public static interface Exec extends DockerCmdExec<CreateContainerCmd, CreateCon
4343

4444
public int getCpuShares();
4545

46+
/**
47+
* @since 1.19
48+
*/
49+
public Integer getCpuPeriod();
50+
51+
/**
52+
* @since 1.19
53+
*/
54+
public String getCpusetMems();
55+
56+
/**
57+
* @since 1.19
58+
*/
59+
public Integer getBlkioWeight();
60+
61+
/**
62+
* @since 1.19
63+
*/
64+
public Boolean isOomKillDisable();
65+
4666
public Device[] getDevices();
4767

4868
public String[] getDns();
@@ -139,6 +159,26 @@ public static interface Exec extends DockerCmdExec<CreateContainerCmd, CreateCon
139159

140160
public CreateContainerCmd withCpuShares(int cpuShares);
141161

162+
/**
163+
* @since 1.19
164+
*/
165+
public CreateContainerCmd withCpuPeriod(Integer cpuPeriod);
166+
167+
/**
168+
* @since 1.19
169+
*/
170+
public CreateContainerCmd withCpusetMems(String cpusetMems);
171+
172+
/**
173+
* @since 1.19
174+
*/
175+
public CreateContainerCmd withBlkioWeight(Integer blkioWeight);
176+
177+
/**
178+
* @since 1.19
179+
*/
180+
public CreateContainerCmd withOomKillDisable(Boolean oomKillDisable);
181+
142182
/**
143183
* Add host devices to the container
144184
*/

src/main/java/com/github/dockerjava/api/model/Filters.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,7 @@ public Filters withLabels(Map<String, String> labels) {
8383
private static List<String> labelsMapToList(Map<String, String> labels) {
8484
List<String> result = new ArrayList<String>();
8585
for (Entry<String, String> entry : labels.entrySet()) {
86-
String rest = (entry.getValue() != null & !entry.getValue().isEmpty()) ? "=" + entry.getValue()
87-
: "";
86+
String rest = (entry.getValue() != null & !entry.getValue().isEmpty()) ? "=" + entry.getValue() : "";
8887

8988
String label = entry.getKey() + rest;
9089

src/main/java/com/github/dockerjava/core/command/CreateContainerCmdImpl.java

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ public class CreateContainerCmdImpl extends AbstrDockerCmd<CreateContainerCmd, C
5555
@JsonProperty("CpuShares")
5656
private int cpuShares = 0;
5757

58+
@JsonProperty("CpuPeriod")
59+
private Integer cpuPeriod;
60+
5861
@JsonProperty("Cpuset")
5962
private String cpuset;
6063

@@ -112,6 +115,15 @@ public class CreateContainerCmdImpl extends AbstrDockerCmd<CreateContainerCmd, C
112115
@JsonProperty("Labels")
113116
private Map<String, String> labels;
114117

118+
@JsonProperty("CpusetMems")
119+
private String cpusetMems;
120+
121+
@JsonProperty("BlkioWeight")
122+
private Integer blkioWeight;
123+
124+
@JsonProperty("OomKillDisable")
125+
private Boolean oomKillDisable;
126+
115127
public CreateContainerCmdImpl(CreateContainerCmd.Exec exec, String image) {
116128
super(exec);
117129
checkNotNull(image, "image was not specified");
@@ -160,6 +172,26 @@ public int getCpuShares() {
160172
return cpuShares;
161173
}
162174

175+
@Override
176+
public Integer getCpuPeriod() {
177+
return cpuPeriod;
178+
}
179+
180+
@Override
181+
public String getCpusetMems() {
182+
return cpusetMems;
183+
}
184+
185+
@Override
186+
public Integer getBlkioWeight() {
187+
return blkioWeight;
188+
}
189+
190+
@Override
191+
public Boolean isOomKillDisable() {
192+
return oomKillDisable;
193+
}
194+
163195
@Override
164196
@JsonIgnore
165197
public Device[] getDevices() {
@@ -409,6 +441,30 @@ public CreateContainerCmdImpl withCpuShares(int cpuShares) {
409441
return this;
410442
}
411443

444+
@Override
445+
public CreateContainerCmd withCpuPeriod(Integer cpuPeriod) {
446+
this.cpuPeriod = cpuPeriod;
447+
return this;
448+
}
449+
450+
@Override
451+
public CreateContainerCmd withCpusetMems(String cpusetMems) {
452+
this.cpusetMems = cpusetMems;
453+
return null;
454+
}
455+
456+
@Override
457+
public CreateContainerCmd withBlkioWeight(Integer blkioWeight) {
458+
this.blkioWeight = blkioWeight;
459+
return null;
460+
}
461+
462+
@Override
463+
public CreateContainerCmd withOomKillDisable(Boolean oomKillDisable) {
464+
this.oomKillDisable = oomKillDisable;
465+
return null;
466+
}
467+
412468
@Override
413469
public CreateContainerCmd withDevices(Device... devices) {
414470
this.hostConfig.setDevices(devices);

src/test/java/com/github/dockerjava/core/command/ListContainersCmdImplTest.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,10 @@ public void testListContainersWithLabelsFilter() throws DockerException {
148148
assertThat(container2.getCommand(), not(isEmptyString()));
149149
assertThat(container2.getImage(), startsWith(testImage));
150150

151-
152151
Map<String, String> labels = ImmutableMap.of("test", "docker-java");
153152

154153
// list with filter by label
155-
dockerClient.createContainerCmd(testImage).withCmd("echo").withLabels(labels)
156-
.exec();
154+
dockerClient.createContainerCmd(testImage).withCmd("echo").withLabels(labels).exec();
157155
filteredContainers = dockerClient.listContainersCmd().withShowAll(true)
158156
.withFilters(new Filters().withLabels(labels)).exec();
159157
assertThat(filteredContainers.size(), is(equalTo(1)));

0 commit comments

Comments
 (0)