diff --git a/extensions/geode-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/internal/DeltaSessionStatistics.java b/extensions/geode-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/internal/DeltaSessionStatistics.java index 2d591038f15e..99a3a83c416d 100644 --- a/extensions/geode-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/internal/DeltaSessionStatistics.java +++ b/extensions/geode-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/internal/DeltaSessionStatistics.java @@ -21,7 +21,7 @@ import com.gemstone.gemfire.StatisticsFactory; import com.gemstone.gemfire.StatisticsType; import com.gemstone.gemfire.StatisticsTypeFactory; -import com.gemstone.gemfire.internal.StatisticsTypeFactoryImpl; +import com.gemstone.gemfire.internal.statistics.StatisticsTypeFactoryImpl; public class DeltaSessionStatistics { diff --git a/extensions/geode-modules/src/main/java/com/gemstone/gemfire/modules/util/ModuleStatistics.java b/extensions/geode-modules/src/main/java/com/gemstone/gemfire/modules/util/ModuleStatistics.java index 82e882ca9951..48020a301c6d 100644 --- a/extensions/geode-modules/src/main/java/com/gemstone/gemfire/modules/util/ModuleStatistics.java +++ b/extensions/geode-modules/src/main/java/com/gemstone/gemfire/modules/util/ModuleStatistics.java @@ -22,7 +22,7 @@ import com.gemstone.gemfire.StatisticsType; import com.gemstone.gemfire.StatisticsTypeFactory; import com.gemstone.gemfire.distributed.DistributedSystem; -import com.gemstone.gemfire.internal.StatisticsTypeFactoryImpl; +import com.gemstone.gemfire.internal.statistics.StatisticsTypeFactoryImpl; /** * Statistics for modules. diff --git a/geode-core/src/main/java/com/gemstone/gemfire/StatisticsFactory.java b/geode-core/src/main/java/com/gemstone/gemfire/StatisticsFactory.java index 3ef5ba5d89b1..3ba1665d6fb0 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/StatisticsFactory.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/StatisticsFactory.java @@ -17,7 +17,7 @@ package com.gemstone.gemfire; //import com.gemstone.gemfire.distributed.DistributedSystem; -//import com.gemstone.gemfire.internal.StatArchiveFormat; +//import com.gemstone.gemfire.internal.statistics.StatArchiveFormat; //import java.io.IOException; //import java.io.Reader; diff --git a/geode-core/src/main/java/com/gemstone/gemfire/StatisticsTypeFactory.java b/geode-core/src/main/java/com/gemstone/gemfire/StatisticsTypeFactory.java index 9b6c5462c17a..4569b7e75fa7 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/StatisticsTypeFactory.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/StatisticsTypeFactory.java @@ -17,7 +17,7 @@ package com.gemstone.gemfire; //import com.gemstone.gemfire.distributed.DistributedSystem; -import com.gemstone.gemfire.internal.StatArchiveFormat; +import com.gemstone.gemfire.internal.statistics.StatArchiveFormat; import java.io.IOException; import java.io.Reader; diff --git a/geode-core/src/main/java/com/gemstone/gemfire/admin/internal/MemberHealthEvaluator.java b/geode-core/src/main/java/com/gemstone/gemfire/admin/internal/MemberHealthEvaluator.java index d0710cab7440..534472435bbc 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/admin/internal/MemberHealthEvaluator.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/admin/internal/MemberHealthEvaluator.java @@ -24,6 +24,8 @@ import com.gemstone.gemfire.internal.i18n.LocalizedStrings; import com.gemstone.gemfire.internal.cache.CachePerfStats; import com.gemstone.gemfire.internal.cache.GemFireCacheImpl; +import com.gemstone.gemfire.internal.statistics.GemFireStatSampler; +import com.gemstone.gemfire.internal.statistics.platform.ProcessStats; import java.util.*; diff --git a/geode-core/src/main/java/com/gemstone/gemfire/cache/asyncqueue/internal/AsyncEventQueueStats.java b/geode-core/src/main/java/com/gemstone/gemfire/cache/asyncqueue/internal/AsyncEventQueueStats.java index 8d541a3283a9..e9e1e0bab451 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/cache/asyncqueue/internal/AsyncEventQueueStats.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/cache/asyncqueue/internal/AsyncEventQueueStats.java @@ -20,7 +20,7 @@ import com.gemstone.gemfire.StatisticsFactory; import com.gemstone.gemfire.StatisticsType; import com.gemstone.gemfire.StatisticsTypeFactory; -import com.gemstone.gemfire.internal.StatisticsTypeFactoryImpl; +import com.gemstone.gemfire.internal.statistics.StatisticsTypeFactoryImpl; import com.gemstone.gemfire.internal.cache.wan.GatewaySenderStats; public class AsyncEventQueueStats extends GatewaySenderStats { diff --git a/geode-core/src/main/java/com/gemstone/gemfire/cache/client/internal/ConnectionStats.java b/geode-core/src/main/java/com/gemstone/gemfire/cache/client/internal/ConnectionStats.java index 4bd443989b63..6aaae2d95b12 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/cache/client/internal/ConnectionStats.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/cache/client/internal/ConnectionStats.java @@ -22,7 +22,7 @@ import com.gemstone.gemfire.StatisticsType; import com.gemstone.gemfire.StatisticsTypeFactory; import com.gemstone.gemfire.distributed.internal.DistributionStats; -import com.gemstone.gemfire.internal.StatisticsTypeFactoryImpl; +import com.gemstone.gemfire.internal.statistics.StatisticsTypeFactoryImpl; import com.gemstone.gemfire.internal.cache.PoolStats; import com.gemstone.gemfire.internal.cache.tier.sockets.MessageStats; diff --git a/geode-core/src/main/java/com/gemstone/gemfire/cache/client/internal/EndpointManagerImpl.java b/geode-core/src/main/java/com/gemstone/gemfire/cache/client/internal/EndpointManagerImpl.java index d15560251732..111cec68bb91 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/cache/client/internal/EndpointManagerImpl.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/cache/client/internal/EndpointManagerImpl.java @@ -32,7 +32,7 @@ import com.gemstone.gemfire.distributed.DistributedMember; import com.gemstone.gemfire.distributed.DistributedSystem; import com.gemstone.gemfire.distributed.internal.ServerLocation; -import com.gemstone.gemfire.internal.DummyStatisticsFactory; +import com.gemstone.gemfire.internal.statistics.DummyStatisticsFactory; import com.gemstone.gemfire.internal.cache.PoolStats; import com.gemstone.gemfire.internal.cache.tier.InternalClientMembership; import com.gemstone.gemfire.internal.logging.LogService; diff --git a/geode-core/src/main/java/com/gemstone/gemfire/cache/client/internal/PoolImpl.java b/geode-core/src/main/java/com/gemstone/gemfire/cache/client/internal/PoolImpl.java index b26d76b5b208..371098d03565 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/cache/client/internal/PoolImpl.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/cache/client/internal/PoolImpl.java @@ -33,7 +33,7 @@ import com.gemstone.gemfire.distributed.internal.DistributionConfig; import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem; import com.gemstone.gemfire.distributed.internal.ServerLocation; -import com.gemstone.gemfire.internal.DummyStatisticsFactory; +import com.gemstone.gemfire.internal.statistics.DummyStatisticsFactory; import com.gemstone.gemfire.internal.ScheduledThreadPoolExecutorWithKeepAlive; import com.gemstone.gemfire.internal.admin.ClientStatsManager; import com.gemstone.gemfire.internal.cache.*; diff --git a/geode-core/src/main/java/com/gemstone/gemfire/cache/query/internal/CqQueryVsdStats.java b/geode-core/src/main/java/com/gemstone/gemfire/cache/query/internal/CqQueryVsdStats.java index e9d30d527d27..e65af17e5721 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/cache/query/internal/CqQueryVsdStats.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/cache/query/internal/CqQueryVsdStats.java @@ -22,7 +22,7 @@ import com.gemstone.gemfire.StatisticsType; import com.gemstone.gemfire.StatisticsTypeFactory; import com.gemstone.gemfire.cache.query.CqEvent; -import com.gemstone.gemfire.internal.StatisticsTypeFactoryImpl; +import com.gemstone.gemfire.internal.statistics.StatisticsTypeFactoryImpl; import com.gemstone.gemfire.internal.cache.tier.MessageType; /** diff --git a/geode-core/src/main/java/com/gemstone/gemfire/cache/query/internal/index/IndexStats.java b/geode-core/src/main/java/com/gemstone/gemfire/cache/query/internal/index/IndexStats.java index 77941b6c63c5..84d9b618f301 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/cache/query/internal/index/IndexStats.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/cache/query/internal/index/IndexStats.java @@ -19,7 +19,7 @@ import com.gemstone.gemfire.*; //import com.gemstone.gemfire.cache.query.*; -import com.gemstone.gemfire.internal.StatisticsTypeFactoryImpl; +import com.gemstone.gemfire.internal.statistics.StatisticsTypeFactoryImpl; import com.gemstone.gemfire.internal.cache.CachePerfStats; /** diff --git a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/DistributionStats.java b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/DistributionStats.java index c4803ab6f07f..dcd4aba70cc2 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/DistributionStats.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/DistributionStats.java @@ -24,7 +24,7 @@ import com.gemstone.gemfire.StatisticsType; import com.gemstone.gemfire.StatisticsTypeFactory; import com.gemstone.gemfire.internal.NanoTimer; -import com.gemstone.gemfire.internal.StatisticsTypeFactoryImpl; +import com.gemstone.gemfire.internal.statistics.StatisticsTypeFactoryImpl; import com.gemstone.gemfire.internal.logging.LogService; //import java.io.*; import com.gemstone.gemfire.internal.tcp.Buffers; diff --git a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/InternalDistributedSystem.java b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/InternalDistributedSystem.java index 1ea5611fcc19..49a4c9742fd3 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/InternalDistributedSystem.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/InternalDistributedSystem.java @@ -55,6 +55,14 @@ import com.gemstone.gemfire.internal.logging.log4j.LogWriterAppenders; import com.gemstone.gemfire.internal.offheap.MemoryAllocator; import com.gemstone.gemfire.internal.offheap.OffHeapStorage; +import com.gemstone.gemfire.internal.statistics.DummyStatisticsImpl; +import com.gemstone.gemfire.internal.statistics.GemFireStatSampler; +import com.gemstone.gemfire.internal.statistics.platform.LinuxProcFsStatistics; +import com.gemstone.gemfire.internal.statistics.LocalStatisticsImpl; +import com.gemstone.gemfire.internal.statistics.platform.OsStatisticsFactory; +import com.gemstone.gemfire.internal.statistics.StatisticsImpl; +import com.gemstone.gemfire.internal.statistics.StatisticsManager; +import com.gemstone.gemfire.internal.statistics.StatisticsTypeFactoryImpl; import com.gemstone.gemfire.internal.tcp.ConnectionTable; import com.gemstone.gemfire.internal.util.concurrent.StoppableCondition; import com.gemstone.gemfire.internal.util.concurrent.StoppableReentrantLock; diff --git a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/LocatorStats.java b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/LocatorStats.java index f59ed84bd6ef..897b8c3ff678 100755 --- a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/LocatorStats.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/LocatorStats.java @@ -17,7 +17,7 @@ package com.gemstone.gemfire.distributed.internal; import com.gemstone.gemfire.*; -import com.gemstone.gemfire.internal.StatisticsTypeFactoryImpl; +import com.gemstone.gemfire.internal.statistics.StatisticsTypeFactoryImpl; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicLong; diff --git a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/locks/DLockStats.java b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/locks/DLockStats.java index 9a61c10b283b..ac83d1447769 100755 --- a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/locks/DLockStats.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/locks/DLockStats.java @@ -18,8 +18,8 @@ package com.gemstone.gemfire.distributed.internal.locks; import com.gemstone.gemfire.*; -import com.gemstone.gemfire.internal.*; import com.gemstone.gemfire.distributed.internal.*; +import com.gemstone.gemfire.internal.statistics.StatisticsTypeFactoryImpl; /** * This class maintains statistics in GemFire about the distributed lock diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/SystemAdmin.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/SystemAdmin.java index cc03ad6a372f..e52950f69a48 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/internal/SystemAdmin.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/SystemAdmin.java @@ -26,8 +26,9 @@ import com.gemstone.gemfire.distributed.DistributedMember; import com.gemstone.gemfire.distributed.internal.*; import com.gemstone.gemfire.distributed.internal.membership.InternalDistributedMember; -import com.gemstone.gemfire.internal.StatArchiveReader.ResourceInst; -import com.gemstone.gemfire.internal.StatArchiveReader.StatValue; +import com.gemstone.gemfire.internal.statistics.StatArchiveReader; +import com.gemstone.gemfire.internal.statistics.StatArchiveReader.ResourceInst; +import com.gemstone.gemfire.internal.statistics.StatArchiveReader.StatValue; import com.gemstone.gemfire.internal.admin.remote.TailLogResponse; import com.gemstone.gemfire.internal.cache.DiskStoreImpl; import com.gemstone.gemfire.internal.i18n.LocalizedStrings; @@ -940,7 +941,7 @@ private static int findWordBreak(String str, int fromIdx) { return result; } - private static class StatSpec implements StatArchiveReader.StatSpec { + public static class StatSpec implements StatArchiveReader.StatSpec { public final String cmdLineSpec; public final String typeId; public final String instanceId; diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/admin/remote/AddStatListenerResponse.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/admin/remote/AddStatListenerResponse.java index 7ea19f57cbdc..078798f19725 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/internal/admin/remote/AddStatListenerResponse.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/admin/remote/AddStatListenerResponse.java @@ -19,12 +19,12 @@ package com.gemstone.gemfire.internal.admin.remote; //import com.gemstone.gemfire.*; -import com.gemstone.gemfire.internal.*; //import com.gemstone.gemfire.internal.admin.*; import com.gemstone.gemfire.distributed.internal.*; import java.io.*; //import java.util.*; import com.gemstone.gemfire.distributed.internal.membership.*; +import com.gemstone.gemfire.internal.statistics.GemFireStatSampler; /** * A message that is sent to a particular distribution manager to diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/admin/remote/AdminConsoleDisconnectMessage.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/admin/remote/AdminConsoleDisconnectMessage.java index 2f8d336e204a..a1d36804fa52 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/internal/admin/remote/AdminConsoleDisconnectMessage.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/admin/remote/AdminConsoleDisconnectMessage.java @@ -28,7 +28,7 @@ import com.gemstone.gemfire.distributed.internal.DistributionManager; import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem; import com.gemstone.gemfire.distributed.internal.PooledDistributionMessage; -import com.gemstone.gemfire.internal.GemFireStatSampler; +import com.gemstone.gemfire.internal.statistics.GemFireStatSampler; import com.gemstone.gemfire.internal.i18n.LocalizedStrings; import com.gemstone.gemfire.internal.logging.LogService; import com.gemstone.gemfire.internal.logging.log4j.AlertAppender; diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/admin/remote/CancelStatListenerResponse.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/admin/remote/CancelStatListenerResponse.java index d338b70d7212..a223524948e5 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/internal/admin/remote/CancelStatListenerResponse.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/admin/remote/CancelStatListenerResponse.java @@ -19,13 +19,13 @@ package com.gemstone.gemfire.internal.admin.remote; //import com.gemstone.gemfire.*; -import com.gemstone.gemfire.internal.*; import com.gemstone.gemfire.internal.i18n.LocalizedStrings; //import com.gemstone.gemfire.internal.admin.*; import com.gemstone.gemfire.distributed.internal.*; import java.io.*; //import java.util.*; import com.gemstone.gemfire.distributed.internal.membership.*; +import com.gemstone.gemfire.internal.statistics.GemFireStatSampler; /** * A message that is sent to a particular distribution manager to diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/admin/remote/RemoteStat.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/admin/remote/RemoteStat.java index cdc2b88f7c91..6127e45fb4be 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/internal/admin/remote/RemoteStat.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/admin/remote/RemoteStat.java @@ -18,8 +18,8 @@ package com.gemstone.gemfire.internal.admin.remote; import com.gemstone.gemfire.*; -import com.gemstone.gemfire.internal.*; import com.gemstone.gemfire.internal.admin.*; +import com.gemstone.gemfire.internal.statistics.StatisticDescriptorImpl; //import java.util.*; import java.io.*; diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/admin/remote/package.html b/geode-core/src/main/java/com/gemstone/gemfire/internal/admin/remote/package.html index a2fef69435ab..a47f53dbb733 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/internal/admin/remote/package.html +++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/admin/remote/package.html @@ -34,7 +34,7 @@

Alerting

Statistics

StatListeners are assigned a {@link -com.gemstone.gemfire.internal.GemFireStatSampler#addListener} unique +com.gemstone.gemfire.internal.statistics.GemFireStatSampler#addListener} unique id} in the remote VM. diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/CachePerfStats.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/CachePerfStats.java index 72a850d3d234..532bafa8351a 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/CachePerfStats.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/CachePerfStats.java @@ -21,6 +21,7 @@ import com.gemstone.gemfire.internal.*; import com.gemstone.gemfire.distributed.internal.PoolStatHelper; import com.gemstone.gemfire.distributed.internal.QueueStatHelper; +import com.gemstone.gemfire.internal.statistics.StatisticsTypeFactoryImpl; /** * CachePerfStats tracks statistics about GemFire cache performance. diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/DiskDirectoryStats.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/DiskDirectoryStats.java index 21a7b260db8e..a0d70225dfb6 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/DiskDirectoryStats.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/DiskDirectoryStats.java @@ -19,7 +19,7 @@ import com.gemstone.gemfire.*; //import com.gemstone.gemfire.internal.NanoTimer; //import com.gemstone.gemfire.cache.Region; -import com.gemstone.gemfire.internal.*; +import com.gemstone.gemfire.internal.statistics.StatisticsTypeFactoryImpl; /** * GemFire statistics about Disk Directories diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/DiskRegionStats.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/DiskRegionStats.java index ae9b0a9a9910..014fd6f41033 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/DiskRegionStats.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/DiskRegionStats.java @@ -21,7 +21,7 @@ import com.gemstone.gemfire.StatisticsFactory; import com.gemstone.gemfire.StatisticsType; import com.gemstone.gemfire.StatisticsTypeFactory; -import com.gemstone.gemfire.internal.StatisticsTypeFactoryImpl; +import com.gemstone.gemfire.internal.statistics.StatisticsTypeFactoryImpl; /** * GemFire statistics about a {@link DiskRegion}. diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/DiskStoreStats.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/DiskStoreStats.java index db505b9fd47d..e5f4bb238ff3 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/DiskStoreStats.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/DiskStoreStats.java @@ -18,8 +18,8 @@ import com.gemstone.gemfire.*; //import com.gemstone.gemfire.cache.Region; -import com.gemstone.gemfire.internal.*; import com.gemstone.gemfire.distributed.internal.DistributionStats; +import com.gemstone.gemfire.internal.statistics.StatisticsTypeFactoryImpl; /** * GemFire statistics about a {@link DiskStoreImpl}. diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/PartitionedRegionStats.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/PartitionedRegionStats.java index 04d432fe1521..c6f12436cbeb 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/PartitionedRegionStats.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/PartitionedRegionStats.java @@ -27,7 +27,7 @@ import com.gemstone.gemfire.StatisticsType; import com.gemstone.gemfire.StatisticsTypeFactory; import com.gemstone.gemfire.cache.Region; -import com.gemstone.gemfire.internal.StatisticsTypeFactoryImpl; +import com.gemstone.gemfire.internal.statistics.StatisticsTypeFactoryImpl; /** * Represents a statistics type that can be archived to vsd. Loading of this diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/PoolStats.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/PoolStats.java index 2161de71ff8f..e53b61cbaa5f 100755 --- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/PoolStats.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/PoolStats.java @@ -18,7 +18,7 @@ import com.gemstone.gemfire.*; import com.gemstone.gemfire.distributed.internal.DistributionStats; -import com.gemstone.gemfire.internal.StatisticsTypeFactoryImpl; +import com.gemstone.gemfire.internal.statistics.StatisticsTypeFactoryImpl; import static com.gemstone.gemfire.distributed.ConfigurationProperties.LOCATORS; diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/control/HeapMemoryMonitor.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/control/HeapMemoryMonitor.java index bc83335fe530..eeaad427d780 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/control/HeapMemoryMonitor.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/control/HeapMemoryMonitor.java @@ -22,10 +22,10 @@ import com.gemstone.gemfire.cache.query.internal.QueryMonitor; import com.gemstone.gemfire.distributed.internal.DistributionConfig; import com.gemstone.gemfire.distributed.internal.membership.InternalDistributedMember; -import com.gemstone.gemfire.internal.GemFireStatSampler; -import com.gemstone.gemfire.internal.LocalStatListener; +import com.gemstone.gemfire.internal.statistics.GemFireStatSampler; +import com.gemstone.gemfire.internal.statistics.LocalStatListener; import com.gemstone.gemfire.internal.SetUtils; -import com.gemstone.gemfire.internal.StatisticsImpl; +import com.gemstone.gemfire.internal.statistics.StatisticsImpl; import com.gemstone.gemfire.internal.cache.GemFireCacheImpl; import com.gemstone.gemfire.internal.cache.control.InternalResourceManager.ResourceType; import com.gemstone.gemfire.internal.cache.control.MemoryThresholds.MemoryState; @@ -759,7 +759,7 @@ public final boolean isMemberHeapCritical(final InternalDistributedMember member class LocalHeapStatListener implements LocalStatListener { /* (non-Javadoc) - * @see com.gemstone.gemfire.internal.LocalStatListener#statValueChanged(double) + * @see com.gemstone.gemfire.internal.statistics.LocalStatListener#statValueChanged(double) */ @Override @SuppressWarnings("synthetic-access") diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/control/ResourceManagerStats.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/control/ResourceManagerStats.java index d54e7c4d69b3..32812735c1ce 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/control/ResourceManagerStats.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/control/ResourceManagerStats.java @@ -23,7 +23,7 @@ import com.gemstone.gemfire.StatisticsTypeFactory; import com.gemstone.gemfire.distributed.internal.PoolStatHelper; import com.gemstone.gemfire.distributed.internal.QueueStatHelper; -import com.gemstone.gemfire.internal.StatisticsTypeFactoryImpl; +import com.gemstone.gemfire.internal.statistics.StatisticsTypeFactoryImpl; /** * Contains methods for manipulating resource manager statistics. diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/execute/FunctionServiceStats.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/execute/FunctionServiceStats.java index e62d8001f4bc..b4ad43b1a207 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/execute/FunctionServiceStats.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/execute/FunctionServiceStats.java @@ -22,8 +22,8 @@ import com.gemstone.gemfire.StatisticsType; import com.gemstone.gemfire.StatisticsTypeFactory; import com.gemstone.gemfire.distributed.internal.DistributionStats; -import com.gemstone.gemfire.internal.DummyStatisticsImpl; -import com.gemstone.gemfire.internal.StatisticsTypeFactoryImpl; +import com.gemstone.gemfire.internal.statistics.DummyStatisticsImpl; +import com.gemstone.gemfire.internal.statistics.StatisticsTypeFactoryImpl; public class FunctionServiceStats { diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/execute/FunctionStats.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/execute/FunctionStats.java index 0e7687a8062d..88a8b109b58c 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/execute/FunctionStats.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/execute/FunctionStats.java @@ -20,9 +20,8 @@ import com.gemstone.gemfire.distributed.internal.DistributionConfig; import com.gemstone.gemfire.distributed.internal.DistributionStats; import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem; -import com.gemstone.gemfire.internal.DummyStatisticsImpl; -import com.gemstone.gemfire.internal.StatisticsTypeFactoryImpl; -import com.gemstone.gemfire.internal.cache.GemFireCacheImpl; +import com.gemstone.gemfire.internal.statistics.DummyStatisticsImpl; +import com.gemstone.gemfire.internal.statistics.StatisticsTypeFactoryImpl; public class FunctionStats { diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/ha/HARegionQueueStats.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/ha/HARegionQueueStats.java index e7b74d132dee..150c080d054a 100755 --- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/ha/HARegionQueueStats.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/ha/HARegionQueueStats.java @@ -21,7 +21,7 @@ import com.gemstone.gemfire.StatisticsFactory; import com.gemstone.gemfire.StatisticsType; import com.gemstone.gemfire.StatisticsTypeFactory; -import com.gemstone.gemfire.internal.StatisticsTypeFactoryImpl; +import com.gemstone.gemfire.internal.statistics.StatisticsTypeFactoryImpl; /** * This class tracks GemFire statistics related to a {@link HARegionQueue}. diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/lru/HeapLRUCapacityController.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/lru/HeapLRUCapacityController.java index 7bf2d1f35b45..a2a7be1f745a 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/lru/HeapLRUCapacityController.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/lru/HeapLRUCapacityController.java @@ -25,7 +25,7 @@ import com.gemstone.gemfire.cache.Region; import com.gemstone.gemfire.cache.util.ObjectSizer; import com.gemstone.gemfire.distributed.internal.DistributionConfig; -import com.gemstone.gemfire.internal.StatisticsTypeFactoryImpl; +import com.gemstone.gemfire.internal.statistics.StatisticsTypeFactoryImpl; import com.gemstone.gemfire.internal.cache.*; import com.gemstone.gemfire.internal.cache.control.InternalResourceManager; import com.gemstone.gemfire.internal.i18n.LocalizedStrings; diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/lru/LRUCapacityController.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/lru/LRUCapacityController.java index 0e5afab452dd..ffbc4ad19636 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/lru/LRUCapacityController.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/lru/LRUCapacityController.java @@ -18,7 +18,7 @@ import com.gemstone.gemfire.*; import com.gemstone.gemfire.cache.*; -import com.gemstone.gemfire.internal.StatisticsTypeFactoryImpl; +import com.gemstone.gemfire.internal.statistics.StatisticsTypeFactoryImpl; import com.gemstone.gemfire.internal.cache.*; import com.gemstone.gemfire.internal.i18n.LocalizedStrings; diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/lru/MemLRUCapacityController.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/lru/MemLRUCapacityController.java index d1634b4537bb..6cfa58219135 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/lru/MemLRUCapacityController.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/lru/MemLRUCapacityController.java @@ -29,7 +29,7 @@ import com.gemstone.gemfire.cache.RegionAttributes; import com.gemstone.gemfire.cache.util.ObjectSizer; import com.gemstone.gemfire.internal.ClassPathLoader; -import com.gemstone.gemfire.internal.StatisticsTypeFactoryImpl; +import com.gemstone.gemfire.internal.statistics.StatisticsTypeFactoryImpl; import com.gemstone.gemfire.internal.cache.AbstractLRURegionMap.CDValueWrapper; import com.gemstone.gemfire.internal.cache.CachedDeserializableFactory; import com.gemstone.gemfire.internal.cache.Token; diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/CacheClientNotifier.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/CacheClientNotifier.java index edf3a9484418..6fd45605c97a 100755 --- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/CacheClientNotifier.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/CacheClientNotifier.java @@ -81,7 +81,7 @@ import com.gemstone.gemfire.distributed.internal.ReplyMessage; import com.gemstone.gemfire.distributed.internal.ReplyProcessor21; import com.gemstone.gemfire.internal.ClassLoadUtil; -import com.gemstone.gemfire.internal.DummyStatisticsFactory; +import com.gemstone.gemfire.internal.statistics.DummyStatisticsFactory; import com.gemstone.gemfire.internal.InternalDataSerializer; import com.gemstone.gemfire.internal.InternalInstantiator; import com.gemstone.gemfire.internal.SocketCloser; diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/CacheClientNotifierStats.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/CacheClientNotifierStats.java index afc42358d7c9..36c22b6a43c8 100755 --- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/CacheClientNotifierStats.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/CacheClientNotifierStats.java @@ -21,8 +21,7 @@ import com.gemstone.gemfire.StatisticsFactory; import com.gemstone.gemfire.StatisticsType; import com.gemstone.gemfire.StatisticsTypeFactory; -import com.gemstone.gemfire.internal.NanoTimer; -import com.gemstone.gemfire.internal.StatisticsTypeFactoryImpl; +import com.gemstone.gemfire.internal.statistics.StatisticsTypeFactoryImpl; import com.gemstone.gemfire.distributed.internal.DistributionStats; /** diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/CacheClientProxyStats.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/CacheClientProxyStats.java index cf69d901b16c..7812a3a74c16 100755 --- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/CacheClientProxyStats.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/CacheClientProxyStats.java @@ -22,7 +22,7 @@ import com.gemstone.gemfire.StatisticsFactory; import com.gemstone.gemfire.StatisticsType; import com.gemstone.gemfire.StatisticsTypeFactory; -import com.gemstone.gemfire.internal.StatisticsTypeFactoryImpl; +import com.gemstone.gemfire.internal.statistics.StatisticsTypeFactoryImpl; import com.gemstone.gemfire.distributed.internal.DistributionStats; /** diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/CacheClientUpdater.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/CacheClientUpdater.java index 391c3e60ca77..26efd4d0f9ce 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/CacheClientUpdater.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/CacheClientUpdater.java @@ -45,6 +45,7 @@ import com.gemstone.gemfire.internal.logging.log4j.LogMarker; import com.gemstone.gemfire.internal.offheap.annotations.Released; import com.gemstone.gemfire.internal.sequencelog.EntryLogger; +import com.gemstone.gemfire.internal.statistics.StatisticsTypeFactoryImpl; import com.gemstone.gemfire.security.AuthenticationFailedException; import com.gemstone.gemfire.security.AuthenticationRequiredException; import com.gemstone.gemfire.security.GemFireSecurityException; diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/CacheServerStats.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/CacheServerStats.java index 626e0755f1d9..360a87ce8fe1 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/CacheServerStats.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/CacheServerStats.java @@ -14,14 +14,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -/** - * Bridge Server statistic definitions - */ package com.gemstone.gemfire.internal.cache.tier.sockets; -import java.net.InetAddress; - import com.gemstone.gemfire.StatisticDescriptor; import com.gemstone.gemfire.Statistics; import com.gemstone.gemfire.StatisticsFactory; @@ -29,10 +23,11 @@ import com.gemstone.gemfire.cache.server.ServerLoad; import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem; import com.gemstone.gemfire.distributed.internal.PoolStatHelper; -import com.gemstone.gemfire.internal.DummyStatisticsFactory; import com.gemstone.gemfire.internal.SocketCreator; -import com.gemstone.gemfire.internal.util.ArrayUtils; +/** + * Bridge Server statistic definitions + */ public class CacheServerStats implements MessageStats { private static final String typeName = "CacheServerStats"; diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/wan/GatewaySenderStats.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/wan/GatewaySenderStats.java index 15a6dee2785d..10444568ab3b 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/wan/GatewaySenderStats.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/wan/GatewaySenderStats.java @@ -22,7 +22,7 @@ import com.gemstone.gemfire.StatisticsType; import com.gemstone.gemfire.StatisticsTypeFactory; import com.gemstone.gemfire.distributed.internal.DistributionStats; -import com.gemstone.gemfire.internal.StatisticsTypeFactoryImpl; +import com.gemstone.gemfire.internal.statistics.StatisticsTypeFactoryImpl; import com.gemstone.gemfire.internal.cache.CachePerfStats; public class GatewaySenderStats { diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/concurrent/Atomics.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/concurrent/Atomics.java index 8940a69963a2..94750591fd9b 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/internal/concurrent/Atomics.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/concurrent/Atomics.java @@ -20,9 +20,9 @@ import com.gemstone.gemfire.Statistics; import com.gemstone.gemfire.StatisticsType; import com.gemstone.gemfire.distributed.internal.DistributionConfig; -import com.gemstone.gemfire.internal.LocalStatisticsImpl; -import com.gemstone.gemfire.internal.StatisticsManager; -import com.gemstone.gemfire.internal.StatisticsTypeImpl; +import com.gemstone.gemfire.internal.statistics.LocalStatisticsImpl; +import com.gemstone.gemfire.internal.statistics.StatisticsManager; +import com.gemstone.gemfire.internal.statistics.StatisticsTypeImpl; import com.gemstone.gemfire.internal.stats50.Atomic50StatisticsImpl; import java.util.concurrent.atomic.AtomicLong; diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/OffHeapStorage.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/OffHeapStorage.java index bc7fb6a4bd99..449e05a75e4f 100755 --- a/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/OffHeapStorage.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/OffHeapStorage.java @@ -24,7 +24,7 @@ import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem; import com.gemstone.gemfire.distributed.internal.InternalLocator; import com.gemstone.gemfire.internal.ClassPathLoader; -import com.gemstone.gemfire.internal.StatisticsTypeFactoryImpl; +import com.gemstone.gemfire.internal.statistics.StatisticsTypeFactoryImpl; import com.gemstone.gemfire.internal.i18n.LocalizedStrings; import java.lang.reflect.Method; diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/AbstractStatisticsFactory.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/AbstractStatisticsFactory.java similarity index 99% rename from geode-core/src/main/java/com/gemstone/gemfire/internal/AbstractStatisticsFactory.java rename to geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/AbstractStatisticsFactory.java index 972e670e8db4..fb07d456aff9 100755 --- a/geode-core/src/main/java/com/gemstone/gemfire/internal/AbstractStatisticsFactory.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/AbstractStatisticsFactory.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.gemstone.gemfire.internal; +package com.gemstone.gemfire.internal.statistics; import com.gemstone.gemfire.StatisticDescriptor; import com.gemstone.gemfire.Statistics; diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/ArchiveSplitter.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/ArchiveSplitter.java similarity index 99% rename from geode-core/src/main/java/com/gemstone/gemfire/internal/ArchiveSplitter.java rename to geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/ArchiveSplitter.java index 28b9dd73b01c..14aadf1ac21f 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/internal/ArchiveSplitter.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/ArchiveSplitter.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.gemstone.gemfire.internal; +package com.gemstone.gemfire.internal.statistics; import com.gemstone.gemfire.*; import com.gemstone.gemfire.internal.i18n.LocalizedStrings; @@ -512,7 +512,7 @@ public int read(byte[] b, int off, int len) throws IOException { public static void main(String args[]) throws IOException { if (args.length != 1) { - System.err.println(LocalizedStrings.ArchiveSplitter_USAGE.toLocalizedString() + ": com.gemstone.gemfire.internal.ArchiveSplitter "); + System.err.println(LocalizedStrings.ArchiveSplitter_USAGE.toLocalizedString() + ": com.gemstone.gemfire.internal.statistics.ArchiveSplitter "); System.exit(1); } ArchiveSplitter as = new ArchiveSplitter(new File(args[0])); diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/CallbackSampler.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/CallbackSampler.java index 4bc300966626..4b16a28835be 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/CallbackSampler.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/CallbackSampler.java @@ -23,9 +23,6 @@ import com.gemstone.gemfire.CancelCriterion; import com.gemstone.gemfire.Statistics; import com.gemstone.gemfire.SystemFailure; -import com.gemstone.gemfire.internal.StatSamplerStats; -import com.gemstone.gemfire.internal.StatisticsImpl; -import com.gemstone.gemfire.internal.StatisticsManager; import com.gemstone.gemfire.internal.logging.LogService; import org.apache.logging.log4j.Logger; diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/DummyStatisticsFactory.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/DummyStatisticsFactory.java similarity index 98% rename from geode-core/src/main/java/com/gemstone/gemfire/internal/DummyStatisticsFactory.java rename to geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/DummyStatisticsFactory.java index 9d280eb34015..350e381c9a34 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/internal/DummyStatisticsFactory.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/DummyStatisticsFactory.java @@ -15,9 +15,10 @@ * limitations under the License. */ -package com.gemstone.gemfire.internal; +package com.gemstone.gemfire.internal.statistics; import com.gemstone.gemfire.*; + import java.io.*; /** @@ -25,7 +26,7 @@ */ public class DummyStatisticsFactory implements StatisticsFactory { - private final static StatisticsTypeFactoryImpl tf = (StatisticsTypeFactoryImpl)StatisticsTypeFactoryImpl.singleton(); + private final static StatisticsTypeFactoryImpl tf = (StatisticsTypeFactoryImpl) StatisticsTypeFactoryImpl.singleton(); /** Creates a new instance of DummyStatisticsFactory */ public DummyStatisticsFactory() { diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/DummyStatisticsImpl.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/DummyStatisticsImpl.java similarity index 99% rename from geode-core/src/main/java/com/gemstone/gemfire/internal/DummyStatisticsImpl.java rename to geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/DummyStatisticsImpl.java index aa8da5069697..b5c5ec1b69d1 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/internal/DummyStatisticsImpl.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/DummyStatisticsImpl.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.gemstone.gemfire.internal; +package com.gemstone.gemfire.internal.statistics; import java.util.function.DoubleSupplier; import java.util.function.IntSupplier; diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/GemFireStatSampler.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/GemFireStatSampler.java similarity index 96% rename from geode-core/src/main/java/com/gemstone/gemfire/internal/GemFireStatSampler.java rename to geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/GemFireStatSampler.java index 1eb35d0c5589..c723b0ce8001 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/internal/GemFireStatSampler.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/GemFireStatSampler.java @@ -14,17 +14,22 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.gemstone.gemfire.internal; +package com.gemstone.gemfire.internal.statistics; import com.gemstone.gemfire.Statistics; import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem; import com.gemstone.gemfire.distributed.internal.membership.InternalDistributedMember; +import com.gemstone.gemfire.internal.GemFireVersion; +import com.gemstone.gemfire.internal.OSProcess; +import com.gemstone.gemfire.internal.PureJavaMode; import com.gemstone.gemfire.internal.admin.ListenerIdMap; import com.gemstone.gemfire.internal.admin.remote.StatListenerMessage; import com.gemstone.gemfire.internal.i18n.LocalizedStrings; import com.gemstone.gemfire.internal.logging.LogService; import com.gemstone.gemfire.internal.logging.log4j.LocalizedMessage; import com.gemstone.gemfire.internal.logging.log4j.LogMarker; +import com.gemstone.gemfire.internal.statistics.platform.OsStatisticsFactory; +import com.gemstone.gemfire.internal.statistics.platform.ProcessStats; import java.io.File; import java.util.ArrayList; @@ -43,7 +48,7 @@ * The StatisticsManager is implemented by DistributedSystem. * */ -public final class GemFireStatSampler extends HostStatSampler { +public final class GemFireStatSampler extends HostStatSampler { private static final Logger logger = LogService.getLogger(); @@ -83,8 +88,8 @@ public final ProcessStats getProcessStats() { @Override public String getProductDescription() { return "GemFire " + GemFireVersion.getGemFireVersion() - + " #" + GemFireVersion.getBuildId() - + " as of " + GemFireVersion.getSourceDate(); + + " #" + GemFireVersion.getBuildId() + + " as of " + GemFireVersion.getSourceDate(); } public int addListener(InternalDistributedMember recipient, long resourceId, String statName) { diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/HostStatHelper.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/HostStatHelper.java similarity index 91% rename from geode-core/src/main/java/com/gemstone/gemfire/internal/HostStatHelper.java rename to geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/HostStatHelper.java index 7ff0b1b7368b..b52eaae7abdf 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/internal/HostStatHelper.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/HostStatHelper.java @@ -14,11 +14,25 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.gemstone.gemfire.internal; +package com.gemstone.gemfire.internal.statistics; import com.gemstone.gemfire.*; //import com.gemstone.gemfire.util.*; +import com.gemstone.gemfire.internal.PureJavaMode; +import com.gemstone.gemfire.internal.SocketCreator; import com.gemstone.gemfire.internal.i18n.LocalizedStrings; +import com.gemstone.gemfire.internal.statistics.platform.LinuxProcFsStatistics; +import com.gemstone.gemfire.internal.statistics.platform.LinuxProcessStats; +import com.gemstone.gemfire.internal.statistics.platform.LinuxSystemStats; +import com.gemstone.gemfire.internal.statistics.platform.OSXProcessStats; +import com.gemstone.gemfire.internal.statistics.platform.OSXSystemStats; +import com.gemstone.gemfire.internal.statistics.platform.OsStatisticsFactory; +import com.gemstone.gemfire.internal.statistics.platform.ProcessStats; +import com.gemstone.gemfire.internal.statistics.platform.SolarisProcessStats; +import com.gemstone.gemfire.internal.statistics.platform.SolarisSystemStats; +import com.gemstone.gemfire.internal.statistics.platform.WindowsProcessStats; +import com.gemstone.gemfire.internal.statistics.platform.WindowsSystemStats; + import java.net.InetAddress; import java.net.UnknownHostException; diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/HostStatSampler.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/HostStatSampler.java similarity index 98% rename from geode-core/src/main/java/com/gemstone/gemfire/internal/HostStatSampler.java rename to geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/HostStatSampler.java index ff9d2fba8320..d414d2c8d677 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/internal/HostStatSampler.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/HostStatSampler.java @@ -14,22 +14,21 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.gemstone.gemfire.internal; +package com.gemstone.gemfire.internal.statistics; import com.gemstone.gemfire.CancelCriterion; import com.gemstone.gemfire.CancelException; import com.gemstone.gemfire.Statistics; import com.gemstone.gemfire.SystemFailure; import com.gemstone.gemfire.distributed.internal.DistributionConfig; +import com.gemstone.gemfire.internal.NanoTimer; +import com.gemstone.gemfire.internal.SocketCreator; import com.gemstone.gemfire.internal.i18n.LocalizedStrings; import com.gemstone.gemfire.internal.logging.LogService; import com.gemstone.gemfire.internal.logging.LoggingThreadGroup; import com.gemstone.gemfire.internal.logging.log4j.LocalizedMessage; import com.gemstone.gemfire.internal.logging.log4j.LogMarker; -import com.gemstone.gemfire.internal.statistics.CallbackSampler; -import com.gemstone.gemfire.internal.statistics.SampleCollector; -import com.gemstone.gemfire.internal.statistics.StatArchiveHandlerConfig; -import com.gemstone.gemfire.internal.statistics.StatisticsSampler; +import com.gemstone.gemfire.internal.statistics.platform.OsStatisticsFactory; import com.gemstone.gemfire.internal.util.concurrent.StoppableCountDownLatch; import org.apache.logging.log4j.Logger; diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/IgnoreResourceException.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/IgnoreResourceException.java index 2abf4b87a16d..4e6e5620a50a 100755 --- a/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/IgnoreResourceException.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/IgnoreResourceException.java @@ -22,7 +22,7 @@ * Indicates that a Statistics resource instance with a null StatisticsType * should be ignored by the statistics sampler. *

- * Extracted from {@link com.gemstone.gemfire.internal.StatArchiveWriter}. + * Extracted from {@link StatArchiveWriter}. * * @since GemFire 7.0 */ diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/LocalStatListener.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/LocalStatListener.java similarity index 96% rename from geode-core/src/main/java/com/gemstone/gemfire/internal/LocalStatListener.java rename to geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/LocalStatListener.java index c46bc2f4382f..0942e78fc060 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/internal/LocalStatListener.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/LocalStatListener.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.gemstone.gemfire.internal; +package com.gemstone.gemfire.internal.statistics; /** * Implement this interface to receive call back when a stat value has changed. diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/LocalStatisticsFactory.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/LocalStatisticsFactory.java similarity index 91% rename from geode-core/src/main/java/com/gemstone/gemfire/internal/LocalStatisticsFactory.java rename to geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/LocalStatisticsFactory.java index 6f8315a0fd71..489894bcf686 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/internal/LocalStatisticsFactory.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/LocalStatisticsFactory.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.gemstone.gemfire.internal; +package com.gemstone.gemfire.internal.statistics; import org.apache.logging.log4j.Logger; @@ -26,6 +26,10 @@ import com.gemstone.gemfire.internal.logging.LogService; import com.gemstone.gemfire.internal.logging.log4j.LocalizedMessage; import com.gemstone.gemfire.internal.logging.log4j.LogMarker; +import com.gemstone.gemfire.internal.statistics.AbstractStatisticsFactory; +import com.gemstone.gemfire.internal.statistics.DummyStatisticsImpl; +import com.gemstone.gemfire.internal.statistics.SimpleStatSampler; +import com.gemstone.gemfire.internal.statistics.StatisticsManager; /** * A standalone implementation of {@link StatisticsFactory}. diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/LocalStatisticsImpl.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/LocalStatisticsImpl.java similarity index 96% rename from geode-core/src/main/java/com/gemstone/gemfire/internal/LocalStatisticsImpl.java rename to geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/LocalStatisticsImpl.java index cf59e1f2f6c3..4c8733aa59ad 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/internal/LocalStatisticsImpl.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/LocalStatisticsImpl.java @@ -14,9 +14,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.gemstone.gemfire.internal; +package com.gemstone.gemfire.internal.statistics; import com.gemstone.gemfire.*; +import com.gemstone.gemfire.internal.OSProcess; +import com.gemstone.gemfire.internal.statistics.StatisticsImpl; +import com.gemstone.gemfire.internal.statistics.StatisticsManager; +import com.gemstone.gemfire.internal.statistics.StatisticsTypeImpl; //import com.gemstone.gemfire.util.IntArray; //import com.gemstone.gemfire.util.LongArray; diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/ResourceInstance.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/ResourceInstance.java index 0de95e2781cf..6d63d3cdce5c 100755 --- a/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/ResourceInstance.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/ResourceInstance.java @@ -24,7 +24,7 @@ * instances depending on the statistics type. The ResourceInstance holds * an array of the latest stat values. *

- * Extracted from {@link com.gemstone.gemfire.internal.StatArchiveWriter}. + * Extracted from {@link StatArchiveWriter}. * * @since GemFire 7.0 */ diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/ResourceType.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/ResourceType.java index d401969b6194..fcdc1a088e3a 100755 --- a/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/ResourceType.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/ResourceType.java @@ -24,7 +24,7 @@ * each ResourceInstance. The ResourceType holds an array of * StatisticDescriptors for its StatisticsType. *

- * Extracted from {@link com.gemstone.gemfire.internal.StatArchiveWriter}. + * Extracted from {@link StatArchiveWriter}. * * @since GemFire 7.0 */ diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/SimpleStatSampler.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/SimpleStatSampler.java similarity index 97% rename from geode-core/src/main/java/com/gemstone/gemfire/internal/SimpleStatSampler.java rename to geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/SimpleStatSampler.java index b3cc56bf8af7..599d42c3e5af 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/internal/SimpleStatSampler.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/SimpleStatSampler.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.gemstone.gemfire.internal; +package com.gemstone.gemfire.internal.statistics; import java.io.File; @@ -35,7 +35,7 @@ * not require a GemFire connection. */ -public class SimpleStatSampler extends HostStatSampler { +public class SimpleStatSampler extends HostStatSampler { private static final Logger logger = LogService.getLogger(); diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/StatArchiveDescriptor.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/StatArchiveDescriptor.java index 6d6624ad104b..54d6af0c22c0 100755 --- a/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/StatArchiveDescriptor.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/StatArchiveDescriptor.java @@ -18,11 +18,11 @@ /** * Descriptor containing all of the parameters required to construct a new - * instance of a {@link com.gemstone.gemfire.internal.StatArchiveWriter}. + * instance of a {@link StatArchiveWriter}. * This describes the statistics archive. *

* This is a constructor parameter object for {@link - * com.gemstone.gemfire.internal.StatArchiveWriter}. + * StatArchiveWriter}. *

* {@link StatArchiveDescriptor.Builder} is used for constructing instances * instead of a constructor with many similar parameters (ie, multiple Strings diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/StatArchiveFormat.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/StatArchiveFormat.java similarity index 99% rename from geode-core/src/main/java/com/gemstone/gemfire/internal/StatArchiveFormat.java rename to geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/StatArchiveFormat.java index d1e67f95048c..4651b5dd839f 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/internal/StatArchiveFormat.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/StatArchiveFormat.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.gemstone.gemfire.internal; +package com.gemstone.gemfire.internal.statistics; /** * StatArchiveFormat defines constants related to the statistic archive diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/StatArchiveHandler.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/StatArchiveHandler.java index e686ad6c3155..fc9030c2b3c0 100755 --- a/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/StatArchiveHandler.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/StatArchiveHandler.java @@ -28,7 +28,6 @@ import com.gemstone.gemfire.GemFireException; import com.gemstone.gemfire.GemFireIOException; import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem; -import com.gemstone.gemfire.internal.StatArchiveWriter; import com.gemstone.gemfire.internal.i18n.LocalizedStrings; import com.gemstone.gemfire.internal.logging.InternalLogWriter; import com.gemstone.gemfire.internal.logging.LogService; @@ -40,13 +39,13 @@ import com.gemstone.gemfire.internal.logging.log4j.LogWriterLogger; /** - * Extracted from {@link com.gemstone.gemfire.internal.HostStatSampler} and - * {@link com.gemstone.gemfire.internal.GemFireStatSampler}. + * Extracted from {@link HostStatSampler} and + * {@link GemFireStatSampler}. *

* The StatArchiveHandler handles statistics samples by archiving them to a * file. This handler provides archive file rolling (file size limit) and * removal (disk space limit). This handler creates and uses an instance of - * {@link com.gemstone.gemfire.internal.StatArchiveWriter} for the currently + * {@link StatArchiveWriter} for the currently * open archive file (unless archiving is disabled). * * @since GemFire 7.0 @@ -100,7 +99,7 @@ public void initialize(long nanosTimeStamp) { } /** - * Closes any {@link com.gemstone.gemfire.internal.StatArchiveWriter} + * Closes any {@link StatArchiveWriter} * currently in use by this handler. * @throws GemFireException */ diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/StatArchiveHandlerConfig.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/StatArchiveHandlerConfig.java index dd46013c220d..ea078275954d 100755 --- a/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/StatArchiveHandlerConfig.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/StatArchiveHandlerConfig.java @@ -22,7 +22,7 @@ * Defines the contract enabling the {@link StatArchiveHandler} to retrieve * configuration details (some of which may change at runtime). *

- * Implemented by {@link com.gemstone.gemfire.internal.HostStatSampler}. + * Implemented by {@link HostStatSampler}. * @since GemFire 7.0 * @see com.gemstone.gemfire.distributed.internal.RuntimeDistributionConfigImpl diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/StatArchiveReader.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/StatArchiveReader.java similarity index 99% rename from geode-core/src/main/java/com/gemstone/gemfire/internal/StatArchiveReader.java rename to geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/StatArchiveReader.java index 0947b0dfdf3f..12637bc69162 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/internal/StatArchiveReader.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/StatArchiveReader.java @@ -14,10 +14,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.gemstone.gemfire.internal; +package com.gemstone.gemfire.internal.statistics; import com.gemstone.gemfire.GemFireIOException; import com.gemstone.gemfire.InternalGemFireException; +import com.gemstone.gemfire.internal.Assert; import com.gemstone.gemfire.internal.i18n.LocalizedStrings; import com.gemstone.gemfire.internal.logging.DateFormatter; diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/StatArchiveWriter.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/StatArchiveWriter.java similarity index 99% rename from geode-core/src/main/java/com/gemstone/gemfire/internal/StatArchiveWriter.java rename to geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/StatArchiveWriter.java index fcf645da3318..027bde1aa669 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/internal/StatArchiveWriter.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/StatArchiveWriter.java @@ -14,19 +14,18 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.gemstone.gemfire.internal; +package com.gemstone.gemfire.internal.statistics; import com.gemstone.gemfire.GemFireIOException; import com.gemstone.gemfire.InternalGemFireException; import com.gemstone.gemfire.StatisticDescriptor; import com.gemstone.gemfire.distributed.internal.DistributionConfig; +import com.gemstone.gemfire.internal.NanoTimer; +import com.gemstone.gemfire.internal.SocketCreator; import com.gemstone.gemfire.internal.i18n.LocalizedStrings; import com.gemstone.gemfire.internal.logging.LogService; import com.gemstone.gemfire.internal.logging.log4j.LogMarker; -import com.gemstone.gemfire.internal.statistics.ResourceInstance; -import com.gemstone.gemfire.internal.statistics.ResourceType; -import com.gemstone.gemfire.internal.statistics.SampleHandler; -import com.gemstone.gemfire.internal.statistics.StatArchiveDescriptor; + import org.apache.logging.log4j.Logger; import java.io.*; diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/StatSamplerStats.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/StatSamplerStats.java similarity index 99% rename from geode-core/src/main/java/com/gemstone/gemfire/internal/StatSamplerStats.java rename to geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/StatSamplerStats.java index c3d556fb91f8..e83d46ce894b 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/internal/StatSamplerStats.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/StatSamplerStats.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.gemstone.gemfire.internal; +package com.gemstone.gemfire.internal.statistics; import com.gemstone.gemfire.*; diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/StatisticDescriptorImpl.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/StatisticDescriptorImpl.java similarity index 99% rename from geode-core/src/main/java/com/gemstone/gemfire/internal/StatisticDescriptorImpl.java rename to geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/StatisticDescriptorImpl.java index 2f407ba563b6..682f77e1618a 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/internal/StatisticDescriptorImpl.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/StatisticDescriptorImpl.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.gemstone.gemfire.internal; +package com.gemstone.gemfire.internal.statistics; import com.gemstone.gemfire.*; import com.gemstone.gemfire.internal.i18n.LocalizedStrings; diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/StatisticsImpl.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/StatisticsImpl.java similarity index 99% rename from geode-core/src/main/java/com/gemstone/gemfire/internal/StatisticsImpl.java rename to geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/StatisticsImpl.java index 04bfc019086c..ea3b953cf735 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/internal/StatisticsImpl.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/StatisticsImpl.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.gemstone.gemfire.internal; +package com.gemstone.gemfire.internal.statistics; //import com.gemstone.gemfire.distributed.DistributedSystem; import java.util.HashSet; @@ -23,7 +23,6 @@ import java.util.function.DoubleSupplier; import java.util.function.IntSupplier; import java.util.function.LongSupplier; -import java.util.function.Supplier; import com.gemstone.gemfire.StatisticDescriptor; import com.gemstone.gemfire.Statistics; diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/StatisticsManager.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/StatisticsManager.java similarity index 97% rename from geode-core/src/main/java/com/gemstone/gemfire/internal/StatisticsManager.java rename to geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/StatisticsManager.java index c33d163c5341..9257271027a4 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/internal/StatisticsManager.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/StatisticsManager.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package com.gemstone.gemfire.internal; +package com.gemstone.gemfire.internal.statistics; import java.util.List; diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/StatisticsTypeFactoryImpl.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/StatisticsTypeFactoryImpl.java similarity index 99% rename from geode-core/src/main/java/com/gemstone/gemfire/internal/StatisticsTypeFactoryImpl.java rename to geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/StatisticsTypeFactoryImpl.java index e4688d52e7f1..8450dd3f3ee3 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/internal/StatisticsTypeFactoryImpl.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/StatisticsTypeFactoryImpl.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.gemstone.gemfire.internal; +package com.gemstone.gemfire.internal.statistics; import com.gemstone.gemfire.*; import com.gemstone.gemfire.internal.i18n.LocalizedStrings; diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/StatisticsTypeImpl.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/StatisticsTypeImpl.java similarity index 99% rename from geode-core/src/main/java/com/gemstone/gemfire/internal/StatisticsTypeImpl.java rename to geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/StatisticsTypeImpl.java index ccd4d6caa449..a338dfb9e98a 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/internal/StatisticsTypeImpl.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/StatisticsTypeImpl.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.gemstone.gemfire.internal; +package com.gemstone.gemfire.internal.statistics; import com.gemstone.gemfire.*; import com.gemstone.gemfire.internal.i18n.LocalizedStrings; diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/StatisticsTypeXml.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/StatisticsTypeXml.java similarity index 98% rename from geode-core/src/main/java/com/gemstone/gemfire/internal/StatisticsTypeXml.java rename to geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/StatisticsTypeXml.java index 0ce0422c04c1..3fa179606d15 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/internal/StatisticsTypeXml.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/StatisticsTypeXml.java @@ -14,9 +14,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.gemstone.gemfire.internal; +package com.gemstone.gemfire.internal.statistics; import com.gemstone.gemfire.*; +import com.gemstone.gemfire.internal.Assert; +import com.gemstone.gemfire.internal.ClassPathLoader; import com.gemstone.gemfire.internal.i18n.LocalizedStrings; import java.io.*; diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/VMStats.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/VMStats.java similarity index 94% rename from geode-core/src/main/java/com/gemstone/gemfire/internal/VMStats.java rename to geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/VMStats.java index d7dde4666686..8f441f5e23c3 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/internal/VMStats.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/VMStats.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.gemstone.gemfire.internal; +package com.gemstone.gemfire.internal.statistics; import com.gemstone.gemfire.*; @@ -72,14 +72,14 @@ public void close() { } /* (non-Javadoc) - * @see com.gemstone.gemfire.internal.VMStatsContract#getFdsOpen() + * @see com.gemstone.gemfire.internal.statistics.VMStatsContract#getFdsOpen() */ public long getFdsOpen() { return -1; } /* (non-Javadoc) - * @see com.gemstone.gemfire.internal.VMStatsContract#getFdLimit() + * @see com.gemstone.gemfire.internal.statistics.VMStatsContract#getFdLimit() */ public long getFdLimit() { return 0; diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/VMStatsContract.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/VMStatsContract.java similarity index 96% rename from geode-core/src/main/java/com/gemstone/gemfire/internal/VMStatsContract.java rename to geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/VMStatsContract.java index 238cf86921ea..1870f274166f 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/internal/VMStatsContract.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/VMStatsContract.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.gemstone.gemfire.internal; +package com.gemstone.gemfire.internal.statistics; /** * Describes the contract a VMStats implementation must implement. diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/VMStatsContractFactory.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/VMStatsContractFactory.java similarity index 97% rename from geode-core/src/main/java/com/gemstone/gemfire/internal/VMStatsContractFactory.java rename to geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/VMStatsContractFactory.java index ff84b0edcd0b..4555683858d4 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/internal/VMStatsContractFactory.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/VMStatsContractFactory.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.gemstone.gemfire.internal; +package com.gemstone.gemfire.internal.statistics; import com.gemstone.gemfire.*; import com.gemstone.gemfire.internal.stats50.VMStats50; diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/ValueMonitor.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/ValueMonitor.java index 211719fcd0f3..725abb219c27 100755 --- a/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/ValueMonitor.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/ValueMonitor.java @@ -23,7 +23,6 @@ import com.gemstone.gemfire.StatisticDescriptor; import com.gemstone.gemfire.Statistics; import com.gemstone.gemfire.internal.CopyOnWriteHashSet; -import com.gemstone.gemfire.internal.StatisticDescriptorImpl; /** * Adds coarser-grained monitoring of entire Statistics instances. diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/package.html b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/package.html index 8875df2e352f..4cb2d4f936a3 100755 --- a/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/package.html +++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/package.html @@ -23,8 +23,8 @@ package is temporarily home for new external API classes that may eventually be included in com.gemstone.gemfire.statistics. The original specification is the - -7.0 Statistics API Specification. + +Statistics API.

diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/LinuxProcFsStatistics.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/platform/LinuxProcFsStatistics.java similarity index 98% rename from geode-core/src/main/java/com/gemstone/gemfire/internal/LinuxProcFsStatistics.java rename to geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/platform/LinuxProcFsStatistics.java index 3070287cca80..1ce57a77dc24 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/internal/LinuxProcFsStatistics.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/platform/LinuxProcFsStatistics.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.gemstone.gemfire.internal; +package com.gemstone.gemfire.internal.statistics.platform; import com.gemstone.gemfire.distributed.internal.DistributionConfig; import org.apache.logging.log4j.Logger; @@ -63,7 +63,7 @@ private enum CPU { private LinuxProcFsStatistics() { } - static int init() { + public static int init() { // TODO: was package-protected nonPidFilesInProc = getNumberOfNonProcessProcFiles(); sys_cpus = Runtime.getRuntime().availableProcessors(); pageSize = Integer.getInteger(pageSizeProperty, DEFAULT_PAGESIZE); @@ -74,12 +74,12 @@ static int init() { return 0; } - static void close() { + public static void close() { // TODO: was package-protected cpuStatSingleton = null; st = null; } - static void readyRefresh() { + public static void readyRefresh() { // TODO: was package-protected } /* get the statistics for the specified process. @@ -89,7 +89,7 @@ static void readyRefresh() { * pageSize. This is the mem_unit member of the struct returned by sysinfo() * */ - static void refreshProcess(int pid, int[] ints, long[] longs, double[] doubles) { + public static void refreshProcess(int pid, int[] ints, long[] longs, double[] doubles) { // TODO: was package-protected //Just incase a pid is not available if(pid == 0) return; InputStreamReader isr = null; @@ -122,7 +122,7 @@ static void refreshProcess(int pid, int[] ints, long[] longs, double[] doubles) } } - static void refreshSystem(int[] ints, long[] longs, double[] doubles) { + public static void refreshSystem(int[] ints, long[] longs, double[] doubles) { // TODO: was package-protected ints[LinuxSystemStats.processesINT] = getProcessCount(); ints[LinuxSystemStats.cpusINT] = sys_cpus; InputStreamReader isr = null; diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/LinuxProcessStats.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/platform/LinuxProcessStats.java similarity index 85% rename from geode-core/src/main/java/com/gemstone/gemfire/internal/LinuxProcessStats.java rename to geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/platform/LinuxProcessStats.java index 05bc284eacf2..ab4b78d359bf 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/internal/LinuxProcessStats.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/platform/LinuxProcessStats.java @@ -15,9 +15,14 @@ * limitations under the License. */ -package com.gemstone.gemfire.internal; +package com.gemstone.gemfire.internal.statistics.platform; import com.gemstone.gemfire.*; +import com.gemstone.gemfire.internal.Assert; +import com.gemstone.gemfire.internal.statistics.HostStatHelper; +import com.gemstone.gemfire.internal.statistics.LocalStatisticsImpl; +import com.gemstone.gemfire.internal.statistics.StatisticsTypeFactoryImpl; +import com.gemstone.gemfire.internal.statistics.platform.ProcessStats; /** *

This class provides the interface for statistics about a @@ -64,7 +69,7 @@ public static StatisticsType getType() { * * @since GemFire 3.5 */ - static ProcessStats createProcessStats(final Statistics stats) { + public static ProcessStats createProcessStats(final Statistics stats) { // TODO: was package-protected if (stats instanceof LocalStatisticsImpl) { HostStatHelper.refresh((LocalStatisticsImpl) stats); } // otherwise its a Dummy implementation so do nothing diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/LinuxSystemStats.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/platform/LinuxSystemStats.java similarity index 99% rename from geode-core/src/main/java/com/gemstone/gemfire/internal/LinuxSystemStats.java rename to geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/platform/LinuxSystemStats.java index 22158dac2932..f50204e1a242 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/internal/LinuxSystemStats.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/platform/LinuxSystemStats.java @@ -15,9 +15,11 @@ * limitations under the License. */ -package com.gemstone.gemfire.internal; +package com.gemstone.gemfire.internal.statistics.platform; import com.gemstone.gemfire.*; +import com.gemstone.gemfire.internal.Assert; +import com.gemstone.gemfire.internal.statistics.StatisticsTypeFactoryImpl; /** *

This class provides the interface for statistics about the diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/OSXProcessStats.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/platform/OSXProcessStats.java similarity index 87% rename from geode-core/src/main/java/com/gemstone/gemfire/internal/OSXProcessStats.java rename to geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/platform/OSXProcessStats.java index 0706c7b0b99f..7af725f63d67 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/internal/OSXProcessStats.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/platform/OSXProcessStats.java @@ -15,9 +15,13 @@ * limitations under the License. */ -package com.gemstone.gemfire.internal; +package com.gemstone.gemfire.internal.statistics.platform; import com.gemstone.gemfire.*; +import com.gemstone.gemfire.internal.Assert; +import com.gemstone.gemfire.internal.statistics.HostStatHelper; +import com.gemstone.gemfire.internal.statistics.LocalStatisticsImpl; +import com.gemstone.gemfire.internal.statistics.StatisticsTypeFactoryImpl; /** *

This class provides the interface for statistics about a @@ -67,7 +71,7 @@ public static StatisticsType getType() { * * @since GemFire 3.5 */ - static ProcessStats createProcessStats(final Statistics stats) { + public static ProcessStats createProcessStats(final Statistics stats) { // TODO: was package-protected if (stats instanceof LocalStatisticsImpl) { HostStatHelper.refresh((LocalStatisticsImpl) stats); } // otherwise its a Dummy implementation so do nothing diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/OSXSystemStats.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/platform/OSXSystemStats.java similarity index 98% rename from geode-core/src/main/java/com/gemstone/gemfire/internal/OSXSystemStats.java rename to geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/platform/OSXSystemStats.java index 8d440ca97449..3f782bca49a4 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/internal/OSXSystemStats.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/platform/OSXSystemStats.java @@ -15,9 +15,11 @@ * limitations under the License. */ -package com.gemstone.gemfire.internal; +package com.gemstone.gemfire.internal.statistics.platform; import com.gemstone.gemfire.*; +import com.gemstone.gemfire.internal.Assert; +import com.gemstone.gemfire.internal.statistics.StatisticsTypeFactoryImpl; /** *

This class provides the interface for statistics about the diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/OsStatisticsFactory.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/platform/OsStatisticsFactory.java similarity index 96% rename from geode-core/src/main/java/com/gemstone/gemfire/internal/OsStatisticsFactory.java rename to geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/platform/OsStatisticsFactory.java index 7dac90e18844..0ec1f5ad33da 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/internal/OsStatisticsFactory.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/platform/OsStatisticsFactory.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.gemstone.gemfire.internal; +package com.gemstone.gemfire.internal.statistics.platform; import com.gemstone.gemfire.*; diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/ProcessStats.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/platform/ProcessStats.java similarity index 96% rename from geode-core/src/main/java/com/gemstone/gemfire/internal/ProcessStats.java rename to geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/platform/ProcessStats.java index c80e34047e7f..0c4465e04259 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/internal/ProcessStats.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/platform/ProcessStats.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.gemstone.gemfire.internal; +package com.gemstone.gemfire.internal.statistics.platform; import com.gemstone.gemfire.Statistics; diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/SolarisProcessStats.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/platform/SolarisProcessStats.java similarity index 96% rename from geode-core/src/main/java/com/gemstone/gemfire/internal/SolarisProcessStats.java rename to geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/platform/SolarisProcessStats.java index d07d398a59f5..c9b67466a080 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/internal/SolarisProcessStats.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/platform/SolarisProcessStats.java @@ -15,9 +15,14 @@ * limitations under the License. */ -package com.gemstone.gemfire.internal; +package com.gemstone.gemfire.internal.statistics.platform; import com.gemstone.gemfire.*; +import com.gemstone.gemfire.internal.Assert; +import com.gemstone.gemfire.internal.statistics.HostStatHelper; +import com.gemstone.gemfire.internal.statistics.LocalStatisticsImpl; +import com.gemstone.gemfire.internal.statistics.StatisticsTypeFactoryImpl; +import com.gemstone.gemfire.internal.statistics.platform.ProcessStats; /** *

This class provides the interface for statistics about a @@ -203,7 +208,7 @@ public static StatisticsType getType() { * * @since GemFire 3.5 */ - static ProcessStats createProcessStats(final Statistics stats) { + public static ProcessStats createProcessStats(final Statistics stats) { // TODO: was package-protected if (stats instanceof LocalStatisticsImpl) { HostStatHelper.refresh((LocalStatisticsImpl) stats); } // otherwise its a Dummy implementation so do nothing diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/SolarisSystemStats.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/platform/SolarisSystemStats.java similarity index 99% rename from geode-core/src/main/java/com/gemstone/gemfire/internal/SolarisSystemStats.java rename to geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/platform/SolarisSystemStats.java index 9f569430b6c2..3fe4495d6ed8 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/internal/SolarisSystemStats.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/platform/SolarisSystemStats.java @@ -15,9 +15,11 @@ * limitations under the License. */ -package com.gemstone.gemfire.internal; +package com.gemstone.gemfire.internal.statistics.platform; import com.gemstone.gemfire.*; +import com.gemstone.gemfire.internal.Assert; +import com.gemstone.gemfire.internal.statistics.StatisticsTypeFactoryImpl; /** *

This class provides the interface for statistics about the diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/WindowsProcessStats.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/platform/WindowsProcessStats.java similarity index 95% rename from geode-core/src/main/java/com/gemstone/gemfire/internal/WindowsProcessStats.java rename to geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/platform/WindowsProcessStats.java index a671717803be..5082316156f3 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/internal/WindowsProcessStats.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/platform/WindowsProcessStats.java @@ -15,9 +15,14 @@ * limitations under the License. */ -package com.gemstone.gemfire.internal; +package com.gemstone.gemfire.internal.statistics.platform; import com.gemstone.gemfire.*; +import com.gemstone.gemfire.internal.Assert; +import com.gemstone.gemfire.internal.statistics.HostStatHelper; +import com.gemstone.gemfire.internal.statistics.LocalStatisticsImpl; +import com.gemstone.gemfire.internal.statistics.StatisticsTypeFactoryImpl; +import com.gemstone.gemfire.internal.statistics.platform.ProcessStats; /** *

This class provides the interface for statistics about a @@ -145,7 +150,7 @@ public static StatisticsType getType() { * * @since GemFire 3.5 */ - static ProcessStats createProcessStats(final Statistics stats) { + public static ProcessStats createProcessStats(final Statistics stats) { // TODO: was package-protected if (stats instanceof LocalStatisticsImpl) { HostStatHelper.refresh((LocalStatisticsImpl) stats); } // otherwise its a Dummy implementation so do nothing diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/WindowsSystemStats.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/platform/WindowsSystemStats.java similarity index 99% rename from geode-core/src/main/java/com/gemstone/gemfire/internal/WindowsSystemStats.java rename to geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/platform/WindowsSystemStats.java index 1325fcc87cbc..b0a128ffd69a 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/internal/WindowsSystemStats.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/platform/WindowsSystemStats.java @@ -15,9 +15,11 @@ * limitations under the License. */ -package com.gemstone.gemfire.internal; +package com.gemstone.gemfire.internal.statistics.platform; import com.gemstone.gemfire.*; +import com.gemstone.gemfire.internal.Assert; +import com.gemstone.gemfire.internal.statistics.StatisticsTypeFactoryImpl; /** *

This class provides the interface for statistics about the diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/stats50/Atomic50StatisticsImpl.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/stats50/Atomic50StatisticsImpl.java index f374394e226e..cff9142b5510 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/internal/stats50/Atomic50StatisticsImpl.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/stats50/Atomic50StatisticsImpl.java @@ -19,6 +19,10 @@ import com.gemstone.gemfire.*; import com.gemstone.gemfire.internal.*; import com.gemstone.gemfire.internal.i18n.LocalizedStrings; +import com.gemstone.gemfire.internal.statistics.StatisticsImpl; +import com.gemstone.gemfire.internal.statistics.StatisticsManager; +import com.gemstone.gemfire.internal.statistics.StatisticsTypeImpl; + import java.util.concurrent.atomic.AtomicIntegerArray; // don't use backport here! import java.util.concurrent.atomic.AtomicLongArray; // don't use backport here! import java.util.concurrent.ConcurrentLinkedQueue; // don't use backport here! diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/stats50/VMStats50.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/stats50/VMStats50.java index 6f2eea6cccef..e5b55f4479fb 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/internal/stats50/VMStats50.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/stats50/VMStats50.java @@ -43,8 +43,8 @@ import com.gemstone.gemfire.SystemFailure; import com.gemstone.gemfire.distributed.internal.DistributionConfig; import com.gemstone.gemfire.internal.ClassPathLoader; -import com.gemstone.gemfire.internal.StatisticsTypeFactoryImpl; -import com.gemstone.gemfire.internal.VMStatsContract; +import com.gemstone.gemfire.internal.statistics.StatisticsTypeFactoryImpl; +import com.gemstone.gemfire.internal.statistics.VMStatsContract; import com.gemstone.gemfire.internal.logging.LogService; /** diff --git a/geode-core/src/main/java/com/gemstone/gemfire/management/internal/beans/MemberMBeanBridge.java b/geode-core/src/main/java/com/gemstone/gemfire/management/internal/beans/MemberMBeanBridge.java index 89cc4f02484f..08260d387288 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/management/internal/beans/MemberMBeanBridge.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/management/internal/beans/MemberMBeanBridge.java @@ -47,6 +47,14 @@ import com.gemstone.gemfire.internal.offheap.OffHeapMemoryStats; import com.gemstone.gemfire.internal.process.PidUnavailableException; import com.gemstone.gemfire.internal.process.ProcessUtils; +import com.gemstone.gemfire.internal.statistics.GemFireStatSampler; +import com.gemstone.gemfire.internal.statistics.HostStatHelper; +import com.gemstone.gemfire.internal.statistics.platform.LinuxSystemStats; +import com.gemstone.gemfire.internal.statistics.platform.ProcessStats; +import com.gemstone.gemfire.internal.statistics.platform.SolarisSystemStats; +import com.gemstone.gemfire.internal.statistics.StatSamplerStats; +import com.gemstone.gemfire.internal.statistics.VMStatsContract; +import com.gemstone.gemfire.internal.statistics.platform.WindowsSystemStats; import com.gemstone.gemfire.internal.stats50.VMStats50; import com.gemstone.gemfire.internal.tcp.ConnectionTable; import com.gemstone.gemfire.management.*; diff --git a/geode-core/src/test/java/com/gemstone/gemfire/GemFireTestCase.java b/geode-core/src/test/java/com/gemstone/gemfire/GemFireTestCase.java deleted file mode 100644 index 337f97136713..000000000000 --- a/geode-core/src/test/java/com/gemstone/gemfire/GemFireTestCase.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.gemstone.gemfire; - -import com.gemstone.gemfire.distributed.DistributedSystem; -import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem; -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.rules.TestName; - -import java.util.Properties; - -import static com.gemstone.gemfire.distributed.ConfigurationProperties.*; -import static org.junit.Assert.assertTrue; - -/** - * This is an abstract superclass for classes that test GemFire. It - * has setUp() and tearDown() methods that create and initialize a - * GemFire connection. - * - * - */ -public abstract class GemFireTestCase { - - @Rule - public TestName testName = new TestName(); - - @Before - public void setUp() throws Exception { - Properties p = new Properties(); - // make it a loner - p.setProperty(MCAST_PORT, "0"); - p.setProperty(LOCATORS, ""); - p.setProperty(NAME, getName()); - DistributedSystem.connect(p); - } - - @After - public void tearDown() throws Exception { - DistributedSystem ds = InternalDistributedSystem.getAnyInstance(); - if (ds != null) { - ds.disconnect(); - } - } - - protected String getName() { - return testName.getMethodName(); - } - - /** - * Strip the package off and gives just the class name. - * Needed because of Windows file name limits. - */ - private String getShortClassName() { - return getClass().getSimpleName(); - } - - /** - * Returns a unique name for this test method. It is based on the - * name of the class as well as the name of the method. - */ - protected String getUniqueName() { - return getShortClassName() + "_" + getName(); - } - - /** - * Assert an Invariant condition on an object. - * @param inv the Invariant to assert. If null, this method just returns - * @param obj the Object to assert the Invariant on. - */ - protected void assertInvariant(Invariant inv, Object obj) { - if (inv == null) return; - InvariantResult result = inv.verify(obj); - assertTrue(result.message, result.valid); - } -} diff --git a/geode-core/src/test/java/com/gemstone/gemfire/Invariant.java b/geode-core/src/test/java/com/gemstone/gemfire/Invariant.java deleted file mode 100644 index 1c712d2fa5d6..000000000000 --- a/geode-core/src/test/java/com/gemstone/gemfire/Invariant.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.gemstone.gemfire; - -/** - * Interface used for testing an invariant - * - */ -public interface Invariant { - /** - * @return error message, or null if verification passes - */ - public InvariantResult verify(Object obj); -} - - - diff --git a/geode-core/src/test/java/com/gemstone/gemfire/InvariantResult.java b/geode-core/src/test/java/com/gemstone/gemfire/InvariantResult.java deleted file mode 100644 index 272e02644713..000000000000 --- a/geode-core/src/test/java/com/gemstone/gemfire/InvariantResult.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.gemstone.gemfire; - -/** -* Used as result of verifying an Invariant -* @see Invariant -* -*/ -public class InvariantResult { - public String message; - public boolean valid; -} diff --git a/geode-core/src/test/java/com/gemstone/gemfire/LocalStatisticsJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/LocalStatisticsJUnitTest.java deleted file mode 100644 index ab5b8e129966..000000000000 --- a/geode-core/src/test/java/com/gemstone/gemfire/LocalStatisticsJUnitTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.gemstone.gemfire; - -import com.gemstone.gemfire.distributed.DistributedSystem; -import com.gemstone.gemfire.test.junit.categories.IntegrationTest; -import org.junit.experimental.categories.Category; - -import java.util.Properties; - -import static com.gemstone.gemfire.distributed.ConfigurationProperties.*; - -/** - * Tests the functionality of JOM {@link Statistics}. - */ -@Category(IntegrationTest.class) -public class LocalStatisticsJUnitTest extends StatisticsTestCase { - - /** - * Returns a distributed system configured to not use shared - * memory. - */ - protected DistributedSystem getSystem() { - if (this.system == null) { - Properties props = new Properties(); - props.setProperty(STATISTIC_SAMPLING_ENABLED, "true"); - props.setProperty(STATISTIC_ARCHIVE_FILE, "StatisticsTestCase-localTest.gfs"); - props.setProperty(MCAST_PORT, "0"); - props.setProperty(LOCATORS, ""); - props.setProperty(NAME, getName()); - this.system = DistributedSystem.connect(props); - } - - return this.system; - } -} diff --git a/geode-core/src/test/java/com/gemstone/gemfire/StatisticsTestCase.java b/geode-core/src/test/java/com/gemstone/gemfire/StatisticsTestCase.java deleted file mode 100644 index 03b5e16c5ab6..000000000000 --- a/geode-core/src/test/java/com/gemstone/gemfire/StatisticsTestCase.java +++ /dev/null @@ -1,388 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.gemstone.gemfire; - -import static org.junit.Assert.*; - -import com.gemstone.gemfire.distributed.DistributedSystem; - -import java.util.*; - -import org.junit.Test; - -/** - * Tests the functionality of {@link Statistics}. Uses a - * subclass to tests JOM-only statistics. - */ -public abstract class StatisticsTestCase extends GemFireTestCase { - - /** The distributed system used in this test */ - protected DistributedSystem system; - - private StatisticsFactory factory() { - return system; - } - - /** - * Creates the distributed system - * @throws Exception - */ - @Override - public void setUp() throws Exception { - this.system = getSystem(); - } - - /** - * Closes the distributed system - * @throws Exception - */ - @Override - public void tearDown() throws Exception { - this.system.disconnect(); - this.system = null; - } - - /** - * Returns the distributed system used when creating statistics. It - * determines whether or not shared memory is used. - */ - protected abstract DistributedSystem getSystem(); - - //////// Test methods - - /** - * Tests int statistics - */ - @Test - public void testIntStatistics() { - String statName1 = "one"; - String statName2 = "two"; - String statName3 = "three"; - String[] statNames = { statName1, statName2, statName3 }; - - StatisticsType type = - factory().createType(this.getUniqueName(), "", new - StatisticDescriptor[] { - factory().createIntGauge(statName1, "ONE", "x"), - factory().createIntGauge(statName2, "TWO", "x"), - factory().createIntGauge(statName3, "THREE", "x") - }); - - Statistics stats = factory().createAtomicStatistics(type, "Display"); - stats.setInt(statName1, 0); - stats.setInt(statName2, 0); - stats.setInt(statName3, 0); - - for (int j = 0; j < statNames.length; j++) { - String statName = statNames[j]; - for (int i = 0; i < 10; i++) { - stats.setInt(statName, i); - stats.incInt(statName, 1); - assertEquals(i + 1, stats.getInt(statName)); - } - } - } - - /** - * Tests long statistics - */ - @Test - public void testLongStatistics() { - String statName1 = "one"; - String statName2 = "two"; - String statName3 = "three"; - String[] statNames = { statName1, statName2, statName3 }; - - StatisticsType type = - factory().createType(this.getUniqueName(), "", new - StatisticDescriptor[] { - factory().createLongGauge(statName1, "ONE", "x"), - factory().createLongGauge(statName2, "TWO", "x"), - factory().createLongGauge(statName3, "THREE", "x") - }); - - Statistics stats = factory().createAtomicStatistics(type, "Display"); - stats.setLong(statName1, 0L); - stats.setLong(statName2, 0L); - stats.setLong(statName3, 0L); - - Random random = new Random(); - - // Set/get some random long values - for (int i = 0; i < 100; i++) { - for (int j = 0; j < statNames.length; j++) { - String statName = statNames[j]; - long value = random.nextLong(); - stats.setLong(statName, value); - assertEquals(value, stats.getLong(statName)); - } - } - - // Increment by some random values - for (int i = 0; i < 100; i++) { - for (int j = 0; j < statNames.length; j++) { - String statName = statNames[j]; - long inc = random.nextLong(); - long before = stats.getLong(statName); - stats.incLong(statName, inc); - assertEquals(before + inc, stats.getLong(statName)); - } - } - } - - /** - * Tests double statistics - */ - @Test - public void testDoubleStatistics() { - String statName1 = "one"; - String statName2 = "two"; - String statName3 = "three"; - String[] statNames = { statName1, statName2, statName3 }; - - StatisticsType type = - factory().createType(this.getUniqueName(), "", new - StatisticDescriptor[] { - factory().createDoubleGauge(statName1, "ONE", "x"), - factory().createDoubleGauge(statName2, "TWO", "x"), - factory().createDoubleGauge(statName3, "THREE", "x") - }); - - Statistics stats = factory().createAtomicStatistics(type, "Display"); - stats.setDouble(statName1, 0.0); - stats.setDouble(statName2, 0.0); - stats.setDouble(statName3, 0.0); - - Random random = new Random(); - - // Set/get some random double values - for (int i = 0; i < 100; i++) { - for (int j = 0; j < statNames.length; j++) { - String statName = statNames[j]; - double value = random.nextDouble(); - stats.setDouble(statName, value); - assertEquals(value, stats.getDouble(statName), 0.0); - } - } - - // Increment by some random values - for (int i = 0; i < 100; i++) { - for (int j = 0; j < statNames.length; j++) { - String statName = statNames[j]; - double inc = random.nextDouble(); - double before = stats.getDouble(statName); - stats.incDouble(statName, inc); - assertEquals(before + inc, stats.getDouble(statName), 0.0); - } - } - } - - /** - * Tests that accessing an int stat throws the - * appropriate exceptions. - */ - @Test - public void testAccessingIntStat() { - String statName1 = "one"; - - StatisticsType type = - factory().createType(this.getUniqueName(), "", new - StatisticDescriptor[] { - factory().createIntGauge(statName1, "ONE", "x"), - }); - - Statistics stats = factory().createAtomicStatistics(type, "Display"); - - stats.getInt(statName1); - try { - stats.getDouble(statName1); - fail("Should have thrown an IllegalArgumentException"); - - } catch (IllegalArgumentException ex) { - // pass... - } - try { - stats.getLong(statName1); - fail("Should have thrown an IllegalArgumentException"); - - } catch (IllegalArgumentException ex) { - // pass... - } - - stats.setInt(statName1, 4); - try { - stats.setDouble(statName1, 4.0); - fail("Should have thrown an IllegalArgumentException"); - - } catch (IllegalArgumentException ex) { - // pass... - } - try { - stats.setLong(statName1, 4L); - fail("Should have thrown an IllegalArgumentException"); - - } catch (IllegalArgumentException ex) { - // pass... - } - - stats.incInt(statName1, 4); - try { - stats.incDouble(statName1, 4.0); - fail("Should have thrown an IllegalArgumentException"); - - } catch (IllegalArgumentException ex) { - // pass... - } - try { - stats.incLong(statName1, 4L); - fail("Should have thrown an IllegalArgumentException"); - - } catch (IllegalArgumentException ex) { - // pass... - } - } - - /** - * Tests that accessing a long stat throws the - * appropriate exceptions. - */ - @Test - public void testAccessingLongStat() { - String statName1 = "one"; - - StatisticsType type = - factory().createType(this.getUniqueName(), "", new - StatisticDescriptor[] { - factory().createLongGauge(statName1, "ONE", "x"), - }); - - Statistics stats = factory().createAtomicStatistics(type, "Display"); - - stats.getLong(statName1); - try { - stats.getDouble(statName1); - fail("Should have thrown an IllegalArgumentException"); - - } catch (IllegalArgumentException ex) { - // pass... - } - try { - stats.getInt(statName1); - fail("Should have thrown an IllegalArgumentException"); - - } catch (IllegalArgumentException ex) { - // pass... - } - - stats.setLong(statName1, 4L); - try { - stats.setDouble(statName1, 4.0); - fail("Should have thrown an IllegalArgumentException"); - - } catch (IllegalArgumentException ex) { - // pass... - } - try { - stats.setInt(statName1, 4); - fail("Should have thrown an IllegalArgumentException"); - - } catch (IllegalArgumentException ex) { - // pass... - } - - stats.incLong(statName1, 4L); - try { - stats.incDouble(statName1, 4.0); - fail("Should have thrown an IllegalArgumentException"); - - } catch (IllegalArgumentException ex) { - // pass... - } - try { - stats.incInt(statName1, 4); - fail("Should have thrown an IllegalArgumentException"); - - } catch (IllegalArgumentException ex) { - // pass... - } - } - - /** - * Tests that accessing an double stat throws the - * appropriate exceptions. - */ - @Test - public void testAccessingDoubleStat() { - String statName1 = "one"; - - StatisticsType type = - factory().createType(this.getUniqueName(), "", new - StatisticDescriptor[] { - factory().createDoubleGauge(statName1, "ONE", "x"), - }); - - Statistics stats = factory().createStatistics(type, "Display"); - - stats.getDouble(statName1); - try { - stats.getInt(statName1); - fail("Should have thrown an IllegalArgumentException"); - - } catch (IllegalArgumentException ex) { - // pass... - } - try { - stats.getLong(statName1); - fail("Should have thrown an IllegalArgumentException"); - - } catch (IllegalArgumentException ex) { - // pass... - } - - stats.setDouble(statName1, 4.0); - try { - stats.setInt(statName1, 4); - fail("Should have thrown an IllegalArgumentException"); - - } catch (IllegalArgumentException ex) { - // pass... - } - try { - stats.setLong(statName1, 4L); - fail("Should have thrown an IllegalArgumentException"); - - } catch (IllegalArgumentException ex) { - // pass... - } - - stats.incDouble(statName1, 4.0); - try { - stats.incInt(statName1, 4); - fail("Should have thrown an IllegalArgumentException"); - - } catch (IllegalArgumentException ex) { - // pass... - } - try { - stats.incLong(statName1, 4L); - fail("Should have thrown an IllegalArgumentException"); - - } catch (IllegalArgumentException ex) { - // pass... - } - } -} diff --git a/geode-core/src/test/java/com/gemstone/gemfire/StatisticsTypeJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/StatisticsTypeJUnitTest.java deleted file mode 100644 index 1d221a27a8b0..000000000000 --- a/geode-core/src/test/java/com/gemstone/gemfire/StatisticsTypeJUnitTest.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.gemstone.gemfire; - -import static org.junit.Assert.*; - -import org.junit.Test; -import org.junit.experimental.categories.Category; - -import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem; -import com.gemstone.gemfire.test.junit.categories.IntegrationTest; - -/** - * Tests the functionality of the {@link StatisticsType} class. - * - * - */ -@Category(IntegrationTest.class) -public class StatisticsTypeJUnitTest extends GemFireTestCase { - - private StatisticsFactory factory() { - return InternalDistributedSystem.getAnyInstance(); - } - - /** - * Get the offset of an unknown statistic - */ - @Test - public void testNameToIdUnknownStatistic() { - StatisticDescriptor[] stats = { - factory().createIntGauge("test", "TEST", "ms") - }; - - StatisticsType type = factory().createType("testNameToIdUnknownStatistic", "TEST", stats); - assertEquals(0, type.nameToId("test")); - try { - type.nameToId("Fred"); - fail("Should have thrown an IllegalArgumentException"); - - } catch (IllegalArgumentException ex) { - // pass... - } - } - - @Test - public void testNameToDescriptorUnknownStatistic() { - StatisticDescriptor[] stats = { - factory().createIntGauge("test", "TEST", "ms") - }; - - StatisticsType type = factory().createType("testNameToDescriptorUnknownStatistic", "TEST", stats); - assertEquals("test", type.nameToDescriptor("test").getName()); - try { - type.nameToDescriptor("Fred"); - fail("Should have thrown an IllegalArgumentException"); - - } catch (IllegalArgumentException ex) { - // pass... - } - } - -} diff --git a/geode-core/src/test/java/com/gemstone/gemfire/admin/internal/MemberHealthEvaluatorJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/admin/internal/MemberHealthEvaluatorJUnitTest.java index 6791dccd1f01..886305999100 100644 --- a/geode-core/src/test/java/com/gemstone/gemfire/admin/internal/MemberHealthEvaluatorJUnitTest.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/admin/internal/MemberHealthEvaluatorJUnitTest.java @@ -28,8 +28,8 @@ import com.gemstone.gemfire.admin.GemFireHealth; import com.gemstone.gemfire.admin.GemFireHealthConfig; -import com.gemstone.gemfire.internal.GemFireStatSampler; -import com.gemstone.gemfire.internal.ProcessStats; +import com.gemstone.gemfire.internal.statistics.GemFireStatSampler; +import com.gemstone.gemfire.internal.statistics.platform.ProcessStats; import com.gemstone.gemfire.internal.PureJavaMode; import com.gemstone.gemfire.test.junit.categories.IntegrationTest; diff --git a/geode-core/src/test/java/com/gemstone/gemfire/cache/management/MemoryThresholdsDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/cache/management/MemoryThresholdsDUnitTest.java index baad698114c5..c3a490f1139e 100644 --- a/geode-core/src/test/java/com/gemstone/gemfire/cache/management/MemoryThresholdsDUnitTest.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/cache/management/MemoryThresholdsDUnitTest.java @@ -67,9 +67,9 @@ import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem; import com.gemstone.gemfire.distributed.internal.membership.InternalDistributedMember; import com.gemstone.gemfire.internal.AvailablePortHelper; -import com.gemstone.gemfire.internal.GemFireStatSampler; -import com.gemstone.gemfire.internal.LocalStatListener; -import com.gemstone.gemfire.internal.StatisticsImpl; +import com.gemstone.gemfire.internal.statistics.GemFireStatSampler; +import com.gemstone.gemfire.internal.statistics.LocalStatListener; +import com.gemstone.gemfire.internal.statistics.StatisticsImpl; import com.gemstone.gemfire.internal.cache.DistributedRegion; import com.gemstone.gemfire.internal.cache.GemFireCacheImpl; import com.gemstone.gemfire.internal.cache.PartitionedRegion; diff --git a/geode-core/src/test/java/com/gemstone/gemfire/codeAnalysis/decode/CompiledClass.java b/geode-core/src/test/java/com/gemstone/gemfire/codeAnalysis/decode/CompiledClass.java index 9e0395690124..43175f6fb323 100644 --- a/geode-core/src/test/java/com/gemstone/gemfire/codeAnalysis/decode/CompiledClass.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/codeAnalysis/decode/CompiledClass.java @@ -177,7 +177,7 @@ public boolean isSerializableAndNotDataSerializable() { // in junit String name = fullyQualifiedName().replace('/', '.'); if (name.startsWith("com.gemstone.gemfire.internal.shared.NativeCallsJNAImpl") - || name.startsWith("com.gemstone.gemfire.internal.HostStatHelper")) { + || name.startsWith("com.gemstone.gemfire.internal.statistics.HostStatHelper")) { return false; } try { diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/DataSerializableJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/DataSerializableJUnitTest.java index 273d3c6898c5..13ab363a124d 100644 --- a/geode-core/src/test/java/com/gemstone/gemfire/internal/DataSerializableJUnitTest.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/DataSerializableJUnitTest.java @@ -64,6 +64,7 @@ import com.gemstone.gemfire.DataSerializer; import com.gemstone.gemfire.Instantiator; import com.gemstone.gemfire.SystemFailure; +import com.gemstone.gemfire.internal.statistics.StatArchiveWriter; import com.gemstone.gemfire.internal.tcp.ByteBufferInputStream; import com.gemstone.gemfire.test.junit.categories.UnitTest; diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/lru/LRUClockJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/lru/LRUClockJUnitTest.java index 16b7ac584aa3..7e24d0c99117 100755 --- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/lru/LRUClockJUnitTest.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/lru/LRUClockJUnitTest.java @@ -39,7 +39,7 @@ import com.gemstone.gemfire.cache.EvictionAlgorithm; import com.gemstone.gemfire.cache.Region; import com.gemstone.gemfire.distributed.DistributedSystem; -import com.gemstone.gemfire.internal.StatisticsTypeFactoryImpl; +import com.gemstone.gemfire.internal.statistics.StatisticsTypeFactoryImpl; import com.gemstone.gemfire.internal.cache.InternalRegionArguments; import com.gemstone.gemfire.internal.cache.PlaceHolderDiskRegion; import com.gemstone.gemfire.test.junit.categories.IntegrationTest; diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapStorageJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapStorageJUnitTest.java index 93bef986de8e..bf5a1763d006 100755 --- a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapStorageJUnitTest.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapStorageJUnitTest.java @@ -23,7 +23,7 @@ import com.gemstone.gemfire.distributed.internal.DistributionStats; import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem; import com.gemstone.gemfire.distributed.internal.InternalLocator; -import com.gemstone.gemfire.internal.LocalStatisticsFactory; +import com.gemstone.gemfire.internal.statistics.LocalStatisticsFactory; import com.gemstone.gemfire.test.junit.categories.UnitTest; import org.junit.Rule; import org.junit.Test; diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/CallbackSamplerJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/CallbackSamplerTest.java similarity index 92% rename from geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/CallbackSamplerJUnitTest.java rename to geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/CallbackSamplerTest.java index 47bfc5807f66..fd442bbc7354 100644 --- a/geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/CallbackSamplerJUnitTest.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/CallbackSamplerTest.java @@ -16,20 +16,12 @@ */ package com.gemstone.gemfire.internal.statistics; -import static org.junit.Assert.*; import static org.mockito.Mockito.*; import java.util.Arrays; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; -import com.gemstone.gemfire.CancelCriterion; -import com.gemstone.gemfire.Statistics; -import com.gemstone.gemfire.internal.StatSamplerStats; -import com.gemstone.gemfire.internal.StatisticsImpl; -import com.gemstone.gemfire.internal.StatisticsManager; -import com.gemstone.gemfire.test.junit.categories.UnitTest; - import org.junit.Before; import org.junit.Test; import org.junit.experimental.categories.Category; @@ -38,9 +30,16 @@ import org.mockito.Mock; import org.mockito.runners.MockitoJUnitRunner; +import com.gemstone.gemfire.CancelCriterion; +import com.gemstone.gemfire.test.junit.categories.UnitTest; + +/** + * Unit tests for {@link CallbackSampler}. + */ @Category(UnitTest.class) @RunWith(MockitoJUnitRunner.class) -public class CallbackSamplerJUnitTest { +public class CallbackSamplerTest { + @Mock CancelCriterion cancelCriterion; @Mock @@ -49,6 +48,7 @@ public class CallbackSamplerJUnitTest { StatisticsManager statisticsManager; @Mock ScheduledExecutorService executorService; + private CallbackSampler sampler; @Before diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/DistributedSystemStatisticsIntegrationTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/DistributedSystemStatisticsIntegrationTest.java new file mode 100644 index 000000000000..76763dea7ae0 --- /dev/null +++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/DistributedSystemStatisticsIntegrationTest.java @@ -0,0 +1,271 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.gemstone.gemfire.internal.statistics; + +import static com.gemstone.gemfire.distributed.ConfigurationProperties.*; +import static org.assertj.core.api.Assertions.*; + +import java.util.Properties; +import java.util.Random; + +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.experimental.categories.Category; +import org.junit.rules.TestName; + +import com.gemstone.gemfire.StatisticDescriptor; +import com.gemstone.gemfire.Statistics; +import com.gemstone.gemfire.StatisticsFactory; +import com.gemstone.gemfire.StatisticsType; +import com.gemstone.gemfire.distributed.DistributedSystem; +import com.gemstone.gemfire.test.junit.categories.IntegrationTest; + +/** + * Integration tests for {@link Statistics} as implemented by {@link DistributedSystem}. + */ +@Category(IntegrationTest.class) +public class DistributedSystemStatisticsIntegrationTest { + + private DistributedSystem system; + + private String statName1; + private String statName2; + private String statName3; + private String[] statNames; + + private Random random; + + @Rule + public TestName testName = new TestName(); + + @Before + public void setUp() throws Exception { + Properties props = new Properties(); + props.setProperty(MCAST_PORT, "0"); + props.setProperty(LOCATORS, ""); + props.setProperty(NAME, getUniqueName()); + + this.system = DistributedSystem.connect(props); + + this.statName1 = "one"; + this.statName2 = "two"; + this.statName3 = "three"; + this.statNames = new String[] { statName1, statName2, statName3 }; + + this.random = new Random(); + } + + @After + public void tearDown() throws Exception { + this.system.disconnect(); + this.system = null; + } + + /** + * Tests {@code int} statistics + */ + @Test + public void testIntStatistics() { + Statistics stats = setUpIntStatistics(3); + + for (int j = 0; j < this.statNames.length; j++) { + String statName = this.statNames[j]; + for (int i = 0; i < 10; i++) { + stats.setInt(statName, i); + stats.incInt(statName, 1); + assertThat(stats.getInt(statName)).isEqualTo(i + 1); + } + } + } + + /** + * Tests {@code long} statistics + */ + @Test + public void testLongStatistics() { + Statistics stats = setUpLongStatistics(3); + + // Set/get some random long values + for (int i = 0; i < 100; i++) { + for (int j = 0; j < this.statNames.length; j++) { + String statName = this.statNames[j]; + long value = this.random.nextLong(); + stats.setLong(statName, value); + assertThat(stats.getLong(statName)).isEqualTo(value); + } + } + + // Increment by some random values + for (int i = 0; i < 100; i++) { + for (int j = 0; j < this.statNames.length; j++) { + String statName = this.statNames[j]; + long inc = this.random.nextLong(); + long before = stats.getLong(statName); + stats.incLong(statName, inc); + assertThat(stats.getLong(statName)).isEqualTo(before + inc); + } + } + } + + /** + * Tests {@code double} statistics + */ + @Test + public void testDoubleStatistics() { + Statistics stats = setUpDoubleStatistics(3); + + // Set/get some random double values + for (int i = 0; i < 100; i++) { + for (int j = 0; j < this.statNames.length; j++) { + String statName = this.statNames[j]; + double value = this.random.nextDouble(); + stats.setDouble(statName, value); + assertThat(stats.getDouble(statName)).isEqualTo(value); + } + } + + // Increment by some random values + for (int i = 0; i < 100; i++) { + for (int j = 0; j < this.statNames.length; j++) { + String statName = this.statNames[j]; + double inc = this.random.nextDouble(); + double before = stats.getDouble(statName); + stats.incDouble(statName, inc); + assertThat(stats.getDouble(statName)).isEqualTo(before + inc); + } + } + } + + /** + * Tests that accessing an {@code int} stat throws the appropriate exceptions. + */ + @Test + public void testAccessingIntStat() { + Statistics stats = setUpIntStatistics(1); + + assertThat(stats.getInt(this.statName1)).isEqualTo(0); + assertThatThrownBy(() -> stats.getDouble(this.statName1)).isExactlyInstanceOf(IllegalArgumentException.class); + assertThatThrownBy(() -> stats.getLong(this.statName1)).isExactlyInstanceOf(IllegalArgumentException.class); + + stats.setInt(this.statName1, 4); + assertThatThrownBy(() -> stats.setDouble(this.statName1, 4.0)).isExactlyInstanceOf(IllegalArgumentException.class); + assertThatThrownBy(() -> stats.setLong(this.statName1, 4L)).isExactlyInstanceOf(IllegalArgumentException.class); + + stats.incInt(this.statName1, 4); + assertThatThrownBy(() -> stats.incDouble(this.statName1, 4.0)).isExactlyInstanceOf(IllegalArgumentException.class); + assertThatThrownBy(() -> stats.incLong(this.statName1, 4L)).isExactlyInstanceOf(IllegalArgumentException.class); + } + + /** + * Tests that accessing a {@code long} stat throws the appropriate exceptions. + */ + @Test + public void testAccessingLongStat() { + Statistics stats = setUpLongStatistics(1); + + assertThat(stats.getLong(this.statName1)).isEqualTo(0L); + assertThatThrownBy(() -> stats.getDouble(this.statName1)).isExactlyInstanceOf(IllegalArgumentException.class); + assertThatThrownBy(() -> stats.getInt(this.statName1)).isExactlyInstanceOf(IllegalArgumentException.class); + + stats.setLong(this.statName1, 4L); + assertThatThrownBy(() -> stats.setDouble(this.statName1, 4.0)).isExactlyInstanceOf(IllegalArgumentException.class); + assertThatThrownBy(() -> stats.setInt(this.statName1, 4)).isExactlyInstanceOf(IllegalArgumentException.class); + + stats.incLong(this.statName1, 4L); + assertThatThrownBy(() -> stats.incDouble(this.statName1, 4.0)).isExactlyInstanceOf(IllegalArgumentException.class); + assertThatThrownBy(() -> stats.incInt(this.statName1, 4)).isExactlyInstanceOf(IllegalArgumentException.class); + } + + /** + * Tests that accessing an {@code double} stat throws the appropriate exceptions. + */ + @Test + public void testAccessingDoubleStat() { + Statistics stats = setUpDoubleStatistics(1); + + assertThat(stats.getDouble(this.statName1)).isEqualTo(0.0); + assertThatThrownBy(() -> stats.getInt(this.statName1)).isExactlyInstanceOf(IllegalArgumentException.class); + assertThatThrownBy(() -> stats.getLong(this.statName1)).isExactlyInstanceOf(IllegalArgumentException.class); + + stats.setDouble(this.statName1, 4.0); + assertThatThrownBy(() -> stats.setInt(this.statName1, 4)).isExactlyInstanceOf(IllegalArgumentException.class); + assertThatThrownBy(() -> stats.setLong(this.statName1, 4L)).isExactlyInstanceOf(IllegalArgumentException.class); + + stats.incDouble(this.statName1, 4.0); + assertThatThrownBy(() -> stats.incInt(this.statName1, 4)).isExactlyInstanceOf(IllegalArgumentException.class); + assertThatThrownBy(() -> stats.incLong(this.statName1, 4L)).isExactlyInstanceOf(IllegalArgumentException.class); + } + + private StatisticsFactory factory() { + return this.system; + } + + private Statistics setUpIntStatistics(final int count) { + String[] descriptions = new String[] {"ONE", "TWO", "THREE"}; + StatisticDescriptor[] descriptors = new StatisticDescriptor[count]; + for (int i = 0; i < count; i++) { + descriptors[i] = factory().createIntGauge(this.statNames[i], descriptions[i], "x"); + } + + StatisticsType type = factory().createType(getUniqueName(), "", descriptors); + Statistics stats = factory().createStatistics(type, "Display"); + + for (int i = 0; i < count; i++) { + stats.setInt(this.statNames[i], 0); + } + return stats; + } + + private Statistics setUpLongStatistics(final int count) { + String[] descriptions = new String[] {"ONE", "TWO", "THREE"}; + StatisticDescriptor[] descriptors = new StatisticDescriptor[count]; + for (int i = 0; i < count; i++) { + descriptors[i] = factory().createLongGauge(this.statNames[i], descriptions[i], "x"); + } + + StatisticsType type = factory().createType(getUniqueName(), "", descriptors); + Statistics stats = factory().createStatistics(type, "Display"); + + for (int i = 0; i < count; i++) { + stats.setLong(this.statNames[i], 0L); + } + return stats; + } + + private Statistics setUpDoubleStatistics(final int count) { + String[] descriptions = new String[] {"ONE", "TWO", "THREE"}; + StatisticDescriptor[] descriptors = new StatisticDescriptor[count]; + for (int i = 0; i < count; i++) { + descriptors[i] = factory().createDoubleGauge(this.statNames[i], descriptions[i], "x"); + } + + StatisticsType type = factory().createType(getUniqueName(), "", descriptors); + Statistics stats = factory().createStatistics(type, "Display"); + + for (int i = 0; i < count; i++) { + stats.setDouble(this.statNames[i], 0.0); + } + return stats; + } + + private String getUniqueName() { + return getClass().getSimpleName() + "_" + this.testName.getMethodName(); + } + +} diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/DistributedSystemStatisticsTypeIntegrationTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/DistributedSystemStatisticsTypeIntegrationTest.java new file mode 100644 index 000000000000..a87dd52d7ec1 --- /dev/null +++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/DistributedSystemStatisticsTypeIntegrationTest.java @@ -0,0 +1,90 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.gemstone.gemfire.internal.statistics; + +import static com.gemstone.gemfire.distributed.ConfigurationProperties.*; +import static org.assertj.core.api.Assertions.*; + +import java.util.Properties; + +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.experimental.categories.Category; +import org.junit.rules.TestName; + +import com.gemstone.gemfire.StatisticDescriptor; +import com.gemstone.gemfire.StatisticsFactory; +import com.gemstone.gemfire.StatisticsType; +import com.gemstone.gemfire.distributed.DistributedSystem; +import com.gemstone.gemfire.test.junit.categories.IntegrationTest; + +/** + * Integration tests for {@link StatisticsType} as implemented by {@link DistributedSystem}. + */ +@Category(IntegrationTest.class) +public class DistributedSystemStatisticsTypeIntegrationTest { + + private DistributedSystem system; + private StatisticsType type; + + @Rule + public TestName testName = new TestName(); + + @Before + public void setUp() throws Exception { + Properties props = new Properties(); + props.setProperty(MCAST_PORT, "0"); + props.setProperty(LOCATORS, ""); + props.setProperty(NAME, getUniqueName()); + this.system = DistributedSystem.connect(props); + + StatisticDescriptor[] stats = { + factory().createIntGauge("test", "TEST", "ms") + }; + + this.type = factory().createType(getUniqueName(), "TEST", stats); + } + + @After + public void tearDown() throws Exception { + this.system.disconnect(); + this.system = null; + } + + @Test + public void testNameToIdUnknownStatistic() { + assertThat(type.nameToId("test")).isEqualTo(0); + assertThatThrownBy(() -> type.nameToId("Fred")).isExactlyInstanceOf(IllegalArgumentException.class); + } + + @Test + public void testNameToDescriptorUnknownStatistic() { + assertThat(type.nameToDescriptor("test").getName()).isEqualTo("test"); + assertThatThrownBy(() -> type.nameToDescriptor("Fred")).isExactlyInstanceOf(IllegalArgumentException.class); + } + + private String getUniqueName() { + return getClass().getSimpleName() + "_" + this.testName.getMethodName(); + } + + private StatisticsFactory factory() { + return this.system; + } + +} diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/GemFireStatSamplerJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/GemFireStatSamplerIntegrationTest.java similarity index 94% rename from geode-core/src/test/java/com/gemstone/gemfire/internal/GemFireStatSamplerJUnitTest.java rename to geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/GemFireStatSamplerIntegrationTest.java index ef07633827f3..ff7c34d3042e 100644 --- a/geode-core/src/test/java/com/gemstone/gemfire/internal/GemFireStatSamplerJUnitTest.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/GemFireStatSamplerIntegrationTest.java @@ -14,25 +14,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.gemstone.gemfire.internal; +package com.gemstone.gemfire.internal.statistics; -import com.gemstone.gemfire.Statistics; -import com.gemstone.gemfire.StatisticsType; -import com.gemstone.gemfire.distributed.DistributedSystem; -import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem; -import com.gemstone.gemfire.internal.GemFireStatSampler.LocalStatListenerImpl; -import com.gemstone.gemfire.internal.cache.control.HeapMemoryMonitor; -import com.gemstone.gemfire.internal.logging.LogService; -import com.gemstone.gemfire.internal.statistics.SampleCollector; -import com.gemstone.gemfire.internal.statistics.StatArchiveHandler; -import com.gemstone.gemfire.internal.statistics.StatArchiveHandlerConfig; -import com.gemstone.gemfire.internal.stats50.VMStats50; -import com.gemstone.gemfire.internal.util.StopWatch; -import com.gemstone.gemfire.test.junit.categories.IntegrationTest; -import org.apache.logging.log4j.Logger; -import org.junit.*; -import org.junit.experimental.categories.Category; -import org.junit.rules.TestName; +import static com.gemstone.gemfire.distributed.ConfigurationProperties.*; +import static org.junit.Assert.*; +import static org.junit.Assume.*; import java.io.File; import java.lang.reflect.Method; @@ -42,42 +28,56 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; -import static com.gemstone.gemfire.distributed.ConfigurationProperties.*; -import static org.junit.Assert.*; -import static org.junit.Assume.assumeFalse; +import org.apache.logging.log4j.Logger; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.experimental.categories.Category; +import org.junit.rules.TemporaryFolder; +import org.junit.rules.TestName; + +import com.gemstone.gemfire.Statistics; +import com.gemstone.gemfire.StatisticsType; +import com.gemstone.gemfire.distributed.DistributedSystem; +import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem; +import com.gemstone.gemfire.internal.GemFireVersion; +import com.gemstone.gemfire.internal.PureJavaMode; +import com.gemstone.gemfire.internal.SocketCreator; +import com.gemstone.gemfire.internal.cache.control.HeapMemoryMonitor; +import com.gemstone.gemfire.internal.logging.LogService; +import com.gemstone.gemfire.internal.statistics.GemFireStatSampler.LocalStatListenerImpl; +import com.gemstone.gemfire.internal.statistics.platform.OsStatisticsFactory; +import com.gemstone.gemfire.internal.statistics.platform.ProcessStats; +import com.gemstone.gemfire.internal.stats50.VMStats50; +import com.gemstone.gemfire.internal.util.StopWatch; +import com.gemstone.gemfire.test.junit.categories.IntegrationTest; /** - * Integration tests for GemFireStatSampler. + * Integration tests for {@link GemFireStatSampler}. * * @since GemFire 7.0 */ @Category(IntegrationTest.class) -public class GemFireStatSamplerJUnitTest extends StatSamplerTestCase { +public class GemFireStatSamplerIntegrationTest extends StatSamplerTestCase { private static final Logger logger = LogService.getLogger(); private static final int STAT_SAMPLE_RATE = 1000; + private DistributedSystem system; + private File testDir; + + @Rule + public TemporaryFolder temporaryFolder = new TemporaryFolder(); + @Rule public TestName testName = new TestName(); - private DistributedSystem system; - private File testDir = new File(getClass().getSimpleName()); - - @BeforeClass - public static void beforeClass() throws Exception { - final String dirName = GemFireStatSamplerJUnitTest.class.getSimpleName(); - final File dir = new File(dirName); - if (dir.exists()) { - FileUtil.delete(dir); - } - } - @Before public void setUp() throws Exception { - if (!this.testDir.exists()) { - this.testDir.mkdir(); - } + this.testDir = this.temporaryFolder.getRoot(); assertTrue(this.testDir.exists()); } @@ -116,9 +116,9 @@ public void testBasics() throws Exception { assertEquals(statsCount, statSampler.getStatisticsManager().getStatisticsCount()); assertEquals(statsCount, statSampler.getStatistics().length); - assertEquals(getStatisticsManager().getId(), statSampler.getSystemId()); + Assert.assertEquals(getStatisticsManager().getId(), statSampler.getSystemId()); assertTrue(statSampler.getSystemStartTime() < System.currentTimeMillis()); - assertEquals(SocketCreator.getHostName(SocketCreator.getLocalHost()), + Assert.assertEquals(SocketCreator.getHostName(SocketCreator.getLocalHost()), statSampler.getSystemDirectoryPath()); AllStatistics allStats = new AllStatistics(statSampler); @@ -173,10 +173,10 @@ public void testBasics() throws Exception { */ @Test public void testArchiveFileExists() throws Exception { - final String dir = this.testDir.getName(); - final String archiveFileName = dir + File.separator + this.testName + ".gfs"; + final String dir = this.testDir.getAbsolutePath(); + final String archiveFileName = dir + File.separator + this.testName.getMethodName() + ".gfs"; - final File archiveFile1 = new File(dir + File.separator + this.testName + ".gfs"); + final File archiveFile1 = new File(dir + File.separator + this.testName.getMethodName() + ".gfs"); Properties props = createGemFireProperties(); props.setProperty(STATISTIC_ARCHIVE_FILE, archiveFileName); @@ -346,7 +346,7 @@ public void testStop() throws Exception { */ @Test public void testArchiveRolling() throws Exception { - final String dirName = this.testDir.getName() + File.separator + this.testName; + final String dirName = this.testDir.getAbsolutePath() + File.separator + this.testName; new File(dirName).mkdirs(); final String archiveFileName = dirName + File.separator + this.testName + ".gfs"; @@ -391,7 +391,7 @@ public void testArchiveRolling() throws Exception { */ @Test public void testArchiveRemoval() throws Exception { - final String dirName = this.testDir.getName();// + File.separator + this.testName; + final String dirName = this.testDir.getAbsolutePath();// + File.separator + this.testName; new File(dirName).mkdirs(); final String archiveFileName = dirName + File.separator + this.testName + ".gfs"; diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/SampleCollectorJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/SampleCollectorTest.java similarity index 99% rename from geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/SampleCollectorJUnitTest.java rename to geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/SampleCollectorTest.java index 1babbc1fb712..dd6de3473dca 100755 --- a/geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/SampleCollectorJUnitTest.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/SampleCollectorTest.java @@ -38,12 +38,12 @@ import com.gemstone.gemfire.test.junit.categories.UnitTest; /** - * Unit tests for the SampleCollector class. No disk IO. + * Unit tests for {@link SampleCollector}. * * @since GemFire 7.0 */ @Category(UnitTest.class) -public class SampleCollectorJUnitTest { +public class SampleCollectorTest { private TestStatisticsManager manager; private SampleCollector sampleCollector; diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/SimpleStatSamplerJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/SimpleStatSamplerIntegrationTest.java similarity index 92% rename from geode-core/src/test/java/com/gemstone/gemfire/internal/SimpleStatSamplerJUnitTest.java rename to geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/SimpleStatSamplerIntegrationTest.java index 5d7c9f4e6db4..d86b968e5d06 100755 --- a/geode-core/src/test/java/com/gemstone/gemfire/internal/SimpleStatSamplerJUnitTest.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/SimpleStatSamplerIntegrationTest.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.gemstone.gemfire.internal; +package com.gemstone.gemfire.internal.statistics; import static org.junit.Assert.*; @@ -23,50 +23,44 @@ import java.util.List; import org.junit.After; +import org.junit.Assert; import org.junit.Before; -import org.junit.BeforeClass; import org.junit.Rule; import org.junit.Test; import org.junit.experimental.categories.Category; +import org.junit.rules.TemporaryFolder; import org.junit.rules.TestName; import com.gemstone.gemfire.CancelCriterion; import com.gemstone.gemfire.Statistics; import com.gemstone.gemfire.StatisticsType; +import com.gemstone.gemfire.internal.SocketCreator; import com.gemstone.gemfire.internal.stats50.VMStats50; import com.gemstone.gemfire.test.junit.categories.IntegrationTest; /** - * Integration tests for SimpleStatSampler. + * Integration tests for {@link SimpleStatSampler}. * * @since GemFire 7.0 */ @Category(IntegrationTest.class) -public class SimpleStatSamplerJUnitTest extends StatSamplerTestCase { +public class SimpleStatSamplerIntegrationTest extends StatSamplerTestCase { - @Rule - public TestName testName = new TestName(); - private LocalStatisticsFactory statisticsFactory; + private File testDir; - private File testDir = new File(getClass().getSimpleName()); + @Rule + public TemporaryFolder temporaryFolder = new TemporaryFolder(); + + @Rule + public TestName testName = new TestName(); - @BeforeClass - public static void beforeClass() throws Exception { - final String dirName = SimpleStatSamplerJUnitTest.class.getSimpleName(); - final File dir = new File(dirName); - if (dir.exists()) { - FileUtil.delete(dir); - } - } @Before public void setUp() throws Exception { - if (!this.testDir.exists()) { - this.testDir.mkdir(); - } + this.testDir = this.temporaryFolder.getRoot(); assertTrue(this.testDir.exists()); - System.setProperty(SimpleStatSampler.ARCHIVE_FILE_NAME_PROPERTY, - this.testDir.getName() + File.separator + SimpleStatSampler.DEFAULT_ARCHIVE_FILE_NAME); + System.setProperty(SimpleStatSampler.ARCHIVE_FILE_NAME_PROPERTY, + this.testDir.getAbsolutePath() + File.separator + SimpleStatSampler.DEFAULT_ARCHIVE_FILE_NAME); } @After @@ -103,9 +97,9 @@ public void testBasics() throws Exception { assertTrue(statsCount > 0); - assertEquals(getStatisticsManager().getId(), statSampler.getSystemId()); + Assert.assertEquals(getStatisticsManager().getId(), statSampler.getSystemId()); assertTrue(statSampler.getSystemStartTime() <= System.currentTimeMillis()); - assertEquals(SocketCreator.getHostName(SocketCreator.getLocalHost()), + Assert.assertEquals(SocketCreator.getHostName(SocketCreator.getLocalHost()), statSampler.getSystemDirectoryPath()); VMStatsContract vmStats = statSampler.getVMStats(); @@ -135,7 +129,7 @@ public void testBasics() throws Exception { */ @Test public void testArchiveFileExists() throws Exception { - final String dir = this.testDir.getName(); + final String dir = this.testDir.getAbsolutePath(); final String archiveFileName = dir + File.separator + this.testName + ".gfs"; final File archiveFile1 = new File(dir + File.separator + this.testName + ".gfs"); System.setProperty(SimpleStatSampler.ARCHIVE_FILE_NAME_PROPERTY, archiveFileName); @@ -265,7 +259,7 @@ public void testArchiveRolling() throws Exception { // set the system property to use KB instead of MB for file size System.setProperty(HostStatSampler.TEST_FILE_SIZE_LIMIT_IN_KB_PROPERTY, "true"); - final String dir = this.testDir.getName() + File.separator + this.testName; + final String dir = this.testDir.getAbsolutePath() + File.separator + this.testName; new File(dir).mkdir(); final String archiveFileName = dir + File.separator + this.testName + ".gfs"; @@ -300,7 +294,7 @@ public void testArchiveRemoval() throws Exception { // set the system property to use KB instead of MB for file size System.setProperty(HostStatSampler.TEST_FILE_SIZE_LIMIT_IN_KB_PROPERTY, "true"); - final String dir = this.testDir.getName() + File.separator + this.testName; + final String dir = this.testDir.getAbsolutePath() + File.separator + this.testName; new File(dir).mkdir(); final String archiveFileName = dir + File.separator + this.testName + ".gfs"; diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/StatArchiveWriterReaderJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/StatArchiveWriterReaderIntegrationTest.java similarity index 76% rename from geode-core/src/test/java/com/gemstone/gemfire/internal/StatArchiveWriterReaderJUnitTest.java rename to geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/StatArchiveWriterReaderIntegrationTest.java index ea9ff4b47fbf..69ec1fbf422b 100755 --- a/geode-core/src/test/java/com/gemstone/gemfire/internal/StatArchiveWriterReaderJUnitTest.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/StatArchiveWriterReaderIntegrationTest.java @@ -14,13 +14,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.gemstone.gemfire.internal; +package com.gemstone.gemfire.internal.statistics; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static com.gemstone.gemfire.internal.statistics.StatArchiveFormat.NANOS_PER_MILLI; +import static com.gemstone.gemfire.internal.statistics.TestStatArchiveWriter.*; +import static org.junit.Assert.*; import static org.mockito.Mockito.*; import java.io.BufferedInputStream; @@ -36,48 +34,52 @@ import java.util.List; import java.util.Map; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.junit.After; import org.junit.Before; +import org.junit.Rule; import org.junit.Test; import org.junit.experimental.categories.Category; +import org.junit.rules.TemporaryFolder; +import org.junit.rules.TestName; import com.gemstone.gemfire.StatisticDescriptor; import com.gemstone.gemfire.Statistics; import com.gemstone.gemfire.StatisticsType; -import com.gemstone.gemfire.i18n.LogWriterI18n; -import com.gemstone.gemfire.internal.StatArchiveReader.StatValue; -import com.gemstone.gemfire.internal.logging.InternalLogWriter; -import com.gemstone.gemfire.internal.logging.PureLogWriter; -import com.gemstone.gemfire.internal.statistics.ResourceInstance; -import com.gemstone.gemfire.internal.statistics.ResourceType; -import com.gemstone.gemfire.internal.statistics.SampleCollector; -import com.gemstone.gemfire.internal.statistics.StatArchiveDescriptor; -import com.gemstone.gemfire.internal.statistics.TestStatArchiveWriter; -import com.gemstone.gemfire.internal.statistics.TestStatisticsManager; -import com.gemstone.gemfire.internal.statistics.TestStatisticsSampler; -import com.gemstone.gemfire.util.test.TestUtil; +import com.gemstone.gemfire.internal.NanoTimer; +import com.gemstone.gemfire.internal.statistics.StatArchiveReader.StatValue; import com.gemstone.gemfire.test.junit.categories.IntegrationTest; +import com.gemstone.gemfire.util.test.TestUtil; /** - * Integration tests for StatArchiveWriter and StatArchiveReader. The tests - * are very redundant and desperately need refactoring. - * + * Integration tests for {@link StatArchiveWriter} and {@link StatArchiveReader}. + * * @since GemFire 7.0 */ @Category(IntegrationTest.class) -public class StatArchiveWriterReaderJUnitTest { +@SuppressWarnings({ "rawtypes","unused" }) +public class StatArchiveWriterReaderIntegrationTest { - private static final String dir = "StatArchiveWriterReaderJUnitTest"; + private static final Logger logger = LogManager.getLogger(); + private File dir; private Map statisticTypes; - private Map> allStatistics; - + private String archiveFileName; + + @Rule + public TemporaryFolder temporaryFolder = new TemporaryFolder(); + + @Rule + public TestName testName = new TestName(); + @Before public void setUp() throws Exception { - this.statisticTypes = new HashMap(); - this.allStatistics = new HashMap>(); - new File(dir).mkdir(); + this.statisticTypes = new HashMap<>(); + this.allStatistics = new HashMap<>(); + this.dir = this.temporaryFolder.getRoot(); + this.archiveFileName = this.dir.getAbsolutePath() + File.separator + this.testName.getMethodName() + ".gfs"; } @After @@ -87,39 +89,21 @@ public void tearDown() throws Exception { StatisticsTypeFactoryImpl.clear(); } - private static void deleteTestOutputDir() { - try { - for (File file : new File(dir).listFiles()) { - file.delete(); - } - new File(dir).delete(); - } catch (NullPointerException e) { - // dir probably doesn't exist - } - } - @Test public void testDoubleCounterOneSample() throws Exception { - final String testName = "testDoubleCounterOneSample"; - final String archiveFileName = dir + File.separator + testName + ".gfs"; - - final InternalLogWriter log = new PureLogWriter(InternalLogWriter.CONFIG_LEVEL); - final TestStatisticsManager manager = new TestStatisticsManager( - 1, - "StatArchiveWriterReaderJUnitTest_" + testName, - TestStatArchiveWriter.WRITER_INITIAL_DATE_MILLIS); + final TestStatisticsManager manager = new TestStatisticsManager(1, getUniqueName(), WRITER_INITIAL_DATE_MILLIS); final TestStatisticsSampler sampler = new TestStatisticsSampler(manager); final SampleCollector sampleCollector = new SampleCollector(sampler); final StatArchiveDescriptor archiveDescriptor = new StatArchiveDescriptor.Builder() - .setArchiveName(archiveFileName) + .setArchiveName(this.archiveFileName) .setSystemId(1) - .setSystemStartTime(TestStatArchiveWriter.WRITER_INITIAL_DATE_MILLIS) - .setSystemDirectoryPath(testName) - .setProductDescription("StatArchiveWriterReaderJUnitTest") + .setSystemStartTime(WRITER_INITIAL_DATE_MILLIS) + .setSystemDirectoryPath(this.testName.getMethodName()) + .setProductDescription(getClass().getSimpleName()) .build(); - final StatArchiveWriter writer = new TestStatArchiveWriter(archiveDescriptor, log); + final StatArchiveWriter writer = new TestStatArchiveWriter(archiveDescriptor); sampleCollector.addSampleHandler(writer); final StatisticDescriptor[] statsST1 = new StatisticDescriptor[] { @@ -131,8 +115,8 @@ public void testDoubleCounterOneSample() throws Exception { final double value = 32317.716467; incDouble(st1_1, "long_double_1", value); - final long sampleIncNanos = StatArchiveFormat.NANOS_PER_MILLI*1000; - final long sampleTimeNanos = TestStatArchiveWriter.WRITER_PREVIOUS_TIMESTAMP_NANOS + sampleIncNanos; + final long sampleIncNanos = NANOS_PER_MILLI * 1000; + final long sampleTimeNanos = WRITER_PREVIOUS_TIMESTAMP_NANOS + sampleIncNanos; sampleCollector.sample(sampleTimeNanos); writer.close(); @@ -142,12 +126,10 @@ public void testDoubleCounterOneSample() throws Exception { assertEquals(value, st1_1.get(sds[i].getName())); } - final StatArchiveReader reader = new StatArchiveReader( - new File[]{new File(archiveFileName)}, null, false); + final StatArchiveReader reader = new StatArchiveReader(new File[]{new File(this.archiveFileName)}, null, false); // compare all resourceInst values against what was printed above - @SuppressWarnings("rawtypes") final List resources = reader.getResourceInstList(); assertNotNull(resources); assertEquals(1, resources.size()); @@ -174,12 +156,12 @@ public void testDoubleCounterOneSample() throws Exception { assertNotNull(timeStampsMillis); assertEquals(1, timeStampsMillis.length); - final long initPreviousTimeStampMillis = NanoTimer.nanosToMillis(TestStatArchiveWriter.WRITER_PREVIOUS_TIMESTAMP_NANOS); + final long initPreviousTimeStampMillis = NanoTimer.nanosToMillis(WRITER_PREVIOUS_TIMESTAMP_NANOS); final long timeStampMillis = NanoTimer.nanosToMillis(sampleTimeNanos); final long deltaMillis = timeStampMillis - initPreviousTimeStampMillis; assertEquals(NanoTimer.nanosToMillis(sampleIncNanos), deltaMillis); - final long expectedTimeStampMillis = deltaMillis + TestStatArchiveWriter.WRITER_INITIAL_DATE_MILLIS; + final long expectedTimeStampMillis = deltaMillis + WRITER_INITIAL_DATE_MILLIS; assertEquals(expectedTimeStampMillis, timeStampsMillis[0]); final double[] snapshots = statValues[0].getRawSnapshots(); @@ -190,26 +172,22 @@ public void testDoubleCounterOneSample() throws Exception { @Test public void testIntCounterOneSample() throws Exception { - final String testName = "testIntCounterOneSample"; - final String archiveFileName = dir + File.separator + testName + ".gfs"; - - final InternalLogWriter log = new PureLogWriter(InternalLogWriter.CONFIG_LEVEL); final TestStatisticsManager manager = new TestStatisticsManager( - 1, - "StatArchiveWriterReaderJUnitTest_" + testName, - TestStatArchiveWriter.WRITER_INITIAL_DATE_MILLIS); + 1, + getUniqueName(), + WRITER_INITIAL_DATE_MILLIS); final TestStatisticsSampler sampler = new TestStatisticsSampler(manager); final SampleCollector sampleCollector = new SampleCollector(sampler); final StatArchiveDescriptor archiveDescriptor = new StatArchiveDescriptor.Builder() - .setArchiveName(archiveFileName) + .setArchiveName(this.archiveFileName) .setSystemId(1) - .setSystemStartTime(TestStatArchiveWriter.WRITER_INITIAL_DATE_MILLIS) - .setSystemDirectoryPath(testName) - .setProductDescription("StatArchiveWriterReaderJUnitTest") + .setSystemStartTime(WRITER_INITIAL_DATE_MILLIS) + .setSystemDirectoryPath(this.testName.getMethodName()) + .setProductDescription(getClass().getSimpleName()) .build(); - final StatArchiveWriter writer = new TestStatArchiveWriter(archiveDescriptor, log); + final StatArchiveWriter writer = new TestStatArchiveWriter(archiveDescriptor); sampleCollector.addSampleHandler(writer); final StatisticDescriptor[] statsST1 = new StatisticDescriptor[] { @@ -221,8 +199,8 @@ public void testIntCounterOneSample() throws Exception { final int value = 5; incInt(st1_1, "int_counter_1", value); - final long sampleIncNanos = StatArchiveFormat.NANOS_PER_MILLI*1000; - final long sampleTimeNanos = TestStatArchiveWriter.WRITER_PREVIOUS_TIMESTAMP_NANOS + sampleIncNanos; + final long sampleIncNanos = NANOS_PER_MILLI*1000; + final long sampleTimeNanos = WRITER_PREVIOUS_TIMESTAMP_NANOS + sampleIncNanos; sampleCollector.sample(sampleTimeNanos); writer.close(); @@ -232,12 +210,10 @@ public void testIntCounterOneSample() throws Exception { assertEquals(value, st1_1.get(sds[i].getName())); } - final StatArchiveReader reader = new StatArchiveReader( - new File[]{new File(archiveFileName)}, null, false); + final StatArchiveReader reader = new StatArchiveReader(new File[]{new File(this.archiveFileName)}, null, false); // compare all resourceInst values against what was printed above - @SuppressWarnings("rawtypes") final List resources = reader.getResourceInstList(); assertNotNull(resources); assertEquals(1, resources.size()); @@ -264,12 +240,12 @@ public void testIntCounterOneSample() throws Exception { assertNotNull(timeStampsMillis); assertEquals(1, timeStampsMillis.length); - final long initPreviousTimeStampMillis = NanoTimer.nanosToMillis(TestStatArchiveWriter.WRITER_PREVIOUS_TIMESTAMP_NANOS); + final long initPreviousTimeStampMillis = NanoTimer.nanosToMillis(WRITER_PREVIOUS_TIMESTAMP_NANOS); final long timeStampMillis = NanoTimer.nanosToMillis(sampleTimeNanos); final long deltaMillis = timeStampMillis - initPreviousTimeStampMillis; assertEquals(NanoTimer.nanosToMillis(sampleIncNanos), deltaMillis); - final long expectedTimeStampMillis = deltaMillis + TestStatArchiveWriter.WRITER_INITIAL_DATE_MILLIS; + final long expectedTimeStampMillis = deltaMillis + WRITER_INITIAL_DATE_MILLIS; assertEquals(expectedTimeStampMillis, timeStampsMillis[0]); final double[] snapshots = statValues[0].getRawSnapshots(); @@ -280,26 +256,22 @@ public void testIntCounterOneSample() throws Exception { @Test public void testIntGaugeOneSample() throws Exception { - final String testName = "testIntGaugeOneSample"; - final String archiveFileName = dir + File.separator + testName + ".gfs"; - - final InternalLogWriter log = new PureLogWriter(InternalLogWriter.CONFIG_LEVEL); final TestStatisticsManager manager = new TestStatisticsManager( - 1, - "StatArchiveWriterReaderJUnitTest_" + testName, - TestStatArchiveWriter.WRITER_INITIAL_DATE_MILLIS); + 1, + getUniqueName(), + WRITER_INITIAL_DATE_MILLIS); final TestStatisticsSampler sampler = new TestStatisticsSampler(manager); final SampleCollector sampleCollector = new SampleCollector(sampler); final StatArchiveDescriptor archiveDescriptor = new StatArchiveDescriptor.Builder() - .setArchiveName(archiveFileName) + .setArchiveName(this.archiveFileName) .setSystemId(1) - .setSystemStartTime(TestStatArchiveWriter.WRITER_INITIAL_DATE_MILLIS) - .setSystemDirectoryPath(testName) - .setProductDescription("StatArchiveWriterReaderJUnitTest") + .setSystemStartTime(WRITER_INITIAL_DATE_MILLIS) + .setSystemDirectoryPath(this.testName.getMethodName()) + .setProductDescription(getClass().getSimpleName()) .build(); - final StatArchiveWriter writer = new TestStatArchiveWriter(archiveDescriptor, log); + final StatArchiveWriter writer = new TestStatArchiveWriter(archiveDescriptor); sampleCollector.addSampleHandler(writer); final StatisticDescriptor[] statsST1 = new StatisticDescriptor[] { @@ -311,8 +283,8 @@ public void testIntGaugeOneSample() throws Exception { final int value = 5; incInt(st1_1, "int_gauge_1", value); - final long sampleIncNanos = StatArchiveFormat.NANOS_PER_MILLI*1000; - final long sampleTimeNanos = TestStatArchiveWriter.WRITER_PREVIOUS_TIMESTAMP_NANOS + sampleIncNanos; + final long sampleIncNanos = NANOS_PER_MILLI*1000; + final long sampleTimeNanos = WRITER_PREVIOUS_TIMESTAMP_NANOS + sampleIncNanos; sampleCollector.sample(sampleTimeNanos); writer.close(); @@ -322,12 +294,10 @@ public void testIntGaugeOneSample() throws Exception { assertEquals(value, st1_1.get(sds[i].getName())); } - final StatArchiveReader reader = new StatArchiveReader( - new File[]{new File(archiveFileName)}, null, false); + final StatArchiveReader reader = new StatArchiveReader(new File[]{new File(this.archiveFileName)}, null, false); // compare all resourceInst values against what was printed above - @SuppressWarnings("rawtypes") final List resources = reader.getResourceInstList(); assertNotNull(resources); assertEquals(1, resources.size()); @@ -354,12 +324,12 @@ public void testIntGaugeOneSample() throws Exception { assertNotNull(timeStampsMillis); assertEquals(1, timeStampsMillis.length); - final long initialPreviousTimeStampMillis = NanoTimer.nanosToMillis(TestStatArchiveWriter.WRITER_PREVIOUS_TIMESTAMP_NANOS); + final long initialPreviousTimeStampMillis = NanoTimer.nanosToMillis(WRITER_PREVIOUS_TIMESTAMP_NANOS); final long timeStampMillis = NanoTimer.nanosToMillis(sampleTimeNanos); final long deltaMillis = timeStampMillis - initialPreviousTimeStampMillis; assertEquals(NanoTimer.nanosToMillis(sampleIncNanos), deltaMillis); - final long expectedTimeStampMillis = deltaMillis + TestStatArchiveWriter.WRITER_INITIAL_DATE_MILLIS; + final long expectedTimeStampMillis = deltaMillis + WRITER_INITIAL_DATE_MILLIS; assertEquals(expectedTimeStampMillis, timeStampsMillis[0]); final double[] snapshots = statValues[0].getRawSnapshots(); @@ -370,26 +340,22 @@ public void testIntGaugeOneSample() throws Exception { @Test public void testLongCounterOneSample() throws Exception { - final String testName = "testLongCounterOneSample"; - final String archiveFileName = dir + File.separator + testName + ".gfs"; - - final InternalLogWriter log = new PureLogWriter(InternalLogWriter.CONFIG_LEVEL); final TestStatisticsManager manager = new TestStatisticsManager( - 1, - "StatArchiveWriterReaderJUnitTest_" + testName, - TestStatArchiveWriter.WRITER_INITIAL_DATE_MILLIS); + 1, + getUniqueName(), + WRITER_INITIAL_DATE_MILLIS); final TestStatisticsSampler sampler = new TestStatisticsSampler(manager); final SampleCollector sampleCollector = new SampleCollector(sampler); final StatArchiveDescriptor archiveDescriptor = new StatArchiveDescriptor.Builder() - .setArchiveName(archiveFileName) + .setArchiveName(this.archiveFileName) .setSystemId(1) - .setSystemStartTime(TestStatArchiveWriter.WRITER_INITIAL_DATE_MILLIS) - .setSystemDirectoryPath(testName) - .setProductDescription("StatArchiveWriterReaderJUnitTest") + .setSystemStartTime(WRITER_INITIAL_DATE_MILLIS) + .setSystemDirectoryPath(this.testName.getMethodName()) + .setProductDescription(getClass().getSimpleName()) .build(); - final StatArchiveWriter writer = new TestStatArchiveWriter(archiveDescriptor, log); + final StatArchiveWriter writer = new TestStatArchiveWriter(archiveDescriptor); sampleCollector.addSampleHandler(writer); final StatisticDescriptor[] statsST1 = new StatisticDescriptor[] { @@ -401,8 +367,8 @@ public void testLongCounterOneSample() throws Exception { final long value = 5; incLong(st1_1, "long_counter_1", value); - final long sampleIncNanos = StatArchiveFormat.NANOS_PER_MILLI*1000; - final long sampleTimeNanos = TestStatArchiveWriter.WRITER_PREVIOUS_TIMESTAMP_NANOS + sampleIncNanos; + final long sampleIncNanos = NANOS_PER_MILLI*1000; + final long sampleTimeNanos = WRITER_PREVIOUS_TIMESTAMP_NANOS + sampleIncNanos; sampleCollector.sample(sampleTimeNanos); writer.close(); @@ -412,12 +378,10 @@ public void testLongCounterOneSample() throws Exception { assertEquals(value, st1_1.get(sds[i].getName())); } - final StatArchiveReader reader = new StatArchiveReader( - new File[]{new File(archiveFileName)}, null, false); + final StatArchiveReader reader = new StatArchiveReader(new File[]{new File(this.archiveFileName)}, null, false); // compare all resourceInst values against what was printed above - @SuppressWarnings("rawtypes") final List resources = reader.getResourceInstList(); assertNotNull(resources); assertEquals(1, resources.size()); @@ -444,12 +408,12 @@ public void testLongCounterOneSample() throws Exception { assertNotNull(timeStampsMillis); assertEquals(1, timeStampsMillis.length); - final long initialPreviousTimeStampMillis = NanoTimer.nanosToMillis(TestStatArchiveWriter.WRITER_PREVIOUS_TIMESTAMP_NANOS); + final long initialPreviousTimeStampMillis = NanoTimer.nanosToMillis(WRITER_PREVIOUS_TIMESTAMP_NANOS); final long timeStampMillis = NanoTimer.nanosToMillis(sampleTimeNanos); final long deltaMillis = timeStampMillis - initialPreviousTimeStampMillis; assertEquals(NanoTimer.nanosToMillis(sampleIncNanos), deltaMillis); - final long expectedTimeStampMillis = deltaMillis + TestStatArchiveWriter.WRITER_INITIAL_DATE_MILLIS; + final long expectedTimeStampMillis = deltaMillis + WRITER_INITIAL_DATE_MILLIS; assertEquals(expectedTimeStampMillis, timeStampsMillis[0]); final double[] snapshots = statValues[0].getRawSnapshots(); @@ -460,26 +424,22 @@ public void testLongCounterOneSample() throws Exception { @Test public void testLongGaugeOneSample() throws Exception { - final String testName = "testLongGaugeOneSample"; - final String archiveFileName = dir + File.separator + testName + ".gfs"; - - final InternalLogWriter log = new PureLogWriter(InternalLogWriter.CONFIG_LEVEL); final TestStatisticsManager manager = new TestStatisticsManager( - 1, - "StatArchiveWriterReaderJUnitTest_" + testName, - TestStatArchiveWriter.WRITER_INITIAL_DATE_MILLIS); + 1, + getUniqueName(), + WRITER_INITIAL_DATE_MILLIS); final TestStatisticsSampler sampler = new TestStatisticsSampler(manager); final SampleCollector sampleCollector = new SampleCollector(sampler); final StatArchiveDescriptor archiveDescriptor = new StatArchiveDescriptor.Builder() - .setArchiveName(archiveFileName) + .setArchiveName(this.archiveFileName) .setSystemId(1) - .setSystemStartTime(TestStatArchiveWriter.WRITER_INITIAL_DATE_MILLIS) - .setSystemDirectoryPath(testName) - .setProductDescription("StatArchiveWriterReaderJUnitTest") + .setSystemStartTime(WRITER_INITIAL_DATE_MILLIS) + .setSystemDirectoryPath(this.testName.getMethodName()) + .setProductDescription(getClass().getSimpleName()) .build(); - final StatArchiveWriter writer = new TestStatArchiveWriter(archiveDescriptor, log); + final StatArchiveWriter writer = new TestStatArchiveWriter(archiveDescriptor); sampleCollector.addSampleHandler(writer); final StatisticDescriptor[] statsST1 = new StatisticDescriptor[] { @@ -490,7 +450,7 @@ public void testLongGaugeOneSample() throws Exception { final Statistics st1_1 = manager.createAtomicStatistics(ST1, "st1_1", 1); incLong(st1_1, "long_gauge_1", 5); - final long sampleTimeNanos = TestStatArchiveWriter.WRITER_PREVIOUS_TIMESTAMP_NANOS + StatArchiveFormat.NANOS_PER_MILLI*2; + final long sampleTimeNanos = WRITER_PREVIOUS_TIMESTAMP_NANOS + NANOS_PER_MILLI*2; sampleCollector.sample(sampleTimeNanos); writer.close(); @@ -500,12 +460,10 @@ public void testLongGaugeOneSample() throws Exception { assertEquals(5L, st1_1.get(sds[i].getName())); } - final StatArchiveReader reader = new StatArchiveReader( - new File[]{new File(archiveFileName)}, null, false); + final StatArchiveReader reader = new StatArchiveReader(new File[]{new File(this.archiveFileName)}, null, false); // compare all resourceInst values against what was printed above - @SuppressWarnings("rawtypes") final List resources = reader.getResourceInstList(); assertNotNull(resources); assertEquals(1, resources.size()); @@ -532,12 +490,12 @@ public void testLongGaugeOneSample() throws Exception { assertNotNull(timeStampsMillis); assertEquals(1, timeStampsMillis.length); - final long initialPreviousTimeStampMillis = NanoTimer.nanosToMillis(TestStatArchiveWriter.WRITER_PREVIOUS_TIMESTAMP_NANOS); + final long initialPreviousTimeStampMillis = NanoTimer.nanosToMillis(WRITER_PREVIOUS_TIMESTAMP_NANOS); final long timeStampMillis = NanoTimer.nanosToMillis(sampleTimeNanos); final long deltaMillis = timeStampMillis - initialPreviousTimeStampMillis; assertEquals(2, deltaMillis); - final long expectedTimeStampMillis = deltaMillis + TestStatArchiveWriter.WRITER_INITIAL_DATE_MILLIS; + final long expectedTimeStampMillis = deltaMillis + WRITER_INITIAL_DATE_MILLIS; assertEquals(expectedTimeStampMillis, timeStampsMillis[0]); final double[] snapshots = statValues[0].getRawSnapshots(); @@ -548,26 +506,22 @@ public void testLongGaugeOneSample() throws Exception { @Test public void testLongCounterTwoSamples() throws Exception { - final String testName = "testLongCounterTwoSamples"; - final String archiveFileName = dir + File.separator + testName + ".gfs"; - - final InternalLogWriter log = new PureLogWriter(InternalLogWriter.CONFIG_LEVEL); final TestStatisticsManager manager = new TestStatisticsManager( - 1, - "StatArchiveWriterReaderJUnitTest_" + testName, - TestStatArchiveWriter.WRITER_INITIAL_DATE_MILLIS); + 1, + getUniqueName(), + WRITER_INITIAL_DATE_MILLIS); final TestStatisticsSampler sampler = new TestStatisticsSampler(manager); final SampleCollector sampleCollector = new SampleCollector(sampler); final StatArchiveDescriptor archiveDescriptor = new StatArchiveDescriptor.Builder() - .setArchiveName(archiveFileName) + .setArchiveName(this.archiveFileName) .setSystemId(1) - .setSystemStartTime(TestStatArchiveWriter.WRITER_INITIAL_DATE_MILLIS) - .setSystemDirectoryPath(testName) - .setProductDescription("StatArchiveWriterReaderJUnitTest") + .setSystemStartTime(WRITER_INITIAL_DATE_MILLIS) + .setSystemDirectoryPath(this.testName.getMethodName()) + .setProductDescription(getClass().getSimpleName()) .build(); - final StatArchiveWriter writer = new TestStatArchiveWriter(archiveDescriptor, log); + final StatArchiveWriter writer = new TestStatArchiveWriter(archiveDescriptor); sampleCollector.addSampleHandler(writer); final StatisticDescriptor[] statsST1 = new StatisticDescriptor[] { @@ -579,8 +533,8 @@ public void testLongCounterTwoSamples() throws Exception { final long value1 = 5; incLong(st1_1, "long_counter_1", value1); - final long sampleIncNanos = StatArchiveFormat.NANOS_PER_MILLI*1000; - long sampleTimeNanos = TestStatArchiveWriter.WRITER_PREVIOUS_TIMESTAMP_NANOS + sampleIncNanos; + final long sampleIncNanos = NANOS_PER_MILLI*1000; + long sampleTimeNanos = WRITER_PREVIOUS_TIMESTAMP_NANOS + sampleIncNanos; sampleCollector.sample(sampleTimeNanos); final long value2 = 15; @@ -595,12 +549,10 @@ public void testLongCounterTwoSamples() throws Exception { assertEquals(value1 + value2, st1_1.get(sds[i].getName())); } - final StatArchiveReader reader = new StatArchiveReader( - new File[]{new File(archiveFileName)}, null, false); + final StatArchiveReader reader = new StatArchiveReader(new File[]{new File(this.archiveFileName)}, null, false); // compare all resourceInst values against what was printed above - @SuppressWarnings("rawtypes") final List resources = reader.getResourceInstList(); assertNotNull(resources); assertEquals(1, resources.size()); @@ -629,16 +581,15 @@ public void testLongCounterTwoSamples() throws Exception { assertNotNull(timeStampsMillis); assertEquals(2, timeStampsMillis.length); - final long initialPreviousTimeStampMillis = NanoTimer.nanosToMillis(TestStatArchiveWriter.WRITER_PREVIOUS_TIMESTAMP_NANOS); + final long initialPreviousTimeStampMillis = NanoTimer.nanosToMillis(WRITER_PREVIOUS_TIMESTAMP_NANOS); final long timeStampMillis = NanoTimer.nanosToMillis(sampleTimeNanos); final long deltaMillis = timeStampMillis - initialPreviousTimeStampMillis; assertEquals(NanoTimer.nanosToMillis(sampleIncNanos*2), deltaMillis); - long expectedTimeStampMillis = TestStatArchiveWriter.WRITER_INITIAL_DATE_MILLIS; + long expectedTimeStampMillis = WRITER_INITIAL_DATE_MILLIS; for (int i = 0; i < timeStampsMillis.length; i++) { expectedTimeStampMillis += 1000; - assertEquals("expectedTimeStampMillis for " + i + " is wrong", - expectedTimeStampMillis, timeStampsMillis[i]); + assertEquals("expectedTimeStampMillis for " + i + " is wrong", expectedTimeStampMillis, timeStampsMillis[i]); } final double[] snapshots = statValues[0].getRawSnapshots(); @@ -651,33 +602,28 @@ public void testLongCounterTwoSamples() throws Exception { /** * Tests the stat archive file written by StatArchiveWriter. */ - @SuppressWarnings("unused") @Test public void testWriteAfterSamplingBegins() throws Exception { - final String testName = "testWriteAfterSamplingBegins"; - final String archiveFileName = dir + File.separator + testName + ".gfs"; - - final InternalLogWriter log = new PureLogWriter(InternalLogWriter.CONFIG_LEVEL); final TestStatisticsManager manager = new TestStatisticsManager( - 1, - "StatArchiveWriterReaderJUnitTest_" + testName, - TestStatArchiveWriter.WRITER_INITIAL_DATE_MILLIS); + 1, + getUniqueName(), + WRITER_INITIAL_DATE_MILLIS); final TestStatisticsSampler sampler = new TestStatisticsSampler(manager); final SampleCollector sampleCollector = new SampleCollector(sampler); final StatArchiveDescriptor archiveDescriptor = new StatArchiveDescriptor.Builder() - .setArchiveName(archiveFileName) + .setArchiveName(this.archiveFileName) .setSystemId(1) - .setSystemStartTime(TestStatArchiveWriter.WRITER_INITIAL_DATE_MILLIS - 2000) - .setSystemDirectoryPath(testName) - .setProductDescription("StatArchiveWriterReaderJUnitTest") + .setSystemStartTime(WRITER_INITIAL_DATE_MILLIS - 2000) + .setSystemDirectoryPath(this.testName.getMethodName()) + .setProductDescription(getClass().getSimpleName()) .build(); - final StatArchiveWriter writer = new TestStatArchiveWriter(archiveDescriptor, log); + final StatArchiveWriter writer = new TestStatArchiveWriter(archiveDescriptor); sampleCollector.addSampleHandler(writer); - long sampleTimeNanos = TestStatArchiveWriter.WRITER_PREVIOUS_TIMESTAMP_NANOS + StatArchiveFormat.NANOS_PER_MILLI*1000; - sampleCollector.sample(sampleTimeNanos+=(1000*StatArchiveFormat.NANOS_PER_MILLI)); + long sampleTimeNanos = WRITER_PREVIOUS_TIMESTAMP_NANOS + NANOS_PER_MILLI*1000; + sampleCollector.sample(sampleTimeNanos+=(1000*NANOS_PER_MILLI)); // 1) create ST1 and st1_1 @@ -702,7 +648,7 @@ public void testWriteAfterSamplingBegins() throws Exception { final Statistics st1_2 = manager.createAtomicStatistics(ST1, "st1_2", 2); - sampleCollector.sample(sampleTimeNanos+=(1000*StatArchiveFormat.NANOS_PER_MILLI)); + sampleCollector.sample(sampleTimeNanos+=(1000*NANOS_PER_MILLI)); // 3) some new values @@ -720,7 +666,7 @@ public void testWriteAfterSamplingBegins() throws Exception { incLong(st1_2, "long_counter_10", 3497536); incLong(st1_2, "long_gauge_11", 103909646); - sampleCollector.sample(sampleTimeNanos+=(1000*StatArchiveFormat.NANOS_PER_MILLI)); + sampleCollector.sample(sampleTimeNanos+=(1000*NANOS_PER_MILLI)); // 4) all new values @@ -750,11 +696,11 @@ public void testWriteAfterSamplingBegins() throws Exception { incLong(st1_2, "long_gauge_11", -4); incLong(st1_2, "long_gauge_12", 1098764); - sampleCollector.sample(sampleTimeNanos+=(1000*StatArchiveFormat.NANOS_PER_MILLI)); + sampleCollector.sample(sampleTimeNanos+=(1000*NANOS_PER_MILLI)); // 5) no new values - sampleCollector.sample(sampleTimeNanos+=(1000*StatArchiveFormat.NANOS_PER_MILLI)); + sampleCollector.sample(sampleTimeNanos+=(1000*NANOS_PER_MILLI)); // 6) some new values @@ -772,7 +718,7 @@ public void testWriteAfterSamplingBegins() throws Exception { incLong(st1_2, "long_counter_9", 8); incLong(st1_2, "long_gauge_12", 10); - sampleCollector.sample(sampleTimeNanos+=(1000*StatArchiveFormat.NANOS_PER_MILLI)); + sampleCollector.sample(sampleTimeNanos+=(1000*NANOS_PER_MILLI)); // 7) all new values @@ -802,7 +748,7 @@ public void testWriteAfterSamplingBegins() throws Exception { incLong(st1_2, "long_gauge_11", 3); incLong(st1_2, "long_gauge_12", -2); - sampleCollector.sample(sampleTimeNanos+=(1000*StatArchiveFormat.NANOS_PER_MILLI)); + sampleCollector.sample(sampleTimeNanos+=(1000*NANOS_PER_MILLI)); // 8) create ST2 and ST3 and st2_1 and st3_1 and st3_2 @@ -878,7 +824,7 @@ public void testWriteAfterSamplingBegins() throws Exception { incInt(st3_2, "int_counter_5", 1); incInt(st3_2, "int_counter_6", 4); - sampleCollector.sample(sampleTimeNanos+=(1000*StatArchiveFormat.NANOS_PER_MILLI)); + sampleCollector.sample(sampleTimeNanos+=(1000*NANOS_PER_MILLI)); // 10) some new values @@ -908,7 +854,7 @@ public void testWriteAfterSamplingBegins() throws Exception { incDouble(st3_2, "double_gauge_4", 36310.012); incInt(st3_2, "int_counter_6", 4); - sampleCollector.sample(sampleTimeNanos+=(1000*StatArchiveFormat.NANOS_PER_MILLI)); + sampleCollector.sample(sampleTimeNanos+=(1000*NANOS_PER_MILLI)); // 11) remove ST2 and st2_1 @@ -938,11 +884,11 @@ public void testWriteAfterSamplingBegins() throws Exception { incInt(st3_2, "int_counter_5", 3); incInt(st3_2, "int_counter_6", 1); - sampleCollector.sample(sampleTimeNanos+=(1000*StatArchiveFormat.NANOS_PER_MILLI)); + sampleCollector.sample(sampleTimeNanos+=(1000*NANOS_PER_MILLI)); // 13) no new values - sampleCollector.sample(sampleTimeNanos+=(1000*StatArchiveFormat.NANOS_PER_MILLI)); + sampleCollector.sample(sampleTimeNanos+=(1000*NANOS_PER_MILLI)); // 14) remove st1_2 @@ -977,7 +923,7 @@ public void testWriteAfterSamplingBegins() throws Exception { incInt(st3_2, "int_counter_5", 9); incInt(st3_2, "int_counter_6", 5); - sampleCollector.sample(sampleTimeNanos+=(1000*StatArchiveFormat.NANOS_PER_MILLI)); + sampleCollector.sample(sampleTimeNanos+=(1000*NANOS_PER_MILLI)); // close the writer @@ -989,47 +935,39 @@ public void testWriteAfterSamplingBegins() throws Exception { StatisticDescriptor[] sds = ST1.getStatistics(); for (int i = 0; i < sds.length; i++) { - log.convertToLogWriter().info("testWriteAfterSamplingBegins#st1_1#" - + sds[i].getName() + "=" + st1_1.get(sds[i].getName())); + logger.info("testWriteAfterSamplingBegins#st1_1#" + sds[i].getName() + "=" + st1_1.get(sds[i].getName())); } for (int i = 0; i < sds.length; i++) { - log.convertToLogWriter().info("testWriteAfterSamplingBegins#st1_2#" - + sds[i].getName() + "=" + st1_2.get(sds[i].getName())); + logger.info("testWriteAfterSamplingBegins#st1_2#" + sds[i].getName() + "=" + st1_2.get(sds[i].getName())); } sds = ST2.getStatistics(); for (int i = 0; i < sds.length; i++) { - log.convertToLogWriter().info("testWriteAfterSamplingBegins#st2_1#" - + sds[i].getName() + "=" + st2_1.get(sds[i].getName())); + logger.info("testWriteAfterSamplingBegins#st2_1#" + sds[i].getName() + "=" + st2_1.get(sds[i].getName())); } sds = ST3.getStatistics(); for (int i = 0; i < sds.length; i++) { - log.convertToLogWriter().info("testWriteAfterSamplingBegins#st3_1#" - + sds[i].getName() + "=" + st3_1.get(sds[i].getName())); + logger.info("testWriteAfterSamplingBegins#st3_1#" + sds[i].getName() + "=" + st3_1.get(sds[i].getName())); } for (int i = 0; i < sds.length; i++) { - log.convertToLogWriter().info("testWriteAfterSamplingBegins#st3_2#" - + sds[i].getName() + "=" + st3_2.get(sds[i].getName())); + logger.info("testWriteAfterSamplingBegins#st3_2#" + sds[i].getName() + "=" + st3_2.get(sds[i].getName())); } } // validate that stat archive file exists - final File actual = new File(archiveFileName); + final File actual = new File(this.archiveFileName); assertTrue(actual.exists()); // validate content of stat archive file using StatArchiveReader - final StatArchiveReader reader = new StatArchiveReader( - new File[]{actual}, null, false); + final StatArchiveReader reader = new StatArchiveReader(new File[]{actual}, null, false); // compare all resourceInst values against what was printed above - @SuppressWarnings("rawtypes") final List resources = reader.getResourceInstList(); - for (@SuppressWarnings("rawtypes") - final Iterator iter = resources.iterator(); iter.hasNext();) { + for (final Iterator iter = resources.iterator(); iter.hasNext();) { final StatArchiveReader.ResourceInst ri = (StatArchiveReader.ResourceInst) iter.next(); final String resourceName = ri.getName(); assertNotNull(resourceName); @@ -1052,7 +990,7 @@ public void testWriteAfterSamplingBegins() throws Exception { statValues[i].setFilter(StatValue.FILTER_NONE); final double[] rawSnapshots = statValues[i].getRawSnapshots(); //for (int j = 0; j < rawSnapshots.length; j++) { - // log.convertToLogWriter().info("DEBUG " + ri.getName() + " " + statName + " rawSnapshots[" + j + "] = " + rawSnapshots[j]); + // logger.info("DEBUG " + ri.getName() + " " + statName + " rawSnapshots[" + j + "] = " + rawSnapshots[j]); //} assertEquals("Value " + i + " for " + statName + " is wrong: " + expectedStatValues, expectedStatValues.get(statName).doubleValue(), @@ -1062,7 +1000,7 @@ public void testWriteAfterSamplingBegins() throws Exception { // validate byte content of stat archive file against saved expected file - final File expected = new File(TestUtil.getResourcePath(getClass(), "StatArchiveWriterReaderJUnitTest_" + testName + "_expected.gfs")); + final File expected = new File(TestUtil.getResourcePath(getClass(), "StatArchiveWriterReaderJUnitTest_" + this.testName.getMethodName() + "_expected.gfs")); assertTrue(expected + " does not exist!", expected.exists()); assertEquals(expected.length(), actual.length()); @@ -1073,32 +1011,27 @@ public void testWriteAfterSamplingBegins() throws Exception { /** * Tests the stat archive file written by StatArchiveWriter. */ - @SuppressWarnings("unused") @Test public void testWriteWhenSamplingBegins() throws Exception { - final String testName = "testWriteWhenSamplingBegins"; - final String archiveFileName = dir + File.separator + testName + ".gfs"; - - final InternalLogWriter log = new PureLogWriter(InternalLogWriter.CONFIG_LEVEL); final TestStatisticsManager manager = new TestStatisticsManager( - 1, - "StatArchiveWriterReaderJUnitTest_" + testName, - TestStatArchiveWriter.WRITER_INITIAL_DATE_MILLIS); + 1, + getUniqueName(), + WRITER_INITIAL_DATE_MILLIS); final TestStatisticsSampler sampler = new TestStatisticsSampler(manager); final SampleCollector sampleCollector = new SampleCollector(sampler); final StatArchiveDescriptor archiveDescriptor = new StatArchiveDescriptor.Builder() - .setArchiveName(archiveFileName) + .setArchiveName(this.archiveFileName) .setSystemId(1) - .setSystemStartTime(TestStatArchiveWriter.WRITER_INITIAL_DATE_MILLIS - 2000) - .setSystemDirectoryPath(testName) - .setProductDescription("StatArchiveWriterReaderJUnitTest") + .setSystemStartTime(WRITER_INITIAL_DATE_MILLIS - 2000) + .setSystemDirectoryPath(this.testName.getMethodName()) + .setProductDescription(getClass().getSimpleName()) .build(); - final StatArchiveWriter writer = new TestStatArchiveWriter(archiveDescriptor, log); + final StatArchiveWriter writer = new TestStatArchiveWriter(archiveDescriptor); sampleCollector.addSampleHandler(writer); - long sampleTimeNanos = TestStatArchiveWriter.WRITER_PREVIOUS_TIMESTAMP_NANOS + StatArchiveFormat.NANOS_PER_MILLI*1000; + long sampleTimeNanos = WRITER_PREVIOUS_TIMESTAMP_NANOS + NANOS_PER_MILLI*1000; // 1) create ST1 and st1_1 @@ -1139,7 +1072,7 @@ public void testWriteWhenSamplingBegins() throws Exception { incLong(st1_2, "long_counter_10", 3497536); incLong(st1_2, "long_gauge_11", 103909646); - sampleCollector.sample(sampleTimeNanos+=(1000*StatArchiveFormat.NANOS_PER_MILLI)); + sampleCollector.sample(sampleTimeNanos+=(1000*NANOS_PER_MILLI)); // 4) all new values @@ -1169,11 +1102,11 @@ public void testWriteWhenSamplingBegins() throws Exception { incLong(st1_2, "long_gauge_11", -4); incLong(st1_2, "long_gauge_12", 1098764); - sampleCollector.sample(sampleTimeNanos+=(1000*StatArchiveFormat.NANOS_PER_MILLI)); + sampleCollector.sample(sampleTimeNanos+=(1000*NANOS_PER_MILLI)); // 5) no new values - sampleCollector.sample(sampleTimeNanos+=(1000*StatArchiveFormat.NANOS_PER_MILLI)); + sampleCollector.sample(sampleTimeNanos+=(1000*NANOS_PER_MILLI)); // 6) some new values @@ -1191,7 +1124,7 @@ public void testWriteWhenSamplingBegins() throws Exception { incLong(st1_2, "long_counter_9", 8); incLong(st1_2, "long_gauge_12", 10); - sampleCollector.sample(sampleTimeNanos+=(1000*StatArchiveFormat.NANOS_PER_MILLI)); + sampleCollector.sample(sampleTimeNanos+=(1000*NANOS_PER_MILLI)); // 7) all new values @@ -1221,7 +1154,7 @@ public void testWriteWhenSamplingBegins() throws Exception { incLong(st1_2, "long_gauge_11", 3); incLong(st1_2, "long_gauge_12", -2); - sampleCollector.sample(sampleTimeNanos+=(1000*StatArchiveFormat.NANOS_PER_MILLI)); + sampleCollector.sample(sampleTimeNanos+=(1000*NANOS_PER_MILLI)); // 8) create ST2 and ST3 and st2_1 and st3_1 and st3_2 @@ -1297,7 +1230,7 @@ public void testWriteWhenSamplingBegins() throws Exception { incInt(st3_2, "int_counter_5", 1); incInt(st3_2, "int_counter_6", 4); - sampleCollector.sample(sampleTimeNanos+=(1000*StatArchiveFormat.NANOS_PER_MILLI)); + sampleCollector.sample(sampleTimeNanos+=(1000*NANOS_PER_MILLI)); // 10) some new values @@ -1327,7 +1260,7 @@ public void testWriteWhenSamplingBegins() throws Exception { incDouble(st3_2, "double_gauge_4", 36310.012); incInt(st3_2, "int_counter_6", 4); - sampleCollector.sample(sampleTimeNanos+=(1000*StatArchiveFormat.NANOS_PER_MILLI)); + sampleCollector.sample(sampleTimeNanos+=(1000*NANOS_PER_MILLI)); // 11) remove ST2 and st2_1 @@ -1357,11 +1290,11 @@ public void testWriteWhenSamplingBegins() throws Exception { incInt(st3_2, "int_counter_5", 3); incInt(st3_2, "int_counter_6", 1); - sampleCollector.sample(sampleTimeNanos+=(1000*StatArchiveFormat.NANOS_PER_MILLI)); + sampleCollector.sample(sampleTimeNanos+=(1000*NANOS_PER_MILLI)); // 13) no new values - sampleCollector.sample(sampleTimeNanos+=(1000*StatArchiveFormat.NANOS_PER_MILLI)); + sampleCollector.sample(sampleTimeNanos+=(1000*NANOS_PER_MILLI)); // 14) remove st1_2 @@ -1396,7 +1329,7 @@ public void testWriteWhenSamplingBegins() throws Exception { incInt(st3_2, "int_counter_5", 9); incInt(st3_2, "int_counter_6", 5); - sampleCollector.sample(sampleTimeNanos+=(1000*StatArchiveFormat.NANOS_PER_MILLI)); + sampleCollector.sample(sampleTimeNanos+=(1000*NANOS_PER_MILLI)); // close the writer @@ -1408,47 +1341,39 @@ public void testWriteWhenSamplingBegins() throws Exception { StatisticDescriptor[] sds = ST1.getStatistics(); for (int i = 0; i < sds.length; i++) { - log.convertToLogWriter().info("testWriteAfterSamplingBegins#st1_1#" - + sds[i].getName() + "=" + st1_1.get(sds[i].getName())); + logger.info("testWriteAfterSamplingBegins#st1_1#" + sds[i].getName() + "=" + st1_1.get(sds[i].getName())); } for (int i = 0; i < sds.length; i++) { - log.convertToLogWriter().info("testWriteAfterSamplingBegins#st1_2#" - + sds[i].getName() + "=" + st1_2.get(sds[i].getName())); + logger.info("testWriteAfterSamplingBegins#st1_2#" + sds[i].getName() + "=" + st1_2.get(sds[i].getName())); } sds = ST2.getStatistics(); for (int i = 0; i < sds.length; i++) { - log.convertToLogWriter().info("testWriteAfterSamplingBegins#st2_1#" - + sds[i].getName() + "=" + st2_1.get(sds[i].getName())); + logger.info("testWriteAfterSamplingBegins#st2_1#" + sds[i].getName() + "=" + st2_1.get(sds[i].getName())); } sds = ST3.getStatistics(); for (int i = 0; i < sds.length; i++) { - log.convertToLogWriter().info("testWriteAfterSamplingBegins#st3_1#" - + sds[i].getName() + "=" + st3_1.get(sds[i].getName())); + logger.info("testWriteAfterSamplingBegins#st3_1#" + sds[i].getName() + "=" + st3_1.get(sds[i].getName())); } for (int i = 0; i < sds.length; i++) { - log.convertToLogWriter().info("testWriteAfterSamplingBegins#st3_2#" - + sds[i].getName() + "=" + st3_2.get(sds[i].getName())); + logger.info("testWriteAfterSamplingBegins#st3_2#" + sds[i].getName() + "=" + st3_2.get(sds[i].getName())); } } // validate that stat archive file exists - final File actual = new File(archiveFileName); + final File actual = new File(this.archiveFileName); assertTrue(actual.exists()); // validate content of stat archive file using StatArchiveReader - final StatArchiveReader reader = new StatArchiveReader( - new File[]{actual}, null, false); + final StatArchiveReader reader = new StatArchiveReader(new File[]{actual}, null, false); // compare all resourceInst values against what was printed above - @SuppressWarnings("rawtypes") final List resources = reader.getResourceInstList(); - for (@SuppressWarnings("rawtypes") - final Iterator iter = resources.iterator(); iter.hasNext();) { + for (final Iterator iter = resources.iterator(); iter.hasNext();) { final StatArchiveReader.ResourceInst ri = (StatArchiveReader.ResourceInst) iter.next(); final String resourceName = ri.getName(); assertNotNull(resourceName); @@ -1471,7 +1396,7 @@ public void testWriteWhenSamplingBegins() throws Exception { statValues[i].setFilter(StatValue.FILTER_NONE); final double[] rawSnapshots = statValues[i].getRawSnapshots(); //for (int j = 0; j < rawSnapshots.length; j++) { - // log.convertToLogWriter().info("DEBUG " + ri.getName() + " " + statName + " rawSnapshots[" + j + "] = " + rawSnapshots[j]); + // logger.info("DEBUG " + ri.getName() + " " + statName + " rawSnapshots[" + j + "] = " + rawSnapshots[j]); //} assertEquals("Value " + i + " for " + statName + " is wrong: " + expectedStatValues, expectedStatValues.get(statName).doubleValue(), @@ -1481,7 +1406,7 @@ public void testWriteWhenSamplingBegins() throws Exception { // validate byte content of stat archive file against saved expected file - final File expected = new File(TestUtil.getResourcePath(getClass(), "StatArchiveWriterReaderJUnitTest_" + testName + "_expected.gfs")); + final File expected = new File(TestUtil.getResourcePath(getClass(), "StatArchiveWriterReaderJUnitTest_" + this.testName.getMethodName() + "_expected.gfs")); assertTrue(expected + " does not exist!", expected.exists()); assertEquals(expected.length(), actual.length()); @@ -1495,25 +1420,19 @@ public void testWriteWhenSamplingBegins() throws Exception { */ @Test public void testNegativeSampleTimeStamp() throws Exception { - final String testName = "testNegativeSampleTimeStamp"; - final String archiveFileName = dir + File.separator + testName + ".gfs"; - - final LogWriterI18n log = new PureLogWriter(InternalLogWriter.CONFIG_LEVEL); - final StatArchiveDescriptor archiveDescriptor = new StatArchiveDescriptor.Builder() - .setArchiveName(archiveFileName) + .setArchiveName(this.archiveFileName) .setSystemId(1) - .setSystemStartTime(TestStatArchiveWriter.WRITER_INITIAL_DATE_MILLIS) - .setSystemDirectoryPath(testName) - .setProductDescription("StatArchiveWriterReaderJUnitTest") + .setSystemStartTime(WRITER_INITIAL_DATE_MILLIS) + .setSystemDirectoryPath(this.testName.getMethodName()) + .setProductDescription(getClass().getSimpleName()) .build(); - final StatArchiveWriter writer = new TestStatArchiveWriter(archiveDescriptor, log); + final StatArchiveWriter writer = new TestStatArchiveWriter(archiveDescriptor); - final long sampleIncNanos = StatArchiveFormat.NANOS_PER_MILLI*1000; + final long sampleIncNanos = NANOS_PER_MILLI*1000; try { - writer.sampled(TestStatArchiveWriter.WRITER_PREVIOUS_TIMESTAMP_NANOS - sampleIncNanos, - Collections.emptyList()); + writer.sampled(WRITER_PREVIOUS_TIMESTAMP_NANOS - sampleIncNanos, Collections.emptyList()); fail("Expected IllegalArgumentException to be thrown from StatArchiveWriter#writeTimeStamp(long)"); } catch (IllegalArgumentException expected) { // test passed @@ -1528,23 +1447,17 @@ public void testNegativeSampleTimeStamp() throws Exception { */ @Test public void testPreviousSampleTimeStamp() throws Exception { - final String testName = "testPreviousSampleTimeStamp"; - final String archiveFileName = dir + File.separator + testName + ".gfs"; - - final LogWriterI18n log = new PureLogWriter(InternalLogWriter.CONFIG_LEVEL); - final StatArchiveDescriptor archiveDescriptor = new StatArchiveDescriptor.Builder() - .setArchiveName(archiveFileName) + .setArchiveName(this.archiveFileName) .setSystemId(1) - .setSystemStartTime(TestStatArchiveWriter.WRITER_INITIAL_DATE_MILLIS) - .setSystemDirectoryPath(testName) - .setProductDescription("StatArchiveWriterReaderJUnitTest") + .setSystemStartTime(WRITER_INITIAL_DATE_MILLIS) + .setSystemDirectoryPath(this.testName.getMethodName()) + .setProductDescription(getClass().getSimpleName()) .build(); - final StatArchiveWriter writer = new TestStatArchiveWriter(archiveDescriptor, log); + final StatArchiveWriter writer = new TestStatArchiveWriter(archiveDescriptor); try { - writer.sampled(TestStatArchiveWriter.WRITER_PREVIOUS_TIMESTAMP_NANOS, - Collections.emptyList()); + writer.sampled(WRITER_PREVIOUS_TIMESTAMP_NANOS, Collections.emptyList()); fail("Expected IllegalArgumentException to be thrown from StatArchiveWriter#writeTimeStamp(long)"); } catch (IllegalArgumentException expected) { // test passed @@ -1560,18 +1473,14 @@ public void testPreviousSampleTimeStamp() throws Exception { */ @Test public void testDestroyClosedStatistics() throws Exception { - final String testName = "testDestroyClosedStatistics"; - final String archiveFileName = dir + File.separator + testName + ".gfs"; - - final LogWriterI18n log = new PureLogWriter(InternalLogWriter.CONFIG_LEVEL); final StatArchiveDescriptor archiveDescriptor = new StatArchiveDescriptor.Builder() - .setArchiveName(archiveFileName) + .setArchiveName(this.archiveFileName) .setSystemId(1) - .setSystemStartTime(TestStatArchiveWriter.WRITER_INITIAL_DATE_MILLIS - 2000) - .setSystemDirectoryPath(testName) - .setProductDescription("StatArchiveWriterReaderJUnitTest") + .setSystemStartTime(WRITER_INITIAL_DATE_MILLIS - 2000) + .setSystemDirectoryPath(this.testName.getMethodName()) + .setProductDescription(getClass().getSimpleName()) .build(); - final StatArchiveWriter writer = new TestStatArchiveWriter(archiveDescriptor, log); + final StatArchiveWriter writer = new TestStatArchiveWriter(archiveDescriptor); final StatisticsType statsType = createDummyStatisticsType(); final ResourceType rt = new ResourceType(0, statsType); @@ -1588,33 +1497,27 @@ public void testDestroyClosedStatistics() throws Exception { */ @Test public void testDestroyUnallocatedStatistics() throws Exception { - final String testName = "testDestroyUnallocatedStatistics"; - final String archiveFileName = dir + File.separator + testName + ".gfs"; - - final LogWriterI18n log = new PureLogWriter(InternalLogWriter.CONFIG_LEVEL); final StatArchiveDescriptor archiveDescriptor = new StatArchiveDescriptor.Builder() - .setArchiveName(archiveFileName) + .setArchiveName(this.archiveFileName) .setSystemId(1) - .setSystemStartTime(TestStatArchiveWriter.WRITER_INITIAL_DATE_MILLIS - 2000) - .setSystemDirectoryPath(testName) - .setProductDescription("StatArchiveWriterReaderJUnitTest") + .setSystemStartTime(WRITER_INITIAL_DATE_MILLIS - 2000) + .setSystemDirectoryPath(this.testName.getMethodName()) + .setProductDescription(getClass().getSimpleName()) .build(); - final StatArchiveWriter writer = new TestStatArchiveWriter(archiveDescriptor, log); + final StatArchiveWriter writer = new TestStatArchiveWriter(archiveDescriptor); final StatisticsType statsType = createDummyStatisticsType(); final ResourceType rt = new ResourceType(0, statsType); final Statistics statistics = mock(Statistics.class); final ResourceInstance ri = new ResourceInstance(0, statistics, rt); - writer.sampled(TestStatArchiveWriter.WRITER_INITIAL_DATE_MILLIS + 1000, - Collections.singletonList(ri)); + writer.sampled(WRITER_INITIAL_DATE_MILLIS + 1000, Collections.singletonList(ri)); writer.destroyedResourceInstance(ri); writer.close(); - // Verify StatArchiveRader.update returns cleanly, without throwing an exception - final StatArchiveReader reader = new StatArchiveReader( - new File[]{new File(archiveFileName)}, null, false); + // Verify StatArchiveReader.update returns cleanly, without throwing an exception + final StatArchiveReader reader = new StatArchiveReader(new File[]{new File(this.archiveFileName)}, null, false); reader.update(); reader.close(); } @@ -1666,7 +1569,6 @@ private byte[] readBytes(File file) throws MalformedURLException, IOException { byte[] input = new byte[byteCount]; - @SuppressWarnings("deprecation") URL url = file.toURL(); assertNotNull(url); @@ -1680,7 +1582,11 @@ private byte[] readBytes(File file) throws MalformedURLException, IOException { assertEquals(byteCount, bytesRead); return input; } - + + private String getUniqueName() { + return getClass().getSimpleName() + "_" + this.testName.getMethodName(); + } + private static StatisticsType createDummyStatisticsType() { return new StatisticsType() { @@ -1714,7 +1620,7 @@ public StatisticDescriptor nameToDescriptor(String name) { /* [KEEP] alternative method for getting an expected golden file: Class clazz = getClass(); assertNotNull(clazz); - URL url = clazz.getResource("StatArchiveWriterReaderJUnitTest.gfs.expected"); + URL url = clazz.getResource("StatArchiveWriterReaderIntegrationTest.gfs.expected"); assertNotNull(url); File expected; diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/StatMonitorHandlerJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/StatMonitorHandlerTest.java similarity index 98% rename from geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/StatMonitorHandlerJUnitTest.java rename to geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/StatMonitorHandlerTest.java index bcb7497d4c02..135b3d05405f 100755 --- a/geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/StatMonitorHandlerJUnitTest.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/StatMonitorHandlerTest.java @@ -23,7 +23,6 @@ import java.util.Collections; import java.util.List; -import org.junit.Before; import org.junit.Test; import org.junit.experimental.categories.Category; @@ -33,12 +32,12 @@ import com.gemstone.gemfire.test.junit.categories.UnitTest; /** - * Unit tests for the StatMonitorHandler and its inner classes. + * Unit tests for {@link StatMonitorHandler}. * * @since GemFire 7.0 */ @Category(UnitTest.class) -public class StatMonitorHandlerJUnitTest { +public class StatMonitorHandlerTest { @Test public void testAddNewMonitor() throws Exception { diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/StatSamplerJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/StatSamplerIntegrationTest.java similarity index 88% rename from geode-core/src/test/java/com/gemstone/gemfire/internal/StatSamplerJUnitTest.java rename to geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/StatSamplerIntegrationTest.java index e16eeafa72e0..1742b69772b7 100755 --- a/geode-core/src/test/java/com/gemstone/gemfire/internal/StatSamplerJUnitTest.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/StatSamplerIntegrationTest.java @@ -14,8 +14,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.gemstone.gemfire.internal; +package com.gemstone.gemfire.internal.statistics; +import static com.jayway.awaitility.Awaitility.*; +import static java.util.concurrent.TimeUnit.*; import static org.junit.Assert.*; import java.io.File; @@ -38,16 +40,17 @@ import com.gemstone.gemfire.StatisticDescriptor; import com.gemstone.gemfire.Statistics; import com.gemstone.gemfire.StatisticsType; -import com.gemstone.gemfire.internal.StatArchiveReader.StatValue; import com.gemstone.gemfire.internal.logging.LogService; -import com.gemstone.gemfire.internal.util.StopWatch; +import com.gemstone.gemfire.internal.statistics.StatArchiveReader.StatValue; import com.gemstone.gemfire.test.junit.categories.IntegrationTest; /** + * Integration tests for statistics sampling. + * * @since GemFire 7.0 */ @Category(IntegrationTest.class) -public class StatSamplerJUnitTest { +public class StatSamplerIntegrationTest { private static final Logger logger = LogService.getLogger(); @@ -118,9 +121,9 @@ public RuntimeException generateCancelledException(Throwable e) { factory.createLongCounter( "long_counter_10", "d10", "u10", true), factory.createLongGauge( "long_gauge_11", "d11", "u11"), factory.createLongGauge( "long_gauge_12", "d12", "u12", false), - factory.createLongGauge( "sampled_long", "d13", "u13", false), - factory.createIntGauge( "sampled_int", "d14", "u14", false), - factory.createDoubleGauge( "sampled_double", "d15", "u15", false) + factory.createLongGauge( "sampled_long", "d13", "u13", false), + factory.createIntGauge( "sampled_int", "d14", "u14", false), + factory.createDoubleGauge( "sampled_double", "d15", "u15", false) }; final StatisticsType ST1 = factory.createType("ST1", "ST1", statsST1); final Statistics st1_1 = factory.createAtomicStatistics(ST1, "st1_1", 1); @@ -131,17 +134,9 @@ public RuntimeException generateCancelledException(Throwable e) { st1_1.setDoubleSupplier("sampled_double", () -> 7.0); getOrCreateExpectedValueMap(st1_1).put("sampled_double", 7.0); - boolean done = false; + await("awaiting StatSampler readiness").atMost(30, SECONDS).until(() -> hasSamplerStatsInstances(factory)); Statistics[] samplerStatsInstances = factory.findStatisticsByTextId("statSampler"); - for (StopWatch time = new StopWatch(true); !done && time.elapsedTimeMillis() < 4000; done = (samplerStatsInstances != null && samplerStatsInstances.length > 0)) { - Thread.sleep(10); - samplerStatsInstances = factory.findStatisticsByTextId("statSampler"); - } - - assertTrue("Waiting for statSampler stats", done); - - samplerStatsInstances = factory.findStatisticsByTextId("statSampler"); assertNotNull(samplerStatsInstances); assertEquals(1, samplerStatsInstances.length); final Statistics samplerStats = samplerStatsInstances[0]; @@ -153,7 +148,7 @@ public RuntimeException generateCancelledException(Throwable e) { incLong(st1_1, "long_counter_9", 9); incLong(st1_1, "long_gauge_11", 11); - waitForStatSample(samplerStats); + awaitStatSample(samplerStats); incDouble(st1_1, "double_counter_1", 1); incDouble(st1_1, "double_counter_2", 1); @@ -162,7 +157,7 @@ public RuntimeException generateCancelledException(Throwable e) { incInt(st1_1, "int_counter_5", 1); incInt(st1_1, "int_counter_6", 1); - waitForStatSample(samplerStats); + awaitStatSample(samplerStats); incDouble(st1_1, "double_counter_1", 1); incDouble(st1_1, "double_counter_2", 1); @@ -177,7 +172,7 @@ public RuntimeException generateCancelledException(Throwable e) { incLong(st1_1, "long_gauge_11", 1); incLong(st1_1, "long_gauge_12", 1); - waitForStatSample(samplerStats); + awaitStatSample(samplerStats); incDouble(st1_1, "double_counter_1", 1); incDouble(st1_1, "double_counter_2", 1); @@ -192,7 +187,7 @@ public RuntimeException generateCancelledException(Throwable e) { incLong(st1_1, "long_gauge_11", -1); incLong(st1_1, "long_gauge_12", 1); - waitForStatSample(samplerStats); + awaitStatSample(samplerStats); incDouble(st1_1, "double_counter_1", 1); incDouble(st1_1, "double_counter_2", 1); @@ -207,9 +202,9 @@ public RuntimeException generateCancelledException(Throwable e) { incLong(st1_1, "long_gauge_11", 1); incLong(st1_1, "long_gauge_12", 1); - waitForStatSample(samplerStats); - waitForStatSample(samplerStats); - waitForStatSample(samplerStats); + awaitStatSample(samplerStats); + awaitStatSample(samplerStats); + awaitStatSample(samplerStats); incDouble(st1_1, "double_counter_1", 1); incDouble(st1_1, "double_gauge_3", 3); @@ -218,7 +213,7 @@ public RuntimeException generateCancelledException(Throwable e) { incLong(st1_1, "long_counter_9", 9); incLong(st1_1, "long_gauge_11", 11); - waitForStatSample(samplerStats); + awaitStatSample(samplerStats); incDouble(st1_1, "double_counter_1", 1); incDouble(st1_1, "double_counter_2", 1); @@ -227,7 +222,7 @@ public RuntimeException generateCancelledException(Throwable e) { incInt(st1_1, "int_counter_5", 1); incInt(st1_1, "int_counter_6", 1); - waitForStatSample(samplerStats); + awaitStatSample(samplerStats); incDouble(st1_1, "double_counter_1", 1); incDouble(st1_1, "double_counter_2", 1); @@ -242,7 +237,7 @@ public RuntimeException generateCancelledException(Throwable e) { incLong(st1_1, "long_gauge_11", 1); incLong(st1_1, "long_gauge_12", 1); - waitForStatSample(samplerStats); + awaitStatSample(samplerStats); incDouble(st1_1, "double_counter_1", 1); incDouble(st1_1, "double_counter_2", 1); @@ -257,7 +252,7 @@ public RuntimeException generateCancelledException(Throwable e) { incLong(st1_1, "long_gauge_11", -1); incLong(st1_1, "long_gauge_12", 1); - waitForStatSample(samplerStats); + awaitStatSample(samplerStats); incDouble(st1_1, "double_counter_1", 1); incDouble(st1_1, "double_counter_2", 1); @@ -272,7 +267,7 @@ public RuntimeException generateCancelledException(Throwable e) { incLong(st1_1, "long_gauge_11", 1); incLong(st1_1, "long_gauge_12", 1); - waitForStatSample(samplerStats); + awaitStatSample(samplerStats); factory.close(); @@ -316,14 +311,15 @@ public RuntimeException generateCancelledException(Throwable e) { } } } + + private boolean hasSamplerStatsInstances(final LocalStatisticsFactory factory) { + Statistics[] samplerStatsInstances = factory.findStatisticsByTextId("statSampler"); + return samplerStatsInstances != null && samplerStatsInstances.length > 0; + } - private void waitForStatSample(final Statistics samplerStats) throws InterruptedException { + private void awaitStatSample(final Statistics samplerStats) throws InterruptedException { int startSampleCount = samplerStats.getInt("sampleCount"); - boolean done = false; - for (StopWatch time = new StopWatch(true); !done && time.elapsedTimeMillis() < 3000; done = (samplerStats.getInt("sampleCount") > startSampleCount)) { - Thread.sleep(10); - } - assertTrue("Waiting for statSampler sampleCount to increment", done); + await("awaiting stat sample").atMost(30, SECONDS).until(() -> samplerStats.getInt("sampleCount") > startSampleCount); } private void incDouble(Statistics statistics, String stat, double value) { diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/StatSamplerTestCase.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/StatSamplerTestCase.java similarity index 99% rename from geode-core/src/test/java/com/gemstone/gemfire/internal/StatSamplerTestCase.java rename to geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/StatSamplerTestCase.java index 819a79c63422..9b43dde74c01 100755 --- a/geode-core/src/test/java/com/gemstone/gemfire/internal/StatSamplerTestCase.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/StatSamplerTestCase.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.gemstone.gemfire.internal; +package com.gemstone.gemfire.internal.statistics; import static org.junit.Assert.*; @@ -38,6 +38,7 @@ * @since GemFire 7.0 */ public abstract class StatSamplerTestCase { + protected static final Logger logger = LogService.getLogger(); protected abstract StatisticsManager getStatisticsManager(); diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/StatisticsDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/StatisticsDUnitTest.java deleted file mode 100755 index 1e7a4e4b1f9b..000000000000 --- a/geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/StatisticsDUnitTest.java +++ /dev/null @@ -1,947 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.gemstone.gemfire.internal.statistics; - -import static com.gemstone.gemfire.distributed.ConfigurationProperties.*; -import static org.junit.Assert.*; - -import java.io.File; -import java.io.FileFilter; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; -import java.util.Properties; -import java.util.Random; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.concurrent.atomic.AtomicReference; -import java.util.concurrent.atomic.AtomicReferenceArray; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.junit.Test; -import org.junit.experimental.categories.Category; - -import com.gemstone.gemfire.StatisticDescriptor; -import com.gemstone.gemfire.Statistics; -import com.gemstone.gemfire.StatisticsFactory; -import com.gemstone.gemfire.StatisticsType; -import com.gemstone.gemfire.StatisticsTypeFactory; -import com.gemstone.gemfire.cache.Cache; -import com.gemstone.gemfire.cache.CacheException; -import com.gemstone.gemfire.cache.CacheListener; -import com.gemstone.gemfire.cache.EntryEvent; -import com.gemstone.gemfire.cache.Region; -import com.gemstone.gemfire.cache.RegionEvent; -import com.gemstone.gemfire.cache.RegionFactory; -import com.gemstone.gemfire.cache.Scope; -import com.gemstone.gemfire.cache.util.CacheListenerAdapter; -import com.gemstone.gemfire.cache.util.RegionMembershipListenerAdapter; -import com.gemstone.gemfire.cache30.CacheSerializableRunnable; -import com.gemstone.gemfire.distributed.DistributedMember; -import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem; -import com.gemstone.gemfire.distributed.internal.membership.InternalDistributedMember; -import com.gemstone.gemfire.internal.GemFireStatSampler; -import com.gemstone.gemfire.internal.NanoTimer; -import com.gemstone.gemfire.internal.StatArchiveReader; -import com.gemstone.gemfire.internal.StatArchiveReader.StatSpec; -import com.gemstone.gemfire.internal.StatArchiveReader.StatValue; -import com.gemstone.gemfire.internal.StatSamplerStats; -import com.gemstone.gemfire.internal.StatisticsTypeFactoryImpl; -import com.gemstone.gemfire.test.dunit.Assert; -import com.gemstone.gemfire.test.dunit.AsyncInvocation; -import com.gemstone.gemfire.test.dunit.Host; -import com.gemstone.gemfire.test.dunit.Invoke; -import com.gemstone.gemfire.test.dunit.SerializableCallable; -import com.gemstone.gemfire.test.dunit.VM; -import com.gemstone.gemfire.test.dunit.Wait; -import com.gemstone.gemfire.test.dunit.WaitCriterion; -import com.gemstone.gemfire.test.dunit.cache.internal.JUnit4CacheTestCase; -import com.gemstone.gemfire.test.junit.categories.DistributedTest; - -/** - * Integration tests for Statistics. VM0 performs puts and VM1 receives - * updates. Both use custom statistics for start/end with increment to - * add up puts and updates. Then validation tests values in stat resource - * instances and uses StatArchiveReader. Both are tested against static - * counters in both VMs. - *

- * This test mimics hydratest/locators/cacheDS.conf in an attempt to reproduce - * bug #45478. So far this test passes consistently. - * - * @since GemFire 7.0 - */ -@SuppressWarnings("serial") -@Category(DistributedTest.class) -public class StatisticsDUnitTest extends JUnit4CacheTestCase { - - private static final String dir = "StatisticsDUnitTest"; - - private static final int MAX_PUTS = 1000; - private static final int NUM_KEYS = 100; - private static final int NUM_PUB_THREADS = 2; - private static final int NUM_PUBS = 2; - private static final boolean RANDOMIZE_PUTS = true; - - private static AtomicInteger updateEvents = new AtomicInteger(); - - private static AtomicInteger puts = new AtomicInteger(); - - private static AtomicReference subStatsRef = new AtomicReference(); - - private static AtomicReferenceArray pubStatsRef = new AtomicReferenceArray(NUM_PUB_THREADS); - - /** Thread-safe static reference to RegionMembershipListener instance */ - private static AtomicReference rmlRef = - new AtomicReference(); - - @SuppressWarnings("unused") /** invoked by reflection */ - private static void cleanup() { - updateEvents.set(0); - rmlRef.set(null); - } - - @SuppressWarnings("unused") /** invoked by reflection */ - private static int getUpdateEvents() { - return updateEvents.get(); - } - - @SuppressWarnings("unused") /** invoked by reflection */ - private static int getPuts() { - return puts.get(); - } - - public StatisticsDUnitTest() { - super(); - } - - @Override - public final void preTearDownCacheTestCase() throws Exception { - Invoke.invokeInEveryVM(getClass(), "cleanup"); - disconnectAllFromDS(); // because this test enabled stat sampling! - } - - @Test - public void testPubAndSubCustomStats() throws Exception { - final String testName = "testPubAndSubCustomStats"; - - final String regionName = "region_" + testName; - final VM[] pubs = new VM[NUM_PUBS]; - for (int pubVM = 0; pubVM < NUM_PUBS; pubVM++) { - pubs[pubVM] = Host.getHost(0).getVM(pubVM); - } - final VM sub = Host.getHost(0).getVM(NUM_PUBS); - - final String subArchive = dir + File.separator + testName + "_sub" + ".gfs"; - final String[] pubArchives = new String[NUM_PUBS]; - for (int pubVM = 0; pubVM < NUM_PUBS; pubVM++) { - pubArchives[pubVM] = dir + File.separator + testName + "_pub-" + pubVM + ".gfs"; - } - - for (int i = 0; i < NUM_PUBS; i++) { - final int pubVM = i; - pubs[pubVM].invoke(new CacheSerializableRunnable("pub-connect-and-create-data-" + pubVM) { - public void run2() throws CacheException { - new File(dir).mkdir(); - final Properties props = new Properties(); - props.setProperty(STATISTIC_SAMPLING_ENABLED, "true"); - props.setProperty(STATISTIC_SAMPLE_RATE, "1000"); - props.setProperty(STATISTIC_ARCHIVE_FILE, pubArchives[pubVM]); - final InternalDistributedSystem system = getSystem(props); - - // assert that sampler is working as expected - final GemFireStatSampler sampler = system.getStatSampler(); - assertTrue(sampler.isSamplingEnabled()); - assertTrue(sampler.isAlive()); - assertEquals(new File(pubArchives[pubVM]), sampler.getArchiveFileName()); - - final WaitCriterion waitForSampleCollector = new WaitCriterion() { - public boolean done() { - return sampler.getSampleCollector() != null; - } - public String description() { - return "sampler.getSampleCollector() is still null!"; - } - }; - Wait.waitForCriterion(waitForSampleCollector, 4*1000, 10, true); - - final SampleCollector sampleCollector = sampler.getSampleCollector(); - assertNotNull(sampleCollector); - - final StatArchiveHandler archiveHandler = sampleCollector.getStatArchiveHandler(); - assertNotNull(archiveHandler); - assertTrue(archiveHandler.isArchiving()); - - // create cache and region - final Cache cache = getCache(); - final RegionFactory factory = cache.createRegionFactory(); - factory.setScope(Scope.DISTRIBUTED_ACK); - - final RegionMembershipListener rml = new RegionMembershipListener(); - rmlRef.set(rml); - factory.addCacheListener(rml); - final Region region = factory.create(regionName); - - // create the keys - if (region.getAttributes().getScope() == Scope.DISTRIBUTED_ACK) { - for (int key = 0; key < NUM_KEYS; key++) { - region.create("KEY-"+key, null); - } - } - } - }); - } - - final DistributedMember subMember = (DistributedMember) - sub.invoke(new SerializableCallable("sub-connect-and-create-keys") { - @Override - public Object call() throws Exception { - new File(dir).mkdir(); - final Properties props = new Properties(); - props.setProperty(STATISTIC_SAMPLING_ENABLED, "true"); - props.setProperty(STATISTIC_SAMPLE_RATE, "1000"); - props.setProperty(STATISTIC_ARCHIVE_FILE, subArchive); - final InternalDistributedSystem system = getSystem(props); - - final PubSubStats statistics = new PubSubStats(system, "sub-1", 1); - subStatsRef.set(statistics); - - // assert that sampler is working as expected - final GemFireStatSampler sampler = system.getStatSampler(); - assertTrue(sampler.isSamplingEnabled()); - assertTrue(sampler.isAlive()); - assertEquals(new File(subArchive), sampler.getArchiveFileName()); - - final WaitCriterion waitForSampleCollector = new WaitCriterion() { - public boolean done() { - return sampler.getSampleCollector() != null; - } - public String description() { - return "sampler.getSampleCollector() is still null!"; - } - }; - Wait.waitForCriterion(waitForSampleCollector, 2*1000, 10, true); - - final SampleCollector sampleCollector = sampler.getSampleCollector(); - assertNotNull(sampleCollector); - - final StatArchiveHandler archiveHandler = sampleCollector.getStatArchiveHandler(); - assertNotNull(archiveHandler); - assertTrue(archiveHandler.isArchiving()); - - // create cache and region with UpdateListener - final Cache cache = getCache(); - final RegionFactory factory = cache.createRegionFactory(); - factory.setScope(Scope.DISTRIBUTED_ACK); - - final CacheListener cl = new UpdateListener(statistics); - factory.addCacheListener(cl); - final Region region = factory.create(regionName); - - // create the keys - if (region.getAttributes().getScope() == Scope.DISTRIBUTED_ACK) { - for (int key = 0; key < NUM_KEYS; key++) { - region.create("KEY-"+key, null); - } - } - - assertEquals(0, statistics.getUpdateEvents()); - return system.getDistributedMember(); - } - }); - - for (int i = 0; i < NUM_PUBS; i++) { - final int pubVM = i; - AsyncInvocation[] publishers = new AsyncInvocation[NUM_PUB_THREADS]; - for (int j = 0; j < NUM_PUB_THREADS; j++) { - final int pubThread = j; - publishers[pubThread] = pubs[pubVM].invokeAsync( - new CacheSerializableRunnable("pub-connect-and-put-data-" + pubVM + "-thread-" + pubThread) { - public void run2() throws CacheException { - final PubSubStats statistics = new PubSubStats(basicGetSystem(), "pub-" + pubThread, pubVM); - pubStatsRef.set(pubThread, statistics); - - final RegionMembershipListener rml = rmlRef.get(); - final Region region = getCache().getRegion(regionName); - - // assert that sub is in rml membership - assertNotNull(rml); - WaitCriterion wc = new WaitCriterion() { - public boolean done() { - return rml.contains(subMember) && rml.size() == NUM_PUBS; - } - public String description() { - return rml.members + " should contain " + subMember; - } - }; - Wait.waitForCriterion(wc, 4*1000, 10, true); - - // publish lots of puts cycling through the NUM_KEYS - assertEquals(0, statistics.getPuts()); - - // cycle through the keys randomly - if (RANDOMIZE_PUTS) { - Random randomGenerator = new Random(); - int key = 0; - for (int i = 0; i < MAX_PUTS; i++) { - final long start = statistics.startPut(); - key = randomGenerator.nextInt(NUM_KEYS); - region.put("KEY-"+key, i); - statistics.endPut(start); - } - - // cycle through he keys in order and wrapping back around - } else { - int key = 0; - for (int i = 0; i < MAX_PUTS; i++) { - final long start = statistics.startPut(); - region.put("KEY-"+key, i); - key++; // cycle through the keys... - if (key >= NUM_KEYS) { - key = 0; - } - statistics.endPut(start); - } - } - assertEquals(MAX_PUTS, statistics.getPuts()); - - // wait for 2 samples to ensure all stats have been archived - final StatisticsType statSamplerType = getSystem().findType("StatSampler"); - final Statistics[] statsArray = getSystem().findStatisticsByType(statSamplerType); - assertEquals(1, statsArray.length); - - final Statistics statSamplerStats = statsArray[0]; - final int initialSampleCount = statSamplerStats.getInt(StatSamplerStats.SAMPLE_COUNT); - - wc = new WaitCriterion() { - public boolean done() { - return statSamplerStats.getInt(StatSamplerStats.SAMPLE_COUNT) >= initialSampleCount + 2; - } - public String description() { - return "Waiting for " + StatSamplerStats.SAMPLE_COUNT + " >= " + initialSampleCount + 2; - } - }; - Wait.waitForCriterion(wc, 4*1000, 10, true); - } - }); - } - for (int pubThread = 0; pubThread < publishers.length; pubThread++) { - publishers[pubThread].join(); - if (publishers[pubThread].exceptionOccurred()) { - Assert.fail("Test failed", publishers[pubThread].getException()); - } - } - } - - sub.invoke(new CacheSerializableRunnable("sub-wait-for-samples") { - public void run2() throws CacheException { - // wait for 2 samples to ensure all stats have been archived - final StatisticsType statSamplerType = getSystem().findType("StatSampler"); - final Statistics[] statsArray = getSystem().findStatisticsByType(statSamplerType); - assertEquals(1, statsArray.length); - - final Statistics statSamplerStats = statsArray[0]; - final int initialSampleCount = statSamplerStats.getInt(StatSamplerStats.SAMPLE_COUNT); - - final WaitCriterion wc = new WaitCriterion() { - public boolean done() { - return statSamplerStats.getInt(StatSamplerStats.SAMPLE_COUNT) >= initialSampleCount + 2; - } - public String description() { - return "Waiting for " + StatSamplerStats.SAMPLE_COUNT + " >= " + initialSampleCount + 2; - } - }; - Wait.waitForCriterion(wc, 4*1000, 10, true); - - // now post total updateEvents to static - final PubSubStats statistics = subStatsRef.get(); - assertNotNull(statistics); - updateEvents.set(statistics.getUpdateEvents()); - } - }); - - // validate pub values against sub values - final int totalUpdateEvents = sub.invoke(() -> getUpdateEvents()); - - // validate pub values against pub statistics against pub archive - for (int i = 0; i < NUM_PUBS; i++) { - final int pubIdx = i; - pubs[pubIdx].invoke(new CacheSerializableRunnable("pub-validation") { - @SuppressWarnings("unused") - public void run2() throws CacheException { - // add up all the puts - assertEquals(NUM_PUB_THREADS, pubStatsRef.length()); - int totalPuts = 0; - for (int pubThreadIdx = 0; pubThreadIdx < NUM_PUB_THREADS; pubThreadIdx++) { - PubSubStats statistics = pubStatsRef.get(pubThreadIdx); - assertNotNull(statistics); - totalPuts += statistics.getPuts(); - } - - // assert that total puts adds up to max puts times num threads - assertEquals(MAX_PUTS * NUM_PUB_THREADS, totalPuts); - - // assert that archive file contains same values as statistics - File archive = new File(pubArchives[pubIdx]); - assertTrue(archive.exists()); - - StatArchiveReader reader = null; - try { - reader = new StatArchiveReader(new File[]{archive}, null, false); - } catch (IOException e) { - fail("Failed to read " + archive); - } - - double combinedPuts = 0; - - @SuppressWarnings("rawtypes") - List resources = reader.getResourceInstList(); - assertNotNull(resources); - assertFalse(resources.isEmpty()); - - for (@SuppressWarnings("rawtypes") - Iterator iter = resources.iterator(); iter.hasNext();) { - StatArchiveReader.ResourceInst ri = (StatArchiveReader.ResourceInst) iter.next(); - if (!ri.getType().getName().equals(PubSubStats.TYPE_NAME)) { - continue; - } - - StatValue[] statValues = ri.getStatValues(); - for (int i = 0; i < statValues.length; i++) { - String statName = ri.getType().getStats()[i].getName(); - assertNotNull(statName); - - if (statName.equals(PubSubStats.PUTS)) { - StatValue sv = statValues[i]; - sv.setFilter(StatValue.FILTER_NONE); - - double mostRecent = sv.getSnapshotsMostRecent(); - double min = sv.getSnapshotsMinimum(); - double max = sv.getSnapshotsMaximum(); - double maxMinusMin = sv.getSnapshotsMaximum() - sv.getSnapshotsMinimum(); - double mean = sv.getSnapshotsAverage(); - double stdDev = sv.getSnapshotsStandardDeviation(); - - assertEquals(mostRecent, max, 0f); - - double summation = 0; - double[] rawSnapshots = sv.getRawSnapshots(); - for (int j = 0; j < rawSnapshots.length; j++) { - //log.convertToLogWriter().info("DEBUG " + ri.getName() + " " + statName + " rawSnapshots[" + j + "] = " + rawSnapshots[j]); - summation += rawSnapshots[j]; - } - assertEquals(mean, summation / sv.getSnapshotsSize(), 0); - - combinedPuts += mostRecent; - } - } - } - - // assert that sum of mostRecent values for all puts equals totalPuts - assertEquals((double)totalPuts, combinedPuts, 0); - puts.getAndAdd(totalPuts); - } - }); - } - - // validate pub values against sub values - int totalCombinedPuts = 0; - for (int i = 0; i < NUM_PUBS; i++) { - final int pubIdx = i; - final int totalPuts = pubs[pubIdx].invoke(() -> getPuts()); - assertEquals(MAX_PUTS * NUM_PUB_THREADS, totalPuts); - totalCombinedPuts += totalPuts; - } - assertEquals(totalCombinedPuts, totalUpdateEvents); - assertEquals(MAX_PUTS * NUM_PUB_THREADS * NUM_PUBS, totalCombinedPuts); - - // validate sub values against sub statistics against sub archive - final int totalPuts = totalCombinedPuts; - sub.invoke(new CacheSerializableRunnable("sub-validation") { - @SuppressWarnings("unused") - public void run2() throws CacheException { - final PubSubStats statistics = subStatsRef.get(); - assertNotNull(statistics); - final int updateEvents = statistics.getUpdateEvents(); - assertEquals(totalPuts, updateEvents); - assertEquals(totalUpdateEvents, updateEvents); - assertEquals(MAX_PUTS * NUM_PUB_THREADS * NUM_PUBS, updateEvents); - - // assert that archive file contains same values as statistics - File archive = new File(subArchive); - assertTrue(archive.exists()); - - StatArchiveReader reader = null; - try { - reader = new StatArchiveReader(new File[]{archive}, null, false); - } catch (IOException e) { - fail("Failed to read " + archive); - } - - double combinedUpdateEvents = 0; - - @SuppressWarnings("rawtypes") - List resources = reader.getResourceInstList(); - for (@SuppressWarnings("rawtypes") - Iterator iter = resources.iterator(); iter.hasNext();) { - StatArchiveReader.ResourceInst ri = (StatArchiveReader.ResourceInst) iter.next(); - if (!ri.getType().getName().equals(PubSubStats.TYPE_NAME)) { - continue; - } - - StatValue[] statValues = ri.getStatValues(); - for (int i = 0; i < statValues.length; i++) { - String statName = ri.getType().getStats()[i].getName(); - assertNotNull(statName); - - if (statName.equals(PubSubStats.UPDATE_EVENTS)) { - StatValue sv = statValues[i]; - sv.setFilter(StatValue.FILTER_NONE); - - double mostRecent = sv.getSnapshotsMostRecent(); - double min = sv.getSnapshotsMinimum(); - double max = sv.getSnapshotsMaximum(); - double maxMinusMin = sv.getSnapshotsMaximum() - sv.getSnapshotsMinimum(); - double mean = sv.getSnapshotsAverage(); - double stdDev = sv.getSnapshotsStandardDeviation(); - - assertEquals(mostRecent, max,0); - - double summation = 0; - double[] rawSnapshots = sv.getRawSnapshots(); - for (int j = 0; j < rawSnapshots.length; j++) { - //log.convertToLogWriter().info("DEBUG " + ri.getName() + " " + statName + " rawSnapshots[" + j + "] = " + rawSnapshots[j]); - summation += rawSnapshots[j]; - } - assertEquals(mean, summation / sv.getSnapshotsSize(),0); - - combinedUpdateEvents += mostRecent; - } - } - } - assertEquals((double)totalUpdateEvents, combinedUpdateEvents,0); - } - }); - - final int updateEvents = sub.invoke(() -> readIntStat(new File(subArchive), "PubSubStats", "updateEvents")); - assertTrue(updateEvents > 0); - assertEquals(MAX_PUTS * NUM_PUB_THREADS * NUM_PUBS, updateEvents); - - int puts = 0; - for (int pubVM = 0; pubVM < NUM_PUBS; pubVM++) { - int currentPubVM = pubVM; - int vmPuts = (int)pubs[pubVM].invoke(() -> readIntStat(new File(pubArchives[currentPubVM]), "PubSubStats", "puts")); - assertTrue(vmPuts > 0); - assertEquals(MAX_PUTS * NUM_PUB_THREADS, vmPuts); - puts += vmPuts; - } - assertTrue(puts > 0); - assertEquals(MAX_PUTS * NUM_PUB_THREADS * NUM_PUBS, puts); - - // use regex "testPubAndSubCustomStats" - - final MultipleArchiveReader reader = new MultipleArchiveReader(".*testPubAndSubCustomStats.*\\.gfs"); - - final int combinedUpdateEvents = reader.readIntStat(PubSubStats.TYPE_NAME, PubSubStats.UPDATE_EVENTS); - assertTrue("Failed to read updateEvents stat values", combinedUpdateEvents > 0); - - final int combinedPuts = reader.readIntStat(PubSubStats.TYPE_NAME, PubSubStats.PUTS); - assertTrue("Failed to read puts stat values", combinedPuts > 0); - - assertTrue("updateEvents is " + combinedUpdateEvents + " but puts is " + combinedPuts, - combinedUpdateEvents == combinedPuts); - } - - static int readIntStat(File archive, String typeName, String statName) throws IOException { - final MultipleArchiveReader reader = new MultipleArchiveReader(archive); - return reader.readIntStat(typeName, statName); - } - - public static void main(String[] args) throws Exception { - if (args.length == 2) { - final String statType = args[0]; - final String statName = args[1]; - - final MultipleArchiveReader reader = new MultipleArchiveReader(); - final int value = reader.readIntStat(statType, statName); - System.out.println(statType + "#" + statName + "=" + value); - - } else if (args.length == 3) { - final String archiveName = args[0]; - final String statType = args[1]; - final String statName = args[2]; - - final File archive = new File(archiveName).getAbsoluteFile(); - assertTrue("File " + archive + " does not exist!", archive.exists()); - assertTrue(archive + " exists but is not a file!", archive.isFile()); - - final MultipleArchiveReader reader = new MultipleArchiveReader(archive); - final int value = reader.readIntStat(statType, statName); - System.out.println(archive + ": " + statType + "#" + statName + "=" + value); - - } else if (args.length == 4) { - final String statType1 = args[0]; - final String statName1 = args[1]; - final String statType2 = args[2]; - final String statName2 = args[3]; - - final MultipleArchiveReader reader = new MultipleArchiveReader(); - final int value1 = reader.readIntStat(statType1, statName1); - final int value2 = reader.readIntStat(statType2, statName2); - - assertTrue(statType1 + "#" + statName1 + "=" + value1 - + " does not equal " + statType2 + "#" + statName2 + "=" + value2, - value1 == value2); - } else { - assertEquals("Miminum two args are required: statType statName", 2, args.length); - } - } - - /** - * @since GemFire 7.0 - */ - static class PubSubStats { - - private static final String TYPE_NAME = "PubSubStats"; - private static final String TYPE_DESCRIPTION = "Statistics for StatisticsDUnitTest with Pub/Sub."; - - private static final String INSTANCE_PREFIX = "pubSubStats_"; - - private static final String PUTS = "puts"; - private static final String PUT_TIME = "putTime"; - - private static final String UPDATE_EVENTS = "updateEvents"; - - private static StatisticsType createType(StatisticsFactory f) { - StatisticsTypeFactory stf = StatisticsTypeFactoryImpl.singleton(); - StatisticsType type = stf.createType( - TYPE_NAME, - TYPE_DESCRIPTION, - createDescriptors(f)); - return type; - } - - private static StatisticDescriptor[] createDescriptors(StatisticsFactory f) { - boolean largerIsBetter = true; - return new StatisticDescriptor[] { - f.createIntCounter - ( - PUTS, - "Number of puts completed.", - "operations", - largerIsBetter - ), - f.createLongCounter - ( - PUT_TIME, - "Total time spent doing puts.", - "nanoseconds", - !largerIsBetter - ), - f.createIntCounter - ( - UPDATE_EVENTS, - "Number of update events.", - "events", - largerIsBetter - ) - }; - } - - private final Statistics statistics; - - PubSubStats(StatisticsFactory f, String name, int id) { - this.statistics = f.createAtomicStatistics( - createType(f), INSTANCE_PREFIX + "_" + name, id); - } - - Statistics statistics() { - return this.statistics; - } - - void close() { - this.statistics.close(); - } - - int getUpdateEvents() { - return statistics().getInt(UPDATE_EVENTS); - } - - void incUpdateEvents() { - incUpdateEvents(1); - } - - void incUpdateEvents(int amount) { - incStat(UPDATE_EVENTS, amount); - } - - int getPuts() { - return statistics().getInt(PUTS); - } - - void incPuts() { - incPuts(1); - } - - void incPuts(int amount) { - incStat(PUTS, amount); - } - - void incPutTime(long amount) { - incStat(PUT_TIME, amount); - } - - long startPut() { - return NanoTimer.getTime(); - } - - void endPut(long start) { - endPut(start, 1); - } - - void endPut(long start, int amount) { - long elapsed = NanoTimer.getTime() - start; - incPuts(amount); - incPutTime(elapsed); - } - - private void incStat(String statName, int intValue) { - statistics().incInt(statName, intValue); - } - - private void incStat(String statName, long longValue) { - statistics().incLong(statName, longValue); - } - } - - /** - * @since GemFire 7.0 - */ - static class UpdateListener extends CacheListenerAdapter { - - private final PubSubStats statistics; - - UpdateListener(PubSubStats statistics) { - this.statistics = statistics; - } - - @Override - public void afterUpdate(EntryEvent event) { - this.statistics.incUpdateEvents( 1 ); - } - } - - /** - * @since GemFire 7.0 - */ - static class RegionMembershipListener extends RegionMembershipListenerAdapter { - - private final List members = new ArrayList(); - - int size() { - return this.members.size(); - } - - List getMembers() { - return Collections.unmodifiableList(new ArrayList(this.members)); - } - - boolean containsId(DistributedMember member) { - for (DistributedMember peer : getMembers()) { - if (peer.getId().equals(member.getId())) { - return true; - } - } - return false; - } - - boolean contains(DistributedMember member) { - return this.members.contains(member); - } - - String debugContains(DistributedMember member) { - StringBuffer sb = new StringBuffer(); - for (DistributedMember peer : getMembers()) { - if (!peer.equals(member)) { - InternalDistributedMember peerIDM = (InternalDistributedMember)peer; - InternalDistributedMember memberIDM = (InternalDistributedMember)member; - sb.append("peer port=").append(peerIDM.getPort()).append(" "); - sb.append("member port=").append(memberIDM.getPort()).append(" "); - } - } - return sb.toString(); - } - - @Override - public void initialMembers(Region region, DistributedMember[] initialMembers) { - for (int i = 0; i < initialMembers.length; i++) { - this.members.add(initialMembers[i]); - } - } - - @Override - public void afterRemoteRegionCreate(RegionEvent event) { - this.members.add(event.getDistributedMember()); - } - - @Override - public void afterRemoteRegionDeparture(RegionEvent event) { - this.members.remove(event.getDistributedMember()); - } - - @Override - public void afterRemoteRegionCrash(RegionEvent event) { - this.members.remove(event.getDistributedMember()); - } - } - - static class MultipleArchiveReader { - - private final File dir; - private final String regex; - - MultipleArchiveReader(File dir, String regex) { - this.dir = dir; - this.regex = regex; - } - - MultipleArchiveReader(File dir) { - this.dir = dir; - this.regex = null; - } - - MultipleArchiveReader(String regex) { - this(new File(System.getProperty("user.dir")).getAbsoluteFile(), regex); - } - - MultipleArchiveReader() { - this(new File(System.getProperty("user.dir")).getAbsoluteFile(), null); - } - - int readIntStat(String typeName, String statName) throws IOException { - // directory (maybe directories) with one or more archives - if (this.dir.exists() && this.dir.isDirectory()) { - final List archives = findFilesWithSuffix(this.dir, this.regex, ".gfs"); - return readIntStatFromArchives(archives, typeName, statName); - - // one archive file - } else if (this.dir.exists() && this.dir.isFile()) { - final List archives = new ArrayList(); - archives.add(this.dir); - return readIntStatFromArchives(archives, typeName, statName); - - // failure - } else { - throw new IllegalStateException(this.dir + " does not exist!"); - } - } - - private int readIntStatFromArchives(List archives, String typeName, String statName) throws IOException { - final StatValue[] statValues = readStatValues(archives, typeName, statName); - assertNotNull("statValues is null!", statValues); - assertTrue("statValues is empty!", statValues.length > 0); - - int value = 0; - for (int i = 0; i < statValues.length; i++) { - statValues[i].setFilter(StatValue.FILTER_NONE); - value += (int)statValues[i].getSnapshotsMaximum(); - } - return value; - } - - private static List findFilesWithSuffix(final File dir, final String regex, final String suffix) { - Pattern p = null; - if (regex != null) { - p = Pattern.compile(regex); - } - final Pattern pattern = p; - - return findFiles( - dir, - new FileFilter() { - public boolean accept(File file) { - boolean accept = true; - if (regex != null) { - final Matcher matcher = pattern.matcher(file.getName()); - accept = matcher.matches(); - } - if (suffix != null) { - accept = accept && file.getName().endsWith(suffix); - } - return accept; - } - }, - true); - } - - private static List findFiles(File dir, FileFilter filter, boolean recursive) { - File[] tmpfiles = dir.listFiles(filter); - List matches; - if (tmpfiles == null) { - matches = new ArrayList(); - } else { - matches = new ArrayList(Arrays.asList(tmpfiles)); - } - if (recursive) { - File[] files = dir.listFiles(); - if (files != null) { - for (int i = 0; i < files.length; i++) { - File file = files[i]; - if (file.isDirectory()) { - matches.addAll(findFiles(file, filter, recursive)); - } - } - } - } - return matches; - } - - private static StatValue[] readStatValues(final List archives, final String typeName, final String statName) throws IOException { - System.out.println("\nKIRK readStatValues reading archives:\n\n" + archives + "\n"); - final StatSpec statSpec = new StatSpec() { - @Override - public boolean archiveMatches(File value) { - return true; - } - @Override - public boolean typeMatches(String value) { - return typeName.equals(value); - } - @Override - public boolean statMatches(String value) { - return statName.equals(value); - } - @Override - public boolean instanceMatches(String textId, long numericId) { - return true; - } - @Override - public int getCombineType() { - return StatSpec.FILE; - } - }; - - final File[] archiveFiles = archives.toArray(new File[archives.size()]); - final StatSpec[] filters = new StatSpec[] { statSpec }; - final StatArchiveReader reader = new StatArchiveReader(archiveFiles, filters, true); - final StatValue[] values = reader.matchSpec(statSpec); - return values; - } - } -} diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/StatisticsDistributedTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/StatisticsDistributedTest.java new file mode 100755 index 000000000000..21a8ee0b5ef4 --- /dev/null +++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/StatisticsDistributedTest.java @@ -0,0 +1,851 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.gemstone.gemfire.internal.statistics; + +import static com.jayway.awaitility.Awaitility.*; +import static com.gemstone.gemfire.distributed.ConfigurationProperties.*; +import static com.gemstone.gemfire.test.dunit.Assert.*; +import static com.gemstone.gemfire.test.dunit.Host.*; +import static com.gemstone.gemfire.test.dunit.Invoke.*; +import static java.util.concurrent.TimeUnit.*; + +import java.io.File; +import java.io.FileFilter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import java.util.Properties; +import java.util.Random; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.atomic.AtomicReference; +import java.util.concurrent.atomic.AtomicReferenceArray; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.junit.Rule; +import org.junit.Test; +import org.junit.experimental.categories.Category; + +import com.gemstone.gemfire.StatisticDescriptor; +import com.gemstone.gemfire.Statistics; +import com.gemstone.gemfire.StatisticsFactory; +import com.gemstone.gemfire.StatisticsType; +import com.gemstone.gemfire.StatisticsTypeFactory; +import com.gemstone.gemfire.cache.Cache; +import com.gemstone.gemfire.cache.CacheListener; +import com.gemstone.gemfire.cache.EntryEvent; +import com.gemstone.gemfire.cache.Region; +import com.gemstone.gemfire.cache.RegionEvent; +import com.gemstone.gemfire.cache.RegionFactory; +import com.gemstone.gemfire.cache.Scope; +import com.gemstone.gemfire.cache.util.CacheListenerAdapter; +import com.gemstone.gemfire.cache.util.RegionMembershipListenerAdapter; +import com.gemstone.gemfire.distributed.DistributedMember; +import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem; +import com.gemstone.gemfire.distributed.internal.membership.InternalDistributedMember; +import com.gemstone.gemfire.internal.NanoTimer; +import com.gemstone.gemfire.internal.statistics.StatArchiveReader.ResourceInst; +import com.gemstone.gemfire.internal.statistics.StatArchiveReader.StatSpec; +import com.gemstone.gemfire.internal.statistics.StatArchiveReader.StatValue; +import com.gemstone.gemfire.test.dunit.AsyncInvocation; +import com.gemstone.gemfire.test.dunit.VM; +import com.gemstone.gemfire.test.dunit.cache.internal.JUnit4CacheTestCase; +import com.gemstone.gemfire.test.junit.categories.DistributedTest; +import com.gemstone.gemfire.test.junit.rules.serializable.SerializableTemporaryFolder; + +/** + * Distributed tests for {@link Statistics}. + * + *

VM0 performs puts and VM1 receives updates. Both use custom statistics for start/end with increment to add up puts + * and updates. Then validation tests values in stat resource instances and uses StatArchiveReader. Both are tested + * against static counters in both VMs. + * + *

This test mimics hydratest/locators/cacheDS.conf in an attempt to reproduce bug #45478. So far this test passes + * consistently. + * + * @since GemFire 7.0 + */ +@Category(DistributedTest.class) +@SuppressWarnings({ "rawtypes", "serial", "unused" }) +public class StatisticsDistributedTest extends JUnit4CacheTestCase { + + private static final int MAX_PUTS = 1000; + private static final int NUM_KEYS = 100; + private static final int NUM_PUB_THREADS = 2; + private static final int NUM_PUBS = 2; + private static final boolean RANDOMIZE_PUTS = true; + + private static AtomicInteger updateEvents = new AtomicInteger(); + private static AtomicInteger puts = new AtomicInteger(); + private static AtomicReference subStatsRef = new AtomicReference<>(); + private static AtomicReferenceArray pubStatsRef = new AtomicReferenceArray<>(NUM_PUB_THREADS); + private static AtomicReference rmlRef = new AtomicReference<>(); + + private File directory; + + @Rule + public SerializableTemporaryFolder temporaryFolder = new SerializableTemporaryFolder(); + + @Override + public final void postSetUp() throws Exception { + this.directory = this.temporaryFolder.getRoot(); + } + + @Override + public final void preTearDownCacheTestCase() throws Exception { + invokeInEveryVM(() -> cleanup()); + disconnectAllFromDS(); // because this test enabled stat sampling! + } + + @Test + public void testPubAndSubCustomStats() throws Exception { + String regionName = "region_" + getName(); + VM[] pubs = new VM[NUM_PUBS]; + for (int pubVM = 0; pubVM < NUM_PUBS; pubVM++) { + pubs[pubVM] = getHost(0).getVM(pubVM); + } + VM sub = getHost(0).getVM(NUM_PUBS); + + String subArchive = this.directory.getAbsolutePath() + File.separator + getName() + "_sub" + ".gfs"; + String[] pubArchives = new String[NUM_PUBS]; + for (int pubVM = 0; pubVM < NUM_PUBS; pubVM++) { + pubArchives[pubVM] = this.directory.getAbsolutePath() + File.separator + getName() + "_pub-" + pubVM + ".gfs"; + } + + for (int i = 0; i < NUM_PUBS; i++) { + final int pubVM = i; + pubs[pubVM].invoke("pub-connect-and-create-data-" + pubVM, () -> { + Properties props = new Properties(); + props.setProperty(STATISTIC_SAMPLING_ENABLED, "true"); + props.setProperty(STATISTIC_SAMPLE_RATE, "1000"); + props.setProperty(STATISTIC_ARCHIVE_FILE, pubArchives[pubVM]); + + InternalDistributedSystem system = getSystem(props); + + // assert that sampler is working as expected + GemFireStatSampler sampler = system.getStatSampler(); + assertTrue(sampler.isSamplingEnabled()); + assertTrue(sampler.isAlive()); + assertEquals(new File(pubArchives[pubVM]), sampler.getArchiveFileName()); + + await("awaiting SampleCollector to exist").atMost(30, SECONDS).until(() -> sampler.getSampleCollector() != null); + + SampleCollector sampleCollector = sampler.getSampleCollector(); + assertNotNull(sampleCollector); + + StatArchiveHandler archiveHandler = sampleCollector.getStatArchiveHandler(); + assertNotNull(archiveHandler); + assertTrue(archiveHandler.isArchiving()); + + // create cache and region + Cache cache = getCache(); + RegionFactory factory = cache.createRegionFactory(); + factory.setScope(Scope.DISTRIBUTED_ACK); + + RegionMembershipListener rml = new RegionMembershipListener(); + rmlRef.set(rml); + factory.addCacheListener(rml); + Region region = factory.create(regionName); + + // create the keys + if (region.getAttributes().getScope() == Scope.DISTRIBUTED_ACK) { + for (int key = 0; key < NUM_KEYS; key++) { + region.create("KEY-"+key, null); + } + } + }); + } + + DistributedMember subMember = sub.invoke("sub-connect-and-create-keys", () -> { + Properties props = new Properties(); + props.setProperty(STATISTIC_SAMPLING_ENABLED, "true"); + props.setProperty(STATISTIC_SAMPLE_RATE, "1000"); + props.setProperty(STATISTIC_ARCHIVE_FILE, subArchive); + + InternalDistributedSystem system = getSystem(props); + + PubSubStats statistics = new PubSubStats(system, "sub-1", 1); + subStatsRef.set(statistics); + + // assert that sampler is working as expected + GemFireStatSampler sampler = system.getStatSampler(); + assertTrue(sampler.isSamplingEnabled()); + assertTrue(sampler.isAlive()); + assertEquals(new File(subArchive), sampler.getArchiveFileName()); + + await("awaiting SampleCollector to exist").atMost(30, SECONDS).until(() -> sampler.getSampleCollector() != null); + + SampleCollector sampleCollector = sampler.getSampleCollector(); + assertNotNull(sampleCollector); + + StatArchiveHandler archiveHandler = sampleCollector.getStatArchiveHandler(); + assertNotNull(archiveHandler); + assertTrue(archiveHandler.isArchiving()); + + // create cache and region with UpdateListener + Cache cache = getCache(); + RegionFactory factory = cache.createRegionFactory(); + factory.setScope(Scope.DISTRIBUTED_ACK); + + CacheListener cl = new UpdateListener(statistics); + factory.addCacheListener(cl); + Region region = factory.create(regionName); + + // create the keys + if (region.getAttributes().getScope() == Scope.DISTRIBUTED_ACK) { + for (int key = 0; key < NUM_KEYS; key++) { + region.create("KEY-"+key, null); + } + } + + assertEquals(0, statistics.getUpdateEvents()); + return system.getDistributedMember(); + }); + + for (int i = 0; i < NUM_PUBS; i++) { + final int pubVM = i; + AsyncInvocation[] publishers = new AsyncInvocation[NUM_PUB_THREADS]; + for (int j = 0; j < NUM_PUB_THREADS; j++) { + final int pubThread = j; + publishers[pubThread] = pubs[pubVM].invokeAsync("pub-connect-and-put-data-" + pubVM + "-thread-" + pubThread, () -> { + PubSubStats statistics = new PubSubStats(basicGetSystem(), "pub-" + pubThread, pubVM); + pubStatsRef.set(pubThread, statistics); + + RegionMembershipListener rml = rmlRef.get(); + Region region = getCache().getRegion(regionName); + + // assert that sub is in rml membership + assertNotNull(rml); + + await("awaiting Membership to contain subMember").atMost(30, SECONDS).until(() -> rml.contains(subMember) && rml.size() == NUM_PUBS); + + // publish lots of puts cycling through the NUM_KEYS + assertEquals(0, statistics.getPuts()); + + // cycle through the keys randomly + if (RANDOMIZE_PUTS) { + Random randomGenerator = new Random(); + int key = 0; + for (int idx = 0; idx < MAX_PUTS; idx++) { + long start = statistics.startPut(); + key = randomGenerator.nextInt(NUM_KEYS); + region.put("KEY-"+key, idx); + statistics.endPut(start); + } + + // cycle through he keys in order and wrapping back around + } else { + int key = 0; + for (int idx = 0; idx < MAX_PUTS; idx++) { + long start = statistics.startPut(); + region.put("KEY-"+key, idx); + key++; // cycle through the keys... + if (key >= NUM_KEYS) { + key = 0; + } + statistics.endPut(start); + } + } + assertEquals(MAX_PUTS, statistics.getPuts()); + + // wait for 2 samples to ensure all stats have been archived + StatisticsType statSamplerType = getSystem().findType("StatSampler"); + Statistics[] statsArray = getSystem().findStatisticsByType(statSamplerType); + assertEquals(1, statsArray.length); + + Statistics statSamplerStats = statsArray[0]; + int initialSampleCount = statSamplerStats.getInt(StatSamplerStats.SAMPLE_COUNT); + + await("awaiting sampleCount >= 2").atMost(30, SECONDS).until(() -> statSamplerStats.getInt(StatSamplerStats.SAMPLE_COUNT) >= initialSampleCount + 2); + }); + } + + for (int pubThread = 0; pubThread < publishers.length; pubThread++) { + publishers[pubThread].join(); + if (publishers[pubThread].exceptionOccurred()) { + fail("Test failed", publishers[pubThread].getException()); + } + } + } + + sub.invoke("sub-wait-for-samples", () -> { + // wait for 2 samples to ensure all stats have been archived + StatisticsType statSamplerType = getSystem().findType("StatSampler"); + Statistics[] statsArray = getSystem().findStatisticsByType(statSamplerType); + assertEquals(1, statsArray.length); + + Statistics statSamplerStats = statsArray[0]; + int initialSampleCount = statSamplerStats.getInt(StatSamplerStats.SAMPLE_COUNT); + + await("awaiting sampleCount >= 2").atMost(30, SECONDS).until(() -> statSamplerStats.getInt(StatSamplerStats.SAMPLE_COUNT) >= initialSampleCount + 2); + + // now post total updateEvents to static + PubSubStats statistics = subStatsRef.get(); + assertNotNull(statistics); + updateEvents.set(statistics.getUpdateEvents()); + }); + + // validate pub values against sub values + int totalUpdateEvents = sub.invoke(() -> getUpdateEvents()); + + // validate pub values against pub statistics against pub archive + for (int i = 0; i < NUM_PUBS; i++) { + final int pubIdx = i; + pubs[pubIdx].invoke("pub-validation", () -> { + // add up all the puts + assertEquals(NUM_PUB_THREADS, pubStatsRef.length()); + int totalPuts = 0; + for (int pubThreadIdx = 0; pubThreadIdx < NUM_PUB_THREADS; pubThreadIdx++) { + PubSubStats statistics = pubStatsRef.get(pubThreadIdx); + assertNotNull(statistics); + totalPuts += statistics.getPuts(); + } + + // assert that total puts adds up to max puts times num threads + assertEquals(MAX_PUTS * NUM_PUB_THREADS, totalPuts); + + // assert that archive file contains same values as statistics + File archive = new File(pubArchives[pubIdx]); + assertTrue(archive.exists()); + + StatArchiveReader reader = new StatArchiveReader(new File[]{archive}, null, false); + + double combinedPuts = 0; + + List resources = reader.getResourceInstList(); + assertNotNull(resources); + assertFalse(resources.isEmpty()); + + for (Iterator iter = resources.iterator(); iter.hasNext();) { + ResourceInst ri = iter.next(); + if (!ri.getType().getName().equals(PubSubStats.TYPE_NAME)) { + continue; + } + + StatValue[] statValues = ri.getStatValues(); + for (int idx = 0; idx < statValues.length; idx++) { + String statName = ri.getType().getStats()[idx].getName(); + assertNotNull(statName); + + if (statName.equals(PubSubStats.PUTS)) { + StatValue sv = statValues[idx]; + sv.setFilter(StatValue.FILTER_NONE); + + double mostRecent = sv.getSnapshotsMostRecent(); + double min = sv.getSnapshotsMinimum(); + double max = sv.getSnapshotsMaximum(); + double maxMinusMin = sv.getSnapshotsMaximum() - sv.getSnapshotsMinimum(); + double mean = sv.getSnapshotsAverage(); + double stdDev = sv.getSnapshotsStandardDeviation(); + + assertEquals(mostRecent, max, 0f); + + double summation = 0; + double[] rawSnapshots = sv.getRawSnapshots(); + for (int j = 0; j < rawSnapshots.length; j++) { + summation += rawSnapshots[j]; + } + assertEquals(mean, summation / sv.getSnapshotsSize(), 0); + + combinedPuts += mostRecent; + } + } + } + + // assert that sum of mostRecent values for all puts equals totalPuts + assertEquals((double)totalPuts, combinedPuts, 0); + puts.getAndAdd(totalPuts); + }); + } + + // validate pub values against sub values + int totalCombinedPuts = 0; + for (int i = 0; i < NUM_PUBS; i++) { + int pubIdx = i; + int totalPuts = pubs[pubIdx].invoke(() -> getPuts()); + assertEquals(MAX_PUTS * NUM_PUB_THREADS, totalPuts); + totalCombinedPuts += totalPuts; + } + assertEquals(totalCombinedPuts, totalUpdateEvents); + assertEquals(MAX_PUTS * NUM_PUB_THREADS * NUM_PUBS, totalCombinedPuts); + + // validate sub values against sub statistics against sub archive + final int totalPuts = totalCombinedPuts; + sub.invoke("sub-validation", () -> { + PubSubStats statistics = subStatsRef.get(); + assertNotNull(statistics); + int updateEvents = statistics.getUpdateEvents(); + assertEquals(totalPuts, updateEvents); + assertEquals(totalUpdateEvents, updateEvents); + assertEquals(MAX_PUTS * NUM_PUB_THREADS * NUM_PUBS, updateEvents); + + // assert that archive file contains same values as statistics + File archive = new File(subArchive); + assertTrue(archive.exists()); + + StatArchiveReader reader = new StatArchiveReader(new File[]{archive}, null, false); + + double combinedUpdateEvents = 0; + + List resources = reader.getResourceInstList(); + for (Iterator iter = resources.iterator(); iter.hasNext();) { + ResourceInst ri = iter.next(); + if (!ri.getType().getName().equals(PubSubStats.TYPE_NAME)) { + continue; + } + + StatValue[] statValues = ri.getStatValues(); + for (int i = 0; i < statValues.length; i++) { + String statName = ri.getType().getStats()[i].getName(); + assertNotNull(statName); + + if (statName.equals(PubSubStats.UPDATE_EVENTS)) { + StatValue sv = statValues[i]; + sv.setFilter(StatValue.FILTER_NONE); + + double mostRecent = sv.getSnapshotsMostRecent(); + double min = sv.getSnapshotsMinimum(); + double max = sv.getSnapshotsMaximum(); + double maxMinusMin = sv.getSnapshotsMaximum() - sv.getSnapshotsMinimum(); + double mean = sv.getSnapshotsAverage(); + double stdDev = sv.getSnapshotsStandardDeviation(); + + assertEquals(mostRecent, max,0); + + double summation = 0; + double[] rawSnapshots = sv.getRawSnapshots(); + for (int j = 0; j < rawSnapshots.length; j++) { + summation += rawSnapshots[j]; + } + assertEquals(mean, summation / sv.getSnapshotsSize(),0); + + combinedUpdateEvents += mostRecent; + } + } + } + assertEquals((double)totalUpdateEvents, combinedUpdateEvents,0); + }); + + int updateEvents = sub.invoke(() -> readIntStat(new File(subArchive), "PubSubStats", "updateEvents")); + assertTrue(updateEvents > 0); + assertEquals(MAX_PUTS * NUM_PUB_THREADS * NUM_PUBS, updateEvents); + + int puts = 0; + for (int pubVM = 0; pubVM < NUM_PUBS; pubVM++) { + int currentPubVM = pubVM; + int vmPuts = pubs[pubVM].invoke(() -> readIntStat(new File(pubArchives[currentPubVM]), "PubSubStats", "puts")); + assertTrue(vmPuts > 0); + assertEquals(MAX_PUTS * NUM_PUB_THREADS, vmPuts); + puts += vmPuts; + } + assertTrue(puts > 0); + assertEquals(MAX_PUTS * NUM_PUB_THREADS * NUM_PUBS, puts); + + // use regex "testPubAndSubCustomStats" + + MultipleArchiveReader reader = new MultipleArchiveReader(this.directory, ".*" + getTestMethodName() + ".*\\.gfs"); + + int combinedUpdateEvents = reader.readIntStat(PubSubStats.TYPE_NAME, PubSubStats.UPDATE_EVENTS); + assertTrue("Failed to read updateEvents stat values", combinedUpdateEvents > 0); + + int combinedPuts = reader.readIntStat(PubSubStats.TYPE_NAME, PubSubStats.PUTS); + assertTrue("Failed to read puts stat values", combinedPuts > 0); + + assertTrue("updateEvents is " + combinedUpdateEvents + " but puts is " + combinedPuts, + combinedUpdateEvents == combinedPuts); + } + + static int readIntStat(final File archive, final String typeName, final String statName) throws IOException { + MultipleArchiveReader reader = new MultipleArchiveReader(archive); + return reader.readIntStat(typeName, statName); + } + + /** invoked by reflection */ + private static void cleanup() { + updateEvents.set(0); + rmlRef.set(null); + } + + /** invoked by reflection */ + private static int getUpdateEvents() { + return updateEvents.get(); + } + + /** invoked by reflection */ + private static int getPuts() { + return puts.get(); + } + + public static void main(final String[] args) throws Exception { + if (args.length == 2) { + final String statType = args[0]; + final String statName = args[1]; + + MultipleArchiveReader reader = new MultipleArchiveReader(new File(".")); + int value = reader.readIntStat(statType, statName); + System.out.println(statType + "#" + statName + "=" + value); + + } else if (args.length == 3) { + final String archiveName = args[0]; + final String statType = args[1]; + final String statName = args[2]; + + File archive = new File(archiveName).getAbsoluteFile(); + assertTrue("File " + archive + " does not exist!", archive.exists()); + assertTrue(archive + " exists but is not a file!", archive.isFile()); + + MultipleArchiveReader reader = new MultipleArchiveReader(archive); + int value = reader.readIntStat(statType, statName); + System.out.println(archive + ": " + statType + "#" + statName + "=" + value); + + } else if (args.length == 4) { + final String statType1 = args[0]; + final String statName1 = args[1]; + final String statType2 = args[2]; + final String statName2 = args[3]; + + MultipleArchiveReader reader = new MultipleArchiveReader(new File(".")); + int value1 = reader.readIntStat(statType1, statName1); + int value2 = reader.readIntStat(statType2, statName2); + + assertTrue(statType1 + "#" + statName1 + "=" + value1 + " does not equal " + statType2 + "#" + statName2 + "=" + value2, + value1 == value2); + } else { + assertEquals("Minimum two args are required: statType statName", 2, args.length); + } + } + + /** + * @since GemFire 7.0 + */ + static class PubSubStats { + + private static final String TYPE_NAME = "PubSubStats"; + private static final String TYPE_DESCRIPTION = "Statistics for StatisticsDistributedTest with Pub/Sub."; + + private static final String INSTANCE_PREFIX = "pubSubStats_"; + + private static final String PUTS = "puts"; + private static final String PUT_TIME = "putTime"; + + private static final String UPDATE_EVENTS = "updateEvents"; + + private static StatisticsType createType(final StatisticsFactory f) { + StatisticsTypeFactory stf = StatisticsTypeFactoryImpl.singleton(); + StatisticsType type = stf.createType(TYPE_NAME, TYPE_DESCRIPTION, createDescriptors(f)); + return type; + } + + private static StatisticDescriptor[] createDescriptors(final StatisticsFactory f) { + boolean largerIsBetter = true; + return new StatisticDescriptor[] { + f.createIntCounter + ( + PUTS, + "Number of puts completed.", + "operations", + largerIsBetter + ), + f.createLongCounter + ( + PUT_TIME, + "Total time spent doing puts.", + "nanoseconds", + !largerIsBetter + ), + f.createIntCounter + ( + UPDATE_EVENTS, + "Number of update events.", + "events", + largerIsBetter + ) + }; + } + + private final Statistics statistics; + + PubSubStats(final StatisticsFactory f, final String name, final int id) { + this.statistics = f.createAtomicStatistics(createType(f), INSTANCE_PREFIX + "_" + name, id); + } + + Statistics statistics() { + return this.statistics; + } + + void close() { + this.statistics.close(); + } + + int getUpdateEvents() { + return statistics().getInt(UPDATE_EVENTS); + } + + void incUpdateEvents() { + incUpdateEvents(1); + } + + void incUpdateEvents(final int amount) { + incStat(UPDATE_EVENTS, amount); + } + + int getPuts() { + return statistics().getInt(PUTS); + } + + void incPuts() { + incPuts(1); + } + + void incPuts(final int amount) { + incStat(PUTS, amount); + } + + void incPutTime(final long amount) { + incStat(PUT_TIME, amount); + } + + long startPut() { + return NanoTimer.getTime(); + } + + void endPut(final long start) { + endPut(start, 1); + } + + void endPut(final long start, final int amount) { + long elapsed = NanoTimer.getTime() - start; + incPuts(amount); + incPutTime(elapsed); + } + + private void incStat(final String statName, final int intValue) { + statistics().incInt(statName, intValue); + } + + private void incStat(final String statName, final long longValue) { + statistics().incLong(statName, longValue); + } + } + + /** + * @since GemFire 7.0 + */ + static class UpdateListener extends CacheListenerAdapter { + + private final PubSubStats statistics; + + UpdateListener(final PubSubStats statistics) { + this.statistics = statistics; + } + + @Override + public void afterUpdate(final EntryEvent event) { + this.statistics.incUpdateEvents( 1 ); + } + } + + /** + * @since GemFire 7.0 + */ + static class RegionMembershipListener extends RegionMembershipListenerAdapter { + + private final List members = new ArrayList<>(); + + int size() { + return this.members.size(); + } + + List getMembers() { + return Collections.unmodifiableList(new ArrayList<>(this.members)); + } + + boolean containsId(final DistributedMember member) { + for (DistributedMember peer : getMembers()) { + if (peer.getId().equals(member.getId())) { + return true; + } + } + return false; + } + + boolean contains(final DistributedMember member) { + return this.members.contains(member); + } + + String debugContains(final DistributedMember member) { + StringBuilder sb = new StringBuilder(); + for (DistributedMember peer : getMembers()) { + if (!peer.equals(member)) { + InternalDistributedMember peerIDM = (InternalDistributedMember)peer; + InternalDistributedMember memberIDM = (InternalDistributedMember)member; + sb.append("peer port=").append(peerIDM.getPort()).append(" "); + sb.append("member port=").append(memberIDM.getPort()).append(" "); + } + } + return sb.toString(); + } + + @Override + public void initialMembers(final Region region, final DistributedMember[] initialMembers) { + for (int i = 0; i < initialMembers.length; i++) { + this.members.add(initialMembers[i]); + } + } + + @Override + public void afterRemoteRegionCreate(final RegionEvent event) { + this.members.add(event.getDistributedMember()); + } + + @Override + public void afterRemoteRegionDeparture(final RegionEvent event) { + this.members.remove(event.getDistributedMember()); + } + + @Override + public void afterRemoteRegionCrash(final RegionEvent event) { + this.members.remove(event.getDistributedMember()); + } + } + + static class MultipleArchiveReader { + + private final File dir; + private final String regex; + + MultipleArchiveReader(final File dir, final String regex) { + this.dir = dir; + this.regex = regex; + } + + MultipleArchiveReader(final File dir) { + this.dir = dir; + this.regex = null; + } + + int readIntStat(final String typeName, final String statName) throws IOException { + // directory (maybe directories) with one or more archives + if (this.dir.exists() && this.dir.isDirectory()) { + List archives = findFilesWithSuffix(this.dir, this.regex, ".gfs"); + return readIntStatFromArchives(archives, typeName, statName); + + // one archive file + } else if (this.dir.exists() && this.dir.isFile()) { + List archives = new ArrayList(); + archives.add(this.dir); + return readIntStatFromArchives(archives, typeName, statName); + + // failure + } else { + throw new IllegalStateException(this.dir + " does not exist!"); + } + } + + private int readIntStatFromArchives(final List archives, final String typeName, final String statName) throws IOException { + StatValue[] statValues = readStatValues(archives, typeName, statName); + assertNotNull("statValues is null!", statValues); + assertTrue("statValues is empty!", statValues.length > 0); + + int value = 0; + for (int i = 0; i < statValues.length; i++) { + statValues[i].setFilter(StatValue.FILTER_NONE); + value += (int)statValues[i].getSnapshotsMaximum(); + } + return value; + } + + private static List findFilesWithSuffix(final File dir, final String regex, final String suffix) { + Pattern p = null; + if (regex != null) { + p = Pattern.compile(regex); + } + final Pattern pattern = p; + + return findFiles( + dir, + (final File file) -> { + boolean value = true; + if (regex != null) { + final Matcher matcher = pattern.matcher(file.getName()); + value = matcher.matches(); + } + if (suffix != null) { + value = value && file.getName().endsWith(suffix); + } + return value; + }, + true); + } + + private static List findFiles(final File dir, final FileFilter filter, final boolean recursive) { + File[] tmpfiles = dir.listFiles(filter); + List matches; + if (tmpfiles == null) { + matches = new ArrayList<>(); + } else { + matches = new ArrayList<>(Arrays.asList(tmpfiles)); + } + if (recursive) { + File[] files = dir.listFiles(); + if (files != null) { + for (int i = 0; i < files.length; i++) { + File file = files[i]; + if (file.isDirectory()) { + matches.addAll(findFiles(file, filter, recursive)); + } + } + } + } + return matches; + } + + private static StatValue[] readStatValues(final List archives, final String typeName, final String statName) throws IOException { + final StatSpec statSpec = new StatSpec() { + @Override + public boolean archiveMatches(File value) { + return true; + } + @Override + public boolean typeMatches(String value) { + return typeName.equals(value); + } + @Override + public boolean statMatches(String value) { + return statName.equals(value); + } + @Override + public boolean instanceMatches(String textId, long numericId) { + return true; + } + @Override + public int getCombineType() { + return StatSpec.FILE; + } + }; + + File[] archiveFiles = archives.toArray(new File[archives.size()]); + StatSpec[] filters = new StatSpec[] { statSpec }; + StatArchiveReader reader = new StatArchiveReader(archiveFiles, filters, true); + StatValue[] values = reader.matchSpec(statSpec); + return values; + } + } +} diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/LocalStatisticsImplJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/StatisticsImplTest.java similarity index 91% rename from geode-core/src/test/java/com/gemstone/gemfire/internal/LocalStatisticsImplJUnitTest.java rename to geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/StatisticsImplTest.java index a9b1ec7d278b..ab8d5870de09 100644 --- a/geode-core/src/test/java/com/gemstone/gemfire/internal/LocalStatisticsImplJUnitTest.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/StatisticsImplTest.java @@ -14,23 +14,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.gemstone.gemfire.internal; +package com.gemstone.gemfire.internal.statistics; -import static org.junit.Assert.assertEquals; +import static org.junit.Assert.*; import static org.mockito.Mockito.*; import java.util.function.DoubleSupplier; import java.util.function.IntSupplier; import java.util.function.LongSupplier; -import com.gemstone.gemfire.StatisticsType; -import com.gemstone.gemfire.internal.LocalStatisticsImpl; -import com.gemstone.gemfire.internal.StatisticsImpl; -import com.gemstone.gemfire.internal.StatisticsManager; -import com.gemstone.gemfire.internal.StatisticsTypeImpl; -import com.gemstone.gemfire.test.junit.categories.UnitTest; - -import org.apache.commons.lang.ObjectUtils.Null; import org.apache.logging.log4j.Logger; import org.junit.Before; import org.junit.Rule; @@ -38,8 +30,13 @@ import org.junit.experimental.categories.Category; import org.junit.rules.ExpectedException; +import com.gemstone.gemfire.test.junit.categories.UnitTest; + +/** + * Unit tests for {@link StatisticsImpl}. + */ @Category(UnitTest.class) -public class LocalStatisticsImplJUnitTest { +public class StatisticsImplTest { @Rule public ExpectedException thrown = ExpectedException.none(); diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/StatisticsMonitorJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/StatisticsMonitorTest.java similarity index 99% rename from geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/StatisticsMonitorJUnitTest.java rename to geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/StatisticsMonitorTest.java index b995451b8f28..bfd27c4f1a63 100755 --- a/geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/StatisticsMonitorJUnitTest.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/StatisticsMonitorTest.java @@ -36,7 +36,7 @@ * @since GemFire 7.0 */ @Category(UnitTest.class) -public class StatisticsMonitorJUnitTest { +public class StatisticsMonitorTest { private TestStatisticsManager manager; private SampleCollector sampleCollector; diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/TestStatArchiveWriter.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/TestStatArchiveWriter.java index 81d963e6becd..bc3be89da464 100755 --- a/geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/TestStatArchiveWriter.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/TestStatArchiveWriter.java @@ -18,10 +18,6 @@ import java.util.TimeZone; -import com.gemstone.gemfire.i18n.LogWriterI18n; -import com.gemstone.gemfire.internal.NanoTimer; -import com.gemstone.gemfire.internal.StatArchiveWriter; - /** * @since GemFire 7.0 */ @@ -32,7 +28,7 @@ public class TestStatArchiveWriter extends StatArchiveWriter { public static final String WRITER_OS_INFO = "Linux 2.6.18-262.el5"; public static final String WRITER_MACHINE_INFO = "i386 kuwait"; - public TestStatArchiveWriter(StatArchiveDescriptor archiveDescriptor, LogWriterI18n logger) { + public TestStatArchiveWriter(final StatArchiveDescriptor archiveDescriptor) { super(archiveDescriptor); initialize(WRITER_PREVIOUS_TIMESTAMP_NANOS); } diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/TestStatisticsManager.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/TestStatisticsManager.java index fbb3dce2828f..01c59f11fbd4 100755 --- a/geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/TestStatisticsManager.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/TestStatisticsManager.java @@ -18,24 +18,19 @@ import com.gemstone.gemfire.Statistics; import com.gemstone.gemfire.StatisticsType; -import com.gemstone.gemfire.internal.AbstractStatisticsFactory; -import com.gemstone.gemfire.internal.OsStatisticsFactory; -import com.gemstone.gemfire.internal.StatisticsManager; +import com.gemstone.gemfire.internal.statistics.platform.OsStatisticsFactory; /** * @since GemFire 7.0 */ -public class TestStatisticsManager extends AbstractStatisticsFactory - implements StatisticsManager, OsStatisticsFactory { +public class TestStatisticsManager extends AbstractStatisticsFactory implements StatisticsManager, OsStatisticsFactory { - public TestStatisticsManager(long id, String name, long startTime) { + public TestStatisticsManager(final long id, final String name, final long startTime) { super(id, name, startTime); } @Override - public Statistics createOsStatistics(StatisticsType type, String textId, - long numericId, int osStatFlags) { - // TODO ? + public Statistics createOsStatistics(final StatisticsType type, final String textId, final long numericId, final int osStatFlags) { return null; } } diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/TestStatisticsSampler.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/TestStatisticsSampler.java index 0905167f6150..b69d480538bd 100755 --- a/geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/TestStatisticsSampler.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/TestStatisticsSampler.java @@ -19,16 +19,16 @@ import java.util.List; import com.gemstone.gemfire.Statistics; -import com.gemstone.gemfire.internal.StatisticsManager; /** * @since GemFire 7.0 */ +@SuppressWarnings("unchecked") public class TestStatisticsSampler implements StatisticsSampler { private final StatisticsManager manager; - public TestStatisticsSampler(StatisticsManager manager) { + public TestStatisticsSampler(final StatisticsManager manager) { this.manager = manager; } @@ -39,20 +39,19 @@ public int getStatisticsModCount() { @Override public Statistics[] getStatistics() { - @SuppressWarnings("unchecked") - List statsList = (List)this.manager.getStatsList(); + List statsList = this.manager.getStatsList(); synchronized (statsList) { - return (Statistics[])statsList.toArray(new Statistics[statsList.size()]); + return statsList.toArray(new Statistics[statsList.size()]); } } @Override - public boolean waitForSample(long timeout) throws InterruptedException { + public boolean waitForSample(final long timeout) throws InterruptedException { return false; } @Override - public SampleCollector waitForSampleCollector(long timeout) throws InterruptedException { + public SampleCollector waitForSampleCollector(final long timeout) throws InterruptedException { return null; } } diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/ValueMonitorJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/ValueMonitorIntegrationTest.java similarity index 81% rename from geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/ValueMonitorJUnitTest.java rename to geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/ValueMonitorIntegrationTest.java index b671250151ad..9afbe2296d91 100755 --- a/geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/ValueMonitorJUnitTest.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/ValueMonitorIntegrationTest.java @@ -16,6 +16,7 @@ */ package com.gemstone.gemfire.internal.statistics; +import static com.gemstone.gemfire.test.dunit.Wait.*; import static org.junit.Assert.*; import java.io.File; @@ -30,16 +31,16 @@ import org.jmock.lib.legacy.ClassImposteriser; import org.junit.After; import org.junit.Before; +import org.junit.Rule; import org.junit.Test; import org.junit.experimental.categories.Category; +import org.junit.rules.TestName; import com.gemstone.gemfire.StatisticDescriptor; import com.gemstone.gemfire.Statistics; import com.gemstone.gemfire.StatisticsType; import com.gemstone.gemfire.internal.NanoTimer; -import com.gemstone.gemfire.internal.StatisticsManager; import com.gemstone.gemfire.internal.statistics.StatisticsNotification.Type; -import com.gemstone.gemfire.test.dunit.Wait; import com.gemstone.gemfire.test.dunit.WaitCriterion; import com.gemstone.gemfire.test.junit.categories.IntegrationTest; @@ -49,10 +50,13 @@ * @since GemFire 7.0 */ @Category(IntegrationTest.class) -public class ValueMonitorJUnitTest { +public class ValueMonitorIntegrationTest { private Mockery mockContext; - + + @Rule + public TestName testName = new TestName(); + @Before public void setUp() throws Exception { this.mockContext = new Mockery() {{ @@ -68,9 +72,9 @@ public void tearDown() throws Exception { @Test public void testAddRemoveListener() throws Exception { - final long startTime = System.currentTimeMillis(); - final List statsList = new ArrayList(); - final StatisticsManager mockStatisticsManager = this.mockContext.mock(StatisticsManager.class, "testAddRemoveListener$StatisticsManager"); + long startTime = System.currentTimeMillis(); + List statsList = new ArrayList(); + StatisticsManager mockStatisticsManager = this.mockContext.mock(StatisticsManager.class, testName.getMethodName() + "$StatisticsManager"); this.mockContext.checking(new Expectations() {{ allowing(mockStatisticsManager).getName(); will(returnValue("mockStatisticsManager")); @@ -84,7 +88,7 @@ public void testAddRemoveListener() throws Exception { will(returnValue(statsList)); }}); - final StatisticsSampler mockStatisticsSampler = this.mockContext.mock(StatisticsSampler.class, "testAddRemoveListener$StatisticsSampler"); + StatisticsSampler mockStatisticsSampler = this.mockContext.mock(StatisticsSampler.class, testName.getMethodName() + "$StatisticsSampler"); this.mockContext.checking(new Expectations() {{ allowing(mockStatisticsSampler).getStatisticsModCount(); will(returnValue(0)); @@ -92,7 +96,7 @@ public void testAddRemoveListener() throws Exception { will(returnValue(new Statistics[]{})); }}); - final StatArchiveHandlerConfig mockStatArchiveHandlerConfig = this.mockContext.mock(StatArchiveHandlerConfig.class, "testAddRemoveListener$StatArchiveHandlerConfig"); + StatArchiveHandlerConfig mockStatArchiveHandlerConfig = this.mockContext.mock(StatArchiveHandlerConfig.class, testName.getMethodName() + "$StatArchiveHandlerConfig"); this.mockContext.checking(new Expectations() {{ allowing(mockStatArchiveHandlerConfig).getArchiveFileName(); will(returnValue(new File(""))); @@ -114,12 +118,9 @@ public void testAddRemoveListener() throws Exception { SampleCollector sampleCollector = new SampleCollector(mockStatisticsSampler); sampleCollector.initialize(mockStatArchiveHandlerConfig, NanoTimer.getTime()); - final List notifications = new ArrayList(); - StatisticsListener listener = new StatisticsListener() { - @Override - public void handleNotification(StatisticsNotification notification) { - notifications.add(notification); - } + List notifications = new ArrayList<>(); + StatisticsListener listener = (final StatisticsNotification notification) -> { + notifications.add(notification); }; ValueMonitor monitor = new ValueMonitor(); @@ -152,15 +153,11 @@ public void handleNotification(StatisticsNotification notification) { @Test public void testValueMonitorListener() throws Exception { - final long startTime = System.currentTimeMillis(); - TestStatisticsManager manager = new TestStatisticsManager( - 1, - "ValueMonitorJUnitTest", - startTime); + long startTime = System.currentTimeMillis(); + TestStatisticsManager manager = new TestStatisticsManager(1, "ValueMonitorIntegrationTest", startTime); StatisticsSampler sampler = new TestStatisticsSampler(manager); - final StatArchiveHandlerConfig mockStatArchiveHandlerConfig = - this.mockContext.mock(StatArchiveHandlerConfig.class, "testFoo$StatArchiveHandlerConfig"); + StatArchiveHandlerConfig mockStatArchiveHandlerConfig = this.mockContext.mock(StatArchiveHandlerConfig.class, testName.getMethodName() + "$StatArchiveHandlerConfig"); this.mockContext.checking(new Expectations() {{ allowing(mockStatArchiveHandlerConfig).getArchiveFileName(); will(returnValue(new File(""))); @@ -198,12 +195,9 @@ public void testValueMonitorListener() throws Exception { st1_2.incInt("int_counter_2", 3); st1_2.incLong("long_counter_3", 4444444444L); - final List notifications = new ArrayList(); - StatisticsListener listener = new StatisticsListener() { - @Override - public void handleNotification(StatisticsNotification notification) { - notifications.add(notification); - } + List notifications = new ArrayList<>(); + StatisticsListener listener = (final StatisticsNotification notification) -> { + notifications.add(notification); }; ValueMonitor monitor = new ValueMonitor().addStatistics(st1_1); monitor.addListener(listener); @@ -212,8 +206,8 @@ public void handleNotification(StatisticsNotification notification) { long timeStamp = NanoTimer.getTime(); sampleCollector.sample(timeStamp); - - waitForNotification(notifications, 2*1000, 10, false); + + awaitAtLeastTimeoutOrUntilNotifications(notifications, 2 * 1000); assertEquals("Unexpected notifications: " + notifications, 1, notifications.size()); StatisticsNotification notification = notifications.remove(0); @@ -227,15 +221,15 @@ public void handleNotification(StatisticsNotification notification) { timeStamp += NanoTimer.millisToNanos(1000); sampleCollector.sample(timeStamp); - - waitForNotification(notifications, 2*1000, 10, false); + + awaitAtLeastTimeoutOrUntilNotifications(notifications, 2 * 1000); assertEquals("Unexpected notifications: " + notifications, 1, notifications.size()); notification = notifications.remove(0); assertEquals(StatisticsNotification.Type.VALUE_CHANGED, notification.getType()); int statCount = 0; - Map expectedValues = new HashMap(); + Map expectedValues = new HashMap<>(); expectedValues.put("double_counter_1", 1001.1001); expectedValues.put("int_counter_2", 4); expectedValues.put("long_counter_3", 3333333336L); @@ -252,8 +246,8 @@ public void handleNotification(StatisticsNotification notification) { timeStamp += NanoTimer.millisToNanos(1000); sampleCollector.sample(timeStamp); - - waitForNotification(notifications, 2*1000, 10, false); + + awaitAtLeastTimeoutOrUntilNotifications(notifications, 2 * 1000); assertTrue("Unexpected notifications: " + notifications, notifications.isEmpty()); // validate no notification occurs when only other stats are updated @@ -264,8 +258,8 @@ public void handleNotification(StatisticsNotification notification) { timeStamp += NanoTimer.millisToNanos(1000); sampleCollector.sample(timeStamp); - - waitForNotification(notifications, 2*1000, 10, false); + + awaitAtLeastTimeoutOrUntilNotifications(notifications, 2 * 1000); assertTrue("Unexpected notifications: " + notifications, notifications.isEmpty()); // validate notification only contains stats added to monitor @@ -277,15 +271,15 @@ public void handleNotification(StatisticsNotification notification) { timeStamp += NanoTimer.millisToNanos(1000); sampleCollector.sample(timeStamp); - - waitForNotification(notifications, 2*1000, 10, false); + + awaitAtLeastTimeoutOrUntilNotifications(notifications, 2 * 1000); assertEquals("Unexpected notifications: " + notifications, 1, notifications.size()); notification = notifications.remove(0); assertEquals(StatisticsNotification.Type.VALUE_CHANGED, notification.getType()); statCount = 0; - expectedValues = new HashMap(); + expectedValues = new HashMap<>(); expectedValues.put("int_counter_2", 104); for (StatisticId statId : notification) { @@ -309,7 +303,6 @@ public StatisticDescriptor getStatisticDescriptor() { public Statistics getStatistics() { return stats; } - }; } @@ -332,29 +325,33 @@ public Iterator iterator() { } @Override - public Iterator iterator(StatisticDescriptor statDesc) { + public Iterator iterator(final StatisticDescriptor statDesc) { return null; } @Override - public Iterator iterator(Statistics statistics) { + public Iterator iterator(final Statistics statistics) { return null; } @Override - public Iterator iterator(StatisticsType statisticsType) { + public Iterator iterator(final StatisticsType statisticsType) { return null; } @Override - public Number getValue(StatisticId statId) throws StatisticNotFoundException { + public Number getValue(final StatisticId statId) throws StatisticNotFoundException { return value; } - }; } - - private static void waitForNotification(final List notifications, long ms, long interval, boolean throwOnTimeout) { + + /** + * Wait for at least the specified time or until notifications is >0. + */ + private static void awaitAtLeastTimeoutOrUntilNotifications(final List notifications, final long timeoutMillis) { + long pollingIntervalMillis = 10; + boolean throwOnTimeout = false; WaitCriterion wc = new WaitCriterion() { @Override public boolean done() { @@ -365,6 +362,6 @@ public String description() { return "waiting for notification"; } }; - Wait.waitForCriterion(wc, ms, interval, throwOnTimeout); + waitForCriterion(wc, timeoutMillis, pollingIntervalMillis, throwOnTimeout); } } diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/stats50/AtomicStatsJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/stats50/AtomicStatsJUnitTest.java index 1fc1d23fc0e6..b87db464158e 100644 --- a/geode-core/src/test/java/com/gemstone/gemfire/internal/stats50/AtomicStatsJUnitTest.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/stats50/AtomicStatsJUnitTest.java @@ -21,7 +21,7 @@ import com.gemstone.gemfire.StatisticsType; import com.gemstone.gemfire.StatisticsTypeFactory; import com.gemstone.gemfire.distributed.DistributedSystem; -import com.gemstone.gemfire.internal.StatisticsTypeFactoryImpl; +import com.gemstone.gemfire.internal.statistics.StatisticsTypeFactoryImpl; import com.gemstone.gemfire.test.junit.categories.IntegrationTest; import org.junit.Test; import org.junit.experimental.categories.Category; diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/bean/stats/MemberLevelStatsJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/management/bean/stats/MemberLevelStatsJUnitTest.java index dcbbacacf823..5ad58dcfa7ef 100644 --- a/geode-core/src/test/java/com/gemstone/gemfire/management/bean/stats/MemberLevelStatsJUnitTest.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/management/bean/stats/MemberLevelStatsJUnitTest.java @@ -32,7 +32,7 @@ import com.gemstone.gemfire.distributed.internal.locks.DLockStats; import com.gemstone.gemfire.internal.NanoTimer; import com.gemstone.gemfire.internal.OSProcess; -import com.gemstone.gemfire.internal.VMStatsContract; +import com.gemstone.gemfire.internal.statistics.VMStatsContract; import com.gemstone.gemfire.internal.cache.CachePerfStats; import com.gemstone.gemfire.internal.cache.DiskStoreStats; import com.gemstone.gemfire.internal.cache.GemFireCacheImpl; diff --git a/geode-core/src/test/resources/com/gemstone/gemfire/internal/StatArchiveWriterReaderJUnitTest_testWriteAfterSamplingBegins_expected.gfs b/geode-core/src/test/resources/com/gemstone/gemfire/internal/statistics/StatArchiveWriterReaderJUnitTest_testWriteAfterSamplingBegins_expected.gfs similarity index 74% rename from geode-core/src/test/resources/com/gemstone/gemfire/internal/StatArchiveWriterReaderJUnitTest_testWriteAfterSamplingBegins_expected.gfs rename to geode-core/src/test/resources/com/gemstone/gemfire/internal/statistics/StatArchiveWriterReaderJUnitTest_testWriteAfterSamplingBegins_expected.gfs index 7fc826591e7f..ccd20b2dff51 100644 Binary files a/geode-core/src/test/resources/com/gemstone/gemfire/internal/StatArchiveWriterReaderJUnitTest_testWriteAfterSamplingBegins_expected.gfs and b/geode-core/src/test/resources/com/gemstone/gemfire/internal/statistics/StatArchiveWriterReaderJUnitTest_testWriteAfterSamplingBegins_expected.gfs differ diff --git a/geode-core/src/test/resources/com/gemstone/gemfire/internal/StatArchiveWriterReaderJUnitTest_testWriteWhenSamplingBegins_expected.gfs b/geode-core/src/test/resources/com/gemstone/gemfire/internal/statistics/StatArchiveWriterReaderJUnitTest_testWriteWhenSamplingBegins_expected.gfs similarity index 73% rename from geode-core/src/test/resources/com/gemstone/gemfire/internal/StatArchiveWriterReaderJUnitTest_testWriteWhenSamplingBegins_expected.gfs rename to geode-core/src/test/resources/com/gemstone/gemfire/internal/statistics/StatArchiveWriterReaderJUnitTest_testWriteWhenSamplingBegins_expected.gfs index 15a01b03a14f..fd1e77a30d96 100644 Binary files a/geode-core/src/test/resources/com/gemstone/gemfire/internal/StatArchiveWriterReaderJUnitTest_testWriteWhenSamplingBegins_expected.gfs and b/geode-core/src/test/resources/com/gemstone/gemfire/internal/statistics/StatArchiveWriterReaderJUnitTest_testWriteWhenSamplingBegins_expected.gfs differ diff --git a/geode-cq/src/main/java/com/gemstone/gemfire/cache/query/internal/cq/CqServiceVsdStats.java b/geode-cq/src/main/java/com/gemstone/gemfire/cache/query/internal/cq/CqServiceVsdStats.java index 3327909592b1..d1a703c9778c 100644 --- a/geode-cq/src/main/java/com/gemstone/gemfire/cache/query/internal/cq/CqServiceVsdStats.java +++ b/geode-cq/src/main/java/com/gemstone/gemfire/cache/query/internal/cq/CqServiceVsdStats.java @@ -23,15 +23,13 @@ import com.gemstone.gemfire.StatisticsFactory; import com.gemstone.gemfire.StatisticsType; import com.gemstone.gemfire.StatisticsTypeFactory; -import com.gemstone.gemfire.cache.Region; import com.gemstone.gemfire.cache.query.CqException; import com.gemstone.gemfire.cache.query.CqQuery; import com.gemstone.gemfire.cache.query.internal.DefaultQueryService; import com.gemstone.gemfire.internal.NanoTimer; -import com.gemstone.gemfire.internal.StatisticsTypeFactoryImpl; +import com.gemstone.gemfire.internal.statistics.StatisticsTypeFactoryImpl; import com.gemstone.gemfire.internal.cache.FilterProfile; import com.gemstone.gemfire.internal.cache.GemFireCacheImpl; -import com.gemstone.gemfire.internal.cache.LocalRegion; import com.gemstone.gemfire.internal.logging.LogService; /** diff --git a/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneIndexStats.java b/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneIndexStats.java index 4f89fa7925bd..220ae0e00c9d 100644 --- a/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneIndexStats.java +++ b/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneIndexStats.java @@ -28,7 +28,7 @@ import com.gemstone.gemfire.StatisticsType; import com.gemstone.gemfire.StatisticsTypeFactory; import com.gemstone.gemfire.internal.CopyOnWriteHashSet; -import com.gemstone.gemfire.internal.StatisticsTypeFactoryImpl; +import com.gemstone.gemfire.internal.statistics.StatisticsTypeFactoryImpl; public class LuceneIndexStats { // statistics type diff --git a/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/filesystem/FileSystemStats.java b/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/filesystem/FileSystemStats.java index ee668508f312..e6bbf0d7045c 100644 --- a/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/filesystem/FileSystemStats.java +++ b/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/filesystem/FileSystemStats.java @@ -26,7 +26,7 @@ import com.gemstone.gemfire.StatisticsFactory; import com.gemstone.gemfire.StatisticsType; import com.gemstone.gemfire.StatisticsTypeFactory; -import com.gemstone.gemfire.internal.StatisticsTypeFactoryImpl; +import com.gemstone.gemfire.internal.statistics.StatisticsTypeFactoryImpl; public class FileSystemStats { private static final StatisticsType statsType; diff --git a/geode-rebalancer/src/test/java/com/gemstone/gemfire/cache/util/AutoBalancerIntegrationJUnitTest.java b/geode-rebalancer/src/test/java/com/gemstone/gemfire/cache/util/AutoBalancerIntegrationJUnitTest.java index 5ab8d0e22204..cbd57eb685a7 100755 --- a/geode-rebalancer/src/test/java/com/gemstone/gemfire/cache/util/AutoBalancerIntegrationJUnitTest.java +++ b/geode-rebalancer/src/test/java/com/gemstone/gemfire/cache/util/AutoBalancerIntegrationJUnitTest.java @@ -23,7 +23,7 @@ import com.gemstone.gemfire.distributed.DistributedLockService; import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem; import com.gemstone.gemfire.distributed.internal.locks.DLockService; -import com.gemstone.gemfire.internal.HostStatSampler; +import com.gemstone.gemfire.internal.statistics.HostStatSampler; import com.gemstone.gemfire.internal.cache.GemFireCacheImpl; import com.gemstone.gemfire.test.junit.categories.IntegrationTest; import org.junit.After;