You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pr@cassandra.apache.org by GitBox <gi...@apache.org> on 2020/11/21 00:24:06 UTC

[GitHub] [cassandra] yifan-c commented on a change in pull request #831: CASSANDRA-16095 - Nodetool tablestats WriteLatency error

yifan-c commented on a change in pull request #831:
URL: https://github.com/apache/cassandra/pull/831#discussion_r528031218



##########
File path: src/java/org/apache/cassandra/metrics/TableMetrics.java
##########
@@ -62,7 +62,17 @@
  */
 public class TableMetrics
 {
+    /**
+     * stores metrics that will be rolled into a single global metric
+     */
+    private static final ConcurrentMap<String, Set<Metric>> ALL_TABLE_METRICS = Maps.newConcurrentMap();
     public static final long[] EMPTY = new long[0];
+    private static final MetricNameFactory GLOBAL_FACTORY = new AllTableMetricNameFactory("Table");
+    private static final MetricNameFactory GLOBAL_ALIAS_FACTORY = new AllTableMetricNameFactory("ColumnFamily");
+
+    public final static LatencyMetrics GLOBAL_READ_LATENCY = new LatencyMetrics(GLOBAL_FACTORY, GLOBAL_ALIAS_FACTORY, "Read");
+    public final static LatencyMetrics GLOBAL_WRITE_LATENCY = new LatencyMetrics(GLOBAL_FACTORY, GLOBAL_ALIAS_FACTORY, "Write");
+    public final static LatencyMetrics GLOBAL_RANGE_LATENCY = new LatencyMetrics(GLOBAL_FACTORY, GLOBAL_ALIAS_FACTORY, "Range");

Review comment:
       great to group the static variable together. 

##########
File path: src/java/org/apache/cassandra/metrics/TableMetrics.java
##########
@@ -609,7 +609,7 @@ public Long getValue()
             public Long getValue()
             {
                 long min = Long.MAX_VALUE;
-                for (Metric cfGauge : allTableMetrics.get("MinPartitionSize"))
+                for (Metric cfGauge : ALL_TABLE_METRICS.get("MinPartitionSize"))

Review comment:
       nit: maybe also create constants for the metrics names? since this patch is doing some code cleanup already. 
   (Maybe too much work. your call)

##########
File path: src/java/org/apache/cassandra/config/CassandraRelevantProperties.java
##########
@@ -196,6 +199,28 @@ public String getString()
         return value == null ? defaultVal : STRING_CONVERTER.convert(value);
     }
 
+    /**

Review comment:
       The get with overrideDefaultValue methods are not used. Not a big problem if the other patch referenced is to be merged. 

##########
File path: test/distributed/org/apache/cassandra/distributed/test/metric/TableMetricTest.java
##########
@@ -0,0 +1,210 @@
+/*
+ * 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.distributed.test.metric;
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import javax.management.InstanceAlreadyExistsException;
+import javax.management.InstanceNotFoundException;
+import javax.management.ObjectName;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+import org.junit.Assert;
+import org.junit.Test;
+
+import org.apache.cassandra.db.ColumnFamilyStore;
+import org.apache.cassandra.distributed.Cluster;
+import org.apache.cassandra.distributed.api.IInvokableInstance;
+import org.apache.cassandra.distributed.test.TestBaseImpl;
+import org.apache.cassandra.utils.MBeanWrapper;
+
+import static org.apache.cassandra.config.CassandraRelevantProperties.IS_DISABLED_MBEAN_REGISTRATION;
+import static org.apache.cassandra.config.CassandraRelevantProperties.MBEAN_REGISTRATION_CLASS;
+
+public class TableMetricTest extends TestBaseImpl
+{
+    static
+    {
+        MBEAN_REGISTRATION_CLASS.setString(MapMBeanWrapper.class.getName());
+        IS_DISABLED_MBEAN_REGISTRATION.setBoolean(false);
+    }
+
+    private static Map<String, Collection<String>> SYSTEM_TABLES = ImmutableMap.of(
+    "system", ImmutableSet.of("available_ranges", "available_ranges_v2", "batches", "built_views", "compaction_history", "IndexInfo", "local",

Review comment:
       I think it is better to load the tables programmatically. So compiler prompts when code changes. It can be done via
   
   ```java
           Map<String, Collection<String>> systemTables = new HashMap<>();
           Consumer<KeyspaceMetadata> loader = meta ->
           {
               Set<String> tables = meta.tables.stream().map(t -> t.name).collect(Collectors.toSet());
               systemTables.put(meta.name, tables);
           };
           Arrays.asList(SystemKeyspace.metadata(), AuthKeyspace.metadata(), SystemDistributedKeyspace.metadata(),
                         SchemaKeyspace.metadata(), TraceKeyspace.metadata())
                 .forEach(loader);
   ```




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org