diff --git a/CHANGES.txt b/CHANGES.txt index b81efe04ca..1cf4483a85 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -34,6 +34,7 @@ dev mutations (CASSANDRA-1179) * avoid allocating a new byte[] for each mutation on replay (CASSANDRA-1219) * revise HH schema to be per-endpoint (CASSANDRA-1142) + * remove gossip message size limit (CASSANDRA-1138) 0.6.3 diff --git a/src/java/org/apache/cassandra/gms/EndpointState.java b/src/java/org/apache/cassandra/gms/EndpointState.java index ec9d7da2f7..e3325a4d62 100644 --- a/src/java/org/apache/cassandra/gms/EndpointState.java +++ b/src/java/org/apache/cassandra/gms/EndpointState.java @@ -145,9 +145,6 @@ class EndpointStateSerializer implements ICompactSerializer public void serialize(EndpointState epState, DataOutputStream dos) throws IOException { - /* These are for estimating whether we overshoot the MTU limit */ - int estimate = 0; - /* serialize the HeartBeatState */ HeartBeatState hbState = epState.getHeartBeatState(); HeartBeatState.serializer().serialize(hbState, dos); @@ -155,26 +152,13 @@ class EndpointStateSerializer implements ICompactSerializer /* serialize the map of ApplicationState objects */ int size = epState.applicationState_.size(); dos.writeInt(size); - if ( size > 0 ) - { - Set keys = epState.applicationState_.keySet(); - for( String key : keys ) + for (String key : epState.applicationState_.keySet()) + { + ApplicationState appState = epState.applicationState_.get(key); + if (appState != null) { - if ( Gossiper.MAX_GOSSIP_PACKET_SIZE - dos.size() < estimate ) - { - logger_.info("@@@@ Breaking out to respect the MTU size in EndpointState serializer. Estimate is {} @@@@", estimate);; - break; - } - - ApplicationState appState = epState.applicationState_.get(key); - if ( appState != null ) - { - int pre = dos.size(); - dos.writeUTF(key); - ApplicationState.serializer().serialize(appState, dos); - int post = dos.size(); - estimate = post - pre; - } + dos.writeUTF(key); + ApplicationState.serializer().serialize(appState, dos); } } } @@ -191,8 +175,8 @@ class EndpointStateSerializer implements ICompactSerializer { break; } - - String key = dis.readUTF(); + + String key = dis.readUTF(); ApplicationState appState = ApplicationState.serializer().deserialize(dis); epState.addApplicationState(key, appState); } diff --git a/src/java/org/apache/cassandra/gms/GossipDigestAckMessage.java b/src/java/org/apache/cassandra/gms/GossipDigestAckMessage.java index ea565e6501..e306d099a1 100644 --- a/src/java/org/apache/cassandra/gms/GossipDigestAckMessage.java +++ b/src/java/org/apache/cassandra/gms/GossipDigestAckMessage.java @@ -70,26 +70,16 @@ class GossipDigestAckMessageSerializer implements ICompactSerializer epStateMap = new HashMap(); - List gDigestList = GossipDigestSerializationHelper.deserialize(dis); - boolean bContinue = dis.readBoolean(); - - if ( bContinue ) - { - epStateMap = EndpointStatesSerializationHelper.deserialize(dis); - } + List gDigestList = GossipDigestSerializationHelper.deserialize(dis); + dis.readBoolean(); // 0.6 compatibility + Map epStateMap = EndpointStatesSerializationHelper.deserialize(dis); return new GossipDigestAckMessage(gDigestList, epStateMap); } } diff --git a/src/java/org/apache/cassandra/gms/GossipDigestSynMessage.java b/src/java/org/apache/cassandra/gms/GossipDigestSynMessage.java index 5ea8f5b25f..2e978a7413 100644 --- a/src/java/org/apache/cassandra/gms/GossipDigestSynMessage.java +++ b/src/java/org/apache/cassandra/gms/GossipDigestSynMessage.java @@ -69,44 +69,24 @@ class GossipDigestSerializationHelper { private static Logger logger_ = LoggerFactory.getLogger(GossipDigestSerializationHelper.class); - static boolean serialize(List gDigestList, DataOutputStream dos) throws IOException + static void serialize(List gDigestList, DataOutputStream dos) throws IOException { - boolean bVal = true; - int size = gDigestList.size(); - dos.writeInt(size); - - int estimate = 0; + dos.writeInt(gDigestList.size()); for ( GossipDigest gDigest : gDigestList ) { - if ( Gossiper.MAX_GOSSIP_PACKET_SIZE - dos.size() < estimate ) - { - logger_.info("@@@@ Breaking out to respect the MTU size in GD @@@@"); - bVal = false; - break; - } - int pre = dos.size(); GossipDigest.serializer().serialize( gDigest, dos ); - int post = dos.size(); - estimate = post - pre; } - return bVal; } static List deserialize(DataInputStream dis) throws IOException { int size = dis.readInt(); - List gDigests = new ArrayList(); + List gDigests = new ArrayList(size); for ( int i = 0; i < size; ++i ) { - if ( dis.available() == 0 ) - { - logger_.info("Remaining bytes zero. Stopping deserialization of GossipDigests."); - break; - } - - GossipDigest gDigest = GossipDigest.serializer().deserialize(dis); - gDigests.add( gDigest ); + assert dis.available() > 0; + gDigests.add(GossipDigest.serializer().deserialize(dis)); } return gDigests; } @@ -116,49 +96,29 @@ class EndpointStatesSerializationHelper { private static final Logger logger_ = LoggerFactory.getLogger(EndpointStatesSerializationHelper.class); - static boolean serialize(Map epStateMap, DataOutputStream dos) throws IOException + static void serialize(Map epStateMap, DataOutputStream dos) throws IOException { - boolean bVal = true; - int estimate = 0; - int size = epStateMap.size(); - dos.writeInt(size); - + dos.writeInt(epStateMap.size()); for (Entry entry : epStateMap.entrySet()) { InetAddress ep = entry.getKey(); - if ( Gossiper.MAX_GOSSIP_PACKET_SIZE - dos.size() < estimate ) - { - logger_.info("@@@@ Breaking out to respect the MTU size in EPS. Estimate is " + estimate + " @@@@"); - bVal = false; - break; - } - - int pre = dos.size(); CompactEndpointSerializationHelper.serialize(ep, dos); EndpointState.serializer().serialize(entry.getValue(), dos); - int post = dos.size(); - estimate = post - pre; } - return bVal; } static Map deserialize(DataInputStream dis) throws IOException { int size = dis.readInt(); - Map epStateMap = new HashMap(); - + Map epStateMap = new HashMap(size); + for ( int i = 0; i < size; ++i ) { - if ( dis.available() == 0 ) - { - logger_.info("Remaining bytes zero. Stopping deserialization in EndpointState."); - break; - } - // int length = dis.readInt(); + assert dis.available() > 0; InetAddress ep = CompactEndpointSerializationHelper.deserialize(dis); EndpointState epState = EndpointState.serializer().deserialize(dis); epStateMap.put(ep, epState); - } + } return epStateMap; } } diff --git a/src/java/org/apache/cassandra/gms/Gossiper.java b/src/java/org/apache/cassandra/gms/Gossiper.java index 4addd50e5a..b30d83a831 100644 --- a/src/java/org/apache/cassandra/gms/Gossiper.java +++ b/src/java/org/apache/cassandra/gms/Gossiper.java @@ -102,7 +102,6 @@ public class Gossiper implements IFailureDetectionEventListener, IEndpointStateC } } - final static int MAX_GOSSIP_PACKET_SIZE = 1428; public final static int intervalInMillis_ = 1000; private static Logger logger_ = LoggerFactory.getLogger(Gossiper.class); public static final Gossiper instance = new Gossiper(); @@ -287,7 +286,7 @@ public class Gossiper implements IFailureDetectionEventListener, IEndpointStateC Message makeGossipDigestSynMessage(List gDigests) throws IOException { GossipDigestSynMessage gDigestMessage = new GossipDigestSynMessage(DatabaseDescriptor.getClusterName(), gDigests); - ByteArrayOutputStream bos = new ByteArrayOutputStream(Gossiper.MAX_GOSSIP_PACKET_SIZE); + ByteArrayOutputStream bos = new ByteArrayOutputStream(); DataOutputStream dos = new DataOutputStream( bos ); GossipDigestSynMessage.serializer().serialize(gDigestMessage, dos); return new Message(localEndpoint_, StageManager.GOSSIP_STAGE, StorageService.Verb.GOSSIP_DIGEST_SYN, bos.toByteArray()); @@ -295,7 +294,7 @@ public class Gossiper implements IFailureDetectionEventListener, IEndpointStateC Message makeGossipDigestAckMessage(GossipDigestAckMessage gDigestAckMessage) throws IOException { - ByteArrayOutputStream bos = new ByteArrayOutputStream(Gossiper.MAX_GOSSIP_PACKET_SIZE); + ByteArrayOutputStream bos = new ByteArrayOutputStream(); DataOutputStream dos = new DataOutputStream(bos); GossipDigestAckMessage.serializer().serialize(gDigestAckMessage, dos); if (logger_.isTraceEnabled()) @@ -305,7 +304,7 @@ public class Gossiper implements IFailureDetectionEventListener, IEndpointStateC Message makeGossipDigestAck2Message(GossipDigestAck2Message gDigestAck2Message) throws IOException { - ByteArrayOutputStream bos = new ByteArrayOutputStream(Gossiper.MAX_GOSSIP_PACKET_SIZE); + ByteArrayOutputStream bos = new ByteArrayOutputStream(); DataOutputStream dos = new DataOutputStream(bos); GossipDigestAck2Message.serializer().serialize(gDigestAck2Message, dos); return new Message(localEndpoint_, StageManager.GOSSIP_STAGE, StorageService.Verb.GOSSIP_DIGEST_ACK2, bos.toByteArray());