Allow sample rate of MAX_VALUE and add awaitInitialization method
Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/373f5e10 Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/373f5e10 Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/373f5e10 Branch: refs/heads/feature/GEODE-2012 Commit: 373f5e10c36c0ff21306f8fe03f717673c3136e7 Parents: cadc4f6 Author: Kirk Lund <[email protected]> Authored: Thu Oct 20 12:26:13 2016 -0700 Committer: Kirk Lund <[email protected]> Committed: Thu Oct 20 12:26:13 2016 -0700 ---------------------------------------------------------------------- .../internal/statistics/HostStatSampler.java | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/373f5e10/geode-core/src/main/java/org/apache/geode/internal/statistics/HostStatSampler.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/internal/statistics/HostStatSampler.java b/geode-core/src/main/java/org/apache/geode/internal/statistics/HostStatSampler.java index 020b5ab..2ec32e7 100644 --- a/geode-core/src/main/java/org/apache/geode/internal/statistics/HostStatSampler.java +++ b/geode-core/src/main/java/org/apache/geode/internal/statistics/HostStatSampler.java @@ -269,8 +269,10 @@ public abstract class HostStatSampler synchronized(HostStatSampler.class) { if (statThread != null) { try { - int msToWait = getSampleRate() + 100; - statThread.join(msToWait); + if (getSampleRate() < Integer.MAX_VALUE) { + int msToWait = getSampleRate() + 100; + statThread.join(msToWait); + } } catch (InterruptedException ex) { Thread.currentThread().interrupt(); } @@ -366,9 +368,18 @@ public abstract class HostStatSampler * @since GemFire 7.0 */ public final boolean waitForInitialization(long ms) throws InterruptedException { - return this.statSamplerInitializedLatch.await(ms); + return awaitInitialization(ms, TimeUnit.MILLISECONDS); } - + + /** + * Awaits the initialization of special statistics. + * + * @see #initSpecialStats + */ + public final boolean awaitInitialization(final long timeout, final TimeUnit unit) throws InterruptedException { + return this.statSamplerInitializedLatch.await(timeout, unit); + } + public final void changeArchive(File newFile) { this.sampleCollector.changeArchive(newFile, NanoTimer.getTime()); }
