From 82dde85ca1b922d35ee6fd36a42a8f638aa542fb Mon Sep 17 00:00:00 2001 From: Yuting Liu Date: Wed, 29 Nov 2017 09:53:54 -0800 Subject: [PATCH 1/7] Add statistics network config for Statistics API --- .../api/model/StatisticNetworksConfig.java | 189 ++++++++++++++++++ .../dockerjava/api/model/Statistics.java | 4 +- 2 files changed, 191 insertions(+), 2 deletions(-) create mode 100644 src/main/java/com/github/dockerjava/api/model/StatisticNetworksConfig.java diff --git a/src/main/java/com/github/dockerjava/api/model/StatisticNetworksConfig.java b/src/main/java/com/github/dockerjava/api/model/StatisticNetworksConfig.java new file mode 100644 index 000000000..9058e8844 --- /dev/null +++ b/src/main/java/com/github/dockerjava/api/model/StatisticNetworksConfig.java @@ -0,0 +1,189 @@ +package com.github.dockerjava.api.model; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import org.apache.commons.lang.builder.EqualsBuilder; +import org.apache.commons.lang.builder.HashCodeBuilder; +import org.apache.commons.lang.builder.ToStringBuilder; + +import javax.annotation.CheckForNull; +import java.io.Serializable; + +/** + * Used in {@link Statistics} + * + * @author Yuting Liu + */ + +@JsonIgnoreProperties(ignoreUnknown = true) +class StatisticNetWorksConfig implements Serializable { + private static final long serialVersionUID = 1L; + + @JsonProperty("rx_bytes") + private Long rxBytes; + + @JsonProperty("rx_dropped") + private Long rxDropped; + + @JsonProperty("rx_errors") + private Long rxErrors; + + @JsonProperty("rx_packets") + private Long rxPackets; + + @JsonProperty("tx_bytes") + private Long txBytes; + + @JsonProperty("tx_dropped") + private Long txDropped; + + @JsonProperty("tx_errors") + private Long txErrors; + + @JsonProperty("tx_packets") + private Long txPackets; + + /** + * @see #rxBytes + */ + @CheckForNull + public Long getRxBytes() { + return rxBytes; + } + + /** + * @see #rxBytes + */ + public StatisticNetWorksConfig withRxBytes(Long rxBytes) { + this.rxBytes = rxBytes; + return this; + } + + /** + * @see #rxDropped + */ + @CheckForNull + public Long getRxDropped() { + return rxDropped; + } + + /** + * @see #rxDropped + */ + public StatisticNetWorksConfig withRxDropped(Long rxDropped) { + this.rxDropped = rxDropped; + return this; + } + + /** + * @see #rxErrors + */ + @CheckForNull + public Long getRxErrors() { + return rxErrors; + } + + /** + * @see #rxErrors + */ + public StatisticNetWorksConfig withRxErrors(Long rxErrors) { + this.rxErrors = rxErrors; + return this; + } + + /** + * @see #rxPackets + */ + @CheckForNull + public Long getRxPackets() { + return rxPackets; + } + + /** + * @see #rxPackets + */ + public StatisticNetWorksConfig withRxPackets(Long rxPackets) { + this.rxPackets = rxPackets; + return this; + } + + /** + * @see #txBytes + */ + @CheckForNull + public Long getTxBytes() { + return txBytes; + } + + /** + * @see #txBytes + */ + public StatisticNetWorksConfig withTxBytes(Long txBytes) { + this.txBytes = txBytes; + return this; + } + + /** + * @see #txDropped + */ + @CheckForNull + public Long getTxDropped() { + return txDropped; + } + + /** + * @see #txDropped + */ + public StatisticNetWorksConfig withTxDropped(Long txDropped) { + this.txDropped = txDropped; + return this; + } + + /** + * @see #txErrors + */ + @CheckForNull + public Long getTxErrors() { + return txErrors; + } + + /** + * @see #txErrors + */ + public StatisticNetWorksConfig withTxErrors(Long txErrors) { + this.txErrors = txErrors; + return this; + } + + /** + * @see #txPackets + */ + @CheckForNull + public Long getTxPackets() { + return txPackets; + } + + /** + * @see #txPackets + */ + public StatisticNetWorksConfig withTxPackets(Long txPackets) { + this.txPackets = txPackets; + return this; + } + + @Override + public String toString() { + return ToStringBuilder.reflectionToString(this); + } + + @Override + public boolean equals(Object o) { + return EqualsBuilder.reflectionEquals(this, o); + } + + @Override + public int hashCode() { + return HashCodeBuilder.reflectionHashCode(this); + } + +} diff --git a/src/main/java/com/github/dockerjava/api/model/Statistics.java b/src/main/java/com/github/dockerjava/api/model/Statistics.java index 5cbe1c02c..268a4d3ec 100644 --- a/src/main/java/com/github/dockerjava/api/model/Statistics.java +++ b/src/main/java/com/github/dockerjava/api/model/Statistics.java @@ -28,7 +28,7 @@ public class Statistics implements Serializable { */ @CheckForNull @JsonProperty("networks") - private Map networks; + private Map networks; /** * @deprecated as of Docker Remote API 1.21, replaced by {@link #networks} @@ -60,7 +60,7 @@ public String getRead() { * @since Docker Remote API 1.21 */ @CheckForNull - public Map getNetworks() { + public Map getNetworks() { return networks; } From 1b49893854be40b6fedb53ad33b4c9d278b7381a Mon Sep 17 00:00:00 2001 From: Yuting Liu Date: Wed, 29 Nov 2017 10:40:06 -0800 Subject: [PATCH 2/7] Update the structure of network --- src/main/java/com/github/dockerjava/api/model/Statistics.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/github/dockerjava/api/model/Statistics.java b/src/main/java/com/github/dockerjava/api/model/Statistics.java index 268a4d3ec..af5bd7c7a 100644 --- a/src/main/java/com/github/dockerjava/api/model/Statistics.java +++ b/src/main/java/com/github/dockerjava/api/model/Statistics.java @@ -35,7 +35,7 @@ public class Statistics implements Serializable { */ @Deprecated @JsonProperty("network") - private Map network; + private Map network; @JsonProperty("memory_stats") private Map memoryStats; @@ -68,7 +68,7 @@ public Map getNetworks() { * @deprecated as of Docker Remote API 1.21, replaced by {@link #getNetworks()} */ @Deprecated - public Map getNetwork() { + public Map getNetwork() { return network; } From 563e41c92c714dfa55c5463c2e0705ae67993cc9 Mon Sep 17 00:00:00 2001 From: Yuting Liu Date: Wed, 6 Dec 2017 11:19:54 -0800 Subject: [PATCH 3/7] Add statistics Test --- .../dockerjava/api/model/StatisticsTest.java | 41 ++++++ .../containers/container/stats/stats1.json | 132 ++++++++++++++++++ 2 files changed, 173 insertions(+) create mode 100644 src/test/java/com/github/dockerjava/api/model/StatisticsTest.java create mode 100644 src/test/resources/samples/1.27/containers/container/stats/stats1.json diff --git a/src/test/java/com/github/dockerjava/api/model/StatisticsTest.java b/src/test/java/com/github/dockerjava/api/model/StatisticsTest.java new file mode 100644 index 000000000..d98624daa --- /dev/null +++ b/src/test/java/com/github/dockerjava/api/model/StatisticsTest.java @@ -0,0 +1,41 @@ +package com.github.dockerjava.api.model; + +import com.fasterxml.jackson.databind.JavaType; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.github.dockerjava.core.RemoteApiVersion; +import org.junit.Test; + +import java.io.IOException; + +import static com.github.dockerjava.test.serdes.JSONSamples.testRoundTrip; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.IsEqual.equalTo; + +/** + * @author Yuting Liu + */ +public class StatisticsTest { + + @Test + public void serderJson1() throws IOException { + final ObjectMapper mapper = new ObjectMapper(); + final JavaType type = mapper.getTypeFactory().uncheckedSimpleType(Statistics.class); + + final Statistics stat = testRoundTrip(RemoteApiVersion.VERSION_1_27, + "containers/container/stats/stats1.json", + type + ); + + assertThat(stat.getRead(), equalTo("2017-12-06T00:42:03.8352972Z")); + + final StatisticNetWorksConfig networkConfig = stat.getNetworks().get("eth0"); + assertThat(networkConfig.getRxBytes(), equalTo(1230L)); + assertThat(networkConfig.getRxPackets(), equalTo(19L)); + assertThat(networkConfig.getRxErrors(), equalTo(0L)); + assertThat(networkConfig.getRxDropped(), equalTo(0L)); + assertThat(networkConfig.getTxBytes(), equalTo(0L)); + assertThat(networkConfig.getTxPackets(), equalTo(0L)); + assertThat(networkConfig.getTxErrors(), equalTo(0L)); + assertThat(networkConfig.getTxDropped(), equalTo(0L)); + } +} diff --git a/src/test/resources/samples/1.27/containers/container/stats/stats1.json b/src/test/resources/samples/1.27/containers/container/stats/stats1.json new file mode 100644 index 000000000..7a706be14 --- /dev/null +++ b/src/test/resources/samples/1.27/containers/container/stats/stats1.json @@ -0,0 +1,132 @@ +{ + "read":"2017-12-06T00:42:03.8352972Z", + "preread":"2017-12-06T00:42:02.8366736Z", + "pids_stats":{ + "current":2 + }, + "blkio_stats":{ + "io_service_bytes_recursive":[ + + ], + "io_serviced_recursive":[ + + ], + "io_queue_recursive":[ + + ], + "io_service_time_recursive":[ + + ], + "io_wait_time_recursive":[ + + ], + "io_merged_recursive":[ + + ], + "io_time_recursive":[ + + ], + "sectors_recursive":[ + + ] + }, + "num_procs":0, + "storage_stats":{ + + }, + "cpu_stats":{ + "cpu_usage":{ + "total_usage":212198028, + "percpu_usage":[ + 71592953, + 42494761, + 59298344, + 38811970 + ], + "usage_in_kernelmode":170000000, + "usage_in_usermode":20000000 + }, + "system_cpu_usage":545941980000000, + "online_cpus":4, + "throttling_data":{ + "periods":0, + "throttled_periods":0, + "throttled_time":0 + } + }, + "precpu_stats":{ + "cpu_usage":{ + "total_usage":211307214, + "percpu_usage":[ + 71451389, + 42097782, + 59298344, + 38459699 + ], + "usage_in_kernelmode":170000000, + "usage_in_usermode":20000000 + }, + "system_cpu_usage":545937990000000, + "online_cpus":4, + "throttling_data":{ + "periods":0, + "throttled_periods":0, + "throttled_time":0 + } + }, + "memory_stats":{ + "usage":647168, + "max_usage":1703936, + "stats":{ + "active_anon":102400, + "active_file":0, + "cache":0, + "dirty":0, + "hierarchical_memory_limit":9223372036854771712, + "hierarchical_memsw_limit":9223372036854771712, + "inactive_anon":0, + "inactive_file":0, + "mapped_file":0, + "pgfault":9656, + "pgmajfault":0, + "pgpgin":3425, + "pgpgout":3400, + "rss":102400, + "rss_huge":0, + "swap":0, + "total_active_anon":102400, + "total_active_file":0, + "total_cache":0, + "total_dirty":0, + "total_inactive_anon":0, + "total_inactive_file":0, + "total_mapped_file":0, + "total_pgfault":9656, + "total_pgmajfault":0, + "total_pgpgin":3425, + "total_pgpgout":3400, + "total_rss":102400, + "total_rss_huge":0, + "total_swap":0, + "total_unevictable":0, + "total_writeback":0, + "unevictable":0, + "writeback":0 + }, + "limit":2095874048 + }, + "name":"/gallant_hamilton", + "id":"b581d78b03e41d81c9fe941f03f5d35e23733ff96370456b58d2906e002b0deb", + "networks":{ + "eth0":{ + "rx_bytes":1230, + "rx_packets":19, + "rx_errors":0, + "rx_dropped":0, + "tx_bytes":0, + "tx_packets":0, + "tx_errors":0, + "tx_dropped":0 + } + } +} \ No newline at end of file From 2698231c3354d2352cd00ca1cd3f53ed729bc8a0 Mon Sep 17 00:00:00 2001 From: Yuting Liu Date: Wed, 6 Dec 2017 11:32:17 -0800 Subject: [PATCH 4/7] Chagne to is --- .../dockerjava/api/model/StatisticsTest.java | 17 +++++++++-------- .../1.27/containers/container/stats/stats1.json | 2 +- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/test/java/com/github/dockerjava/api/model/StatisticsTest.java b/src/test/java/com/github/dockerjava/api/model/StatisticsTest.java index d98624daa..979c233ac 100644 --- a/src/test/java/com/github/dockerjava/api/model/StatisticsTest.java +++ b/src/test/java/com/github/dockerjava/api/model/StatisticsTest.java @@ -10,6 +10,7 @@ import static com.github.dockerjava.test.serdes.JSONSamples.testRoundTrip; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.IsEqual.equalTo; +import static org.hamcrest.CoreMatchers.is; /** * @author Yuting Liu @@ -29,13 +30,13 @@ public void serderJson1() throws IOException { assertThat(stat.getRead(), equalTo("2017-12-06T00:42:03.8352972Z")); final StatisticNetWorksConfig networkConfig = stat.getNetworks().get("eth0"); - assertThat(networkConfig.getRxBytes(), equalTo(1230L)); - assertThat(networkConfig.getRxPackets(), equalTo(19L)); - assertThat(networkConfig.getRxErrors(), equalTo(0L)); - assertThat(networkConfig.getRxDropped(), equalTo(0L)); - assertThat(networkConfig.getTxBytes(), equalTo(0L)); - assertThat(networkConfig.getTxPackets(), equalTo(0L)); - assertThat(networkConfig.getTxErrors(), equalTo(0L)); - assertThat(networkConfig.getTxDropped(), equalTo(0L)); + assertThat(networkConfig.getRxBytes(), is(1230L)); + assertThat(networkConfig.getRxPackets(), is(19L)); + assertThat(networkConfig.getRxErrors(), is(0L)); + assertThat(networkConfig.getRxDropped(), is(0L)); + assertThat(networkConfig.getTxBytes(), is(0L)); + assertThat(networkConfig.getTxPackets(), is(0L)); + assertThat(networkConfig.getTxErrors(), is(0L)); + assertThat(networkConfig.getTxDropped(), is(0L)); } } diff --git a/src/test/resources/samples/1.27/containers/container/stats/stats1.json b/src/test/resources/samples/1.27/containers/container/stats/stats1.json index 7a706be14..e542c10a9 100644 --- a/src/test/resources/samples/1.27/containers/container/stats/stats1.json +++ b/src/test/resources/samples/1.27/containers/container/stats/stats1.json @@ -129,4 +129,4 @@ "tx_dropped":0 } } -} \ No newline at end of file +} From 2dd5a2d1f354b911951875bba8bcec8abcf1ab40 Mon Sep 17 00:00:00 2001 From: Yuting Liu Date: Wed, 6 Dec 2017 13:36:36 -0800 Subject: [PATCH 5/7] Add MemoryStatsConfig for memoryStats --- .../api/model/MemoryStatsConfig.java | 96 +++ .../dockerjava/api/model/Statistics.java | 4 +- .../dockerjava/api/model/StatsConfig.java | 657 ++++++++++++++++++ .../dockerjava/api/model/StatisticsTest.java | 42 ++ 4 files changed, 797 insertions(+), 2 deletions(-) create mode 100644 src/main/java/com/github/dockerjava/api/model/MemoryStatsConfig.java create mode 100644 src/main/java/com/github/dockerjava/api/model/StatsConfig.java diff --git a/src/main/java/com/github/dockerjava/api/model/MemoryStatsConfig.java b/src/main/java/com/github/dockerjava/api/model/MemoryStatsConfig.java new file mode 100644 index 000000000..9554a8184 --- /dev/null +++ b/src/main/java/com/github/dockerjava/api/model/MemoryStatsConfig.java @@ -0,0 +1,96 @@ +package com.github.dockerjava.api.model; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; + +import javax.annotation.CheckForNull; +import java.io.Serializable; + +/** + * Used in {@link Statistics} + * + * @author Yuting Liu + */ + +@JsonIgnoreProperties(ignoreUnknown = true) +class MemoryStatsConfig implements Serializable { + private static final long serialVersionUID = 1L; + + @JsonProperty("usage") + private Long usage; + + @JsonProperty("max_usage") + private Long maxUsage; + + @JsonProperty("stats") + private StatsConfig stats; + + @JsonProperty("limit") + private Long limit; + + /** + * @see #usage + */ + @CheckForNull + public Long getUsage() { + return usage; + } + + /** + * @see #usage + */ + public MemoryStatsConfig withUsage(Long usage) { + this.usage = usage; + return this; + } + + /** + * @see #maxUsage + */ + @CheckForNull + public Long getMaxUsage() { + return maxUsage; + } + + /** + * @see #maxUsage + */ + public MemoryStatsConfig withMaxUsage(Long maxUsage) { + this.maxUsage = maxUsage; + return this; + } + + /** + * @see #stats + */ + @CheckForNull + public StatsConfig getStats() { + return stats; + } + + /** + * @see #stats + */ + public MemoryStatsConfig withStats(StatsConfig stats) { + this.stats = stats; + return this; + } + + /** + * @see #limit + */ + @CheckForNull + public Long getLimit() { + return limit; + } + + /** + * @see #limit + */ + public MemoryStatsConfig withLimit(Long limit) { + this.limit = limit; + return this; + } + + +} diff --git a/src/main/java/com/github/dockerjava/api/model/Statistics.java b/src/main/java/com/github/dockerjava/api/model/Statistics.java index af5bd7c7a..17f3ca630 100644 --- a/src/main/java/com/github/dockerjava/api/model/Statistics.java +++ b/src/main/java/com/github/dockerjava/api/model/Statistics.java @@ -38,7 +38,7 @@ public class Statistics implements Serializable { private Map network; @JsonProperty("memory_stats") - private Map memoryStats; + private MemoryStatsConfig memoryStats; @JsonProperty("blkio_stats") private Map blkioStats; @@ -84,7 +84,7 @@ public Map getPreCpuStats() { return preCpuStats; } - public Map getMemoryStats() { + public MemoryStatsConfig getMemoryStats() { return memoryStats; } diff --git a/src/main/java/com/github/dockerjava/api/model/StatsConfig.java b/src/main/java/com/github/dockerjava/api/model/StatsConfig.java new file mode 100644 index 000000000..814d8698d --- /dev/null +++ b/src/main/java/com/github/dockerjava/api/model/StatsConfig.java @@ -0,0 +1,657 @@ +package com.github.dockerjava.api.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import javax.annotation.CheckForNull; +import java.io.Serializable; + +class StatsConfig implements Serializable { + private static final long serialVersionUID = 1L; + + @JsonProperty("active_anon") + private Long activeAnon; + + @JsonProperty("active_file") + private Long activeFile; + + @JsonProperty("cache") + private Long cache; + + @JsonProperty("dirty") + private Long dirty; + + @JsonProperty("hierarchical_memory_limit") + private Long hierarchicalMemoryLimit; + + @JsonProperty("hierarchical_memsw_limit") + private Long hierarchicalMemswLimit; + + @JsonProperty("inactive_anon") + private Long inactiveAnon; + + @JsonProperty("inactive_file") + private Long inactiveFile; + + @JsonProperty("mapped_file") + private Long mappedFile; + + @JsonProperty("pgfault") + private Long pgfault; + + @JsonProperty("pgmajfault") + private Long pgmajfault; + + @JsonProperty("pgpgin") + private Long pgpgin; + + @JsonProperty("pgpgout") + private Long pgpgout; + + @JsonProperty("rss") + private Long rss; + + @JsonProperty("rss_huge") + private Long rssHuge; + + @JsonProperty("swap") + private Long swap; + + @JsonProperty("total_active_anon") + private Long totalActiveAnon; + + @JsonProperty("total_active_file") + private Long totalActiveFile; + + @JsonProperty("total_cache") + private Long totalCache; + + @JsonProperty("total_dirty") + private Long totalDirty; + + @JsonProperty("total_inactive_anon") + private Long totalInactiveAnon; + + @JsonProperty("total_inactive_file") + private Long totalInactiveFile; + + @JsonProperty("total_mapped_file") + private Long totalMappedFile; + + @JsonProperty("total_pgfault") + private Long totalPgfault; + + @JsonProperty("total_pgmajfault") + private Long totalPgmajfault; + + @JsonProperty("total_pgpgin") + private Long totalPgpgin; + + @JsonProperty("total_pgpgout") + private Long totalPgpgout; + + @JsonProperty("total_rss") + private Long totalRss; + + @JsonProperty("total_rss_huge") + private Long totalRssHuge; + + @JsonProperty("total_swap") + private Long totalSwap; + + @JsonProperty("total_unevictable") + private Long totalUnevictable; + + @JsonProperty("total_writeback") + private Long totalWriteback; + + @JsonProperty("unevictable") + private Long unevictable; + + @JsonProperty("writeback") + private Long writeback; + + /** + * @see #activeAnon + */ + @CheckForNull + public Long getActiveAnon() { + return activeAnon; + } + + /** + * @see #activeAnon + */ + public StatsConfig withActiveAnon(Long activeAnon) { + this.activeAnon = activeAnon; + return this; + } + + /** + * @see #activeFile + */ + @CheckForNull + public Long getActiveFile() { + return activeFile; + } + + /** + * @see #activeFile + */ + public StatsConfig withActiveFile(Long activeFile) { + this.activeFile = activeFile; + return this; + } + + /** + * @see #cache + */ + @CheckForNull + public Long getCache() { + return cache; + } + + /** + * @see #cache + */ + public StatsConfig withCache(Long cache) { + this.cache = cache; + return this; + } + + /** + * @see #dirty + */ + @CheckForNull + public Long getDirty() { + return dirty; + } + + /** + * @see #dirty + */ + public StatsConfig withDirty(Long dirty) { + this.dirty = dirty; + return this; + } + + /** + * @see #hierarchicalMemoryLimit + */ + @CheckForNull + public Long getHierarchicalMemoryLimit() { + return hierarchicalMemoryLimit; + } + + /** + * @see #hierarchicalMemoryLimit + */ + public StatsConfig withHierarchicalMemoryLimit(Long hierarchicalMemoryLimit) { + this.hierarchicalMemoryLimit = hierarchicalMemoryLimit; + return this; + } + + /** + * @see #hierarchicalMemswLimit + */ + @CheckForNull + public Long getHierarchicalMemswLimit() { + return hierarchicalMemswLimit; + } + + /** + * @see #hierarchicalMemswLimit + */ + public StatsConfig withHierarchicalMemswLimit(Long hierarchicalMemswLimit) { + this.hierarchicalMemswLimit = hierarchicalMemswLimit; + return this; + } + + /** + * @see #inactiveAnon + */ + @CheckForNull + public Long getInactiveAnon() { + return inactiveAnon; + } + + /** + * @see #inactiveAnon + */ + public StatsConfig withInactiveAnon(Long inactiveAnon) { + this.inactiveAnon = inactiveAnon; + return this; + } + + /** + * @see #inactiveFile + */ + @CheckForNull + public Long getInactiveFile() { + return inactiveFile; + } + + /** + * @see #inactiveFile + */ + public StatsConfig withInactiveFile(Long inactiveFile) { + this.inactiveFile = inactiveFile; + return this; + } + + /** + * @see #mappedFile + */ + @CheckForNull + public Long getMappedFile() { + return mappedFile; + } + + /** + * @see #mappedFile + */ + public StatsConfig withMappedFile(Long mappedFile) { + this.mappedFile = mappedFile; + return this; + } + + /** + * @see #pgfault + */ + @CheckForNull + public Long getPgfault() { + return pgfault; + } + + /** + * @see #pgfault + */ + public StatsConfig withPgfault(Long pgfault) { + this.pgfault = pgfault; + return this; + } + + /** + * @see #pgmajfault + */ + @CheckForNull + public Long getPgmajfault() { + return pgmajfault; + } + + /** + * @see #pgmajfault + */ + public StatsConfig withPgmajfault(Long pgmajfault) { + this.pgmajfault = pgmajfault; + return this; + } + + /** + * @see #pgpgin + */ + @CheckForNull + public Long getPgpgin() { + return pgpgin; + } + + /** + * @see #pgpgin + */ + public StatsConfig withPgpgin(Long pgpgin) { + this.pgpgin = pgpgin; + return this; + } + + /** + * @see #pgpgout + */ + @CheckForNull + public Long getPgpgout() { + return pgpgout; + } + + /** + * @see #pgpgout + */ + public StatsConfig withPgpgout(Long pgpgout) { + this.pgpgout = pgpgout; + return this; + } + + /** + * @see #rss + */ + @CheckForNull + public Long getRss() { + return rss; + } + + /** + * @see #rss + */ + public StatsConfig withRss(Long rss) { + this.rss = rss; + return this; + } + + /** + * @see #rssHuge + */ + @CheckForNull + public Long getRssHuge() { + return rssHuge; + } + + /** + * @see #rssHuge + */ + public StatsConfig withRssHuge(Long rssHuge) { + this.rssHuge = rssHuge; + return this; + } + + /** + * @see #swap + */ + @CheckForNull + public Long getSwap() { + return swap; + } + + /** + * @see #swap + */ + public StatsConfig withSwap(Long swap) { + this.swap = swap; + return this; + } + + /** + * @see #totalActiveAnon + */ + @CheckForNull + public Long getTotalActiveAnon() { + return totalActiveAnon; + } + + /** + * @see #totalActiveAnon + */ + public StatsConfig withTotalActiveAnon(Long totalActiveAnon) { + this.totalActiveAnon = totalActiveAnon; + return this; + } + + /** + * @see #totalActiveFile + */ + @CheckForNull + public Long getTotalActiveFile() { + return totalActiveFile; + } + + /** + * @see #totalActiveFile + */ + public StatsConfig withTotalActiveFile(Long totalActiveFile) { + this.totalActiveFile = totalActiveFile; + return this; + } + + /** + * @see #totalCache + */ + @CheckForNull + public Long getTotalCache() { + return totalCache; + } + + /** + * @see #totalCache + */ + public StatsConfig withTotalCache(Long totalCache) { + this.totalCache = totalCache; + return this; + } + + /** + * @see #totalDirty + */ + @CheckForNull + public Long getTotalDirty() { + return totalDirty; + } + + /** + * @see #totalDirty + */ + public StatsConfig withTotalDirty(Long totalDirty) { + this.totalDirty = totalDirty; + return this; + } + + /** + * @see #totalInactiveAnon + */ + @CheckForNull + public Long getTotalInactiveAnon() { + return totalInactiveAnon; + } + + /** + * @see #totalInactiveAnon + */ + public StatsConfig withTotalInactiveAnon(Long totalInactiveAnon) { + this.totalInactiveAnon = totalInactiveAnon; + return this; + } + + /** + * @see #totalInactiveFile + */ + @CheckForNull + public Long getTotalInactiveFile() { + return totalInactiveFile; + } + + /** + * @see #totalInactiveFile + */ + public StatsConfig withTotalInactiveFile(Long totalInactiveFile) { + this.totalInactiveFile = totalInactiveFile; + return this; + } + + /** + * @see #totalMappedFile + */ + @CheckForNull + public Long getTotalMappedFile() { + return totalMappedFile; + } + + /** + * @see #totalMappedFile + */ + public StatsConfig withTotalMappedFile(Long totalMappedFile) { + this.totalMappedFile = totalMappedFile; + return this; + } + + /** + * @see #totalPgfault + */ + @CheckForNull + public Long getTotalPgfault() { + return totalPgfault; + } + + /** + * @see #totalPgfault + */ + public StatsConfig withTotalPgfault(Long totalPgfault) { + this.totalPgfault = totalPgfault; + return this; + } + + /** + * @see #totalPgmajfault + */ + @CheckForNull + public Long getTotalPgmajfault() { + return totalPgmajfault; + } + + /** + * @see #totalPgmajfault + */ + public StatsConfig withTotalPgmajfault(Long totalPgmajfault) { + this.totalPgmajfault = totalPgmajfault; + return this; + } + + /** + * @see #totalPgpgin + */ + @CheckForNull + public Long getTotalPgpgin() { + return totalPgpgin; + } + + /** + * @see #totalPgpgin + */ + public StatsConfig withTotalPgpgin(Long totalPgpgin) { + this.totalPgpgin = totalPgpgin; + return this; + } + + /** + * @see #totalPgpgout + */ + @CheckForNull + public Long getTotalPgpgout() { + return totalPgpgout; + } + + /** + * @see #totalPgpgout + */ + public StatsConfig withTotalPgpgout(Long totalPgpgout) { + this.totalPgpgout = totalPgpgout; + return this; + } + + /** + * @see #totalRss + */ + @CheckForNull + public Long getTotalRss() { + return totalRss; + } + + /** + * @see #totalRss + */ + public StatsConfig withTotalRss(Long totalRss) { + this.totalRss = totalRss; + return this; + } + + /** + * @see #totalRssHuge + */ + @CheckForNull + public Long getTotalRssHuge() { + return totalRssHuge; + } + + /** + * @see #totalRssHuge + */ + public StatsConfig withTotalRssHuge(Long totalRssHuge) { + this.totalRssHuge = totalRssHuge; + return this; + } + + /** + * @see #totalSwap + */ + @CheckForNull + public Long getTotalSwap() { + return totalSwap; + } + + /** + * @see #totalSwap + */ + public StatsConfig withTotalSwap(Long totalSwap) { + this.totalSwap = totalSwap; + return this; + } + + /** + * @see #totalUnevictable + */ + @CheckForNull + public Long getTotalUnevictable() { + return totalUnevictable; + } + + /** + * @see #totalUnevictable + */ + public StatsConfig withTotalUnevictable(Long totalUnevictable) { + this.totalUnevictable = totalUnevictable; + return this; + } + + /** + * @see #totalWriteback + */ + @CheckForNull + public Long getTotalWriteback() { + return totalWriteback; + } + + /** + * @see #totalWriteback + */ + public StatsConfig withTotalWriteback(Long totalWriteback) { + this.totalWriteback = totalWriteback; + return this; + } + + /** + * @see #unevictable + */ + @CheckForNull + public Long getUnevictable() { + return unevictable; + } + + /** + * @see #unevictable + */ + public StatsConfig withUnevictable(Long unevictable) { + this.unevictable = unevictable; + return this; + } + + /** + * @see #writeback + */ + @CheckForNull + public Long getWriteback() { + return writeback; + } + + /** + * @see #writeback + */ + public StatsConfig withWriteback(Long writeback) { + this.writeback = writeback; + return this; + } +} + diff --git a/src/test/java/com/github/dockerjava/api/model/StatisticsTest.java b/src/test/java/com/github/dockerjava/api/model/StatisticsTest.java index 979c233ac..961ae9514 100644 --- a/src/test/java/com/github/dockerjava/api/model/StatisticsTest.java +++ b/src/test/java/com/github/dockerjava/api/model/StatisticsTest.java @@ -38,5 +38,47 @@ public void serderJson1() throws IOException { assertThat(networkConfig.getTxPackets(), is(0L)); assertThat(networkConfig.getTxErrors(), is(0L)); assertThat(networkConfig.getTxDropped(), is(0L)); + + final MemoryStatsConfig memoryStatsConfig = stat.getMemoryStats(); + assertThat(memoryStatsConfig.getUsage(), is(647168L)); + assertThat(memoryStatsConfig.getMaxUsage(), is(1703936L)); + + final StatsConfig statsConfig = memoryStatsConfig.getStats(); + assertThat(statsConfig.getActiveAnon(), is(102400L)); + assertThat(statsConfig.getActiveFile(), is(0L)); + assertThat(statsConfig.getCache(), is(0L)); + assertThat(statsConfig.getDirty(), is(0L)); + assertThat(statsConfig.getHierarchicalMemoryLimit(), is(9223372036854771712L)); + assertThat(statsConfig.getHierarchicalMemswLimit(), is(9223372036854771712L)); + assertThat(statsConfig.getInactiveAnon(), is(0L)); + assertThat(statsConfig.getInactiveFile(), is(0L)); + assertThat(statsConfig.getMappedFile(), is(0L)); + assertThat(statsConfig.getPgfault(), is(9656L)); + assertThat(statsConfig.getPgmajfault(), is(0L)); + assertThat(statsConfig.getPgpgin(), is(3425L)); + assertThat(statsConfig.getPgpgout(), is(3400L)); + assertThat(statsConfig.getRss(), is(102400L)); + assertThat(statsConfig.getRssHuge(), is(0L)); + assertThat(statsConfig.getSwap(), is(0L)); + assertThat(statsConfig.getTotalActiveAnon(), is(102400L)); + assertThat(statsConfig.getTotalActiveFile(), is(0L)); + assertThat(statsConfig.getTotalCache(), is(0L)); + assertThat(statsConfig.getTotalDirty(), is(0L)); + assertThat(statsConfig.getTotalInactiveAnon(), is(0L)); + assertThat(statsConfig.getTotalInactiveFile(), is(0L)); + assertThat(statsConfig.getTotalMappedFile(), is(0L)); + assertThat(statsConfig.getTotalPgfault(), is(9656L)); + assertThat(statsConfig.getTotalPgmajfault(), is(0L)); + assertThat(statsConfig.getTotalPgpgin(), is(3425L)); + assertThat(statsConfig.getTotalPgpgout(), is(3400L)); + assertThat(statsConfig.getTotalRss(), is(102400L)); + assertThat(statsConfig.getTotalRssHuge(), is(0L)); + assertThat(statsConfig.getTotalSwap(), is(0L)); + assertThat(statsConfig.getTotalUnevictable(), is(0L)); + assertThat(statsConfig.getTotalWriteback(), is(0L)); + assertThat(statsConfig.getUnevictable(), is(0L)); + assertThat(statsConfig.getWriteback(), is(0L)); + + assertThat(memoryStatsConfig.getLimit(), is(2095874048L)); } } From e12facbbe59516cbc7f5c3432618a57efa53fd40 Mon Sep 17 00:00:00 2001 From: Yuting Liu Date: Wed, 6 Dec 2017 16:23:22 -0800 Subject: [PATCH 6/7] Add BlkioStatsConfig for blkioStats --- .../api/model/BlkioStatsConfig.java | 106 +++++++ .../api/model/MemoryStatsConfig.java | 35 --- .../api/model/StatisticNetworksConfig.java | 65 ----- .../dockerjava/api/model/Statistics.java | 4 +- .../dockerjava/api/model/StatsConfig.java | 272 ------------------ .../dockerjava/api/model/StatisticsTest.java | 16 ++ 6 files changed, 124 insertions(+), 374 deletions(-) create mode 100644 src/main/java/com/github/dockerjava/api/model/BlkioStatsConfig.java diff --git a/src/main/java/com/github/dockerjava/api/model/BlkioStatsConfig.java b/src/main/java/com/github/dockerjava/api/model/BlkioStatsConfig.java new file mode 100644 index 000000000..b6699f8c3 --- /dev/null +++ b/src/main/java/com/github/dockerjava/api/model/BlkioStatsConfig.java @@ -0,0 +1,106 @@ +package com.github.dockerjava.api.model; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; + +import javax.annotation.CheckForNull; +import java.io.Serializable; +import java.util.List; + +/** + * Used in {@link Statistics} + * + * @author Yuting Liu + */ +@JsonIgnoreProperties(ignoreUnknown = true) +class BlkioStatsConfig implements Serializable { + private static final long serialVersionUID = 1L; + + @JsonProperty("io_service_bytes_recursive") + private List ioServiceBytesRecursive; + + @JsonProperty("io_serviced_recursive") + private List ioServicedRecursive; + + @JsonProperty("io_queue_recursive") + private List ioQueueRecursive; + + @JsonProperty("io_service_time_recursive") + private List ioServiceTimeRecursive; + + @JsonProperty("io_wait_time_recursive") + private List ioWaitTimeRecursive; + + @JsonProperty("io_merged_recursive") + private List ioMergedRecursive; + + @JsonProperty("io_time_recursive") + private List ioTimeRecursive; + + @JsonProperty("sectors_recursive") + private List sectorsRecursive; + + /** + * @see #ioServiceBytesRecursive + */ + @CheckForNull + public List getIoServiceBytesRecursive() { + return ioServiceBytesRecursive; + } + + /** + * @see #ioServicedRecursive + */ + @CheckForNull + public List getIoServicedRecursive() { + return ioServicedRecursive; + } + + /** + * @see #ioQueueRecursive + */ + @CheckForNull + public List getIoQueueRecursive() { + return ioQueueRecursive; + } + + /** + * @see #ioServiceTimeRecursive + */ + @CheckForNull + public List getIoServiceTimeRecursive() { + return ioServiceTimeRecursive; + } + + /** + * @see #ioWaitTimeRecursive + */ + @CheckForNull + public List getIoWaitTimeRecursive() { + return ioWaitTimeRecursive; + } + + /** + * @see #ioMergedRecursive + */ + @CheckForNull + public List getIoMergedRecursive() { + return ioMergedRecursive; + } + + /** + * @see #ioTimeRecursive + */ + @CheckForNull + public List getIoTimeRecursive() { + return ioTimeRecursive; + } + + /** + * @see #sectorsRecursive + */ + @CheckForNull + public List getSectorsRecursive() { + return sectorsRecursive; + } +} diff --git a/src/main/java/com/github/dockerjava/api/model/MemoryStatsConfig.java b/src/main/java/com/github/dockerjava/api/model/MemoryStatsConfig.java index 9554a8184..8c1a24bc3 100644 --- a/src/main/java/com/github/dockerjava/api/model/MemoryStatsConfig.java +++ b/src/main/java/com/github/dockerjava/api/model/MemoryStatsConfig.java @@ -11,7 +11,6 @@ * * @author Yuting Liu */ - @JsonIgnoreProperties(ignoreUnknown = true) class MemoryStatsConfig implements Serializable { private static final long serialVersionUID = 1L; @@ -36,14 +35,6 @@ public Long getUsage() { return usage; } - /** - * @see #usage - */ - public MemoryStatsConfig withUsage(Long usage) { - this.usage = usage; - return this; - } - /** * @see #maxUsage */ @@ -52,14 +43,6 @@ public Long getMaxUsage() { return maxUsage; } - /** - * @see #maxUsage - */ - public MemoryStatsConfig withMaxUsage(Long maxUsage) { - this.maxUsage = maxUsage; - return this; - } - /** * @see #stats */ @@ -68,14 +51,6 @@ public StatsConfig getStats() { return stats; } - /** - * @see #stats - */ - public MemoryStatsConfig withStats(StatsConfig stats) { - this.stats = stats; - return this; - } - /** * @see #limit */ @@ -83,14 +58,4 @@ public MemoryStatsConfig withStats(StatsConfig stats) { public Long getLimit() { return limit; } - - /** - * @see #limit - */ - public MemoryStatsConfig withLimit(Long limit) { - this.limit = limit; - return this; - } - - } diff --git a/src/main/java/com/github/dockerjava/api/model/StatisticNetworksConfig.java b/src/main/java/com/github/dockerjava/api/model/StatisticNetworksConfig.java index 9058e8844..c662fe2e8 100644 --- a/src/main/java/com/github/dockerjava/api/model/StatisticNetworksConfig.java +++ b/src/main/java/com/github/dockerjava/api/model/StatisticNetworksConfig.java @@ -14,7 +14,6 @@ * * @author Yuting Liu */ - @JsonIgnoreProperties(ignoreUnknown = true) class StatisticNetWorksConfig implements Serializable { private static final long serialVersionUID = 1L; @@ -51,14 +50,6 @@ public Long getRxBytes() { return rxBytes; } - /** - * @see #rxBytes - */ - public StatisticNetWorksConfig withRxBytes(Long rxBytes) { - this.rxBytes = rxBytes; - return this; - } - /** * @see #rxDropped */ @@ -67,14 +58,6 @@ public Long getRxDropped() { return rxDropped; } - /** - * @see #rxDropped - */ - public StatisticNetWorksConfig withRxDropped(Long rxDropped) { - this.rxDropped = rxDropped; - return this; - } - /** * @see #rxErrors */ @@ -83,14 +66,6 @@ public Long getRxErrors() { return rxErrors; } - /** - * @see #rxErrors - */ - public StatisticNetWorksConfig withRxErrors(Long rxErrors) { - this.rxErrors = rxErrors; - return this; - } - /** * @see #rxPackets */ @@ -99,14 +74,6 @@ public Long getRxPackets() { return rxPackets; } - /** - * @see #rxPackets - */ - public StatisticNetWorksConfig withRxPackets(Long rxPackets) { - this.rxPackets = rxPackets; - return this; - } - /** * @see #txBytes */ @@ -115,14 +82,6 @@ public Long getTxBytes() { return txBytes; } - /** - * @see #txBytes - */ - public StatisticNetWorksConfig withTxBytes(Long txBytes) { - this.txBytes = txBytes; - return this; - } - /** * @see #txDropped */ @@ -131,14 +90,6 @@ public Long getTxDropped() { return txDropped; } - /** - * @see #txDropped - */ - public StatisticNetWorksConfig withTxDropped(Long txDropped) { - this.txDropped = txDropped; - return this; - } - /** * @see #txErrors */ @@ -147,14 +98,6 @@ public Long getTxErrors() { return txErrors; } - /** - * @see #txErrors - */ - public StatisticNetWorksConfig withTxErrors(Long txErrors) { - this.txErrors = txErrors; - return this; - } - /** * @see #txPackets */ @@ -163,14 +106,6 @@ public Long getTxPackets() { return txPackets; } - /** - * @see #txPackets - */ - public StatisticNetWorksConfig withTxPackets(Long txPackets) { - this.txPackets = txPackets; - return this; - } - @Override public String toString() { return ToStringBuilder.reflectionToString(this); diff --git a/src/main/java/com/github/dockerjava/api/model/Statistics.java b/src/main/java/com/github/dockerjava/api/model/Statistics.java index 17f3ca630..17eff8fee 100644 --- a/src/main/java/com/github/dockerjava/api/model/Statistics.java +++ b/src/main/java/com/github/dockerjava/api/model/Statistics.java @@ -41,7 +41,7 @@ public class Statistics implements Serializable { private MemoryStatsConfig memoryStats; @JsonProperty("blkio_stats") - private Map blkioStats; + private BlkioStatsConfig blkioStats; @JsonProperty("cpu_stats") private Map cpuStats; @@ -88,7 +88,7 @@ public MemoryStatsConfig getMemoryStats() { return memoryStats; } - public Map getBlkioStats() { + public BlkioStatsConfig getBlkioStats() { return blkioStats; } diff --git a/src/main/java/com/github/dockerjava/api/model/StatsConfig.java b/src/main/java/com/github/dockerjava/api/model/StatsConfig.java index 814d8698d..2aa529a6f 100644 --- a/src/main/java/com/github/dockerjava/api/model/StatsConfig.java +++ b/src/main/java/com/github/dockerjava/api/model/StatsConfig.java @@ -118,14 +118,6 @@ public Long getActiveAnon() { return activeAnon; } - /** - * @see #activeAnon - */ - public StatsConfig withActiveAnon(Long activeAnon) { - this.activeAnon = activeAnon; - return this; - } - /** * @see #activeFile */ @@ -134,14 +126,6 @@ public Long getActiveFile() { return activeFile; } - /** - * @see #activeFile - */ - public StatsConfig withActiveFile(Long activeFile) { - this.activeFile = activeFile; - return this; - } - /** * @see #cache */ @@ -150,14 +134,6 @@ public Long getCache() { return cache; } - /** - * @see #cache - */ - public StatsConfig withCache(Long cache) { - this.cache = cache; - return this; - } - /** * @see #dirty */ @@ -166,14 +142,6 @@ public Long getDirty() { return dirty; } - /** - * @see #dirty - */ - public StatsConfig withDirty(Long dirty) { - this.dirty = dirty; - return this; - } - /** * @see #hierarchicalMemoryLimit */ @@ -182,14 +150,6 @@ public Long getHierarchicalMemoryLimit() { return hierarchicalMemoryLimit; } - /** - * @see #hierarchicalMemoryLimit - */ - public StatsConfig withHierarchicalMemoryLimit(Long hierarchicalMemoryLimit) { - this.hierarchicalMemoryLimit = hierarchicalMemoryLimit; - return this; - } - /** * @see #hierarchicalMemswLimit */ @@ -198,14 +158,6 @@ public Long getHierarchicalMemswLimit() { return hierarchicalMemswLimit; } - /** - * @see #hierarchicalMemswLimit - */ - public StatsConfig withHierarchicalMemswLimit(Long hierarchicalMemswLimit) { - this.hierarchicalMemswLimit = hierarchicalMemswLimit; - return this; - } - /** * @see #inactiveAnon */ @@ -214,14 +166,6 @@ public Long getInactiveAnon() { return inactiveAnon; } - /** - * @see #inactiveAnon - */ - public StatsConfig withInactiveAnon(Long inactiveAnon) { - this.inactiveAnon = inactiveAnon; - return this; - } - /** * @see #inactiveFile */ @@ -230,14 +174,6 @@ public Long getInactiveFile() { return inactiveFile; } - /** - * @see #inactiveFile - */ - public StatsConfig withInactiveFile(Long inactiveFile) { - this.inactiveFile = inactiveFile; - return this; - } - /** * @see #mappedFile */ @@ -246,14 +182,6 @@ public Long getMappedFile() { return mappedFile; } - /** - * @see #mappedFile - */ - public StatsConfig withMappedFile(Long mappedFile) { - this.mappedFile = mappedFile; - return this; - } - /** * @see #pgfault */ @@ -262,14 +190,6 @@ public Long getPgfault() { return pgfault; } - /** - * @see #pgfault - */ - public StatsConfig withPgfault(Long pgfault) { - this.pgfault = pgfault; - return this; - } - /** * @see #pgmajfault */ @@ -278,14 +198,6 @@ public Long getPgmajfault() { return pgmajfault; } - /** - * @see #pgmajfault - */ - public StatsConfig withPgmajfault(Long pgmajfault) { - this.pgmajfault = pgmajfault; - return this; - } - /** * @see #pgpgin */ @@ -294,14 +206,6 @@ public Long getPgpgin() { return pgpgin; } - /** - * @see #pgpgin - */ - public StatsConfig withPgpgin(Long pgpgin) { - this.pgpgin = pgpgin; - return this; - } - /** * @see #pgpgout */ @@ -310,14 +214,6 @@ public Long getPgpgout() { return pgpgout; } - /** - * @see #pgpgout - */ - public StatsConfig withPgpgout(Long pgpgout) { - this.pgpgout = pgpgout; - return this; - } - /** * @see #rss */ @@ -326,14 +222,6 @@ public Long getRss() { return rss; } - /** - * @see #rss - */ - public StatsConfig withRss(Long rss) { - this.rss = rss; - return this; - } - /** * @see #rssHuge */ @@ -342,14 +230,6 @@ public Long getRssHuge() { return rssHuge; } - /** - * @see #rssHuge - */ - public StatsConfig withRssHuge(Long rssHuge) { - this.rssHuge = rssHuge; - return this; - } - /** * @see #swap */ @@ -358,14 +238,6 @@ public Long getSwap() { return swap; } - /** - * @see #swap - */ - public StatsConfig withSwap(Long swap) { - this.swap = swap; - return this; - } - /** * @see #totalActiveAnon */ @@ -374,14 +246,6 @@ public Long getTotalActiveAnon() { return totalActiveAnon; } - /** - * @see #totalActiveAnon - */ - public StatsConfig withTotalActiveAnon(Long totalActiveAnon) { - this.totalActiveAnon = totalActiveAnon; - return this; - } - /** * @see #totalActiveFile */ @@ -390,14 +254,6 @@ public Long getTotalActiveFile() { return totalActiveFile; } - /** - * @see #totalActiveFile - */ - public StatsConfig withTotalActiveFile(Long totalActiveFile) { - this.totalActiveFile = totalActiveFile; - return this; - } - /** * @see #totalCache */ @@ -406,14 +262,6 @@ public Long getTotalCache() { return totalCache; } - /** - * @see #totalCache - */ - public StatsConfig withTotalCache(Long totalCache) { - this.totalCache = totalCache; - return this; - } - /** * @see #totalDirty */ @@ -422,14 +270,6 @@ public Long getTotalDirty() { return totalDirty; } - /** - * @see #totalDirty - */ - public StatsConfig withTotalDirty(Long totalDirty) { - this.totalDirty = totalDirty; - return this; - } - /** * @see #totalInactiveAnon */ @@ -438,14 +278,6 @@ public Long getTotalInactiveAnon() { return totalInactiveAnon; } - /** - * @see #totalInactiveAnon - */ - public StatsConfig withTotalInactiveAnon(Long totalInactiveAnon) { - this.totalInactiveAnon = totalInactiveAnon; - return this; - } - /** * @see #totalInactiveFile */ @@ -454,14 +286,6 @@ public Long getTotalInactiveFile() { return totalInactiveFile; } - /** - * @see #totalInactiveFile - */ - public StatsConfig withTotalInactiveFile(Long totalInactiveFile) { - this.totalInactiveFile = totalInactiveFile; - return this; - } - /** * @see #totalMappedFile */ @@ -470,14 +294,6 @@ public Long getTotalMappedFile() { return totalMappedFile; } - /** - * @see #totalMappedFile - */ - public StatsConfig withTotalMappedFile(Long totalMappedFile) { - this.totalMappedFile = totalMappedFile; - return this; - } - /** * @see #totalPgfault */ @@ -486,14 +302,6 @@ public Long getTotalPgfault() { return totalPgfault; } - /** - * @see #totalPgfault - */ - public StatsConfig withTotalPgfault(Long totalPgfault) { - this.totalPgfault = totalPgfault; - return this; - } - /** * @see #totalPgmajfault */ @@ -502,14 +310,6 @@ public Long getTotalPgmajfault() { return totalPgmajfault; } - /** - * @see #totalPgmajfault - */ - public StatsConfig withTotalPgmajfault(Long totalPgmajfault) { - this.totalPgmajfault = totalPgmajfault; - return this; - } - /** * @see #totalPgpgin */ @@ -518,14 +318,6 @@ public Long getTotalPgpgin() { return totalPgpgin; } - /** - * @see #totalPgpgin - */ - public StatsConfig withTotalPgpgin(Long totalPgpgin) { - this.totalPgpgin = totalPgpgin; - return this; - } - /** * @see #totalPgpgout */ @@ -534,14 +326,6 @@ public Long getTotalPgpgout() { return totalPgpgout; } - /** - * @see #totalPgpgout - */ - public StatsConfig withTotalPgpgout(Long totalPgpgout) { - this.totalPgpgout = totalPgpgout; - return this; - } - /** * @see #totalRss */ @@ -550,14 +334,6 @@ public Long getTotalRss() { return totalRss; } - /** - * @see #totalRss - */ - public StatsConfig withTotalRss(Long totalRss) { - this.totalRss = totalRss; - return this; - } - /** * @see #totalRssHuge */ @@ -566,14 +342,6 @@ public Long getTotalRssHuge() { return totalRssHuge; } - /** - * @see #totalRssHuge - */ - public StatsConfig withTotalRssHuge(Long totalRssHuge) { - this.totalRssHuge = totalRssHuge; - return this; - } - /** * @see #totalSwap */ @@ -582,14 +350,6 @@ public Long getTotalSwap() { return totalSwap; } - /** - * @see #totalSwap - */ - public StatsConfig withTotalSwap(Long totalSwap) { - this.totalSwap = totalSwap; - return this; - } - /** * @see #totalUnevictable */ @@ -598,14 +358,6 @@ public Long getTotalUnevictable() { return totalUnevictable; } - /** - * @see #totalUnevictable - */ - public StatsConfig withTotalUnevictable(Long totalUnevictable) { - this.totalUnevictable = totalUnevictable; - return this; - } - /** * @see #totalWriteback */ @@ -614,14 +366,6 @@ public Long getTotalWriteback() { return totalWriteback; } - /** - * @see #totalWriteback - */ - public StatsConfig withTotalWriteback(Long totalWriteback) { - this.totalWriteback = totalWriteback; - return this; - } - /** * @see #unevictable */ @@ -630,14 +374,6 @@ public Long getUnevictable() { return unevictable; } - /** - * @see #unevictable - */ - public StatsConfig withUnevictable(Long unevictable) { - this.unevictable = unevictable; - return this; - } - /** * @see #writeback */ @@ -645,13 +381,5 @@ public StatsConfig withUnevictable(Long unevictable) { public Long getWriteback() { return writeback; } - - /** - * @see #writeback - */ - public StatsConfig withWriteback(Long writeback) { - this.writeback = writeback; - return this; - } } diff --git a/src/test/java/com/github/dockerjava/api/model/StatisticsTest.java b/src/test/java/com/github/dockerjava/api/model/StatisticsTest.java index 961ae9514..8459a0c7b 100644 --- a/src/test/java/com/github/dockerjava/api/model/StatisticsTest.java +++ b/src/test/java/com/github/dockerjava/api/model/StatisticsTest.java @@ -3,14 +3,18 @@ import com.fasterxml.jackson.databind.JavaType; import com.fasterxml.jackson.databind.ObjectMapper; import com.github.dockerjava.core.RemoteApiVersion; +import org.hamcrest.Matchers; import org.junit.Test; import java.io.IOException; +import java.util.List; +import java.util.ArrayList; import static com.github.dockerjava.test.serdes.JSONSamples.testRoundTrip; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.IsEqual.equalTo; import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.Matchers.empty; /** * @author Yuting Liu @@ -80,5 +84,17 @@ public void serderJson1() throws IOException { assertThat(statsConfig.getWriteback(), is(0L)); assertThat(memoryStatsConfig.getLimit(), is(2095874048L)); + + final BlkioStatsConfig blkioStatsConfig = stat.getBlkioStats(); + assertThat(blkioStatsConfig.getIoServiceBytesRecursive(), is(empty())); + assertThat(blkioStatsConfig.getIoServicedRecursive(), is(empty())); + assertThat(blkioStatsConfig.getIoQueueRecursive(), is(empty())); + assertThat(blkioStatsConfig.getIoServiceTimeRecursive(), is(empty())); + assertThat(blkioStatsConfig.getIoWaitTimeRecursive(), is(empty())); + assertThat(blkioStatsConfig.getIoMergedRecursive(), is(empty())); + assertThat(blkioStatsConfig.getIoTimeRecursive(), is(empty())); + assertThat(blkioStatsConfig.getSectorsRecursive(), is(empty())); + + } } From 83374529e8ee35fb93fb0613d27e9bad8a3be190 Mon Sep 17 00:00:00 2001 From: Yuting Liu Date: Thu, 7 Dec 2017 10:24:49 -0800 Subject: [PATCH 7/7] Add CpuStatsConfig and pids_stats --- .../dockerjava/api/model/CpuStatsConfig.java | 61 +++++++ .../dockerjava/api/model/CpuUsageConfig.java | 62 ++++++++ .../dockerjava/api/model/PidsStatsConfig.java | 26 +++ .../api/model/StatisticNetworksConfig.java | 1 - .../dockerjava/api/model/Statistics.java | 18 ++- .../dockerjava/api/model/StatsConfig.java | 1 - .../api/model/ThrottlingDataConfig.java | 50 ++++++ .../dockerjava/api/model/StatisticsTest.java | 149 ++++++++++-------- 8 files changed, 300 insertions(+), 68 deletions(-) create mode 100644 src/main/java/com/github/dockerjava/api/model/CpuStatsConfig.java create mode 100644 src/main/java/com/github/dockerjava/api/model/CpuUsageConfig.java create mode 100644 src/main/java/com/github/dockerjava/api/model/PidsStatsConfig.java create mode 100644 src/main/java/com/github/dockerjava/api/model/ThrottlingDataConfig.java diff --git a/src/main/java/com/github/dockerjava/api/model/CpuStatsConfig.java b/src/main/java/com/github/dockerjava/api/model/CpuStatsConfig.java new file mode 100644 index 000000000..7a7a699b4 --- /dev/null +++ b/src/main/java/com/github/dockerjava/api/model/CpuStatsConfig.java @@ -0,0 +1,61 @@ +package com.github.dockerjava.api.model; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; + +import javax.annotation.CheckForNull; +import java.io.Serializable; + +/** + * Used in {@link Statistics} + * + * @author Yuting Liu + */ +@JsonIgnoreProperties(ignoreUnknown = true) +class CpuStatsConfig implements Serializable { + private static final long serialVersionUID = 1L; + + @JsonProperty("cpu_usage") + private CpuUsageConfig cpuUsage; + + @JsonProperty("system_cpu_usage") + private Long systemCpuUsage; + + @JsonProperty("online_cpus") + private Long onlineCpus; + + @JsonProperty("throttling_data") + private ThrottlingDataConfig throttlingData; + + /** + * @see #cpuUsage + */ + @CheckForNull + public CpuUsageConfig getCpuUsage() { + return cpuUsage; + } + + /** + * @see #systemCpuUsage + */ + @CheckForNull + public Long getSystemCpuUsage() { + return systemCpuUsage; + } + + /** + * @see #onlineCpus + */ + @CheckForNull + public Long getOnlineCpus() { + return onlineCpus; + } + + /** + * @see #throttlingData + */ + @CheckForNull + public ThrottlingDataConfig getThrottlingData() { + return throttlingData; + } +} diff --git a/src/main/java/com/github/dockerjava/api/model/CpuUsageConfig.java b/src/main/java/com/github/dockerjava/api/model/CpuUsageConfig.java new file mode 100644 index 000000000..73cf0c57c --- /dev/null +++ b/src/main/java/com/github/dockerjava/api/model/CpuUsageConfig.java @@ -0,0 +1,62 @@ +package com.github.dockerjava.api.model; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; + +import javax.annotation.CheckForNull; +import java.io.Serializable; +import java.util.List; + +/** + * Used in {@link Statistics} + * + * @author Yuting Liu + */ +@JsonIgnoreProperties(ignoreUnknown = true) +class CpuUsageConfig implements Serializable { + private static final long serialVersionUID = 1L; + + @JsonProperty("total_usage") + private Long totalUsage; + + @JsonProperty("percpu_usage") + private List percpuUsage; + + @JsonProperty("usage_in_kernelmode") + private Long usageInKernelmode; + + @JsonProperty("usage_in_usermode") + private Long usageInUsermode; + + /** + * @see #totalUsage + */ + @CheckForNull + public Long getTotalUsage() { + return totalUsage; + } + + /** + * @see #percpuUsage + */ + @CheckForNull + public List getPercpuUsage() { + return percpuUsage; + } + + /** + * @see #usageInKernelmode + */ + @CheckForNull + public Long getUsageInKernelmode() { + return usageInKernelmode; + } + + /** + * @see #usageInUsermode + */ + @CheckForNull + public Long getUsageInUsermode() { + return usageInUsermode; + } +} diff --git a/src/main/java/com/github/dockerjava/api/model/PidsStatsConfig.java b/src/main/java/com/github/dockerjava/api/model/PidsStatsConfig.java new file mode 100644 index 000000000..bbf8806a3 --- /dev/null +++ b/src/main/java/com/github/dockerjava/api/model/PidsStatsConfig.java @@ -0,0 +1,26 @@ +package com.github.dockerjava.api.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import javax.annotation.CheckForNull; +import java.io.Serializable; + +/** + * Used in {@link Statistics} + * + * @author Yuting Liu + */ +class PidsStatsConfig implements Serializable { + private static final long serialVersionUID = 1L; + + @JsonProperty("current") + private Long current; + + /** + * @see #current + */ + @CheckForNull + public Long getCurrent() { + return current; + } +} diff --git a/src/main/java/com/github/dockerjava/api/model/StatisticNetworksConfig.java b/src/main/java/com/github/dockerjava/api/model/StatisticNetworksConfig.java index c662fe2e8..a6cc5ff0e 100644 --- a/src/main/java/com/github/dockerjava/api/model/StatisticNetworksConfig.java +++ b/src/main/java/com/github/dockerjava/api/model/StatisticNetworksConfig.java @@ -120,5 +120,4 @@ public boolean equals(Object o) { public int hashCode() { return HashCodeBuilder.reflectionHashCode(this); } - } diff --git a/src/main/java/com/github/dockerjava/api/model/Statistics.java b/src/main/java/com/github/dockerjava/api/model/Statistics.java index 17eff8fee..3b020c4d2 100644 --- a/src/main/java/com/github/dockerjava/api/model/Statistics.java +++ b/src/main/java/com/github/dockerjava/api/model/Statistics.java @@ -44,13 +44,19 @@ public class Statistics implements Serializable { private BlkioStatsConfig blkioStats; @JsonProperty("cpu_stats") - private Map cpuStats; + private CpuStatsConfig cpuStats; /** * @since Docker Remote API 1.19 */ @JsonProperty("precpu_stats") - private Map preCpuStats; + private CpuStatsConfig preCpuStats; + + /** + * @since Docker Remote API 1.23 + */ + @JsonProperty("pids_stats") + private PidsStatsConfig pidsStats; public String getRead() { return read; @@ -72,7 +78,7 @@ public Map getNetwork() { return network; } - public Map getCpuStats() { + public CpuStatsConfig getCpuStats() { return cpuStats; } @@ -80,7 +86,7 @@ public Map getCpuStats() { * The cpu statistic of last read, which is used for calculating the cpu usage percent. * It is not the exact copy of the {@link #getCpuStats()}. */ - public Map getPreCpuStats() { + public CpuStatsConfig getPreCpuStats() { return preCpuStats; } @@ -92,6 +98,10 @@ public BlkioStatsConfig getBlkioStats() { return blkioStats; } + public PidsStatsConfig getPidsStats() { + return pidsStats; + } + @Override public String toString() { return ToStringBuilder.reflectionToString(this); diff --git a/src/main/java/com/github/dockerjava/api/model/StatsConfig.java b/src/main/java/com/github/dockerjava/api/model/StatsConfig.java index 2aa529a6f..a732c78fa 100644 --- a/src/main/java/com/github/dockerjava/api/model/StatsConfig.java +++ b/src/main/java/com/github/dockerjava/api/model/StatsConfig.java @@ -382,4 +382,3 @@ public Long getWriteback() { return writeback; } } - diff --git a/src/main/java/com/github/dockerjava/api/model/ThrottlingDataConfig.java b/src/main/java/com/github/dockerjava/api/model/ThrottlingDataConfig.java new file mode 100644 index 000000000..e08f93b6d --- /dev/null +++ b/src/main/java/com/github/dockerjava/api/model/ThrottlingDataConfig.java @@ -0,0 +1,50 @@ +package com.github.dockerjava.api.model; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; + +import javax.annotation.CheckForNull; +import java.io.Serializable; + +/** + * Used in {@link Statistics} + * + * @author Yuting Liu + */ +@JsonIgnoreProperties(ignoreUnknown = true) +class ThrottlingDataConfig implements Serializable { + private static final long serialVersionUID = 1L; + + @JsonProperty("periods") + private Long periods; + + @JsonProperty("throttled_periods") + private Long throttledPeriods; + + @JsonProperty("throttled_time") + private Long throttledTime; + + /** + * @see #periods + */ + @CheckForNull + public Long getPeriods() { + return periods; + } + + /** + * @see #throttledPeriods + */ + @CheckForNull + public Long getThrottledPeriods() { + return throttledPeriods; + } + + /** + * @see #throttledTime + */ + @CheckForNull + public Long getThrottledTime() { + return throttledTime; + } +} diff --git a/src/test/java/com/github/dockerjava/api/model/StatisticsTest.java b/src/test/java/com/github/dockerjava/api/model/StatisticsTest.java index 8459a0c7b..d2083c4b3 100644 --- a/src/test/java/com/github/dockerjava/api/model/StatisticsTest.java +++ b/src/test/java/com/github/dockerjava/api/model/StatisticsTest.java @@ -3,12 +3,10 @@ import com.fasterxml.jackson.databind.JavaType; import com.fasterxml.jackson.databind.ObjectMapper; import com.github.dockerjava.core.RemoteApiVersion; -import org.hamcrest.Matchers; import org.junit.Test; import java.io.IOException; -import java.util.List; -import java.util.ArrayList; +import java.util.Arrays; import static com.github.dockerjava.test.serdes.JSONSamples.testRoundTrip; import static org.hamcrest.MatcherAssert.assertThat; @@ -26,75 +24,102 @@ public void serderJson1() throws IOException { final ObjectMapper mapper = new ObjectMapper(); final JavaType type = mapper.getTypeFactory().uncheckedSimpleType(Statistics.class); - final Statistics stat = testRoundTrip(RemoteApiVersion.VERSION_1_27, + final Statistics statistics = testRoundTrip(RemoteApiVersion.VERSION_1_27, "containers/container/stats/stats1.json", type ); - assertThat(stat.getRead(), equalTo("2017-12-06T00:42:03.8352972Z")); + assertThat(statistics.getRead(), equalTo("2017-12-06T00:42:03.8352972Z")); - final StatisticNetWorksConfig networkConfig = stat.getNetworks().get("eth0"); - assertThat(networkConfig.getRxBytes(), is(1230L)); - assertThat(networkConfig.getRxPackets(), is(19L)); - assertThat(networkConfig.getRxErrors(), is(0L)); - assertThat(networkConfig.getRxDropped(), is(0L)); - assertThat(networkConfig.getTxBytes(), is(0L)); - assertThat(networkConfig.getTxPackets(), is(0L)); - assertThat(networkConfig.getTxErrors(), is(0L)); - assertThat(networkConfig.getTxDropped(), is(0L)); + final StatisticNetWorksConfig network = statistics.getNetworks().get("eth0"); + assertThat(network.getRxBytes(), is(1230L)); + assertThat(network.getRxPackets(), is(19L)); + assertThat(network.getRxErrors(), is(0L)); + assertThat(network.getRxDropped(), is(0L)); + assertThat(network.getTxBytes(), is(0L)); + assertThat(network.getTxPackets(), is(0L)); + assertThat(network.getTxErrors(), is(0L)); + assertThat(network.getTxDropped(), is(0L)); - final MemoryStatsConfig memoryStatsConfig = stat.getMemoryStats(); - assertThat(memoryStatsConfig.getUsage(), is(647168L)); - assertThat(memoryStatsConfig.getMaxUsage(), is(1703936L)); + final MemoryStatsConfig memoryStats = statistics.getMemoryStats(); + assertThat(memoryStats.getUsage(), is(647168L)); + assertThat(memoryStats.getMaxUsage(), is(1703936L)); - final StatsConfig statsConfig = memoryStatsConfig.getStats(); - assertThat(statsConfig.getActiveAnon(), is(102400L)); - assertThat(statsConfig.getActiveFile(), is(0L)); - assertThat(statsConfig.getCache(), is(0L)); - assertThat(statsConfig.getDirty(), is(0L)); - assertThat(statsConfig.getHierarchicalMemoryLimit(), is(9223372036854771712L)); - assertThat(statsConfig.getHierarchicalMemswLimit(), is(9223372036854771712L)); - assertThat(statsConfig.getInactiveAnon(), is(0L)); - assertThat(statsConfig.getInactiveFile(), is(0L)); - assertThat(statsConfig.getMappedFile(), is(0L)); - assertThat(statsConfig.getPgfault(), is(9656L)); - assertThat(statsConfig.getPgmajfault(), is(0L)); - assertThat(statsConfig.getPgpgin(), is(3425L)); - assertThat(statsConfig.getPgpgout(), is(3400L)); - assertThat(statsConfig.getRss(), is(102400L)); - assertThat(statsConfig.getRssHuge(), is(0L)); - assertThat(statsConfig.getSwap(), is(0L)); - assertThat(statsConfig.getTotalActiveAnon(), is(102400L)); - assertThat(statsConfig.getTotalActiveFile(), is(0L)); - assertThat(statsConfig.getTotalCache(), is(0L)); - assertThat(statsConfig.getTotalDirty(), is(0L)); - assertThat(statsConfig.getTotalInactiveAnon(), is(0L)); - assertThat(statsConfig.getTotalInactiveFile(), is(0L)); - assertThat(statsConfig.getTotalMappedFile(), is(0L)); - assertThat(statsConfig.getTotalPgfault(), is(9656L)); - assertThat(statsConfig.getTotalPgmajfault(), is(0L)); - assertThat(statsConfig.getTotalPgpgin(), is(3425L)); - assertThat(statsConfig.getTotalPgpgout(), is(3400L)); - assertThat(statsConfig.getTotalRss(), is(102400L)); - assertThat(statsConfig.getTotalRssHuge(), is(0L)); - assertThat(statsConfig.getTotalSwap(), is(0L)); - assertThat(statsConfig.getTotalUnevictable(), is(0L)); - assertThat(statsConfig.getTotalWriteback(), is(0L)); - assertThat(statsConfig.getUnevictable(), is(0L)); - assertThat(statsConfig.getWriteback(), is(0L)); + final StatsConfig stats = memoryStats.getStats(); + assertThat(stats.getActiveAnon(), is(102400L)); + assertThat(stats.getActiveFile(), is(0L)); + assertThat(stats.getCache(), is(0L)); + assertThat(stats.getDirty(), is(0L)); + assertThat(stats.getHierarchicalMemoryLimit(), is(9223372036854771712L)); + assertThat(stats.getHierarchicalMemswLimit(), is(9223372036854771712L)); + assertThat(stats.getInactiveAnon(), is(0L)); + assertThat(stats.getInactiveFile(), is(0L)); + assertThat(stats.getMappedFile(), is(0L)); + assertThat(stats.getPgfault(), is(9656L)); + assertThat(stats.getPgmajfault(), is(0L)); + assertThat(stats.getPgpgin(), is(3425L)); + assertThat(stats.getPgpgout(), is(3400L)); + assertThat(stats.getRss(), is(102400L)); + assertThat(stats.getRssHuge(), is(0L)); + assertThat(stats.getSwap(), is(0L)); + assertThat(stats.getTotalActiveAnon(), is(102400L)); + assertThat(stats.getTotalActiveFile(), is(0L)); + assertThat(stats.getTotalCache(), is(0L)); + assertThat(stats.getTotalDirty(), is(0L)); + assertThat(stats.getTotalInactiveAnon(), is(0L)); + assertThat(stats.getTotalInactiveFile(), is(0L)); + assertThat(stats.getTotalMappedFile(), is(0L)); + assertThat(stats.getTotalPgfault(), is(9656L)); + assertThat(stats.getTotalPgmajfault(), is(0L)); + assertThat(stats.getTotalPgpgin(), is(3425L)); + assertThat(stats.getTotalPgpgout(), is(3400L)); + assertThat(stats.getTotalRss(), is(102400L)); + assertThat(stats.getTotalRssHuge(), is(0L)); + assertThat(stats.getTotalSwap(), is(0L)); + assertThat(stats.getTotalUnevictable(), is(0L)); + assertThat(stats.getTotalWriteback(), is(0L)); + assertThat(stats.getUnevictable(), is(0L)); + assertThat(stats.getWriteback(), is(0L)); - assertThat(memoryStatsConfig.getLimit(), is(2095874048L)); + assertThat(memoryStats.getLimit(), is(2095874048L)); - final BlkioStatsConfig blkioStatsConfig = stat.getBlkioStats(); - assertThat(blkioStatsConfig.getIoServiceBytesRecursive(), is(empty())); - assertThat(blkioStatsConfig.getIoServicedRecursive(), is(empty())); - assertThat(blkioStatsConfig.getIoQueueRecursive(), is(empty())); - assertThat(blkioStatsConfig.getIoServiceTimeRecursive(), is(empty())); - assertThat(blkioStatsConfig.getIoWaitTimeRecursive(), is(empty())); - assertThat(blkioStatsConfig.getIoMergedRecursive(), is(empty())); - assertThat(blkioStatsConfig.getIoTimeRecursive(), is(empty())); - assertThat(blkioStatsConfig.getSectorsRecursive(), is(empty())); + final BlkioStatsConfig blkioStats = statistics.getBlkioStats(); + assertThat(blkioStats.getIoServiceBytesRecursive(), is(empty())); + assertThat(blkioStats.getIoServicedRecursive(), is(empty())); + assertThat(blkioStats.getIoQueueRecursive(), is(empty())); + assertThat(blkioStats.getIoServiceTimeRecursive(), is(empty())); + assertThat(blkioStats.getIoWaitTimeRecursive(), is(empty())); + assertThat(blkioStats.getIoMergedRecursive(), is(empty())); + assertThat(blkioStats.getIoTimeRecursive(), is(empty())); + assertThat(blkioStats.getSectorsRecursive(), is(empty())); + final CpuStatsConfig cpuStats = statistics.getCpuStats(); + final CpuUsageConfig cpuUsage = cpuStats.getCpuUsage(); + assertThat(cpuUsage.getTotalUsage(), is(212198028L)); + assertThat(cpuUsage.getPercpuUsage(), equalTo(Arrays.asList(71592953L, 42494761L, 59298344L, 38811970L))); + assertThat(cpuUsage.getUsageInKernelmode(), is(170000000L)); + assertThat(cpuUsage.getUsageInUsermode(), is(20000000L)); + assertThat(cpuStats.getSystemCpuUsage(), is(545941980000000L)); + assertThat(cpuStats.getOnlineCpus(), is(4L)); + final ThrottlingDataConfig throttlingData = cpuStats.getThrottlingData(); + assertThat(throttlingData.getPeriods(), is(0L)); + assertThat(throttlingData.getThrottledPeriods(), is(0L)); + assertThat(throttlingData.getThrottledTime(), is(0L)); + final CpuStatsConfig preCpuStats = statistics.getPreCpuStats(); + final CpuUsageConfig preCpuUsage = preCpuStats.getCpuUsage(); + assertThat(preCpuUsage.getTotalUsage(), is(211307214L)); + assertThat(preCpuUsage.getPercpuUsage(), equalTo(Arrays.asList(71451389L, 42097782L, 59298344L, 38459699L))); + assertThat(preCpuUsage.getUsageInKernelmode(), is(170000000L)); + assertThat(preCpuUsage.getUsageInUsermode(), is(20000000L)); + assertThat(preCpuStats.getSystemCpuUsage(), is(545937990000000L)); + assertThat(preCpuStats.getOnlineCpus(), is(4L)); + final ThrottlingDataConfig preThrottlingData = preCpuStats.getThrottlingData(); + assertThat(preThrottlingData.getPeriods(), is(0L)); + assertThat(preThrottlingData.getThrottledPeriods(), is(0L)); + assertThat(preThrottlingData.getThrottledTime(), is(0L)); + + final PidsStatsConfig pidsStats = statistics.getPidsStats(); + assertThat(pidsStats.getCurrent(), is(2L)); } }