add cassandra.default_messaging_version patch by Minh Do; reviewed by jbellis for CASSANDRA-6619
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/1d81765d Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/1d81765d Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/1d81765d Branch: refs/heads/cassandra-2.0 Commit: 1d81765daa1360aa361c12774838cd705ddc4116 Parents: 35c78d6 Author: Jonathan Ellis <jbel...@apache.org> Authored: Wed Jan 29 09:48:41 2014 -0600 Committer: Jonathan Ellis <jbel...@apache.org> Committed: Wed Jan 29 09:48:51 2014 -0600 ---------------------------------------------------------------------- CHANGES.txt | 2 ++ NEWS.txt | 9 ++++++ .../cassandra/net/OutboundTcpConnection.java | 29 ++++++++++++++++---- 3 files changed, 35 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/1d81765d/CHANGES.txt ---------------------------------------------------------------------- diff --git a/CHANGES.txt b/CHANGES.txt index ec546db..2920c15 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,4 +1,6 @@ 1.2.14 + * add cassandra.default_messaging_version property to allow easier + upgrading from 1.1 (CASSANDRA-6619) * Allow executing CREATE statements multiple times (CASSANDRA-6471) * Don't send confusing info with timeouts (CASSANDRA-6491) * Don't resubmit counter mutation runnables internally (CASSANDRA-6427) http://git-wip-us.apache.org/repos/asf/cassandra/blob/1d81765d/NEWS.txt ---------------------------------------------------------------------- diff --git a/NEWS.txt b/NEWS.txt index 8c22bea..53cb7ca 100644 --- a/NEWS.txt +++ b/NEWS.txt @@ -22,6 +22,15 @@ Features - Batchlog replay can be, and is throttled by default now. See batchlog_replay_throttle_in_kb setting in cassandra.yaml. +Upgrading +--------- + - The system property cassandra.default_messaging_version has been added + to allow faster upgrades from 1.1. Normally, a 1.2 node will need to + wait until a 1.1 node connects to it to discover that the 1.1 node uses + an older internal message protocol; setting this property (to 5, + corresponding to 1.1.7+) will allow newly upgraded 1.2 nodes to + participate in a mostly-1.1 cluster faster. + 1.2.13 ====== http://git-wip-us.apache.org/repos/asf/cassandra/blob/1d81765d/src/java/org/apache/cassandra/net/OutboundTcpConnection.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/net/OutboundTcpConnection.java b/src/java/org/apache/cassandra/net/OutboundTcpConnection.java index 4edac5d..9989221 100644 --- a/src/java/org/apache/cassandra/net/OutboundTcpConnection.java +++ b/src/java/org/apache/cassandra/net/OutboundTcpConnection.java @@ -36,15 +36,14 @@ import java.util.concurrent.atomic.AtomicLong; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.apache.cassandra.config.Config; +import org.apache.cassandra.config.DatabaseDescriptor; import org.apache.cassandra.tracing.TraceState; import org.apache.cassandra.tracing.Tracing; import org.apache.cassandra.utils.FBUtilities; import org.apache.cassandra.utils.UUIDGen; import org.xerial.snappy.SnappyOutputStream; -import org.apache.cassandra.config.Config; -import org.apache.cassandra.config.DatabaseDescriptor; - public class OutboundTcpConnection extends Thread { private static final Logger logger = LoggerFactory.getLogger(OutboundTcpConnection.class); @@ -322,6 +321,8 @@ public class OutboundTcpConnection extends Thread } out = new DataOutputStream(new BufferedOutputStream(socket.getOutputStream(), 4096)); + // (MS defaults to assuming everyone else is on the same version as us until proven otherwise, so this + // code will run once even for older nodes, which allows us to reset the version to the correct one) if (targetVersion >= MessagingService.VERSION_12) { out.writeInt(MessagingService.PROTOCOL_MAGIC); @@ -335,8 +336,26 @@ public class OutboundTcpConnection extends Thread // no version is returned, so disconnect an try again: we will either get // a different target version (targetVersion < MessagingService.VERSION_12) // or if the same version the handshake will finally succeed - logger.debug("Target max version is {}; no version information yet, will retry", maxTargetVersion); - disconnect(); + //Try to downgrade to the version passed in from the env variable + if (System.getProperty("cassandra.default_messaging_version") != null) + { + try + { + int defaultVersion = Integer.parseInt(System.getProperty("cassandra.default_messaging_version")); + logger.debug("No messaging version received; assuming default of {} ", defaultVersion); + MessagingService.instance().setVersion(poolReference.endPoint(), defaultVersion); + } + catch (NumberFormatException e) + { + logger.debug("Unable to parse the value of cassandra.default_messaging_version"); + } + } + else + { + logger.debug("No messaging version received; will retry", maxTargetVersion); + } + + disconnect(); //do we need to disconnect? continue; } if (targetVersion > maxTargetVersion)