You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by jb...@apache.org on 2009/05/26 22:23:16 UTC

svn commit: r778871 - /incubator/cassandra/trunk/src/java/org/apache/cassandra/service/StorageProxy.java

Author: jbellis
Date: Tue May 26 20:23:16 2009
New Revision: 778871

URL: http://svn.apache.org/viewvc?rev=778871&view=rev
Log:
short circuits sending a message if the mutation's destination is the local node.  does not implement hint handling; takes the full message route if hints are involved.  patch by Sandeep Tata; reviewed by jbellis for CASSANDRA-132

Modified:
    incubator/cassandra/trunk/src/java/org/apache/cassandra/service/StorageProxy.java

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/service/StorageProxy.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/service/StorageProxy.java?rev=778871&r1=778870&r2=778871&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/service/StorageProxy.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/service/StorageProxy.java Tue May 26 20:23:16 2009
@@ -84,7 +84,8 @@
 			{
 				Message hintedMessage = rm.makeRowMutationMessage();
 				hintedMessage.addHeader(RowMutation.HINT, EndPoint.toBytes(hint) );
-				logger.debug("Sending the hint of " + target.getHost() + " to " + hint.getHost());
+				if (logger.isDebugEnabled())
+				    logger.debug("Sending the hint of " + hint.getHost() + " to " + target.getHost());
 				messageMap.put(target, hintedMessage);
 			}
 			else
@@ -121,8 +122,22 @@
 			{
                 Message message = entry.getValue();
                 EndPoint endpoint = entry.getKey();
-                logger.debug("insert writing key " + rm.key() + " to " + message.getMessageId() + "@" + endpoint);
-                MessagingService.getMessagingInstance().sendOneWay(message, endpoint);
+                // Check if local and not hinted
+                byte[] hintedBytes = message.getHeader(RowMutation.HINT);
+                if (endpoint.equals(StorageService.getLocalStorageEndPoint())
+                        && !(hintedBytes!= null && hintedBytes.length>0))
+                {
+                    if (logger.isDebugEnabled())
+                        logger.debug("locally writing writing key " + rm.key()
+                                + " to " + endpoint);
+                    rm.apply();
+                } else
+                {
+                    if (logger.isDebugEnabled())
+                        logger.debug("insert writing key " + rm.key() + " to "
+                                + message.getMessageId() + "@" + endpoint);
+                	MessagingService.getMessagingInstance().sendOneWay(message, endpoint);
+                }
 			}
 		}
         catch (IOException e)