cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yu...@apache.org
Subject [3/6] git commit: Do not quote metric names after metrics-core upgrade
Date Thu, 19 Sep 2013 05:50:44 GMT
Do not quote metric names after metrics-core upgrade

patch by yukim; reviewed by jbellis for CASSANDRA-5947


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/eb390d02
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/eb390d02
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/eb390d02

Branch: refs/heads/trunk
Commit: eb390d02e57894bc04505571e1d0c1d0a08b3dd4
Parents: 9d7bb1e
Author: Yuki Morishita <yukim@apache.org>
Authored: Thu Sep 19 00:38:53 2013 -0500
Committer: Yuki Morishita <yukim@apache.org>
Committed: Thu Sep 19 00:38:53 2013 -0500

----------------------------------------------------------------------
 .../apache/cassandra/metrics/CacheMetrics.java  | 18 +++--
 .../cassandra/metrics/ClientRequestMetrics.java | 10 +--
 .../cassandra/metrics/CommitLogMetrics.java     | 10 ++-
 .../cassandra/metrics/CompactionMetrics.java    | 12 ++--
 .../cassandra/metrics/ConnectionMetrics.java    | 32 ++++-----
 .../cassandra/metrics/DefaultNameFactory.java   | 71 ++++++++++++++++++++
 .../metrics/DroppedMessageMetrics.java          |  7 +-
 .../cassandra/metrics/HintedHandoffMetrics.java | 11 +--
 .../cassandra/metrics/LatencyMetrics.java       | 30 ++-------
 .../cassandra/metrics/ReadRepairMetrics.java    | 40 +++++------
 .../cassandra/metrics/StorageMetrics.java       | 11 +--
 .../cassandra/metrics/StreamingMetrics.java     | 13 ++--
 .../cassandra/scheduler/WeightedQueue.java      |  2 +-
 13 files changed, 152 insertions(+), 115 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/eb390d02/src/java/org/apache/cassandra/metrics/CacheMetrics.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/metrics/CacheMetrics.java b/src/java/org/apache/cassandra/metrics/CacheMetrics.java
index 3157511..9d5d783 100644
--- a/src/java/org/apache/cassandra/metrics/CacheMetrics.java
+++ b/src/java/org/apache/cassandra/metrics/CacheMetrics.java
@@ -23,7 +23,6 @@ import java.util.concurrent.atomic.AtomicLong;
 import com.yammer.metrics.Metrics;
 import com.yammer.metrics.core.Gauge;
 import com.yammer.metrics.core.Meter;
-import com.yammer.metrics.core.MetricName;
 import com.yammer.metrics.util.RatioGauge;
 
 import org.apache.cassandra.cache.ICache;
