incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amccu...@apache.org
Subject [4/7] git commit: Moved the old metrics class to gui project, will refactor and delete in future.
Date Sun, 31 Mar 2013 15:10:56 GMT
Moved the old metrics class to gui project, will refactor and delete in future.


Project: http://git-wip-us.apache.org/repos/asf/incubator-blur/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-blur/commit/77ea8b85
Tree: http://git-wip-us.apache.org/repos/asf/incubator-blur/tree/77ea8b85
Diff: http://git-wip-us.apache.org/repos/asf/incubator-blur/diff/77ea8b85

Branch: refs/heads/0.1.5
Commit: 77ea8b85439d9beffc97dd5d91615b98ed10fc71
Parents: 36b7784
Author: Aaron McCurry <amccurry@gmail.com>
Authored: Sun Mar 31 11:08:32 2013 -0400
Committer: Aaron McCurry <amccurry@gmail.com>
Committed: Sun Mar 31 11:08:32 2013 -0400

----------------------------------------------------------------------
 .../main/java/org/apache/blur/gui/HeapMetrics.java |   86 +++++++
 .../org/apache/blur/gui/LiveMetricsServlet.java    |    3 -
 .../java/org/apache/blur/gui/QueryMetrics.java     |  180 +++++++++++++++
 .../org/apache/blur/gui/SystemLoadMetrics.java     |   72 ++++++
 .../java/org/apache/blur/metrics/HeapMetrics.java  |   86 -------
 .../java/org/apache/blur/metrics/QueryMetrics.java |  180 ---------------
 .../org/apache/blur/metrics/SystemLoadMetrics.java |   72 ------
 7 files changed, 338 insertions(+), 341 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/77ea8b85/src/blur-gui/src/main/java/org/apache/blur/gui/HeapMetrics.java
