This is an automated email from the ASF dual-hosted git repository. marcuse pushed a commit to branch trunk in repository https://gitbox.apache.org/repos/asf/cassandra.git
commit dcf6fe8162f00353dae497a6adcfec2ac88f8e0a Author: Blake Eggleston <bdeggles...@gmail.com> AuthorDate: Tue Mar 17 15:51:36 2020 +0100 Emit metric on preview repair failure Patch by Blake Eggleston; reviewed by Ekaterina Dimitrova for CASSANDRA-15654 --- CHANGES.txt | 1 + .../apache/cassandra/metrics/RepairMetrics.java | 34 ++++++++++++++++++++++ .../apache/cassandra/repair/RepairRunnable.java | 2 ++ .../repair/consistent/SyncStatSummary.java | 12 ++++++++ .../cassandra/service/ActiveRepairService.java | 2 ++ 5 files changed, 51 insertions(+) diff --git a/CHANGES.txt b/CHANGES.txt index b71d8da..9896272 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,4 +1,5 @@ 4.0-alpha4 + * Emit metric on preview repair failure (CASSANDRA-15654) * Use more appropriate logging levels (CASSANDRA-15661) * Added production recommendations and improved compaction doc organization * Document usage of EC2Snitch with intra-region VPC peering (CASSANDRA-15337) diff --git a/src/java/org/apache/cassandra/metrics/RepairMetrics.java b/src/java/org/apache/cassandra/metrics/RepairMetrics.java new file mode 100644 index 0000000..5b4f67e --- /dev/null +++ b/src/java/org/apache/cassandra/metrics/RepairMetrics.java @@ -0,0 +1,34 @@ +/* + * 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.codahale.metrics.Counter; + +import static org.apache.cassandra.metrics.CassandraMetricsRegistry.Metrics; + +public class RepairMetrics +{ + public static final String TYPE_NAME = "Repair"; + public static final Counter previewFailures = Metrics.counter(DefaultNameFactory.createMetricName(TYPE_NAME, "PreviewFailures", null)); + + public static void init() + { + // noop + } +} diff --git a/src/java/org/apache/cassandra/repair/RepairRunnable.java b/src/java/org/apache/cassandra/repair/RepairRunnable.java index c673a6c..0ac34a3 100644 --- a/src/java/org/apache/cassandra/repair/RepairRunnable.java +++ b/src/java/org/apache/cassandra/repair/RepairRunnable.java @@ -53,6 +53,7 @@ import com.codahale.metrics.Timer; import org.apache.cassandra.concurrent.JMXEnabledThreadPoolExecutor; import org.apache.cassandra.concurrent.NamedThreadFactory; import org.apache.cassandra.config.DatabaseDescriptor; +import org.apache.cassandra.metrics.RepairMetrics; import org.apache.cassandra.cql3.QueryOptions; import org.apache.cassandra.cql3.QueryProcessor; import org.apache.cassandra.cql3.UntypedResultSet; @@ -527,6 +528,7 @@ public class RepairRunnable implements Runnable, ProgressEventNotifier else { message = (previewKind == PreviewKind.REPAIRED ? "Repaired data is inconsistent\n" : "Preview complete\n") + summary.toString(); + RepairMetrics.previewFailures.inc(); } notification(message); diff --git a/src/java/org/apache/cassandra/repair/consistent/SyncStatSummary.java b/src/java/org/apache/cassandra/repair/consistent/SyncStatSummary.java index 156fde7..f8e1bfb 100644 --- a/src/java/org/apache/cassandra/repair/consistent/SyncStatSummary.java +++ b/src/java/org/apache/cassandra/repair/consistent/SyncStatSummary.java @@ -30,6 +30,8 @@ import org.apache.cassandra.locator.InetAddressAndPort; import org.apache.cassandra.repair.RepairResult; import org.apache.cassandra.repair.RepairSessionResult; import org.apache.cassandra.repair.SyncStat; +import org.apache.cassandra.schema.Schema; +import org.apache.cassandra.schema.TableMetadata; import org.apache.cassandra.streaming.SessionSummary; import org.apache.cassandra.streaming.StreamSummary; import org.apache.cassandra.utils.FBUtilities; @@ -130,6 +132,12 @@ public class SyncStatSummary totalsCalculated = true; } + boolean isCounter() + { + TableMetadata tmd = Schema.instance.getTableMetadata(keyspace, table); + return tmd != null && tmd.isCounter(); + } + public String toString() { if (!totalsCalculated) @@ -192,6 +200,10 @@ public class SyncStatSummary summaries.values().forEach(Table::calculateTotals); for (Table table: summaries.values()) { + if (table.isCounter()) + { + continue; + } table.calculateTotals(); files += table.files; bytes += table.bytes; diff --git a/src/java/org/apache/cassandra/service/ActiveRepairService.java b/src/java/org/apache/cassandra/service/ActiveRepairService.java index 467d2bc..c679987 100644 --- a/src/java/org/apache/cassandra/service/ActiveRepairService.java +++ b/src/java/org/apache/cassandra/service/ActiveRepairService.java @@ -58,6 +58,7 @@ import org.apache.cassandra.gms.IFailureDetectionEventListener; import org.apache.cassandra.gms.VersionedValue; import org.apache.cassandra.locator.InetAddressAndPort; import org.apache.cassandra.locator.TokenMetadata; +import org.apache.cassandra.metrics.RepairMetrics; import org.apache.cassandra.net.RequestCallback; import org.apache.cassandra.net.Message; import org.apache.cassandra.net.MessagingService; @@ -142,6 +143,7 @@ public class ActiveRepairService implements IEndpointStateChangeSubscriber, IFai new NamedThreadFactory("Repair-Task"), "internal", new ThreadPoolExecutor.AbortPolicy()); + RepairMetrics.init(); } private final IFailureDetector failureDetector; --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org For additional commands, e-mail: commits-h...@cassandra.apache.org