geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kl...@apache.org
Subject [14/24] incubator-geode git commit: GEODE-1781: refactor internal statistics classes
Date Wed, 17 Aug 2016 23:11:03 GMT
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/11507012/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/HostStatSampler.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/HostStatSampler.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/HostStatSampler.java
new file mode 100644
index 0000000..d414d2c
--- /dev/null
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/HostStatSampler.java
@@ -0,0 +1,549 @@
+/*
+ * 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 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.platform.OsStatisticsFactory;
+import com.gemstone.gemfire.internal.util.concurrent.StoppableCountDownLatch;
+import org.apache.logging.log4j.Logger;
+
+import java.io.File;
+import java.net.UnknownHostException;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * HostStatSampler implements a thread which will monitor, sample, and archive
+ * statistics. It only has the common functionality that any sampler needs.
+
+ */
+public abstract class HostStatSampler 
+    implements Runnable, StatisticsSampler, StatArchiveHandlerConfig {
+
+  private static final Logger logger = LogService.getLogger();
+
+  public static final String TEST_FILE_SIZE_LIMIT_IN_KB_PROPERTY = DistributionConfig.GEMFIRE_PREFIX + "stats.test.fileSizeLimitInKB";
+  public static final String OS_STATS_DISABLED_PROPERTY = "osStatsDisabled";
+
+  protected static final String INITIALIZATION_TIMEOUT_PROPERTY = DistributionConfig.GEMFIRE_PREFIX + "statSamplerInitializationTimeout";
+  protected static final int INITIALIZATION_TIMEOUT_DEFAULT = 30000;
+  protected static final long INITIALIZATION_TIMEOUT_MILLIS = 
+      Long.getLong(INITIALIZATION_TIMEOUT_PROPERTY, INITIALIZATION_TIMEOUT_DEFAULT);
+  
+  /** 
+   * Used to check if the sampler thread wake-up is delayed, and log a warning if it is delayed by longer than 
+   * the amount of milliseconds specified by this property. The value of 0 disables the check. 
+   */
+  private static final long STAT_SAMPLER_DELAY_THRESHOLD = Long.getLong(DistributionConfig.GEMFIRE_PREFIX + "statSamplerDelayThreshold", 3000);
+  private static final long STAT_SAMPLER_DELAY_THRESHOLD_NANOS = NanoTimer.millisToNanos(STAT_SAMPLER_DELAY_THRESHOLD);
+  
+  private static final int MIN_MS_SLEEP = 1;
+  
+  private static final int WAIT_FOR_SLEEP_INTERVAL = 10;
+  
+  private static Thread statThread = null;
+
+  private volatile boolean stopRequested = false;
+  
+  private final boolean osStatsDisabled = Boolean.getBoolean(OS_STATS_DISABLED_PROPERTY);
+  private final boolean fileSizeLimitInKB;
+  private final StatSamplerStats samplerStats;
+  
+  private VMStatsContract vmStats;
+  private SampleCollector sampleCollector;
+
+  /**
+   * Used to signal thread that are waiting for the stat sampler to be initialized.
+   */
+  private final StoppableCountDownLatch statSamplerInitializedLatch;
+
+  private final CancelCriterion stopper;
+
+  private final CallbackSampler callbackSampler;
+  
+  protected HostStatSampler(CancelCriterion stopper, 
+                            StatSamplerStats samplerStats) {
+    this.stopper = stopper;
+    this.statSamplerInitializedLatch = new StoppableCountDownLatch(this.stopper, 1);
+    this.samplerStats = samplerStats;
+    this.fileSizeLimitInKB = Boolean.getBoolean(TEST_FILE_SIZE_LIMIT_IN_KB_PROPERTY);
+    this.callbackSampler = new CallbackSampler(stopper, samplerStats);
+  }
+  
+  public final StatSamplerStats getStatSamplerStats() {
+    return this.samplerStats;
+  }
+  
+  /**
+   * Returns the number of times a statistics resource has been add or deleted.
+   */
+  @Override
+  public final int getStatisticsModCount() {
+    return getStatisticsManager().getStatListModCount();
+  }
+
+  /**
+   * Returns an array of all the current statistic resource instances.
+   */
+  @Override
+  public final Statistics[] getStatistics() {
+    return getStatisticsManager().getStatistics();
+  }
+
+  /**
+   * Returns a unique id for the sampler's system.
+   */
+  @Override
+  public final long getSystemId() {
+    return getStatisticsManager().getId();
+  }
+
+  /**
+   * Returns the time this sampler's system was started.
+   */
+  @Override
+  public final long getSystemStartTime() {
+    return getStatisticsManager().getStartTime();
+  }
+
+  /**
+   * Returns the path to this sampler's system directory; if it has one.
+   */
+  @Override
+  public final String getSystemDirectoryPath() {
+    try {
+      return SocketCreator.getHostName(SocketCreator.getLocalHost());
+    } catch (UnknownHostException ignore) {
+      return "";
+    }
+  }
+
+  @Override
+  public boolean waitForSample(long timeout) throws InterruptedException {
+    final long endTime = System.currentTimeMillis() + timeout;
+    final int startSampleCount = this.samplerStats.getSampleCount();
+    while (System.currentTimeMillis() < endTime && 
+        this.samplerStats.getSampleCount() <= startSampleCount) {
+      Thread.sleep(WAIT_FOR_SLEEP_INTERVAL);
+    }
+    return this.samplerStats.getSampleCount() > startSampleCount;
+  }
+
+  @Override
+  public SampleCollector waitForSampleCollector(long timeout) throws InterruptedException {
+    final long endTime = System.currentTimeMillis() + timeout;
+    while (System.currentTimeMillis() < endTime && 
+        this.sampleCollector == null || !this.sampleCollector.isInitialized()) {
+      Thread.sleep(WAIT_FOR_SLEEP_INTERVAL);
+    }
+    return this.sampleCollector;
+  }
+  
+  /**
+   * This service's main loop
+   */
+  @Override
+  public final void run() {
+    NanoTimer timer = new NanoTimer();
+
+    final boolean isDebugEnabled_STATISTICS = logger.isTraceEnabled(LogMarker.STATISTICS);
+    if (isDebugEnabled_STATISTICS) {
+      logger.trace(LogMarker.STATISTICS, "HostStatSampler started");
+    }
+    boolean latchCountedDown = false;
+    try {
+      initSpecialStats();
+      
+      this.sampleCollector = new SampleCollector(this);
+      this.sampleCollector.initialize(this, NanoTimer.getTime());
+      
+      this.statSamplerInitializedLatch.countDown();
+      latchCountedDown = true;
+
+      timer.reset();
+      // subtract getNanoRate from lastTS to force a quick initial sample
+      long nanosLastTimeStamp = timer.getLastResetTime() - getNanoRate();
+      while (!stopRequested()) {
+        SystemFailure.checkFailure();
+        if (Thread.currentThread().isInterrupted()) {
+          break;
+        }
+        final long nanosBeforeSleep = timer.getLastResetTime();
+        final long nanosToDelay = nanosLastTimeStamp + getNanoRate();
+        delay(timer, nanosToDelay);
+        nanosLastTimeStamp = timer.getLastResetTime();
+        if (!stopRequested() && isSamplingEnabled()) {
+          final long nanosTimeStamp = timer.getLastResetTime();
+          final long nanosElapsedSleeping = nanosTimeStamp - nanosBeforeSleep;
+          checkElapsedSleepTime(nanosElapsedSleeping);
+          if (stopRequested()) break;
+          sampleSpecialStats(false);
+          if (stopRequested()) break;
+          checkListeners();
+          if (stopRequested()) break;
+          
+          this.sampleCollector.sample(nanosTimeStamp);
+          
+          final long nanosSpentWorking = timer.reset();
+          accountForTimeSpentWorking(nanosSpentWorking, nanosElapsedSleeping);
+        } else if (!stopRequested() && !isSamplingEnabled()) {
+          sampleSpecialStats(true); // fixes bug 42527
+        }
+      }
+    } 
+    catch (InterruptedException ex) {
+      // Silently exit
+    }
+    catch (CancelException ex) {
+      // Silently exit
+    }
+    catch (RuntimeException ex) {
+      logger.fatal(LogMarker.STATISTICS, ex.getMessage(), ex);
+      throw ex;
+    } 
+    catch (VirtualMachineError err) {
+      SystemFailure.initiateFailure(err);
+      // If this ever returns, rethrow the error.  We're poisoned
+      // now, so don't let this thread continue.
+      throw err;
+    }
+    catch (Error ex) {
+      // Whenever you catch Error or Throwable, you must also
+      // catch VirtualMachineError (see above).  However, there is
+      // _still_ a possibility that you are dealing with a cascading
+      // error condition, so you also need to check to see if the JVM
+      // is still usable:
+      SystemFailure.checkFailure();
+      logger.fatal(LogMarker.STATISTICS, ex.getMessage(), ex);
+      throw ex;
+    } finally {
+      try {
+      closeSpecialStats();
+      if (this.sampleCollector != null) {
+        this.sampleCollector.close();
+      }
+      } finally {
+        if (!latchCountedDown) {
+          // Make sure the latch gets counted down since
+          // other threads wait for this to indicate that 
+          // the sampler is initialized.
+          this.statSamplerInitializedLatch.countDown();
+        }
+      }
+      if (isDebugEnabled_STATISTICS) {
+        logger.trace(LogMarker.STATISTICS, "HostStatSampler stopped");
+      }
+    }
+  }
+
+  /**
+   * Starts the main thread for this service.
+   * @throws IllegalStateException if an instance of the {@link #statThread} is still running from a previous DistributedSystem.
+   */
+  public final void start() {
+    synchronized(HostStatSampler.class) { 
+      if (statThread != null) {
+        try {
+          int msToWait = getSampleRate() + 100;
+          statThread.join(msToWait);
+        } catch (InterruptedException ex) {
+          Thread.currentThread().interrupt();
+        } 
+        if (statThread.isAlive()) {
+          throw new IllegalStateException(LocalizedStrings.HostStatSampler_STATISTICS_SAMPLING_THREAD_IS_ALREADY_RUNNING_INDICATING_AN_INCOMPLETE_SHUTDOWN_OF_A_PREVIOUS_CACHE.toLocalizedString());
+        }
+      }  
+      ThreadGroup group = 
+        LoggingThreadGroup.createThreadGroup("StatSampler Threads");
+
+      this.callbackSampler.start(getStatisticsManager(), group, getSampleRate(), TimeUnit.MILLISECONDS);
+      statThread = new Thread(group, this);
+      statThread.setName(statThread.getName() + " StatSampler");
+      statThread.setPriority(Thread.MAX_PRIORITY);
+      statThread.setDaemon(true);
+      statThread.start();
+      // fix #46310 (race between management and sampler init) by waiting for init here
+      try {
+        waitForInitialization(INITIALIZATION_TIMEOUT_MILLIS);
+      } catch (InterruptedException e) {
+        Thread.currentThread().interrupt();
+      }
+    }
+  }
+  
+  /**
+   * Tell this service's main thread to terminate.
+   */
+  public final void stop() {
+    stop(true);
+  }
+  private final void stop(boolean interruptIfAlive) {
+    synchronized (HostStatSampler.class) {
+      this.callbackSampler.stop();
+      if ( statThread == null) {
+        return; 
+      }
+
+      this.stopRequested = true;
+      synchronized (this) {
+        this.notifyAll();
+      }
+      try {
+        statThread.join(5000);
+      } catch (InterruptedException ignore) {
+        //It is important that we shutdown so we'll continue trying for another 2 seconds
+        try {
+          statThread.join(2000);
+        } catch (InterruptedException ex) {
+        } finally {
+          Thread.currentThread().interrupt();
+        }
+      } finally {
+        if ( statThread.isAlive() ) {
+          if (interruptIfAlive) {
+            // It is still alive so interrupt the thread
+            statThread.interrupt();
+            stop(false);
+          } else {
+            logger.warn(LogMarker.STATISTICS, LocalizedMessage.create(LocalizedStrings.HostStatSampler_HOSTSTATSAMPLER_THREAD_COULD_NOT_BE_STOPPED));
+          }
+        } else {
+          this.stopRequested = false;
+          statThread = null;
+        }
+      }
+    }
+  }
+  
+  public final boolean isAlive() {
+    synchronized (HostStatSampler.class) {
+      return statThread != null && statThread.isAlive();
+    }
+  }
+
+  /**
+   * Waits for the special statistics to be initialized. For tests, please
+   * use {@link #waitForInitialization(long)} instead.
+   *
+   * @see #initSpecialStats
+   * @since GemFire 3.5
+   */
+  public final void waitForInitialization() throws InterruptedException {
+    this.statSamplerInitializedLatch.await();
+  }
+  
+  /**
+   * Waits for the special statistics to be initialized. This overridden
+   * version of {@link #waitForInitialization()} should always be used
+   * within tests.
+   *
+   * @see #initSpecialStats
+   * @since GemFire 7.0
+   */
+  public final boolean waitForInitialization(long ms) throws InterruptedException {
+    return this.statSamplerInitializedLatch.await(ms);
+  }
+  
+  public final void changeArchive(File newFile) {
+    this.sampleCollector.changeArchive(newFile, NanoTimer.getTime());
+  }
+  
+  /**
+   * Returns the <code>VMStatsContract</code> for this VM.
+   *
+   * @since GemFire 3.5
+   */
+  public final VMStatsContract getVMStats() {
+    return this.vmStats;
+  }
+
+  @Override
+  public String toString() {
+    final StringBuilder sb = new StringBuilder(getClass().getName());
+    sb.append("@").append(System.identityHashCode(this));
+    return sb.toString();
+  }
+
+  protected abstract void checkListeners();
+
+  /**
+   * Gets the sample rate in milliseconds
+   */
+  protected abstract int getSampleRate();
+  
+  /**
+   * Returns true if sampling is enabled.
+   */
+  public abstract boolean isSamplingEnabled();
+  
+  /**
+   * Returns the statistics manager using this sampler.
+   */
+  protected abstract StatisticsManager getStatisticsManager();
+
+  protected OsStatisticsFactory getOsStatisticsFactory() {
+    return null;
+  }
+  
+  protected void initProcessStats(long id) {
+    // do nothing by default
+  }
+  
+  protected void sampleProcessStats(boolean prepareOnly) {
+    // do nothing by default
+  }
+  
+  protected void closeProcessStats() {
+    // do nothing by default
+  }
+
+  protected long getSpecialStatsId() {
+    return getStatisticsManager().getId();
+  }
+  
+  protected final boolean fileSizeLimitInKB() {
+    return this.fileSizeLimitInKB;
+  }
+  
+  protected final boolean osStatsDisabled() {
+    return this.osStatsDisabled;
+  }
+  
+  protected final boolean stopRequested() {
+    return stopper.isCancelInProgress() || this.stopRequested;
+  }
+
+  public final SampleCollector getSampleCollector() {
+    return this.sampleCollector;
+  }
+  
+  /**
+   * Initialize any special sampler stats
+   */
+  private synchronized void initSpecialStats() {
+    // add a vm resource
+    long id = getSpecialStatsId();
+    this.vmStats = VMStatsContractFactory.create(getStatisticsManager(), id);
+    initProcessStats(id);
+  }
+
+  /**
+   * Closes down anything initialied by initSpecialStats.
+   */
+  private synchronized void closeSpecialStats() {
+    if (this.vmStats != null) {
+      this.vmStats.close();
+    }
+    closeProcessStats();
+  }
+  
+  /**
+   * Called when this sampler has spent some time working and wants
+   * it to be accounted for.
+   */
+  private void accountForTimeSpentWorking(long nanosSpentWorking, 
+                                          long nanosSpentSleeping) {
+    this.samplerStats.tookSample(
+        nanosSpentWorking, getStatisticsManager().getStatisticsCount(), nanosSpentSleeping);
+  }
+  
+  /**
+   * @param timer a NanoTimer used to compute the elapsed delay
+   * @param nanosToDelay the timestamp to delay until it is the current time
+   */
+  private void delay(NanoTimer timer, final long nanosToDelay) throws InterruptedException {
+    timer.reset();
+    long now = timer.getLastResetTime();
+    long remainingNanos = nanosToDelay - now;
+    if (remainingNanos <= 0) {
+      remainingNanos = NanoTimer.millisToNanos(MIN_MS_SLEEP);
+    }
+    while (remainingNanos > 0 && !stopRequested()) {
+      long ms = NanoTimer.nanosToMillis(remainingNanos);
+      if (ms <= 0) {
+        Thread.yield();
+      } else {
+        if (ms > MIN_MS_SLEEP) {
+          ms -= MIN_MS_SLEEP;
+        }
+        synchronized (this) {
+          if (stopRequested()) {
+            // check stopRequested inside the sync to prevent a race in which the wait misses the stopper's notify.
+            return;
+          }
+          this.wait(ms); // spurious wakeup ok
+        }
+      }
+      timer.reset();
+      now = timer.getLastResetTime();
+      remainingNanos = nanosToDelay - now;
+    }
+  }
+  
+  private long getNanoRate() {
+    return NanoTimer.millisToNanos(getSampleRate());
+  }
+  
+  /**
+   * Collect samples of any operating system statistics
+   * 
+   * @param prepareOnly
+   *          set to true if you only want to call prepareForSample
+   */
+  private void sampleSpecialStats(boolean prepareOnly) {
+    List<Statistics> statsList = getStatisticsManager().getStatsList();
+    for (Statistics s : statsList) {
+      if (stopRequested()) return;
+      if (s instanceof StatisticsImpl) {
+        ((StatisticsImpl)s).prepareForSample();
+      }
+    }
+
+    if (!prepareOnly && this.vmStats != null) {
+      if (stopRequested()) return;
+      this.vmStats.refresh();
+    }
+    sampleProcessStats(prepareOnly);
+  }
+
+  /**
+   * Check the elapsed sleep time upon wakeup, and log a warning if it is longer than the delay
+   * threshold.
+   * 
+   * @param elapsedSleepTime duration of sleep in nanoseconds
+   */
+  private void checkElapsedSleepTime(long elapsedSleepTime) {
+    if (STAT_SAMPLER_DELAY_THRESHOLD > 0) {
+      final long wakeupDelay = elapsedSleepTime - getNanoRate();
+      if (wakeupDelay > STAT_SAMPLER_DELAY_THRESHOLD_NANOS) {
+        this.samplerStats.incJvmPauses();
+        logger.warn(LogMarker.STATISTICS, LocalizedMessage.create(LocalizedStrings.HostStatSampler_STATISTICS_SAMPLING_THREAD_DETECTED_A_WAKEUP_DELAY_OF_0_MS_INDICATING_A_POSSIBLE_RESOURCE_ISSUE, NanoTimer.nanosToMillis(wakeupDelay)));
+      }
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/11507012/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/IgnoreResourceException.java
----------------------------------------------------------------------
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 2abf4b8..4e6e562 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 @@ import com.gemstone.gemfire.GemFireCheckedException;
  * Indicates that a Statistics resource instance with a null StatisticsType
  * should be ignored by the statistics sampler.
  * <p/>
- * Extracted from {@link com.gemstone.gemfire.internal.StatArchiveWriter}.
+ * Extracted from {@link StatArchiveWriter}.
  * 
  * @since GemFire 7.0
  */

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/11507012/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/LocalStatListener.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/LocalStatListener.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/LocalStatListener.java
new file mode 100644
index 0000000..0942e78
--- /dev/null
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/LocalStatListener.java
@@ -0,0 +1,40 @@
+/*
+ * 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;
+
+/**
+ * Implement this interface to receive call back when a stat value has changed.
+ * The listener has to be registered with statSampler. This can be done in the
+ * following manner:
+ * <code>
+ * InternalDistributedSystem internalSystem = (InternalDistributedSystem)cache
+ *                                                      .getDistributedSystem();
+ * final GemFireStatSampler sampler = internalSystem.getStatSampler();          
+ * sampler.addLocalStatListener(l, stats, statName);
+ * </code>
+ * 
+ *
+ */
+public interface LocalStatListener {
+  /**
+   * Invoked when the value of a statistic has changed
+   *
+   * @param value
+   *        The new value of the statistic 
+   */
+  public void statValueChanged( double value );
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/11507012/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/LocalStatisticsFactory.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/LocalStatisticsFactory.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/LocalStatisticsFactory.java
new file mode 100644
index 0000000..489894b
--- /dev/null
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/LocalStatisticsFactory.java
@@ -0,0 +1,103 @@
+/*
+ * 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 org.apache.logging.log4j.Logger;
+
+import com.gemstone.gemfire.CancelCriterion;
+import com.gemstone.gemfire.Statistics;
+import com.gemstone.gemfire.StatisticsFactory;
+import com.gemstone.gemfire.StatisticsType;
+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.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}.
+ * It can be used in contexts that do not have the GemFire product
+ * or in vm's that do not have a distributed system nor a gemfire connection.
+ *
+ */
+public class LocalStatisticsFactory extends AbstractStatisticsFactory
+    implements StatisticsFactory, StatisticsManager {
+
+  private static final Logger logger = LogService.getLogger();
+  
+  public static final String STATS_DISABLE_NAME_PROPERTY = "stats.disable";
+
+  private final SimpleStatSampler sampler;
+  private final boolean statsDisabled;
+
+  public LocalStatisticsFactory(CancelCriterion stopper) {
+    super(initId(), initName(), initStartTime());
+    
+    this.statsDisabled = Boolean.getBoolean(STATS_DISABLE_NAME_PROPERTY);
+    if (statsDisabled) {
+      this.sampler = null;
+      logger.info(LogMarker.STATISTICS, LocalizedMessage.create(LocalizedStrings.LocalStatisticsFactory_STATISTIC_COLLECTION_IS_DISABLED_USE_DSTATSDISABLEFALSE_TO_TURN_ON_STATISTICS));
+    } else if (stopper != null) {
+      this.sampler = new SimpleStatSampler(stopper, this);
+      this.sampler.start();
+    } else {
+      this.sampler = null;
+    }
+  }
+  
+  protected static long initId() {
+    return Thread.currentThread().hashCode();
+  }
+  
+  protected static String initName() {
+    return System.getProperty("stats.name", Thread.currentThread().getName());
+  }
+  
+  protected static long initStartTime() {
+    return System.currentTimeMillis();
+  }
+  
+ protected SimpleStatSampler getStatSampler() {
+    return this.sampler;
+  }
+
+  @Override
+  public void close() {
+    if (this.sampler != null) {
+      this.sampler.stop();
+    }
+  }
+  
+  @Override
+  protected Statistics createOsStatistics(StatisticsType type, String textId, long numericId, int osStatFlags) {
+    if (this.statsDisabled) {
+      return new DummyStatisticsImpl(type, textId, numericId);
+    }
+    return super.createOsStatistics(type, textId, numericId, osStatFlags);
+  }
+
+  @Override
+  public Statistics createAtomicStatistics(StatisticsType type, String textId, long numericId) {
+    if (this.statsDisabled) {
+      return new DummyStatisticsImpl(type, textId, numericId);
+    }
+    return super.createAtomicStatistics(type, textId, numericId);
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/11507012/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/LocalStatisticsImpl.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/LocalStatisticsImpl.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/LocalStatisticsImpl.java
new file mode 100644
index 0000000..4c8733a
--- /dev/null
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/LocalStatisticsImpl.java
@@ -0,0 +1,272 @@
+/*
+ * 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 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;
+
+/**
+ * An implementation of {@link Statistics} that stores its statistics
+ * in local java memory.
+ *
+ * @see <A href="package-summary.html#statistics">Package introduction</A>
+ *
+ *
+ * @since GemFire 3.0
+ *
+ */
+public class LocalStatisticsImpl extends StatisticsImpl {
+
+  /** In JOM Statistics, the values of the int statistics */
+  private final int[] intStorage;
+
+  /** In JOM Statistics, the values of the long statistics */
+  private final long[] longStorage;
+
+  /** In JOM Statistics, the values of the double statistics */
+  private final double[] doubleStorage;
+
+  /** An array containing the JOM object used to lock a int statistic when
+   * it is incremented. */
+  private transient final Object[] intLocks;
+
+  /** An array containing the JOM object used to lock a long statistic when
+   * it is incremented. */
+  private transient final Object[] longLocks;
+
+  /** An array containing the JOM object used to lock a double statistic when
+   * it is incremented. */
+  private transient final Object[] doubleLocks;
+
+  /** The StatisticsFactory that created this instance */
+  private final StatisticsManager dSystem;
+  
+  ///////////////////////  Constructors  ///////////////////////
+
+  /**
+   * Creates a new statistics instance of the given type
+   *
+   * @param type
+   *        A description of the statistics
+   * @param textId
+   *        Text that identifies this statistic when it is monitored
+   * @param numericId
+   *        A number that displayed when this statistic is monitored
+   * @param uniqueId
+   *        A number that uniquely identifies this instance
+   * @param atomicIncrements
+   *        Are increment operations atomic?  If only one application
+   *        thread increments a statistic, then a <code>false</code>
+   *        value may yield better performance.
+   * @param osStatFlags
+   *        Non-zero if stats require system calls to collect them; for internal use only
+   * @param system
+   *        The distributed system that determines whether or not these
+   *        statistics are stored (and collected) in GemFire shared
+   *        memory or in the local VM
+   */
+  public LocalStatisticsImpl(StatisticsType type, String textId,
+                             long numericId,
+                             long uniqueId,
+                             boolean atomicIncrements,
+                             int osStatFlags,
+                             StatisticsManager system) {
+    super(type, calcTextId(system, textId), calcNumericId(system, numericId),
+          uniqueId, osStatFlags);
+
+    this.dSystem = system;
+
+    StatisticsTypeImpl realType = (StatisticsTypeImpl)type;
+    int intCount = realType.getIntStatCount();
+    int longCount = realType.getLongStatCount();
+    int doubleCount = realType.getDoubleStatCount();
+
+    if (intCount > 0) {
+      this.intStorage = new int[intCount];
+      if (atomicIncrements) {
+        this.intLocks = new Object[intCount];
+        for (int i = 0; i < intLocks.length; i++) {
+          intLocks[i] = new Object();
+        }
+      } else {
+        this.intLocks = null;
+      }
+    } else {
+      this.intStorage = null;
+      this.intLocks = null;
+    }
+
+    if (longCount > 0) {
+      this.longStorage = new long[longCount];
+      if (atomicIncrements) {
+        this.longLocks = new Object[longCount];
+        for (int i = 0; i < longLocks.length; i++) {
+          longLocks[i] = new Object();
+        }
+      } else {
+        this.longLocks = null;
+      }
+    } else {
+      this.longStorage = null;
+      this.longLocks = null;
+    }
+
+    if (doubleCount > 0) {
+      this.doubleStorage = new double[doubleCount];
+      if (atomicIncrements) {
+        this.doubleLocks = new Object[doubleCount];
+        for (int i = 0; i < doubleLocks.length; i++) {
+          doubleLocks[i] = new Object();
+        }
+      } else {
+        this.doubleLocks = null;
+      }
+    } else {
+      this.doubleStorage = null;
+      this.doubleLocks = null;
+    }
+  }
+
+  //////////////////////  Static Methods  //////////////////////
+
+  private static long calcNumericId(StatisticsManager system, long userValue) {
+    if (userValue != 0) {
+      return userValue;
+    } else {
+      long result = OSProcess.getId(); // fix for bug 30239
+      if (result == 0) {
+        if (system != null) {
+          result = system.getId();
+        }
+      }
+      return result;
+    }
+  }
+
+  private static String calcTextId(StatisticsManager system, String userValue) {
+    if (userValue != null && !userValue.equals("")) {
+      return userValue;
+    } else {
+      if (system != null) {
+        return system.getName();
+      } else {
+        return "";
+      }
+    }
+  }
+
+  //////////////////////  Instance Methods  //////////////////////
+
+  @Override
+  public final boolean isAtomic() {
+    return intLocks != null || longLocks != null || doubleLocks != null;
+  }
+
+  @Override
+  public void close() {
+    super.close();
+    if (this.dSystem != null) {
+      dSystem.destroyStatistics(this);
+    }
+  }
+
+  ////////////////////////  store() Methods  ///////////////////////
+
+  @Override
+  protected final void _setInt(int offset, int value) {
+    this.intStorage[offset] = value;
+  }
+
+  @Override
+  protected final void _setLong(int offset, long value) {
+    this.longStorage[offset] = value;
+  }
+
+  @Override
+  protected final void _setDouble(int offset, double value) {
+    this.doubleStorage[offset] = value;
+  }
+
+  ///////////////////////  get() Methods  ///////////////////////
+
+  @Override
+  protected final int _getInt(int offset) {
+    return this.intStorage[offset];
+  }
+
+  @Override
+  protected final long _getLong(int offset) {
+    return this.longStorage[offset];
+  }
+
+  @Override
+  protected final double _getDouble(int offset) {
+    return this.doubleStorage[offset];
+  }
+
+  ////////////////////////  inc() Methods  ////////////////////////
+
+  @Override
+  protected final void _incInt(int offset, int delta) {
+    if (this.intLocks != null) {
+      synchronized (this.intLocks[offset]) {
+        this.intStorage[offset] += delta;
+      }
+    } else {
+      this.intStorage[offset] += delta;
+    }
+  }
+
+  @Override
+  protected final void _incLong(int offset, long delta) {
+    if (this.longLocks != null) {
+      synchronized (this.longLocks[offset]) {
+        this.longStorage[offset] += delta;
+      }
+    } else {
+      this.longStorage[offset] += delta;
+    }
+  }
+
+  @Override
+  protected final void _incDouble(int offset, double delta) {
+    if (this.doubleLocks != null) {
+      synchronized (this.doubleLocks[offset]) {
+        this.doubleStorage[offset] += delta;
+      }
+    } else {
+      this.doubleStorage[offset] += delta;
+    }
+  }
+
+  /////////////////// internal package methods //////////////////
+
+  final int[] _getIntStorage() {
+    return this.intStorage;
+  }
+  final long[] _getLongStorage() {
+    return this.longStorage;
+  }
+  final double[] _getDoubleStorage() {
+    return this.doubleStorage;
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/11507012/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/ResourceInstance.java
----------------------------------------------------------------------
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 0de95e2..6d63d3c 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 @@ import com.gemstone.gemfire.Statistics;
  * instances depending on the statistics type. The ResourceInstance holds
  * an array of the latest stat values.
  * <p/>
- * Extracted from {@link com.gemstone.gemfire.internal.StatArchiveWriter}.
+ * Extracted from {@link StatArchiveWriter}.
  * 
  * @since GemFire 7.0
  */

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/11507012/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/ResourceType.java
----------------------------------------------------------------------
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 d401969..fcdc1a0 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 @@ import com.gemstone.gemfire.StatisticsType;
  * each ResourceInstance. The ResourceType holds an array of 
  * StatisticDescriptors for its StatisticsType.
  * <p/>
- * Extracted from {@link com.gemstone.gemfire.internal.StatArchiveWriter}.
+ * Extracted from {@link StatArchiveWriter}.
  *  
  * @since GemFire 7.0
  */

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/11507012/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/SimpleStatSampler.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/SimpleStatSampler.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/SimpleStatSampler.java
new file mode 100644
index 0000000..599d42c
--- /dev/null
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/SimpleStatSampler.java
@@ -0,0 +1,112 @@
+/*
+ * 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 java.io.File;
+
+import org.apache.logging.log4j.Logger;
+
+import com.gemstone.gemfire.CancelCriterion;
+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;
+
+/**
+ * SimpleStatSampler is a functional implementation of HostStatSampler
+ * that samples statistics stored in local java memory and does not
+ * require any native code or additional GemFire features.
+ * <p>
+ * The StatisticsManager may be implemented by LocalStatisticsFactory and does
+ * not require a GemFire connection.
+
+ */
+public class SimpleStatSampler extends HostStatSampler {
+
+  private static final Logger logger = LogService.getLogger();
+  
+  public static final String ARCHIVE_FILE_NAME_PROPERTY = "stats.archive-file";
+  public static final String FILE_SIZE_LIMIT_PROPERTY = "stats.file-size-limit";
+  public static final String DISK_SPACE_LIMIT_PROPERTY = "stats.disk-space-limit";
+  public static final String SAMPLE_RATE_PROPERTY = "stats.sample-rate";
+  
+  public static final String DEFAULT_ARCHIVE_FILE_NAME = "stats.gfs";
+  public static final long DEFAULT_FILE_SIZE_LIMIT = 0;
+  public static final long DEFAULT_DISK_SPACE_LIMIT = 0;
+  public static final int DEFAULT_SAMPLE_RATE = 1000;
+  
+  private final File archiveFileName = new File(System.getProperty(ARCHIVE_FILE_NAME_PROPERTY, DEFAULT_ARCHIVE_FILE_NAME));
+  private final long archiveFileSizeLimit = Long.getLong(FILE_SIZE_LIMIT_PROPERTY, DEFAULT_FILE_SIZE_LIMIT).longValue() * (1024*1024);
+  private final long archiveDiskSpaceLimit = Long.getLong(DISK_SPACE_LIMIT_PROPERTY, DEFAULT_DISK_SPACE_LIMIT).longValue() * (1024*1024);
+  private final int sampleRate = Integer.getInteger(SAMPLE_RATE_PROPERTY, DEFAULT_SAMPLE_RATE).intValue();
+
+  private final StatisticsManager sm;
+
+  public SimpleStatSampler(CancelCriterion stopper, StatisticsManager sm) {
+    super(stopper, new StatSamplerStats(sm, sm.getId()));
+    this.sm = sm;
+    logger.info(LogMarker.STATISTICS, LocalizedMessage.create(LocalizedStrings.SimpleStatSampler_STATSSAMPLERATE_0, getSampleRate()));
+  }
+
+  @Override
+  protected void checkListeners() {
+    // do nothing
+  }
+  
+  @Override
+  public File getArchiveFileName() {
+    return this.archiveFileName;
+  }
+  
+  @Override
+  public long getArchiveFileSizeLimit() {
+    if (fileSizeLimitInKB()) {
+      return this.archiveFileSizeLimit / 1024;
+    } else {
+      return this.archiveFileSizeLimit;
+    }
+  }
+  
+  @Override
+  public long getArchiveDiskSpaceLimit() {
+    if (fileSizeLimitInKB()) {
+      return this.archiveDiskSpaceLimit / 1024;
+    } else {
+      return this.archiveDiskSpaceLimit;
+    }
+  }
+  
+  @Override
+  public String getProductDescription() {
+    return "Unknown product";
+  }
+
+  @Override
+  protected StatisticsManager getStatisticsManager() {
+    return this.sm;
+  }
+  
+  @Override
+  protected int getSampleRate() {
+    return this.sampleRate;
+  }
+  
+  @Override
+  public boolean isSamplingEnabled() {
+    return true;
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/11507012/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/StatArchiveDescriptor.java
----------------------------------------------------------------------
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 6d6624a..54d6af0 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 @@ package com.gemstone.gemfire.internal.statistics;
 
 /**
  * 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.
  * <p/>
  * This is a constructor parameter object for {@link 
- * com.gemstone.gemfire.internal.StatArchiveWriter}. 
+ * StatArchiveWriter}.
  * <p/>
  * {@link StatArchiveDescriptor.Builder} is used for constructing instances
  * instead of a constructor with many similar parameters (ie, multiple Strings

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/11507012/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/StatArchiveFormat.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/StatArchiveFormat.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/StatArchiveFormat.java
new file mode 100644
index 0000000..4651b5d
--- /dev/null
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/StatArchiveFormat.java
@@ -0,0 +1,197 @@
+/*
+ * 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;
+
+/**
+ * StatArchiveFormat defines constants related to the statistic archive
+ * file format.
+ */
+public interface StatArchiveFormat {
+  /**
+   * ARCHIVE_VERSION identifies the format of the contents of the archive.
+   * It should be changed any time an incompatible change is made.
+   * Its current value is <code>3</code>.
+   * <p>
+   * <ol>
+   * <li> Changed from 2 to 3 with addition of <code>RESOURCE_INSTANCE_INITIALIZE_TOKEN</code>
+   * <li> Changed from 3 to 4 with addition of largerBetter boolean in statistic descriptor
+   * </ol>
+   */
+  public static final byte ARCHIVE_VERSION=4;
+
+  /**
+   * Token consists of a timestamp and any statistic value changes.
+   */
+  public static final byte SAMPLE_TOKEN=0;
+  /**
+   * Token defines a new resource type.
+   */
+  public static final byte RESOURCE_TYPE_TOKEN=1;
+  /**
+   * Token defines a new resource instance.
+   */
+  public static final byte RESOURCE_INSTANCE_CREATE_TOKEN=2;
+  /**
+   * Token notes that a previous resource instance no longer exists
+   * and thus will have any more samples of its statistic values taken.
+   */
+  public static final byte RESOURCE_INSTANCE_DELETE_TOKEN=3;
+  /**
+   * Token defines a new resource instance with initial data.
+   */
+  public static final byte RESOURCE_INSTANCE_INITIALIZE_TOKEN=4;
+  /**
+   * Token defines a new archive and provides some global information
+   * about the environment the archive was created in.
+   */
+  public static final byte HEADER_TOKEN=77;
+
+  /**
+   * The value used to signal the end of a list of resource instances.
+   */
+  public static final int ILLEGAL_RESOURCE_INST_ID=-1;
+  /**
+   * The maximum value a resource inst id can have and still be stored
+   * in the archive as an unsigned byte.
+   */
+  public static final int MAX_BYTE_RESOURCE_INST_ID=252;
+  /**
+   * Used to say that the next two bytes contain the resource inst id
+   * as an unsigned short.
+   */
+  public static final int SHORT_RESOURCE_INST_ID_TOKEN=253;
+  /**
+   * Used to say that the next four bytes contain the resource inst id
+   * as an int.
+   */
+  public static final int INT_RESOURCE_INST_ID_TOKEN=254;
+  /**
+   * Used to say that the current byte represents the ILLEGAL_RESOURCE_INST_ID.
+   */
+  public static final int ILLEGAL_RESOURCE_INST_ID_TOKEN=255;
+  /**
+   * The maximum value a resource inst id can have and still be stored
+   * in the archive as an unsigned short.
+   */
+  public static final int MAX_SHORT_RESOURCE_INST_ID=65535;
+  /**
+   * The value used to signal the end of a list of statistic samples.
+   */
+  public static final int ILLEGAL_STAT_OFFSET=255;
+
+  /**
+   * The maximum value a timestamp can have and still be stored
+   * in the archive as an unsigned short.
+   */
+  public static final int MAX_SHORT_TIMESTAMP=65534;
+  /**
+   * Means the next 4 bytes contain the timestamp as an int.
+   */
+  public static final int INT_TIMESTAMP_TOKEN=65535;
+
+  /**
+   * The maximum value a compact value can have and still be stored
+   * in the archive as one byte.
+   */
+  public static final int MAX_1BYTE_COMPACT_VALUE=Byte.MAX_VALUE;
+  /**
+   * The minimum value a compact value can have and still be stored
+   * in the archive as one byte.
+   */
+  public static final int MIN_1BYTE_COMPACT_VALUE=Byte.MIN_VALUE+7;
+  /**
+   * The maximum value a compact value can have and still be stored
+   * in the archive as two bytes.
+   */
+  public static final int MAX_2BYTE_COMPACT_VALUE=Short.MAX_VALUE;
+  /**
+   * The minimum value a compact value can have and still be stored
+   * in the archive as two bytes.
+   */
+  public static final int MIN_2BYTE_COMPACT_VALUE=Short.MIN_VALUE;
+
+  /**
+   * Means the next 2 bytes hold the compact value's data.
+   */
+  public static final int COMPACT_VALUE_2_TOKEN=Byte.MIN_VALUE;
+  /**
+   * Means the next 3 bytes hold the compact value's data.
+   */
+  public static final int COMPACT_VALUE_3_TOKEN=Byte.MIN_VALUE+1;
+  /**
+   * Means the next 4 bytes hold the compact value's data.
+   */
+  public static final int COMPACT_VALUE_4_TOKEN=Byte.MIN_VALUE+2;
+  /**
+   * Means the next 5 bytes hold the compact value's data.
+   */
+  public static final int COMPACT_VALUE_5_TOKEN=Byte.MIN_VALUE+3;
+  /**
+   * Means the next 6 bytes hold the compact value's data.
+   */
+  public static final int COMPACT_VALUE_6_TOKEN=Byte.MIN_VALUE+4;
+  /**
+   * Means the next 7 bytes hold the compact value's data.
+   */
+  public static final int COMPACT_VALUE_7_TOKEN=Byte.MIN_VALUE+5;
+  /**
+   * Means the next 8 bytes hold the compact value's data.
+   */
+  public static final int COMPACT_VALUE_8_TOKEN=Byte.MIN_VALUE+6;
+
+  /**
+   * Statistic represents a <code>boolean</code> java primitive.
+   */
+  public static final int BOOLEAN_CODE = 1;
+  /**
+   * Statistic represents a <code>char</code> java primitive.
+   */
+  public static final int CHAR_CODE = 2;
+  /**
+   * Statistic represents a <code>char</code> java primitive.
+   */
+  public static final int WCHAR_CODE = 12;
+  /**
+   * Statistic represents a <code>byte</code> java primitive.
+   */
+  public static final int BYTE_CODE = 3;
+  /**
+   * Statistic represents a <code>short</code> java primitive.
+   */
+  public static final int SHORT_CODE = 4;
+  /**
+   * Statistic represents a <code>int</code> java primitive.
+   */
+  public static final int INT_CODE = 5;
+  /**
+   * Statistic represents a <code>long</code> java primitive.
+   */
+  public static final int LONG_CODE = 6;
+  /**
+   * Statistic represents a <code>float</code> java primitive.
+   */
+  public static final int FLOAT_CODE = 7;
+  /**
+   * Statistic represents a <code>double</code> java primitive.
+   */
+  public static final int DOUBLE_CODE = 8;
+  /**
+   * Number of nanoseconds in one millisecond
+   */
+  public static final long NANOS_PER_MILLI = 1000000;
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/11507012/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/StatArchiveHandler.java
----------------------------------------------------------------------
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 e686ad6..fc9030c 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 org.apache.logging.log4j.Logger;
 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.LogWriterAppenders;
 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}.
  * <p/>
  * 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 class StatArchiveHandler implements SampleHandler {
   }
   
   /**
-   * Closes any {@link com.gemstone.gemfire.internal.StatArchiveWriter} 
+   * Closes any {@link StatArchiveWriter}
    * currently in use by this handler.
    * @throws GemFireException
    */

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/11507012/geode-core/src/main/java/com/gemstone/gemfire/internal/statistics/StatArchiveHandlerConfig.java
----------------------------------------------------------------------
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 dd46013..ea07827 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 @@ import java.io.File;
  * Defines the contract enabling the {@link StatArchiveHandler} to retrieve
  * configuration details (some of which may change at runtime).
  * <p/>
- * Implemented by {@link com.gemstone.gemfire.internal.HostStatSampler}.
+ * Implemented by {@link HostStatSampler}.
 
  * @since GemFire 7.0
  * @see com.gemstone.gemfire.distributed.internal.RuntimeDistributionConfigImpl


Mime
View raw message