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/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/MemoryStatsConfig.java b/src/main/java/com/github/dockerjava/api/model/MemoryStatsConfig.java new file mode 100644 index 000000000..8c1a24bc3 --- /dev/null +++ b/src/main/java/com/github/dockerjava/api/model/MemoryStatsConfig.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 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 #maxUsage + */ + @CheckForNull + public Long getMaxUsage() { + return maxUsage; + } + + /** + * @see #stats + */ + @CheckForNull + public StatsConfig getStats() { + return stats; + } + + /** + * @see #limit + */ + @CheckForNull + public Long getLimit() { + return limit; + } +} 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 new file mode 100644 index 000000000..a6cc5ff0e --- /dev/null +++ b/src/main/java/com/github/dockerjava/api/model/StatisticNetworksConfig.java @@ -0,0 +1,123 @@ +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 #rxDropped + */ + @CheckForNull + public Long getRxDropped() { + return rxDropped; + } + + /** + * @see #rxErrors + */ + @CheckForNull + public Long getRxErrors() { + return rxErrors; + } + + /** + * @see #rxPackets + */ + @CheckForNull + public Long getRxPackets() { + return rxPackets; + } + + /** + * @see #txBytes + */ + @CheckForNull + public Long getTxBytes() { + return txBytes; + } + + /** + * @see #txDropped + */ + @CheckForNull + public Long getTxDropped() { + return txDropped; + } + + /** + * @see #txErrors + */ + @CheckForNull + public Long getTxErrors() { + return txErrors; + } + + /** + * @see #txPackets + */ + @CheckForNull + public Long getTxPackets() { + return txPackets; + } + + @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..3b020c4d2 100644 --- a/src/main/java/com/github/dockerjava/api/model/Statistics.java +++ b/src/main/java/com/github/dockerjava/api/model/Statistics.java @@ -28,29 +28,35 @@ 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} */ @Deprecated @JsonProperty("network") - private Map network; + private Map network; @JsonProperty("memory_stats") - private Map memoryStats; + private MemoryStatsConfig memoryStats; @JsonProperty("blkio_stats") - private Map blkioStats; + 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; @@ -60,7 +66,7 @@ public String getRead() { * @since Docker Remote API 1.21 */ @CheckForNull - public Map getNetworks() { + public Map getNetworks() { return networks; } @@ -68,11 +74,11 @@ public Map getNetworks() { * @deprecated as of Docker Remote API 1.21, replaced by {@link #getNetworks()} */ @Deprecated - public Map getNetwork() { + public Map getNetwork() { return network; } - public Map getCpuStats() { + public CpuStatsConfig getCpuStats() { return cpuStats; } @@ -80,18 +86,22 @@ 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; } - public Map getMemoryStats() { + public MemoryStatsConfig getMemoryStats() { return memoryStats; } - public Map getBlkioStats() { + 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 new file mode 100644 index 000000000..a732c78fa --- /dev/null +++ b/src/main/java/com/github/dockerjava/api/model/StatsConfig.java @@ -0,0 +1,384 @@ +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 #activeFile + */ + @CheckForNull + public Long getActiveFile() { + return activeFile; + } + + /** + * @see #cache + */ + @CheckForNull + public Long getCache() { + return cache; + } + + /** + * @see #dirty + */ + @CheckForNull + public Long getDirty() { + return dirty; + } + + /** + * @see #hierarchicalMemoryLimit + */ + @CheckForNull + public Long getHierarchicalMemoryLimit() { + return hierarchicalMemoryLimit; + } + + /** + * @see #hierarchicalMemswLimit + */ + @CheckForNull + public Long getHierarchicalMemswLimit() { + return hierarchicalMemswLimit; + } + + /** + * @see #inactiveAnon + */ + @CheckForNull + public Long getInactiveAnon() { + return inactiveAnon; + } + + /** + * @see #inactiveFile + */ + @CheckForNull + public Long getInactiveFile() { + return inactiveFile; + } + + /** + * @see #mappedFile + */ + @CheckForNull + public Long getMappedFile() { + return mappedFile; + } + + /** + * @see #pgfault + */ + @CheckForNull + public Long getPgfault() { + return pgfault; + } + + /** + * @see #pgmajfault + */ + @CheckForNull + public Long getPgmajfault() { + return pgmajfault; + } + + /** + * @see #pgpgin + */ + @CheckForNull + public Long getPgpgin() { + return pgpgin; + } + + /** + * @see #pgpgout + */ + @CheckForNull + public Long getPgpgout() { + return pgpgout; + } + + /** + * @see #rss + */ + @CheckForNull + public Long getRss() { + return rss; + } + + /** + * @see #rssHuge + */ + @CheckForNull + public Long getRssHuge() { + return rssHuge; + } + + /** + * @see #swap + */ + @CheckForNull + public Long getSwap() { + return swap; + } + + /** + * @see #totalActiveAnon + */ + @CheckForNull + public Long getTotalActiveAnon() { + return totalActiveAnon; + } + + /** + * @see #totalActiveFile + */ + @CheckForNull + public Long getTotalActiveFile() { + return totalActiveFile; + } + + /** + * @see #totalCache + */ + @CheckForNull + public Long getTotalCache() { + return totalCache; + } + + /** + * @see #totalDirty + */ + @CheckForNull + public Long getTotalDirty() { + return totalDirty; + } + + /** + * @see #totalInactiveAnon + */ + @CheckForNull + public Long getTotalInactiveAnon() { + return totalInactiveAnon; + } + + /** + * @see #totalInactiveFile + */ + @CheckForNull + public Long getTotalInactiveFile() { + return totalInactiveFile; + } + + /** + * @see #totalMappedFile + */ + @CheckForNull + public Long getTotalMappedFile() { + return totalMappedFile; + } + + /** + * @see #totalPgfault + */ + @CheckForNull + public Long getTotalPgfault() { + return totalPgfault; + } + + /** + * @see #totalPgmajfault + */ + @CheckForNull + public Long getTotalPgmajfault() { + return totalPgmajfault; + } + + /** + * @see #totalPgpgin + */ + @CheckForNull + public Long getTotalPgpgin() { + return totalPgpgin; + } + + /** + * @see #totalPgpgout + */ + @CheckForNull + public Long getTotalPgpgout() { + return totalPgpgout; + } + + /** + * @see #totalRss + */ + @CheckForNull + public Long getTotalRss() { + return totalRss; + } + + /** + * @see #totalRssHuge + */ + @CheckForNull + public Long getTotalRssHuge() { + return totalRssHuge; + } + + /** + * @see #totalSwap + */ + @CheckForNull + public Long getTotalSwap() { + return totalSwap; + } + + /** + * @see #totalUnevictable + */ + @CheckForNull + public Long getTotalUnevictable() { + return totalUnevictable; + } + + /** + * @see #totalWriteback + */ + @CheckForNull + public Long getTotalWriteback() { + return totalWriteback; + } + + /** + * @see #unevictable + */ + @CheckForNull + public Long getUnevictable() { + return unevictable; + } + + /** + * @see #writeback + */ + @CheckForNull + 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 new file mode 100644 index 000000000..d2083c4b3 --- /dev/null +++ b/src/test/java/com/github/dockerjava/api/model/StatisticsTest.java @@ -0,0 +1,125 @@ +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 java.util.Arrays; + +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 + */ +public class StatisticsTest { + + @Test + public void serderJson1() throws IOException { + final ObjectMapper mapper = new ObjectMapper(); + final JavaType type = mapper.getTypeFactory().uncheckedSimpleType(Statistics.class); + + final Statistics statistics = testRoundTrip(RemoteApiVersion.VERSION_1_27, + "containers/container/stats/stats1.json", + type + ); + + assertThat(statistics.getRead(), equalTo("2017-12-06T00:42:03.8352972Z")); + + 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 memoryStats = statistics.getMemoryStats(); + assertThat(memoryStats.getUsage(), is(647168L)); + assertThat(memoryStats.getMaxUsage(), is(1703936L)); + + 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(memoryStats.getLimit(), is(2095874048L)); + + 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)); + } +} 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..e542c10a9 --- /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 + } + } +}