This is an automated email from the ASF dual-hosted git repository.
brandonwilliams pushed a commit to branch cassandra-5.0
in repository https://gitbox.apache.org/repos/asf/cassandra.git
The following commit(s) were added to refs/heads/cassandra-5.0 by this push:
new 4093be5295 Nodetool paxos-only repair is no longer incremental
4093be5295 is described below
commit 4093be5295e15a3665b7ca49e9527785f5893bd9
Author: Brandon Williams <[email protected]>
AuthorDate: Fri Sep 8 09:02:55 2023 -0500
Nodetool paxos-only repair is no longer incremental
Patch by Ningzi Zhan; reviewed by brandonwilliams, jlewandowski, and
Maxwell Guo for CASSANDRA-18466
---
CHANGES.txt | 1 +
.../apache/cassandra/tools/nodetool/Repair.java | 2 +-
.../cassandra/tools/NodeToolCommandTest.java | 85 ++++++++++++++++++++++
3 files changed, 87 insertions(+), 1 deletion(-)
diff --git a/CHANGES.txt b/CHANGES.txt
index c65a1e6671..0622021b79 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -2,6 +2,7 @@
* Fix SAI's SegmentMetadata min and max primary keys (CASSANDRA-18734)
* Remove commons-codec dependency (CASSANDRA-18772)
Merged from 4.1:
+ * Nodetool paxos-only repair is no longer incremental (CASSANDRA-18466)
Merged from 4.0:
Merged from 3.11:
Merged from 3.0:
diff --git a/src/java/org/apache/cassandra/tools/nodetool/Repair.java
b/src/java/org/apache/cassandra/tools/nodetool/Repair.java
index 8e5aab255e..8b077628d8 100644
--- a/src/java/org/apache/cassandra/tools/nodetool/Repair.java
+++ b/src/java/org/apache/cassandra/tools/nodetool/Repair.java
@@ -149,7 +149,7 @@ public class Repair extends NodeToolCmd
parallelismDegree = RepairParallelism.DATACENTER_AWARE;
options.put(RepairOption.PARALLELISM_KEY,
parallelismDegree.getName());
options.put(RepairOption.PRIMARY_RANGE_KEY,
Boolean.toString(primaryRange));
- options.put(RepairOption.INCREMENTAL_KEY,
Boolean.toString(!fullRepair));
+ options.put(RepairOption.INCREMENTAL_KEY,
Boolean.toString(!fullRepair && !(paxosOnly && getPreviewKind() ==
PreviewKind.NONE)));
options.put(RepairOption.JOB_THREADS_KEY,
Integer.toString(numJobThreads));
options.put(RepairOption.TRACE_KEY, Boolean.toString(trace));
options.put(RepairOption.COLUMNFAMILIES_KEY,
StringUtils.join(cfnames, ","));
diff --git a/test/unit/org/apache/cassandra/tools/NodeToolCommandTest.java
b/test/unit/org/apache/cassandra/tools/NodeToolCommandTest.java
new file mode 100644
index 0000000000..8a3a6881ec
--- /dev/null
+++ b/test/unit/org/apache/cassandra/tools/NodeToolCommandTest.java
@@ -0,0 +1,85 @@
+/*
+ * 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.tools;
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Map;
+
+import org.apache.commons.lang3.ArrayUtils;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import org.apache.cassandra.repair.messages.RepairOption;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Mockito;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+public class NodeToolCommandTest
+{
+ final NodeProbe nodeProbe = Mockito.mock(NodeProbe.class);
+ final Output output = Output.CONSOLE;
+
+ final NodeProbeFactory repairNodeFactory = new NodeProbeFactory()
+ {
+ @Override
+ public NodeProbe create(String host, int port) throws IOException
+ {
+ return nodeProbe;
+ }
+
+ @Override
+ public NodeProbe create(String host, int port, String username, String
password) throws IOException
+ {
+ return nodeProbe;
+ }
+ };
+
+
+ @Before
+ public void beforeTest()
+ {
+ Mockito.reset(nodeProbe);
+ when(nodeProbe.getKeyspaces()).thenReturn(Arrays.asList("ks"));
+
when(nodeProbe.getNonSystemKeyspaces()).thenReturn(Arrays.asList("ks"));
+ when(nodeProbe.output()).thenReturn(output);
+ }
+
+ private Map<String, String> testRepairCommand(int expectedExitCode, String
...args) throws IOException
+ {
+ int result = new NodeTool(repairNodeFactory,
output).execute(ArrayUtils.addFirst(args, "repair"));
+ Assert.assertEquals(result, expectedExitCode);
+ ArgumentCaptor<Map<String, String>> optCaptor =
ArgumentCaptor.forClass(Map.class);
+ verify(nodeProbe).repairAsync(any(), any(), optCaptor.capture());
+ return optCaptor.getValue();
+ }
+
+ @Test
+ public void repairCommandTest() throws IOException
+ {
+ Map<String, String> options = testRepairCommand(0, "--paxos-only",
"ks");
+ Assert.assertEquals(options.get(RepairOption.PAXOS_ONLY_KEY),
Boolean.toString(true));
+ Assert.assertEquals(options.get(RepairOption.INCREMENTAL_KEY),
Boolean.toString(false));
+ }
+
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]