cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dbros...@apache.org
Subject cassandra git commit: make EchoMessage a singleton patch by dbrosius reviewed by jbellis for CASSANDRA-8972
Date Tue, 17 Mar 2015 02:30:46 GMT
Repository: cassandra
Updated Branches:
  refs/heads/trunk 482cbc0c8 -> fd67615be


make EchoMessage a singleton
patch by dbrosius reviewed by jbellis for CASSANDRA-8972


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

Branch: refs/heads/trunk
Commit: fd67615be32daa559b4b7d16ad12300494eda389
Parents: 482cbc0
Author: Dave Brosius <dbrosius@mebigfatguy.com>
Authored: Mon Mar 16 22:29:39 2015 -0400
Committer: Dave Brosius <dbrosius@mebigfatguy.com>
Committed: Mon Mar 16 22:29:39 2015 -0400

----------------------------------------------------------------------
 src/java/org/apache/cassandra/gms/EchoMessage.java      | 12 +++++++++---
 src/java/org/apache/cassandra/gms/Gossiper.java         |  2 +-
 .../org/apache/cassandra/service/EchoVerbHandler.java   |  2 +-
 3 files changed, 11 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/fd67615b/src/java/org/apache/cassandra/gms/EchoMessage.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/gms/EchoMessage.java b/src/java/org/apache/cassandra/gms/EchoMessage.java
index 444278f..2d4c095 100644
--- a/src/java/org/apache/cassandra/gms/EchoMessage.java
+++ b/src/java/org/apache/cassandra/gms/EchoMessage.java
@@ -27,10 +27,16 @@ import java.io.IOException;
 import org.apache.cassandra.io.IVersionedSerializer;
 import org.apache.cassandra.io.util.DataOutputPlus;
 
-public class EchoMessage
+public final class EchoMessage
 {
-    public static IVersionedSerializer<EchoMessage> serializer = new EchoMessageSerializer();
+	public static final EchoMessage instance = new EchoMessage();
+	
+    public static final IVersionedSerializer<EchoMessage> serializer = new EchoMessageSerializer();
 
+	private EchoMessage()
+	{
+	}
+	
     public static class EchoMessageSerializer implements IVersionedSerializer<EchoMessage>
     {
         public void serialize(EchoMessage t, DataOutputPlus out, int version) throws IOException
@@ -39,7 +45,7 @@ public class EchoMessage
 
         public EchoMessage deserialize(DataInput in, int version) throws IOException
         {
-            return new EchoMessage();
+            return EchoMessage.instance;
         }
 
         public long serializedSize(EchoMessage t, int version)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/fd67615b/src/java/org/apache/cassandra/gms/Gossiper.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/gms/Gossiper.java b/src/java/org/apache/cassandra/gms/Gossiper.java
index 1820c06..d7b1ec7 100644
--- a/src/java/org/apache/cassandra/gms/Gossiper.java
+++ b/src/java/org/apache/cassandra/gms/Gossiper.java
@@ -899,7 +899,7 @@ public class Gossiper implements IFailureDetectionEventListener, GossiperMBean
 
         localState.markDead();
 
-        MessageOut<EchoMessage> echoMessage = new MessageOut<EchoMessage>(MessagingService.Verb.ECHO,
new EchoMessage(), EchoMessage.serializer);
+        MessageOut<EchoMessage> echoMessage = new MessageOut<EchoMessage>(MessagingService.Verb.ECHO,
EchoMessage.instance, EchoMessage.serializer);
         logger.trace("Sending a EchoMessage to {}", addr);
         IAsyncCallback echoHandler = new IAsyncCallback()
         {

http://git-wip-us.apache.org/repos/asf/cassandra/blob/fd67615b/src/java/org/apache/cassandra/service/EchoVerbHandler.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/service/EchoVerbHandler.java b/src/java/org/apache/cassandra/service/EchoVerbHandler.java
index 57e7a0d..3d3f69e 100644
--- a/src/java/org/apache/cassandra/service/EchoVerbHandler.java
+++ b/src/java/org/apache/cassandra/service/EchoVerbHandler.java
@@ -35,7 +35,7 @@ public class EchoVerbHandler implements IVerbHandler<EchoMessage>
 
     public void doVerb(MessageIn<EchoMessage> message, int id)
     {
-        MessageOut<EchoMessage> echoMessage = new MessageOut<EchoMessage>(MessagingService.Verb.REQUEST_RESPONSE,
new EchoMessage(), EchoMessage.serializer);
+        MessageOut<EchoMessage> echoMessage = new MessageOut<EchoMessage>(MessagingService.Verb.REQUEST_RESPONSE,
EchoMessage.instance, EchoMessage.serializer);
         logger.trace("Sending a EchoMessage reply {}", message.from);
         MessagingService.instance().sendReply(echoMessage, id, message.from);
     }


Mime
View raw message