You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by dc...@apache.org on 2020/09/08 23:48:02 UTC
[cassandra] branch trunk updated: When compaction gets interrupted,
the exception should include the compactionId
This is an automated email from the ASF dual-hosted git repository.
dcapwell pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/cassandra.git
The following commit(s) were added to refs/heads/trunk by this push:
new 7f258f1 When compaction gets interrupted, the exception should include the compactionId
7f258f1 is described below
commit 7f258f1ef6d79c908c4d846d8616d8f5554282ea
Author: Yifan Cai <yc...@gmail.com>
AuthorDate: Tue Sep 8 14:41:47 2020 -0700
When compaction gets interrupted, the exception should include the compactionId
patch by Yifan Cai; reviewed by David Capwell, Caleb Rackliffe for CASSANDRA-15954
---
CHANGES.txt | 1 +
.../cassandra/db/compaction/CompactionInfo.java | 19 +++-----
.../db/compaction/CompactionInfoTest.java | 56 ++++++++++++++++++++++
3 files changed, 63 insertions(+), 13 deletions(-)
diff --git a/CHANGES.txt b/CHANGES.txt
index 1e188bd..4efccd7 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -3,6 +3,7 @@
* Add nodetool getfullquerylog (CASSANDRA-15988)
* Fix yaml format and alignment in tpstats (CASSANDRA-11402)
* Avoid trying to keep track of RTs for endpoints we won't write to during read repair (CASSANDRA-16084)
+ * When compaction gets interrupted, the exception should include the compactionId (CASSANDRA-15954)
4.0-beta2
* Add addition incremental repair visibility to nodetool repair_admin (CASSANDRA-14939)
diff --git a/src/java/org/apache/cassandra/db/compaction/CompactionInfo.java b/src/java/org/apache/cassandra/db/compaction/CompactionInfo.java
index 275ce70..bdddaab 100644
--- a/src/java/org/apache/cassandra/db/compaction/CompactionInfo.java
+++ b/src/java/org/apache/cassandra/db/compaction/CompactionInfo.java
@@ -127,27 +127,20 @@ public final class CompactionInfo
return sstables;
}
+ @Override
public String toString()
{
- StringBuilder buff = new StringBuilder();
- buff.append(getTaskType());
-
if (metadata != null)
{
- buff.append('@').append(metadata.id).append('(');
- buff.append(metadata.keyspace).append(", ").append(metadata.name).append(", ");
+ return String.format("%s(%s, %s / %s %s)@%s(%s, %s)",
+ tasktype, compactionId, completed, total, unit,
+ metadata.id, metadata.keyspace, metadata.name);
}
else
{
- buff.append('(');
+ return String.format("%s(%s, %s / %s %s)",
+ tasktype, compactionId, completed, total, unit);
}
- buff.append(getCompleted())
- .append('/')
- .append(getTotal())
- .append(')')
- .append(unit);
-
- return buff.toString();
}
public Map<String, String> asMap()
diff --git a/test/unit/org/apache/cassandra/db/compaction/CompactionInfoTest.java b/test/unit/org/apache/cassandra/db/compaction/CompactionInfoTest.java
new file mode 100644
index 0000000..c0196e8
--- /dev/null
+++ b/test/unit/org/apache/cassandra/db/compaction/CompactionInfoTest.java
@@ -0,0 +1,56 @@
+/*
+ * 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.db.compaction;
+
+import java.util.ArrayList;
+import java.util.UUID;
+import java.util.regex.Pattern;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import org.apache.cassandra.db.ColumnFamilyStore;
+import org.apache.cassandra.db.repair.AbstractPendingAntiCompactionTest;
+import org.apache.cassandra.schema.MockSchema;
+import org.apache.cassandra.schema.TableId;
+import org.assertj.core.api.Assertions;
+
+public class CompactionInfoTest extends AbstractPendingAntiCompactionTest
+{
+ @Test
+ public void testCompactionInfoToStringContainsTaskId()
+ {
+ ColumnFamilyStore cfs = MockSchema.newCFS();
+ UUID expectedTaskId = UUID.randomUUID();
+ CompactionInfo compactionInfo = new CompactionInfo(cfs.metadata(), OperationType.COMPACTION, 0, 1000, expectedTaskId, new ArrayList<>());
+ Assertions.assertThat(compactionInfo.toString())
+ .contains(expectedTaskId.toString());
+ }
+
+ @Test
+ public void testCompactionInfoToStringFormat()
+ {
+ UUID tableId = UUID.randomUUID();
+ UUID taskId = UUID.randomUUID();
+ ColumnFamilyStore cfs = MockSchema.newCFS(builder -> builder.id(TableId.fromUUID(tableId)));
+ CompactionInfo compactionInfo = new CompactionInfo(cfs.metadata(), OperationType.COMPACTION, 0, 1000, taskId, new ArrayList<>());
+ Assertions.assertThat(compactionInfo.toString())
+ .isEqualTo("Compaction(%s, 0 / 1000 bytes)@%s(mockks, mockcf1)", taskId, tableId);
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org