Repository: cassandra
Updated Branches:
  refs/heads/trunk 30ed83d92 -> 2b507c03c


Throw exception if we send/receive repair messages to incompatible nodes

Patch by Blake Eggleston; Reviewed by Marcus Eriksson for CASSANDRA-13944


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

Branch: refs/heads/trunk
Commit: 2b507c03c5190c744c5e84d7ca5cf7afa2b5c2ae
Parents: 30ed83d
Author: Blake Eggleston <bdeggles...@gmail.com>
Authored: Mon Oct 9 14:39:45 2017 -0700
Committer: Blake Eggleston <bdeggles...@gmail.com>
Committed: Tue Oct 24 13:54:09 2017 -0700

----------------------------------------------------------------------
 CHANGES.txt                                               |  1 +
 .../apache/cassandra/repair/messages/RepairMessage.java   | 10 ++++++++++
 2 files changed, 11 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/2b507c03/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 157cbff..c046187 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 4.0
+ * Throw exception if we send/receive repair messages to incompatible nodes 
(CASSANDRA-13944)
  * Replace usages of MessageDigest with Guava's Hasher (CASSANDRA-13291)
  * Add nodetool cmd to print hinted handoff window (CASSANDRA-13728)
  * Fix some alerts raised by static analysis (CASSANDRA-13799)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/2b507c03/src/java/org/apache/cassandra/repair/messages/RepairMessage.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/repair/messages/RepairMessage.java 
b/src/java/org/apache/cassandra/repair/messages/RepairMessage.java
index 3cb913a..b72f139 100644
--- a/src/java/org/apache/cassandra/repair/messages/RepairMessage.java
+++ b/src/java/org/apache/cassandra/repair/messages/RepairMessage.java
@@ -19,6 +19,8 @@ package org.apache.cassandra.repair.messages;
 
 import java.io.IOException;
 
+import com.google.common.base.Preconditions;
+
 import org.apache.cassandra.io.IVersionedSerializer;
 import org.apache.cassandra.io.util.DataInputPlus;
 import org.apache.cassandra.io.util.DataOutputPlus;
@@ -37,6 +39,10 @@ public abstract class RepairMessage
 
     public static interface MessageSerializer<T extends RepairMessage> extends 
IVersionedSerializer<T> {}
 
+    public static final int MIN_MESSAGING_VERSION = 
MessagingService.VERSION_40;
+    private static final String MIXED_MODE_ERROR = "Some nodes involved in 
repair are on an incompatible major version. " +
+                                                   "Repair is not supported in 
mixed major version clusters.";
+
     public enum Type
     {
         VALIDATION_REQUEST(0, ValidationRequest.serializer),
@@ -90,22 +96,26 @@ public abstract class RepairMessage
         return new MessageOut<>(MessagingService.Verb.REPAIR_MESSAGE, this, 
RepairMessage.serializer);
     }
 
+
     public static class RepairMessageSerializer implements 
MessageSerializer<RepairMessage>
     {
         public void serialize(RepairMessage message, DataOutputPlus out, int 
version) throws IOException
         {
+            Preconditions.checkArgument(version >= MIN_MESSAGING_VERSION, 
MIXED_MODE_ERROR);
             out.write(message.messageType.type);
             message.messageType.serializer.serialize(message, out, version);
         }
 
         public RepairMessage deserialize(DataInputPlus in, int version) throws 
IOException
         {
+            Preconditions.checkArgument(version >= MIN_MESSAGING_VERSION, 
MIXED_MODE_ERROR);
             RepairMessage.Type messageType = 
RepairMessage.Type.fromByte(in.readByte());
             return messageType.serializer.deserialize(in, version);
         }
 
         public long serializedSize(RepairMessage message, int version)
         {
+            Preconditions.checkArgument(version >= MIN_MESSAGING_VERSION, 
MIXED_MODE_ERROR);
             long size = 1; // for messageType byte
             size += message.messageType.serializer.serializedSize(message, 
version);
             return size;


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org
For additional commands, e-mail: commits-h...@cassandra.apache.org

Reply via email to