cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alek...@apache.org
Subject [2/6] cassandra git commit: Enable repair -pr and -local together (fix regression of CASSANDRA-7450)
Date Tue, 30 Aug 2016 15:55:56 GMT
Enable repair -pr and -local together (fix regression of CASSANDRA-7450)

Patch by Jérôme Mainaud; Reviewed by Paulo Motta for CASSANDRA-12522


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

Branch: refs/heads/cassandra-3.0
Commit: 6eff0829d2b3fe8fcac6622971b66792a4e82fef
Parents: acd46ab
Author: Jérôme Mainaud <jerome@mainaud.com>
Authored: Fri Aug 26 20:51:40 2016 -0300
Committer: Aleksey Yeschenko <aleksey@apache.org>
Committed: Tue Aug 30 16:46:01 2016 +0100

----------------------------------------------------------------------
 CHANGES.txt                                     |  1 +
 .../cassandra/repair/messages/RepairOption.java |  6 +++++-
 .../cassandra/service/StorageService.java       |  2 +-
 .../repair/messages/RepairOptionTest.java       | 20 ++++++++++++++++++++
 4 files changed, 27 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/6eff0829/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 74c44f8..0f7cf0e 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 2.2.8
+ * Enable repair -pr and -local together (fix regression of CASSANDRA-7450) (CASSANDRA-12522)
  * Fail repair on non-existing table (CASSANDRA-12279)
  * cqlsh copy: fix missing counter values (CASSANDRA-12476)
  * Move migration tasks to non-periodic queue, assure flush executor shutdown after non-periodic
executor (CASSANDRA-12251)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6eff0829/src/java/org/apache/cassandra/repair/messages/RepairOption.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/repair/messages/RepairOption.java b/src/java/org/apache/cassandra/repair/messages/RepairOption.java
index d50a2ed..44a1e57 100644
--- a/src/java/org/apache/cassandra/repair/messages/RepairOption.java
+++ b/src/java/org/apache/cassandra/repair/messages/RepairOption.java
@@ -208,7 +208,7 @@ public class RepairOption
         {
             throw new IllegalArgumentException("Too many job threads. Max is " + MAX_JOB_THREADS);
         }
-        if (primaryRange && (!dataCenters.isEmpty() || !hosts.isEmpty()))
+        if (primaryRange && ((!dataCenters.isEmpty() && !option.isInLocalDCOnly())
|| !hosts.isEmpty()))
         {
             throw new IllegalArgumentException("You need to run primary range repair on all
nodes in the cluster.");
         }
@@ -303,6 +303,10 @@ public class RepairOption
         return isSubrangeRepair;
     }
 
+    public boolean isInLocalDCOnly() {
+        return dataCenters.size() == 1 && dataCenters.contains(DatabaseDescriptor.getLocalDataCenter());
+    }
+
     @Override
     public String toString()
     {

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6eff0829/src/java/org/apache/cassandra/service/StorageService.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/service/StorageService.java b/src/java/org/apache/cassandra/service/StorageService.java
index e8ab54e..48a291b 100644
--- a/src/java/org/apache/cassandra/service/StorageService.java
+++ b/src/java/org/apache/cassandra/service/StorageService.java
@@ -2801,7 +2801,7 @@ public class StorageService extends NotificationBroadcasterSupport implements
IE
                 if (option.getDataCenters().isEmpty() && option.getHosts().isEmpty())
                     option.getRanges().addAll(getPrimaryRanges(keyspace));
                     // except dataCenters only contain local DC (i.e. -local)
-                else if (option.getDataCenters().size() == 1 && option.getDataCenters().contains(DatabaseDescriptor.getLocalDataCenter()))
+                else if (option.isInLocalDCOnly())
                     option.getRanges().addAll(getPrimaryRangesWithinDC(keyspace));
                 else
                     throw new IllegalArgumentException("You need to run primary range repair
on all nodes in the cluster.");

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6eff0829/test/unit/org/apache/cassandra/repair/messages/RepairOptionTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/repair/messages/RepairOptionTest.java b/test/unit/org/apache/cassandra/repair/messages/RepairOptionTest.java
index cc6f46a..a0eea4e 100644
--- a/test/unit/org/apache/cassandra/repair/messages/RepairOptionTest.java
+++ b/test/unit/org/apache/cassandra/repair/messages/RepairOptionTest.java
@@ -97,6 +97,26 @@ public class RepairOptionTest
     }
 
     @Test
+    public void testPrWithLocalParseOptions()
+    {
+        DatabaseDescriptor.forceStaticInitialization();
+
+        Map<String, String> options = new HashMap<>();
+        options.put(RepairOption.PARALLELISM_KEY, "parallel");
+        options.put(RepairOption.PRIMARY_RANGE_KEY, "true");
+        options.put(RepairOption.INCREMENTAL_KEY, "false");
+        options.put(RepairOption.COLUMNFAMILIES_KEY, "cf1,cf2,cf3");
+        options.put(RepairOption.DATACENTERS_KEY, "datacenter1");
+
+        RepairOption option = RepairOption.parse(options, Murmur3Partitioner.instance);
+        assertTrue(option.isPrimaryRange());
+
+        Set<String> expectedDCs = new HashSet<>(3);
+        expectedDCs.add("datacenter1");
+        assertEquals(expectedDCs, option.getDataCenters());
+    }
+
+    @Test
     public void testIncrementalRepairWithSubrangesIsNotGlobal() throws Exception
     {
         RepairOption ro = RepairOption.parse(ImmutableMap.of(RepairOption.INCREMENTAL_KEY,
"true", RepairOption.RANGES_KEY, "42:42"),


Mime
View raw message