@@ -33,9 +32,6 @@ import org.apache.cassandra.cache.ICache;
  */
 public class CacheMetrics
 {
-    public static final String GROUP_NAME = "org.apache.cassandra.metrics";
-    public static final String TYPE_NAME = "Cache";
-
     /** Cache capacity in bytes */
     public final Gauge<Long> capacity;
     /** Total number of cache hits */
@@ -60,16 +56,18 @@ public class CacheMetrics
      */
     public CacheMetrics(String type, final ICache cache)
     {
-        capacity = Metrics.newGauge(new MetricName(GROUP_NAME, TYPE_NAME, "Capacity", type),
new Gauge<Long>()
+        MetricNameFactory factory = new DefaultNameFactory("Cache", type);
+
+        capacity = Metrics.newGauge(factory.createMetricName("Capacity"), new Gauge<Long>()
         {
             public Long value()
             {
                 return cache.capacity();
             }
         });
-        hits = Metrics.newMeter(new MetricName(GROUP_NAME, TYPE_NAME, "Hits", type), "hits",
TimeUnit.SECONDS);
-        requests = Metrics.newMeter(new MetricName(GROUP_NAME, TYPE_NAME, "Requests", type),
"requests", TimeUnit.SECONDS);
-        hitRate = Metrics.newGauge(new MetricName(GROUP_NAME, TYPE_NAME, "HitRate", type),
new RatioGauge()
+        hits = Metrics.newMeter(factory.createMetricName("Hits"), "hits", TimeUnit.SECONDS);
+        requests = Metrics.newMeter(factory.createMetricName("Requests"), "requests", TimeUnit.SECONDS);
+        hitRate = Metrics.newGauge(factory.createMetricName("HitRate"), new RatioGauge()
         {
             protected double getNumerator()
             {
@@ -81,14 +79,14 @@ public class CacheMetrics
                 return requests.count();
             }
         });
-        size = Metrics.newGauge(new MetricName(GROUP_NAME, TYPE_NAME, "Size", type), new
Gauge<Long>()
+        size = Metrics.newGauge(factory.createMetricName("Size"), new Gauge<Long>()
         {
             public Long value()
             {
                 return cache.weightedSize();
             }
         });
-        entries = Metrics.newGauge(new MetricName(GROUP_NAME, TYPE_NAME, "Entries", type),
new Gauge<Integer>()
+        entries = Metrics.newGauge(factory.createMetricName("Entries"), new Gauge<Integer>()
         {
             public Integer value()
             {

http://git-wip-us.apache.org/repos/asf/cassandra/blob/eb390d02/src/java/org/apache/cassandra/metrics/ClientRequestMetrics.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/metrics/ClientRequestMetrics.java b/src/java/org/apache/cassandra/metrics/ClientRequestMetrics.java
index d6ff01b..1ac3482 100644
--- a/src/java/org/apache/cassandra/metrics/ClientRequestMetrics.java
+++ b/src/java/org/apache/cassandra/metrics/ClientRequestMetrics.java
@@ -28,17 +28,17 @@ import com.yammer.metrics.core.Meter;
 
 public class ClientRequestMetrics extends LatencyMetrics
 {
-    @Deprecated public static final Counter readTimeouts = Metrics.newCounter(ClientRequestMetrics.class,
"ReadTimeouts");
-    @Deprecated public static final Counter writeTimeouts = Metrics.newCounter(ClientRequestMetrics.class,
"WriteTimeouts");
-    @Deprecated public static final Counter readUnavailables = Metrics.newCounter(ClientRequestMetrics.class,
"ReadUnavailables");
-    @Deprecated public static final Counter writeUnavailables = Metrics.newCounter(ClientRequestMetrics.class,
"WriteUnavailables");
+    @Deprecated public static final Counter readTimeouts = Metrics.newCounter(DefaultNameFactory.createMetricName("ClientRequestMetrics",
"ReadTimeouts", null));
+    @Deprecated public static final Counter writeTimeouts = Metrics.newCounter(DefaultNameFactory.createMetricName("ClientRequestMetrics",
"WriteTimeouts", null));
+    @Deprecated public static final Counter readUnavailables = Metrics.newCounter(DefaultNameFactory.createMetricName("ClientRequestMetrics",
"ReadUnavailables", null));
+    @Deprecated public static final Counter writeUnavailables = Metrics.newCounter(DefaultNameFactory.createMetricName("ClientRequestMetrics",
"WriteUnavailables", null));
 
     public final Meter timeouts;
     public final Meter unavailables;
 
     public ClientRequestMetrics(String scope)
     {
-        super("org.apache.cassandra.metrics", "ClientRequest", scope);
+        super("ClientRequest", scope);
 
         timeouts = Metrics.newMeter(factory.createMetricName("Timeouts"), "timeouts", TimeUnit.SECONDS);
         unavailables = Metrics.newMeter(factory.createMetricName("Unavailables"), "unavailables",
TimeUnit.SECONDS);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/eb390d02/src/java/org/apache/cassandra/metrics/CommitLogMetrics.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/metrics/CommitLogMetrics.java b/src/java/org/apache/cassandra/metrics/CommitLogMetrics.java
index 598d295..c18b3a2 100644
--- a/src/java/org/apache/cassandra/metrics/CommitLogMetrics.java
+++ b/src/java/org/apache/cassandra/metrics/CommitLogMetrics.java
@@ -19,7 +19,6 @@ package org.apache.cassandra.metrics;
 
 import com.yammer.metrics.Metrics;
 import com.yammer.metrics.core.Gauge;
-import com.yammer.metrics.core.MetricName;
 
 import org.apache.cassandra.db.commitlog.CommitLogAllocator;
 import org.apache.cassandra.db.commitlog.ICommitLogExecutorService;
@@ -29,8 +28,7 @@ import org.apache.cassandra.db.commitlog.ICommitLogExecutorService;
  */
 public class CommitLogMetrics
 {
-    public static final String GROUP_NAME = "org.apache.cassandra.metrics";
-    public static final String TYPE_NAME = "CommitLog";
+    public static final MetricNameFactory factory = new DefaultNameFactory("CommitLog");
 
     /** Number of completed tasks */
     public final Gauge<Long> completedTasks;
@@ -41,21 +39,21 @@ public class CommitLogMetrics
 
     public CommitLogMetrics(final ICommitLogExecutorService executor, final CommitLogAllocator
allocator)
     {
-        completedTasks = Metrics.newGauge(new MetricName(GROUP_NAME, TYPE_NAME, "CompletedTasks"),
new Gauge<Long>()
+        completedTasks = Metrics.newGauge(factory.createMetricName("CompletedTasks"), new
Gauge<Long>()
         {
             public Long value()
             {
                 return executor.getCompletedTasks();
             }
         });
-        pendingTasks = Metrics.newGauge(new MetricName(GROUP_NAME, TYPE_NAME, "PendingTasks"),
new Gauge<Long>()
+        pendingTasks = Metrics.newGauge(factory.createMetricName("PendingTasks"), new Gauge<Long>()
         {
             public Long value()
             {
                 return executor.getPendingTasks();
             }
         });
-        totalCommitLogSize = Metrics.newGauge(new MetricName(GROUP_NAME, TYPE_NAME, "TotalCommitLogSize"),
new Gauge<Long>()
+        totalCommitLogSize = Metrics.newGauge(factory.createMetricName("TotalCommitLogSize"),
new Gauge<Long>()
         {
             public Long value()
             {

http://git-wip-us.apache.org/repos/asf/cassandra/blob/eb390d02/src/java/org/apache/cassandra/metrics/CompactionMetrics.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/metrics/CompactionMetrics.java b/src/java/org/apache/cassandra/metrics/CompactionMetrics.java
index ae098ca..9b6ebde 100644
--- a/src/java/org/apache/cassandra/metrics/CompactionMetrics.java
+++ b/src/java/org/apache/cassandra/metrics/CompactionMetrics.java
@@ -25,7 +25,6 @@ import com.yammer.metrics.Metrics;
 import com.yammer.metrics.core.Counter;
 import com.yammer.metrics.core.Gauge;
 import com.yammer.metrics.core.Meter;
-import com.yammer.metrics.core.MetricName;
 
 import org.apache.cassandra.config.Schema;
 import org.apache.cassandra.db.ColumnFamilyStore;
@@ -38,8 +37,7 @@ import org.apache.cassandra.db.compaction.CompactionManager;
  */
 public class CompactionMetrics implements CompactionManager.CompactionExecutorStatsCollector
 {
-    public static final String GROUP_NAME = "org.apache.cassandra.metrics";
-    public static final String TYPE_NAME = "Compaction";
+    public static final MetricNameFactory factory = new DefaultNameFactory("Compaction");
 
     // a synchronized identity set of running tasks to their compaction info
     private static final Set<CompactionInfo.Holder> compactions = Collections.synchronizedSet(Collections.newSetFromMap(new
IdentityHashMap<CompactionInfo.Holder, Boolean>()));
@@ -55,7 +53,7 @@ public class CompactionMetrics implements CompactionManager.CompactionExecutorSt
 
     public CompactionMetrics(final ThreadPoolExecutor... collectors)
     {
-        pendingTasks = Metrics.newGauge(new MetricName(GROUP_NAME, TYPE_NAME, "PendingTasks"),
new Gauge<Integer>()
+        pendingTasks = Metrics.newGauge(factory.createMetricName("PendingTasks"), new Gauge<Integer>()
         {
             public Integer value()
             {
@@ -70,7 +68,7 @@ public class CompactionMetrics implements CompactionManager.CompactionExecutorSt
                 return n;
             }
         });
-        completedTasks = Metrics.newGauge(new MetricName(GROUP_NAME, TYPE_NAME, "CompletedTasks"),
new Gauge<Long>()
+        completedTasks = Metrics.newGauge(factory.createMetricName("CompletedTasks"), new
Gauge<Long>()
         {
             public Long value()
             {
@@ -80,8 +78,8 @@ public class CompactionMetrics implements CompactionManager.CompactionExecutorSt
                 return completedTasks;
             }
         });
-        totalCompactionsCompleted = Metrics.newMeter(new MetricName(GROUP_NAME, TYPE_NAME,
"TotalCompactionsCompleted"), "compaction completed", TimeUnit.SECONDS);
-        bytesCompacted = Metrics.newCounter(new MetricName(GROUP_NAME, TYPE_NAME, "BytesCompacted"));
+        totalCompactionsCompleted = Metrics.newMeter(factory.createMetricName("TotalCompactionsCompleted"),
"compaction completed", TimeUnit.SECONDS);
+        bytesCompacted = Metrics.newCounter(factory.createMetricName("BytesCompacted"));
     }
 
     public void beginCompaction(CompactionInfo.Holder ci)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/eb390d02/src/java/org/apache/cassandra/metrics/ConnectionMetrics.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/metrics/ConnectionMetrics.java b/src/java/org/apache/cassandra/metrics/ConnectionMetrics.java
index 5493505..eaf29f8 100644
--- a/src/java/org/apache/cassandra/metrics/ConnectionMetrics.java
+++ b/src/java/org/apache/cassandra/metrics/ConnectionMetrics.java
@@ -23,7 +23,6 @@ import java.util.concurrent.TimeUnit;
 import com.yammer.metrics.Metrics;
 import com.yammer.metrics.core.Gauge;
 import com.yammer.metrics.core.Meter;
-import com.yammer.metrics.core.MetricName;
 
 import org.apache.cassandra.net.OutboundTcpConnectionPool;
 
@@ -32,11 +31,10 @@ import org.apache.cassandra.net.OutboundTcpConnectionPool;
  */
 public class ConnectionMetrics
 {
-    public static final String GROUP_NAME = "org.apache.cassandra.metrics";
     public static final String TYPE_NAME = "Connection";
 
     /** Total number of timeouts happened on this node */
-    public static final Meter totalTimeouts = Metrics.newMeter(new MetricName(GROUP_NAME,
TYPE_NAME, "TotalTimeouts"), "total timeouts", TimeUnit.SECONDS);
+    public static final Meter totalTimeouts = Metrics.newMeter(DefaultNameFactory.createMetricName(TYPE_NAME,
"TotalTimeouts", null), "total timeouts", TimeUnit.SECONDS);
     private static long recentTimeouts;
 
     public final String address;
@@ -53,6 +51,8 @@ public class ConnectionMetrics
     /** Number of timeouts for specific IP */
     public final Meter timeouts;
 
+    private final MetricNameFactory factory;
+
     private long recentTimeoutCount;
 
     /**
@@ -66,52 +66,54 @@ public class ConnectionMetrics
         // ipv6 addresses will contain colons, which are invalid in a JMX ObjectName
         address = ip.getHostAddress().replaceAll(":", ".");
 
-        commandPendingTasks = Metrics.newGauge(new MetricName(GROUP_NAME, TYPE_NAME, "CommandPendingTasks",
address), new Gauge<Integer>()
+        factory = new DefaultNameFactory("Connection", address);
+
+        commandPendingTasks = Metrics.newGauge(factory.createMetricName("CommandPendingTasks"),
new Gauge<Integer>()
         {
             public Integer value()
             {
                 return connectionPool.cmdCon.getPendingMessages();
             }
         });
-        commandCompletedTasks = Metrics.newGauge(new MetricName(GROUP_NAME, TYPE_NAME, "CommandCompletedTasks",
address), new Gauge<Long>()
+        commandCompletedTasks = Metrics.newGauge(factory.createMetricName("CommandCompletedTasks"),
new Gauge<Long>()
         {
             public Long value()
             {
                 return connectionPool.cmdCon.getCompletedMesssages();
             }
         });
-        commandDroppedTasks = Metrics.newGauge(new MetricName(GROUP_NAME, TYPE_NAME, "CommandDroppedTasks",
address), new Gauge<Long>()
+        commandDroppedTasks = Metrics.newGauge(factory.createMetricName("CommandDroppedTasks"),
new Gauge<Long>()
         {
             public Long value()
             {
                 return connectionPool.cmdCon.getDroppedMessages();
             }
         });
-        responsePendingTasks = Metrics.newGauge(new MetricName(GROUP_NAME, TYPE_NAME, "ResponsePendingTasks",
address), new Gauge<Integer>()
+        responsePendingTasks = Metrics.newGauge(factory.createMetricName("ResponsePendingTasks"),
new Gauge<Integer>()
         {
             public Integer value()
             {
                 return connectionPool.ackCon.getPendingMessages();
             }
         });
-        responseCompletedTasks = Metrics.newGauge(new MetricName(GROUP_NAME, TYPE_NAME, "ResponseCompletedTasks",
address), new Gauge<Long>()
+        responseCompletedTasks = Metrics.newGauge(factory.createMetricName("ResponseCompletedTasks"),
new Gauge<Long>()
         {
             public Long value()
             {
                 return connectionPool.ackCon.getCompletedMesssages();
             }
         });
-        timeouts = Metrics.newMeter(new MetricName(GROUP_NAME, TYPE_NAME, "Timeouts", address),
"timeouts", TimeUnit.SECONDS);
+        timeouts = Metrics.newMeter(factory.createMetricName("Timeouts"), "timeouts", TimeUnit.SECONDS);
     }
 
     public void release()
     {
-        Metrics.defaultRegistry().removeMetric(new MetricName(GROUP_NAME, TYPE_NAME, "CommandPendingTasks",
address));
-        Metrics.defaultRegistry().removeMetric(new MetricName(GROUP_NAME, TYPE_NAME, "CommandCompletedTasks",
address));
-        Metrics.defaultRegistry().removeMetric(new MetricName(GROUP_NAME, TYPE_NAME, "CommandDroppedTasks",
address));
-        Metrics.defaultRegistry().removeMetric(new MetricName(GROUP_NAME, TYPE_NAME, "ResponsePendingTasks",
address));
-        Metrics.defaultRegistry().removeMetric(new MetricName(GROUP_NAME, TYPE_NAME, "ResponseCompletedTasks",
address));
-        Metrics.defaultRegistry().removeMetric(new MetricName(GROUP_NAME, TYPE_NAME, "Timeouts",
address));
+        Metrics.defaultRegistry().removeMetric(factory.createMetricName("CommandPendingTasks"));
+        Metrics.defaultRegistry().removeMetric(factory.createMetricName("CommandCompletedTasks"));
+        Metrics.defaultRegistry().removeMetric(factory.createMetricName("CommandDroppedTasks"));
+        Metrics.defaultRegistry().removeMetric(factory.createMetricName("ResponsePendingTasks"));
+        Metrics.defaultRegistry().removeMetric(factory.createMetricName("ResponseCompletedTasks"));
+        Metrics.defaultRegistry().removeMetric(factory.createMetricName("Timeouts"));
     }
 
     @Deprecated

http://git-wip-us.apache.org/repos/asf/cassandra/blob/eb390d02/src/java/org/apache/cassandra/metrics/DefaultNameFactory.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/metrics/DefaultNameFactory.java b/src/java/org/apache/cassandra/metrics/DefaultNameFactory.java
new file mode 100644
index 0000000..f7f23ee
--- /dev/null
+++ b/src/java/org/apache/cassandra/metrics/DefaultNameFactory.java
@@ -0,0 +1,71 @@
+/*
+ * 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 org.apache.cassandra.metrics;
+
+import com.yammer.metrics.core.MetricName;
+
+/**
+ * MetricNameFactory that generates default MetricName of metrics.
+ */
+public class DefaultNameFactory implements MetricNameFactory
+{
+    public static final String GROUP_NAME = "org.apache.cassandra.metrics";
+
+    private final String type;
+    private final String scope;
+
+    public DefaultNameFactory(String type)
+    {
+        this(type, null);
+    }
+
+    public DefaultNameFactory(String type, String scope)
+    {
+        this.type = type;
+        this.scope = scope;
+    }
+
+    public MetricName createMetricName(String metricName)
+    {
+        return createMetricName(type, metricName, scope);
+    }
+
+    public static MetricName createMetricName(String type, String metricName, String scope)
+    {
+        return new MetricName(GROUP_NAME, type, metricName, scope, createDefaultMBeanName(type,
metricName, scope));
+    }
+
+    protected static String createDefaultMBeanName(String type, String name, String scope)
+    {
+        final StringBuilder nameBuilder = new StringBuilder();
+        nameBuilder.append(GROUP_NAME);
+        nameBuilder.append(":type=");
+        nameBuilder.append(type);
+        if (scope != null)
+        {
+            nameBuilder.append(",scope=");
+            nameBuilder.append(scope);
+        }
+        if (name.length() > 0)
+        {
+            nameBuilder.append(",name=");
+            nameBuilder.append(name);
+        }
+        return nameBuilder.toString();
+    }
+}

http://git-wip-us.apache.org/repos/asf/cassandra/blob/eb390d02/src/java/org/apache/cassandra/metrics/DroppedMessageMetrics.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/metrics/DroppedMessageMetrics.java b/src/java/org/apache/cassandra/metrics/DroppedMessageMetrics.java
index e0b12bb..f94ea04 100644
--- a/src/java/org/apache/cassandra/metrics/DroppedMessageMetrics.java
+++ b/src/java/org/apache/cassandra/metrics/DroppedMessageMetrics.java
@@ -21,7 +21,6 @@ import java.util.concurrent.TimeUnit;
 
 import com.yammer.metrics.Metrics;
 import com.yammer.metrics.core.Meter;
-import com.yammer.metrics.core.MetricName;
 
 import org.apache.cassandra.net.MessagingService;
 
@@ -30,9 +29,6 @@ import org.apache.cassandra.net.MessagingService;
  */
 public class DroppedMessageMetrics
 {
-    public static final String GROUP_NAME = "org.apache.cassandra.metrics";
-    public static final String TYPE_NAME = "DroppedMessage";
-
     /** Number of dropped messages */
     public final Meter dropped;
 
@@ -40,7 +36,8 @@ public class DroppedMessageMetrics
 
     public DroppedMessageMetrics(MessagingService.Verb verb)
     {
-        dropped = Metrics.newMeter(new MetricName(GROUP_NAME, TYPE_NAME, "Dropped", verb.toString()),
"dropped", TimeUnit.SECONDS);
+        MetricNameFactory factory = new DefaultNameFactory("DroppedMessage", verb.toString());
+        dropped = Metrics.newMeter(factory.createMetricName("Dropped"), "dropped", TimeUnit.SECONDS);
     }
 
     @Deprecated

http://git-wip-us.apache.org/repos/asf/cassandra/blob/eb390d02/src/java/org/apache/cassandra/metrics/HintedHandoffMetrics.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/metrics/HintedHandoffMetrics.java b/src/java/org/apache/cassandra/metrics/HintedHandoffMetrics.java
index a12be19..a851f50 100644
--- a/src/java/org/apache/cassandra/metrics/HintedHandoffMetrics.java
+++ b/src/java/org/apache/cassandra/metrics/HintedHandoffMetrics.java
@@ -32,7 +32,6 @@ import com.google.common.cache.CacheLoader;
 import com.google.common.cache.LoadingCache;
 import com.yammer.metrics.Metrics;
 import com.yammer.metrics.core.Counter;
-import com.yammer.metrics.core.MetricName;
 
 /**
  * Metrics for {@link HintedHandOffManager}.
@@ -41,8 +40,7 @@ public class HintedHandoffMetrics
 {
     private static final Logger logger = LoggerFactory.getLogger(HintedHandoffMetrics.class);
 
-    public static final String GROUP_NAME = "org.apache.cassandra.metrics";
-    public static final String TYPE_NAME = "HintedHandOffManager";
+    private final MetricNameFactory factory;
 
     /** Total number of hints which are not stored, This is not a cache. */
     private final LoadingCache<InetAddress, DifferencingCounter> notStored = CacheBuilder.newBuilder().build(new
CacheLoader<InetAddress, DifferencingCounter>()
@@ -53,6 +51,11 @@ public class HintedHandoffMetrics
         }
     });
 
+    public HintedHandoffMetrics()
+    {
+        factory = new DefaultNameFactory("HintedHandOffManager");
+    }
+
     public void incrPastWindow(InetAddress address)
     {
         try
@@ -84,7 +87,7 @@ public class HintedHandoffMetrics
 
         public DifferencingCounter(InetAddress address)
         {
-            this.meter = Metrics.newCounter(new MetricName(GROUP_NAME, TYPE_NAME, "Hints_not_stored-"
+ address.toString()));
+            this.meter = Metrics.newCounter(factory.createMetricName("Hints_not_stored-"
+ address.toString()));
         }
 
         public long diffrence()

http://git-wip-us.apache.org/repos/asf/cassandra/blob/eb390d02/src/java/org/apache/cassandra/metrics/LatencyMetrics.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/metrics/LatencyMetrics.java b/src/java/org/apache/cassandra/metrics/LatencyMetrics.java
index d177613..01ba997 100644
--- a/src/java/org/apache/cassandra/metrics/LatencyMetrics.java
+++ b/src/java/org/apache/cassandra/metrics/LatencyMetrics.java
@@ -21,7 +21,6 @@ import java.util.concurrent.TimeUnit;
 
 import com.yammer.metrics.Metrics;
 import com.yammer.metrics.core.Counter;
-import com.yammer.metrics.core.MetricName;
 import com.yammer.metrics.core.Timer;
 
 import org.apache.cassandra.utils.EstimatedHistogram;
@@ -47,26 +46,24 @@ public class LatencyMetrics
     /**
      * Create LatencyMetrics with given group, type, and scope. Name prefix for each metric
will be empty.
      *
-     * @param group Group name
      * @param type Type name
      * @param scope Scope
      */
-    public LatencyMetrics(String group, String type, String scope)
+    public LatencyMetrics(String type, String scope)
     {
-        this(group, type, "", scope);
+        this(type, "", scope);
     }
 
     /**
      * Create LatencyMetrics with given group, type, prefix to append to each metric name,
and scope.
      *
-     * @param group Group name
      * @param type Type name
      * @param namePrefix Prefix to append to each metric name
      * @param scope Scope of metrics
      */
-    public LatencyMetrics(String group, String type, String namePrefix, String scope)
+    public LatencyMetrics(String type, String namePrefix, String scope)
     {
-        this(new LatencyMetricNameFactory(group, type, scope), namePrefix);
+        this(new DefaultNameFactory(type, scope), namePrefix);
     }
 
     /**
@@ -120,23 +117,4 @@ public class LatencyMetrics
             lastOpCount = ops;
         }
     }
-
-    static class LatencyMetricNameFactory implements MetricNameFactory
-    {
-        private final String group;
-        private final String type;
-        private final String scope;
-
-        LatencyMetricNameFactory(String group, String type, String scope)
-        {
-            this.group = group;
-            this.type = type;
-            this.scope = scope;
-        }
-
-        public MetricName createMetricName(String metricName)
-        {
-            return new MetricName(group, type, metricName, scope);
-        }
-    }
 }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/eb390d02/src/java/org/apache/cassandra/metrics/ReadRepairMetrics.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/metrics/ReadRepairMetrics.java b/src/java/org/apache/cassandra/metrics/ReadRepairMetrics.java
index 5b61e42..f9b1a40 100644
--- a/src/java/org/apache/cassandra/metrics/ReadRepairMetrics.java
+++ b/src/java/org/apache/cassandra/metrics/ReadRepairMetrics.java
@@ -1,6 +1,4 @@
-package org.apache.cassandra.metrics;
 /*
- * 
  * 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
@@ -8,39 +6,33 @@ package org.apache.cassandra.metrics;
  * 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.
- * 
+ *
+ *     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 org.apache.cassandra.metrics;
 
 import java.util.concurrent.TimeUnit;
 
 import com.yammer.metrics.Metrics;
-import com.yammer.metrics.core.Counter;
-import com.yammer.metrics.core.Gauge;
 import com.yammer.metrics.core.Meter;
-import com.yammer.metrics.core.MetricName;
-import com.yammer.metrics.util.RatioGauge;
 
 /**
  * Metrics related to Read Repair.
  */
-public class ReadRepairMetrics {
-    public static final String GROUP_NAME = "org.apache.cassandra.metrics";
-    public static final String TYPE_NAME = "ReadRepair";
-    
+public class ReadRepairMetrics
+{
+    private static final MetricNameFactory factory = new DefaultNameFactory("ReadRepair");
+
     public static final Meter repairedBlocking =
-            Metrics.newMeter(new MetricName(GROUP_NAME, TYPE_NAME, "RepairedBlocking"), "RepairedBlocking",
TimeUnit.SECONDS);
+            Metrics.newMeter(factory.createMetricName("RepairedBlocking"), "RepairedBlocking",
TimeUnit.SECONDS);
     public static final Meter repairedBackground =
-            Metrics.newMeter(new MetricName(GROUP_NAME, TYPE_NAME, "RepairedBackground"),
"RepairedBackground", TimeUnit.SECONDS);
+            Metrics.newMeter(factory.createMetricName("RepairedBackground"), "RepairedBackground",
TimeUnit.SECONDS);
     public static final Meter attempted = 
-            Metrics.newMeter(new MetricName(GROUP_NAME, TYPE_NAME, "Attempted"), "Attempted",
TimeUnit.SECONDS);
+            Metrics.newMeter(factory.createMetricName("Attempted"), "Attempted", TimeUnit.SECONDS);
 }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/eb390d02/src/java/org/apache/cassandra/metrics/StorageMetrics.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/metrics/StorageMetrics.java b/src/java/org/apache/cassandra/metrics/StorageMetrics.java
index ab7b886..8ee90bb 100644
--- a/src/java/org/apache/cassandra/metrics/StorageMetrics.java
+++ b/src/java/org/apache/cassandra/metrics/StorageMetrics.java
@@ -19,15 +19,16 @@ package org.apache.cassandra.metrics;
 
 import com.yammer.metrics.Metrics;
 import com.yammer.metrics.core.Counter;
-import com.yammer.metrics.core.MetricName;
 
 /**
  * Metrics related to Storage.
  */
 public class StorageMetrics
 {
-    public static final Counter load = Metrics.newCounter(new MetricName("org.apache.cassandra.metrics",
"Storage", "Load"));
-    public static final Counter exceptions = Metrics.newCounter(new MetricName("org.apache.cassandra.metrics",
"Storage", "Exceptions"));
-    public static final Counter totalHintsInProgress  = Metrics.newCounter(new MetricName("org.apache.cassandra.metrics",
"Storage", "TotalHintsInProgress"));
-    public static final Counter totalHints = Metrics.newCounter(new MetricName("org.apache.cassandra.metrics",
"Storage", "TotalHints"));
+    private static final MetricNameFactory factory = new DefaultNameFactory("Storage");
+
+    public static final Counter load = Metrics.newCounter(factory.createMetricName("Load"));
+    public static final Counter exceptions = Metrics.newCounter(factory.createMetricName("Exceptions"));
+    public static final Counter totalHintsInProgress  = Metrics.newCounter(factory.createMetricName("TotalHintsInProgress"));
+    public static final Counter totalHints = Metrics.newCounter(factory.createMetricName("TotalHints"));
 }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/eb390d02/src/java/org/apache/cassandra/metrics/StreamingMetrics.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/metrics/StreamingMetrics.java b/src/java/org/apache/cassandra/metrics/StreamingMetrics.java
index 96c79c9..51b4f8c 100644
--- a/src/java/org/apache/cassandra/metrics/StreamingMetrics.java
+++ b/src/java/org/apache/cassandra/metrics/StreamingMetrics.java
@@ -22,7 +22,6 @@ import java.util.concurrent.ConcurrentMap;
 
 import com.yammer.metrics.Metrics;
 import com.yammer.metrics.core.Counter;
-import com.yammer.metrics.core.MetricName;
 import org.cliffc.high_scale_lib.NonBlockingHashMap;
 
 /**
@@ -30,14 +29,13 @@ import org.cliffc.high_scale_lib.NonBlockingHashMap;
  */
 public class StreamingMetrics
 {
-    public static final String GROUP_NAME = "org.apache.cassandra.metrics";
     public static final String TYPE_NAME = "Streaming";
 
     private static final ConcurrentMap<InetAddress, StreamingMetrics> instances = new
NonBlockingHashMap<InetAddress, StreamingMetrics>();
 
-    public static final Counter activeStreamsOutbound = Metrics.newCounter(new MetricName(GROUP_NAME,
TYPE_NAME, "ActiveOutboundStreams"));
-    public static final Counter totalIncomingBytes = Metrics.newCounter(new MetricName(GROUP_NAME,
TYPE_NAME, "TotalIncomingBytes"));
-    public static final Counter totalOutgoingBytes = Metrics.newCounter(new MetricName(GROUP_NAME,
TYPE_NAME, "TotalOutgoingBytes"));
+    public static final Counter activeStreamsOutbound = Metrics.newCounter(DefaultNameFactory.createMetricName(TYPE_NAME,
"ActiveOutboundStreams", null));
+    public static final Counter totalIncomingBytes = Metrics.newCounter(DefaultNameFactory.createMetricName(TYPE_NAME,
"TotalIncomingBytes", null));
+    public static final Counter totalOutgoingBytes = Metrics.newCounter(DefaultNameFactory.createMetricName(TYPE_NAME,
"TotalOutgoingBytes", null));
     public final Counter incomingBytes;
     public final Counter outgoingBytes;
 
@@ -54,7 +52,8 @@ public class StreamingMetrics
 
     public StreamingMetrics(final InetAddress peer)
     {
-        incomingBytes = Metrics.newCounter(new MetricName(GROUP_NAME, TYPE_NAME, "IncomingBytes",
peer.getHostAddress().replaceAll(":", ".")));
-        outgoingBytes= Metrics.newCounter(new MetricName(GROUP_NAME, TYPE_NAME, "OutgoingBytes",
peer.getHostAddress().replaceAll(":", ".")));
+        MetricNameFactory factory = new DefaultNameFactory("Streaming", peer.getHostAddress().replaceAll(":",
"."));
+        incomingBytes = Metrics.newCounter(factory.createMetricName("IncomingBytes"));
+        outgoingBytes= Metrics.newCounter(factory.createMetricName("OutgoingBytes"));
     }
 }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/eb390d02/src/java/org/apache/cassandra/scheduler/WeightedQueue.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/scheduler/WeightedQueue.java b/src/java/org/apache/cassandra/scheduler/WeightedQueue.java
index 2d2e0bd..6ab5215 100644
--- a/src/java/org/apache/cassandra/scheduler/WeightedQueue.java
+++ b/src/java/org/apache/cassandra/scheduler/WeightedQueue.java
@@ -38,7 +38,7 @@ class WeightedQueue implements WeightedQueueMBean
         this.key = key;
         this.weight = weight;
         this.queue = new SynchronousQueue<Entry>(true);
-        this.metric =  new LatencyMetrics("org.apache.cassandra.metrics", "scheduler", "WeightedQueue",
key);
+        this.metric =  new LatencyMetrics("scheduler", "WeightedQueue", key);
     }
 
     public void register()


Mime
View raw message