----------------------------------------------------------------------
diff --git a/src/blur-gui/src/main/java/org/apache/blur/gui/HeapMetrics.java b/src/blur-gui/src/main/java/org/apache/blur/gui/HeapMetrics.java
new file mode 100644
index 0000000..4901128
--- /dev/null
+++ b/src/blur-gui/src/main/java/org/apache/blur/gui/HeapMetrics.java
@@ -0,0 +1,86 @@
+package org.apache.blur.gui;
+
+import java.io.PrintWriter;
+import java.lang.management.ManagementFactory;
+import java.lang.management.MemoryUsage;
+import java.util.Timer;
+import java.util.TimerTask;
+import java.util.concurrent.TimeUnit;
+
+public class HeapMetrics extends TimerTask {
+
+  private static final double ONE_GIG = 1024 * 1024 * 1024;
+  private final int sampleSize = (int) TimeUnit.MINUTES.toSeconds(10);
+  private final Timer timer;
+  private final long period = TimeUnit.SECONDS.toMillis(1);
+  private final long[] heapMemoryUsageUsedHistory = new long[sampleSize];
+  private final long[] heapMemoryUsageCommittedHistory = new long[sampleSize];
+  private final long[] timestamp = new long[sampleSize];
+  private volatile static HeapMetrics heapMetrics;
+  private volatile int position = 0;
+
+  public static synchronized HeapMetrics getInstance() {
+    if (heapMetrics == null) {
+      heapMetrics = new HeapMetrics();
+    }
+    return heapMetrics;
+  }
+
+  private HeapMetrics() {
+    timer = new Timer("HeapMetrics", true);
+    timer.scheduleAtFixedRate(this, period, period);
+  }
+
+  @Override
+  public void run() {
+    synchronized (this) {
+      if (position >= sampleSize) {
+        position = 0;
+      }
+      MemoryUsage heapMemoryUsage = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage();
+      setValue(heapMemoryUsage.getUsed(), heapMemoryUsageUsedHistory);
+      setValue(heapMemoryUsage.getCommitted(), heapMemoryUsageCommittedHistory);
+      setValue(System.currentTimeMillis(), timestamp);
+      position++;
+    }
+  }
+
+  private void setValue(long value, long[] history) {
+    history[position] = value;
+  }
+
+  public void writeJson(PrintWriter out) {
+    synchronized (this) {
+      out.print("{\"labels\":[");
+      out.print("{\"name\":\"used\",\"style\":{\"stroke\":\"RoyalBlue\"}},");
+      out.print("{\"name\":\"committed\",\"style\":{\"stroke\":\"Red\"}},");
+      out.print("],\"data\":[");
+      int p = position;
+      boolean comma = false;
+      for (int i = 0; i < sampleSize; i++, p++) {
+        if (p >= sampleSize) {
+          p = 0;
+        }
+        double used = ((double) heapMemoryUsageUsedHistory[p]) / ONE_GIG;
+        double committed = ((double) heapMemoryUsageCommittedHistory[p]) / ONE_GIG;
+
+        long t = timestamp[p];
+        if (t == 0) {
+          continue;
+        }
+        if (comma) {
+          out.print(",");
+        }
+        out.print("{\"used\":");
+        out.print(used);
+        out.print(",\"committed\":");
+        out.print(committed);
+        out.print(",\"recordTime\":");
+        out.print(t);
+        out.print('}');
+        comma = true;
+      }
+      out.print("]}");
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/77ea8b85/src/blur-gui/src/main/java/org/apache/blur/gui/LiveMetricsServlet.java
----------------------------------------------------------------------
diff --git a/src/blur-gui/src/main/java/org/apache/blur/gui/LiveMetricsServlet.java b/src/blur-gui/src/main/java/org/apache/blur/gui/LiveMetricsServlet.java
index 295f7c7..945755e 100644
--- a/src/blur-gui/src/main/java/org/apache/blur/gui/LiveMetricsServlet.java
+++ b/src/blur-gui/src/main/java/org/apache/blur/gui/LiveMetricsServlet.java
@@ -24,9 +24,6 @@ import javax.servlet.http.HttpServlet;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
-import org.apache.blur.metrics.HeapMetrics;
-import org.apache.blur.metrics.QueryMetrics;
-import org.apache.blur.metrics.SystemLoadMetrics;
 
 public class LiveMetricsServlet extends HttpServlet {
 

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/77ea8b85/src/blur-gui/src/main/java/org/apache/blur/gui/QueryMetrics.java
----------------------------------------------------------------------
diff --git a/src/blur-gui/src/main/java/org/apache/blur/gui/QueryMetrics.java b/src/blur-gui/src/main/java/org/apache/blur/gui/QueryMetrics.java
new file mode 100644
index 0000000..05ddcae
--- /dev/null
+++ b/src/blur-gui/src/main/java/org/apache/blur/gui/QueryMetrics.java
@@ -0,0 +1,180 @@
+package org.apache.blur.gui;
+
+import java.io.PrintWriter;
+import java.util.Timer;
+import java.util.TimerTask;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicLong;
+
+public class QueryMetrics extends TimerTask {
+
+  private final int sampleSize = (int) TimeUnit.MINUTES.toSeconds(10);
+  private final AtomicLong _queryCount = new AtomicLong();
+  private final AtomicLong _queryTime = new AtomicLong();
+  private final AtomicLong _queryExceptionCount = new AtomicLong();
+  private final AtomicLong _dataFetchCount = new AtomicLong();
+  private final AtomicLong _dataFetchTime = new AtomicLong();
+  private final AtomicLong _dataFetchRecordCount = new AtomicLong();
+  private final AtomicLong _dataMutateCount = new AtomicLong();
+  private final AtomicLong _dataMutateTime = new AtomicLong();
+  private final AtomicLong _dataMutateRecordCount = new AtomicLong();
+  private final Timer timer;
+  private final long period = TimeUnit.SECONDS.toMillis(1);
+  private final double[] _queryRate = new double[sampleSize];
+  private final double[] _queryResponse = new double[sampleSize];
+  private final double[] _queryExceptionRate = new double[sampleSize];
+  private final double[] _fetchRate = new double[sampleSize];
+  private final double[] _fetchResponse = new double[sampleSize];
+  private final double[] _fetchRecordRate = new double[sampleSize];
+  private final double[] _mutateRate = new double[sampleSize];
+  private final double[] _mutateResponse = new double[sampleSize];
+  private final double[] _mutateRecordRate = new double[sampleSize];
+  private final long[] timestamp = new long[sampleSize];
+  private volatile static QueryMetrics instance;
+  private volatile int position;
+
+  public static synchronized QueryMetrics getInstance() {
+    if (instance == null) {
+      instance = new QueryMetrics();
+    }
+    return instance;
+  }
+
+  private QueryMetrics() {
+    timer = new Timer("QueryMetrics", true);
+    timer.scheduleAtFixedRate(this, period, period);
+  }
+
+  @Override
+  public void run() {
+    synchronized (this) {
+      if (position >= sampleSize) {
+        position = 0;
+      }
+      long queryCount = _queryCount.getAndSet(0);
+      long queryTime = _queryTime.getAndSet(0);
+      long queryExceptionCount = _queryExceptionCount.getAndSet(0);
+
+      long dataFetchCount = _dataFetchCount.getAndSet(0);
+      long dataFetchTime = _dataFetchTime.getAndSet(0);
+      long dataFetchRecordCount = _dataFetchRecordCount.getAndSet(0);
+
+      long dataMutateCount = _dataMutateCount.getAndSet(0);
+      long dataMutateTime = _dataMutateTime.getAndSet(0);
+      long dataMutateRecordCount = _dataMutateRecordCount.getAndSet(0);
+
+      _queryRate[position] = queryCount;
+      _queryResponse[position] = TimeUnit.NANOSECONDS.toMillis(queryTime) / (double) queryCount;
+
+      _queryExceptionRate[position] = queryExceptionCount;
+
+      _fetchRate[position] = dataFetchCount;
+      _fetchResponse[position] = TimeUnit.NANOSECONDS.toMillis(dataFetchTime) / (double)
dataFetchCount;
+      _fetchRecordRate[position] = dataFetchRecordCount;
+
+      _mutateRate[position] = dataMutateCount;
+      _mutateResponse[position] = TimeUnit.NANOSECONDS.toMillis(dataMutateTime) / (double)
dataMutateCount;
+      _mutateRecordRate[position] = dataMutateRecordCount;
+
+      timestamp[position] = System.currentTimeMillis();
+      position++;
+    }
+  }
+
+  public void recordQuery(long totalTimeNs) {
+    _queryCount.incrementAndGet();
+    _queryTime.addAndGet(totalTimeNs);
+  }
+
+  public void recordQueryExceptions() {
+    _queryExceptionCount.incrementAndGet();
+  }
+
+  public void recordDataFetch(long totalTimeNs, long records) {
+    _dataFetchCount.incrementAndGet();
+    _dataFetchTime.addAndGet(totalTimeNs);
+    _dataFetchRecordCount.addAndGet(records);
+  }
+
+  public void recordDataMutate(long totalTimeNs, long records) {
+    _dataMutateCount.incrementAndGet();
+    _dataMutateTime.addAndGet(totalTimeNs);
+    _dataMutateRecordCount.addAndGet(records);
+  }
+
+  public void writeGraph1Json(PrintWriter out) {
+    synchronized (this) {
+      out.print("{\"labels\":[");
+      out.print("{\"name\":\"query\",\"style\":{\"stroke\":\"RoyalBlue\"}},");
+      out.print("{\"name\":\"fetch\",\"style\":{\"stroke\":\"Black\"}},");
+      out.print("{\"name\":\"mutate\",\"style\":{\"stroke\":\"Orange\"}},");
+      out.print("{\"name\":\"except\",\"style\":{\"stroke\":\"Red\"}}");
+      out.print("],\"data\":[");
+      int p = position;
+      boolean comma = false;
+      for (int i = 0; i < sampleSize; i++, p++) {
+        if (p >= sampleSize) {
+          p = 0;
+        }
+        double query = _queryRate[p];
+        double fetch = _fetchRate[p];
+        double mutate = _mutateRate[p];
+        double except = _queryExceptionRate[p];
+        long t = timestamp[p];
+        if (t == 0) {
+          continue;
+        }
+        if (comma) {
+          out.print(",");
+        }
+        out.print("{\"query\":");
+        out.print(query);
+        out.print(",\"fetch\":");
+        out.print(fetch);
+        out.print(",\"mutate\":");
+        out.print(mutate);
+        out.print(",\"except\":");
+        out.print(except);
+        out.print(",\"recordTime\":");
+        out.print(t);
+        out.print('}');
+        comma = true;
+      }
+      out.print("]}");
+    }
+  }
+  
+  public void writeGraph2Json(PrintWriter out) {
+    synchronized (this) {
+      out.print("{\"labels\":[");
+      out.print("{\"name\":\"fetchRecord\",\"style\":{\"stroke\":\"Black\"}},");
+      out.print("{\"name\":\"mutateRecord\",\"style\":{\"stroke\":\"Orange\"}}");
+      out.print("],\"data\":[");
+      int p = position;
+      boolean comma = false;
+      for (int i = 0; i < sampleSize; i++, p++) {
+        if (p >= sampleSize) {
+          p = 0;
+        }
+        double fetch = _fetchRecordRate[p];
+        double mutate = _mutateRecordRate[p];
+        long t = timestamp[p];
+        if (t == 0) {
+          continue;
+        }
+        if (comma) {
+          out.print(",");
+        }
+        out.print("{\"fetchRecord\":");
+        out.print(fetch);
+        out.print(",\"mutateRecord\":");
+        out.print(mutate);
+        out.print(",\"recordTime\":");
+        out.print(t);
+        out.print('}');
+        comma = true;
+      }
+      out.print("]}");
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/77ea8b85/src/blur-gui/src/main/java/org/apache/blur/gui/SystemLoadMetrics.java
----------------------------------------------------------------------
diff --git a/src/blur-gui/src/main/java/org/apache/blur/gui/SystemLoadMetrics.java b/src/blur-gui/src/main/java/org/apache/blur/gui/SystemLoadMetrics.java
new file mode 100644
index 0000000..5b34a7c
--- /dev/null
+++ b/src/blur-gui/src/main/java/org/apache/blur/gui/SystemLoadMetrics.java
@@ -0,0 +1,72 @@
+package org.apache.blur.gui;
+
+import java.io.PrintWriter;
+import java.lang.management.ManagementFactory;
+import java.lang.management.OperatingSystemMXBean;
+import java.util.Timer;
+import java.util.TimerTask;
+import java.util.concurrent.TimeUnit;
+
+public class SystemLoadMetrics extends TimerTask {
+
+  private final int sampleSize = (int) TimeUnit.MINUTES.toSeconds(10);
+  private final Timer timer;
+  private final long period = TimeUnit.SECONDS.toMillis(1);
+  private final double[] systemLoadAverageHistory = new double[sampleSize];
+  private final long[] timestamp = new long[sampleSize];
+  private volatile static SystemLoadMetrics instance;
+  private volatile int position = 0;
+
+  public static synchronized SystemLoadMetrics getInstance() {
+    if (instance == null) {
+      instance = new SystemLoadMetrics();
+    }
+    return instance;
+  }
+
+  private SystemLoadMetrics() {
+    timer = new Timer("SystemLoadMetrics", true);
+    timer.scheduleAtFixedRate(this, period, period);
+  }
+
+  @Override
+  public void run() {
+    synchronized (this) {
+      if (position >= sampleSize) {
+        position = 0;
+      }
+      OperatingSystemMXBean operatingSystemMXBean = ManagementFactory.getOperatingSystemMXBean();
+      systemLoadAverageHistory[position] = operatingSystemMXBean.getSystemLoadAverage();
+      timestamp[position] = System.currentTimeMillis();
+      position++;
+    }
+  }
+
+  public void writeJson(PrintWriter out) {
+    synchronized (this) {
+      out.print("{\"labels\":[{\"name\":\"load\",\"style\":{\"stroke\":\"Red\"}}],\"data\":[");
+      int p = position;
+      boolean comma = false;
+      for (int i = 0; i < sampleSize; i++, p++) {
+        if (p >= sampleSize) {
+          p = 0;
+        }
+        double load = systemLoadAverageHistory[p];
+        long t = timestamp[p];
+        if (t == 0) {
+          continue;
+        }
+        if (comma) {
+          out.print(",");
+        }
+        out.print("{\"load\":");
+        out.print(load);
+        out.print(",\"recordTime\":");
+        out.print(t);
+        out.print('}');
+        comma = true;
+      }
+      out.print("]}");
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/77ea8b85/src/blur-util/src/main/java/org/apache/blur/metrics/HeapMetrics.java
----------------------------------------------------------------------
diff --git a/src/blur-util/src/main/java/org/apache/blur/metrics/HeapMetrics.java b/src/blur-util/src/main/java/org/apache/blur/metrics/HeapMetrics.java
deleted file mode 100644
index e754cf6..0000000
--- a/src/blur-util/src/main/java/org/apache/blur/metrics/HeapMetrics.java
+++ /dev/null
@@ -1,86 +0,0 @@
-package org.apache.blur.metrics;
-
-import java.io.PrintWriter;
-import java.lang.management.ManagementFactory;
-import java.lang.management.MemoryUsage;
-import java.util.Timer;
-import java.util.TimerTask;
-import java.util.concurrent.TimeUnit;
-
-public class HeapMetrics extends TimerTask {
-
-  private static final double ONE_GIG = 1024 * 1024 * 1024;
-  private final int sampleSize = (int) TimeUnit.MINUTES.toSeconds(10);
-  private final Timer timer;
-  private final long period = TimeUnit.SECONDS.toMillis(1);
-  private final long[] heapMemoryUsageUsedHistory = new long[sampleSize];
-  private final long[] heapMemoryUsageCommittedHistory = new long[sampleSize];
-  private final long[] timestamp = new long[sampleSize];
-  private volatile static HeapMetrics heapMetrics;
-  private volatile int position = 0;
-
-  public static synchronized HeapMetrics getInstance() {
-    if (heapMetrics == null) {
-      heapMetrics = new HeapMetrics();
-    }
-    return heapMetrics;
-  }
-
-  private HeapMetrics() {
-    timer = new Timer("HeapMetrics", true);
-    timer.scheduleAtFixedRate(this, period, period);
-  }
-
-  @Override
-  public void run() {
-    synchronized (this) {
-      if (position >= sampleSize) {
-        position = 0;
-      }
-      MemoryUsage heapMemoryUsage = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage();
-      setValue(heapMemoryUsage.getUsed(), heapMemoryUsageUsedHistory);
-      setValue(heapMemoryUsage.getCommitted(), heapMemoryUsageCommittedHistory);
-      setValue(System.currentTimeMillis(), timestamp);
-      position++;
-    }
-  }
-
-  private void setValue(long value, long[] history) {
-    history[position] = value;
-  }
-
-  public void writeJson(PrintWriter out) {
-    synchronized (this) {
-      out.print("{\"labels\":[");
-      out.print("{\"name\":\"used\",\"style\":{\"stroke\":\"RoyalBlue\"}},");
-      out.print("{\"name\":\"committed\",\"style\":{\"stroke\":\"Red\"}},");
-      out.print("],\"data\":[");
-      int p = position;
-      boolean comma = false;
-      for (int i = 0; i < sampleSize; i++, p++) {
-        if (p >= sampleSize) {
-          p = 0;
-        }
-        double used = ((double) heapMemoryUsageUsedHistory[p]) / ONE_GIG;
-        double committed = ((double) heapMemoryUsageCommittedHistory[p]) / ONE_GIG;
-
-        long t = timestamp[p];
-        if (t == 0) {
-          continue;
-        }
-        if (comma) {
-          out.print(",");
-        }
-        out.print("{\"used\":");
-        out.print(used);
-        out.print(",\"committed\":");
-        out.print(committed);
-        out.print(",\"recordTime\":");
-        out.print(t);
-        out.print('}');
-        comma = true;
-      }
-      out.print("]}");
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/77ea8b85/src/blur-util/src/main/java/org/apache/blur/metrics/QueryMetrics.java
----------------------------------------------------------------------
diff --git a/src/blur-util/src/main/java/org/apache/blur/metrics/QueryMetrics.java b/src/blur-util/src/main/java/org/apache/blur/metrics/QueryMetrics.java
deleted file mode 100644
index 5fafc5a..0000000
--- a/src/blur-util/src/main/java/org/apache/blur/metrics/QueryMetrics.java
+++ /dev/null
@@ -1,180 +0,0 @@
-package org.apache.blur.metrics;
-
-import java.io.PrintWriter;
-import java.util.Timer;
-import java.util.TimerTask;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicLong;
-
-public class QueryMetrics extends TimerTask {
-
-  private final int sampleSize = (int) TimeUnit.MINUTES.toSeconds(10);
-  private final AtomicLong _queryCount = new AtomicLong();
-  private final AtomicLong _queryTime = new AtomicLong();
-  private final AtomicLong _queryExceptionCount = new AtomicLong();
-  private final AtomicLong _dataFetchCount = new AtomicLong();
-  private final AtomicLong _dataFetchTime = new AtomicLong();
-  private final AtomicLong _dataFetchRecordCount = new AtomicLong();
-  private final AtomicLong _dataMutateCount = new AtomicLong();
-  private final AtomicLong _dataMutateTime = new AtomicLong();
-  private final AtomicLong _dataMutateRecordCount = new AtomicLong();
-  private final Timer timer;
-  private final long period = TimeUnit.SECONDS.toMillis(1);
-  private final double[] _queryRate = new double[sampleSize];
-  private final double[] _queryResponse = new double[sampleSize];
-  private final double[] _queryExceptionRate = new double[sampleSize];
-  private final double[] _fetchRate = new double[sampleSize];
-  private final double[] _fetchResponse = new double[sampleSize];
-  private final double[] _fetchRecordRate = new double[sampleSize];
-  private final double[] _mutateRate = new double[sampleSize];
-  private final double[] _mutateResponse = new double[sampleSize];
-  private final double[] _mutateRecordRate = new double[sampleSize];
-  private final long[] timestamp = new long[sampleSize];
-  private volatile static QueryMetrics instance;
-  private volatile int position;
-
-  public static synchronized QueryMetrics getInstance() {
-    if (instance == null) {
-      instance = new QueryMetrics();
-    }
-    return instance;
-  }
-
-  private QueryMetrics() {
-    timer = new Timer("QueryMetrics", true);
-    timer.scheduleAtFixedRate(this, period, period);
-  }
-
-  @Override
-  public void run() {
-    synchronized (this) {
-      if (position >= sampleSize) {
-        position = 0;
-      }
-      long queryCount = _queryCount.getAndSet(0);
-      long queryTime = _queryTime.getAndSet(0);
-      long queryExceptionCount = _queryExceptionCount.getAndSet(0);
-
-      long dataFetchCount = _dataFetchCount.getAndSet(0);
-      long dataFetchTime = _dataFetchTime.getAndSet(0);
-      long dataFetchRecordCount = _dataFetchRecordCount.getAndSet(0);
-
-      long dataMutateCount = _dataMutateCount.getAndSet(0);
-      long dataMutateTime = _dataMutateTime.getAndSet(0);
-      long dataMutateRecordCount = _dataMutateRecordCount.getAndSet(0);
-
-      _queryRate[position] = queryCount;
-      _queryResponse[position] = TimeUnit.NANOSECONDS.toMillis(queryTime) / (double) queryCount;
-
-      _queryExceptionRate[position] = queryExceptionCount;
-
-      _fetchRate[position] = dataFetchCount;
-      _fetchResponse[position] = TimeUnit.NANOSECONDS.toMillis(dataFetchTime) / (double)
dataFetchCount;
-      _fetchRecordRate[position] = dataFetchRecordCount;
-
-      _mutateRate[position] = dataMutateCount;
-      _mutateResponse[position] = TimeUnit.NANOSECONDS.toMillis(dataMutateTime) / (double)
dataMutateCount;
-      _mutateRecordRate[position] = dataMutateRecordCount;
-
-      timestamp[position] = System.currentTimeMillis();
-      position++;
-    }
-  }
-
-  public void recordQuery(long totalTimeNs) {
-    _queryCount.incrementAndGet();
-    _queryTime.addAndGet(totalTimeNs);
-  }
-
-  public void recordQueryExceptions() {
-    _queryExceptionCount.incrementAndGet();
-  }
-
-  public void recordDataFetch(long totalTimeNs, long records) {
-    _dataFetchCount.incrementAndGet();
-    _dataFetchTime.addAndGet(totalTimeNs);
-    _dataFetchRecordCount.addAndGet(records);
-  }
-
-  public void recordDataMutate(long totalTimeNs, long records) {
-    _dataMutateCount.incrementAndGet();
-    _dataMutateTime.addAndGet(totalTimeNs);
-    _dataMutateRecordCount.addAndGet(records);
-  }
-
-  public void writeGraph1Json(PrintWriter out) {
-    synchronized (this) {
-      out.print("{\"labels\":[");
-      out.print("{\"name\":\"query\",\"style\":{\"stroke\":\"RoyalBlue\"}},");
-      out.print("{\"name\":\"fetch\",\"style\":{\"stroke\":\"Black\"}},");
-      out.print("{\"name\":\"mutate\",\"style\":{\"stroke\":\"Orange\"}},");
-      out.print("{\"name\":\"except\",\"style\":{\"stroke\":\"Red\"}}");
-      out.print("],\"data\":[");
-      int p = position;
-      boolean comma = false;
-      for (int i = 0; i < sampleSize; i++, p++) {
-        if (p >= sampleSize) {
-          p = 0;
-        }
-        double query = _queryRate[p];
-        double fetch = _fetchRate[p];
-        double mutate = _mutateRate[p];
-        double except = _queryExceptionRate[p];
-        long t = timestamp[p];
-        if (t == 0) {
-          continue;
-        }
-        if (comma) {
-          out.print(",");
-        }
-        out.print("{\"query\":");
-        out.print(query);
-        out.print(",\"fetch\":");
-        out.print(fetch);
-        out.print(",\"mutate\":");
-        out.print(mutate);
-        out.print(",\"except\":");
-        out.print(except);
-        out.print(",\"recordTime\":");
-        out.print(t);
-        out.print('}');
-        comma = true;
-      }
-      out.print("]}");
-    }
-  }
-  
-  public void writeGraph2Json(PrintWriter out) {
-    synchronized (this) {
-      out.print("{\"labels\":[");
-      out.print("{\"name\":\"fetchRecord\",\"style\":{\"stroke\":\"Black\"}},");
-      out.print("{\"name\":\"mutateRecord\",\"style\":{\"stroke\":\"Orange\"}}");
-      out.print("],\"data\":[");
-      int p = position;
-      boolean comma = false;
-      for (int i = 0; i < sampleSize; i++, p++) {
-        if (p >= sampleSize) {
-          p = 0;
-        }
-        double fetch = _fetchRecordRate[p];
-        double mutate = _mutateRecordRate[p];
-        long t = timestamp[p];
-        if (t == 0) {
-          continue;
-        }
-        if (comma) {
-          out.print(",");
-        }
-        out.print("{\"fetchRecord\":");
-        out.print(fetch);
-        out.print(",\"mutateRecord\":");
-        out.print(mutate);
-        out.print(",\"recordTime\":");
-        out.print(t);
-        out.print('}');
-        comma = true;
-      }
-      out.print("]}");
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/77ea8b85/src/blur-util/src/main/java/org/apache/blur/metrics/SystemLoadMetrics.java
----------------------------------------------------------------------
diff --git a/src/blur-util/src/main/java/org/apache/blur/metrics/SystemLoadMetrics.java b/src/blur-util/src/main/java/org/apache/blur/metrics/SystemLoadMetrics.java
deleted file mode 100644
index 16627b6..0000000
--- a/src/blur-util/src/main/java/org/apache/blur/metrics/SystemLoadMetrics.java
+++ /dev/null
@@ -1,72 +0,0 @@
-package org.apache.blur.metrics;
-
-import java.io.PrintWriter;
-import java.lang.management.ManagementFactory;
-import java.lang.management.OperatingSystemMXBean;
-import java.util.Timer;
-import java.util.TimerTask;
-import java.util.concurrent.TimeUnit;
-
-public class SystemLoadMetrics extends TimerTask {
-
-  private final int sampleSize = (int) TimeUnit.MINUTES.toSeconds(10);
-  private final Timer timer;
-  private final long period = TimeUnit.SECONDS.toMillis(1);
-  private final double[] systemLoadAverageHistory = new double[sampleSize];
-  private final long[] timestamp = new long[sampleSize];
-  private volatile static SystemLoadMetrics instance;
-  private volatile int position = 0;
-
-  public static synchronized SystemLoadMetrics getInstance() {
-    if (instance == null) {
-      instance = new SystemLoadMetrics();
-    }
-    return instance;
-  }
-
-  private SystemLoadMetrics() {
-    timer = new Timer("SystemLoadMetrics", true);
-    timer.scheduleAtFixedRate(this, period, period);
-  }
-
-  @Override
-  public void run() {
-    synchronized (this) {
-      if (position >= sampleSize) {
-        position = 0;
-      }
-      OperatingSystemMXBean operatingSystemMXBean = ManagementFactory.getOperatingSystemMXBean();
-      systemLoadAverageHistory[position] = operatingSystemMXBean.getSystemLoadAverage();
-      timestamp[position] = System.currentTimeMillis();
-      position++;
-    }
-  }
-
-  public void writeJson(PrintWriter out) {
-    synchronized (this) {
-      out.print("{\"labels\":[{\"name\":\"load\",\"style\":{\"stroke\":\"Red\"}}],\"data\":[");
-      int p = position;
-      boolean comma = false;
-      for (int i = 0; i < sampleSize; i++, p++) {
-        if (p >= sampleSize) {
-          p = 0;
-        }
-        double load = systemLoadAverageHistory[p];
-        long t = timestamp[p];
-        if (t == 0) {
-          continue;
-        }
-        if (comma) {
-          out.print(",");
-        }
-        out.print("{\"load\":");
-        out.print(load);
-        out.print(",\"recordTime\":");
-        out.print(t);
-        out.print('}');
-        comma = true;
-      }
-      out.print("]}");
-    }
-  }
-}


Mime
View raw message