Author: jbellis
Date: Fri Jul 22 01:13:06 2011
New Revision: 1149426
URL: http://svn.apache.org/viewvc?rev=1149426&view=rev
Log:
store hints in the coordinator node instead of in the closest replica
patch by Patricio Echague; reviewed by jbellis for CASSANDRA-2914
Modified:
cassandra/trunk/CHANGES.txt
cassandra/trunk/src/java/org/apache/cassandra/db/RowMutation.java
cassandra/trunk/src/java/org/apache/cassandra/locator/AbstractReplicationStrategy.java
Modified: cassandra/trunk/CHANGES.txt
URL:
http://svn.apache.org/viewvc/cassandra/trunk/CHANGES.txt?rev=1149426&r1=1149425&r2=1149426&view=diff
==============================================================================
--- cassandra/trunk/CHANGES.txt (original)
+++ cassandra/trunk/CHANGES.txt Fri Jul 22 01:13:06 2011
@@ -16,6 +16,8 @@
* use reference counting for deleting sstables instead of relying on the GC
(CASSANDRA-2521)
* store hints as serialized mutations instead of pointers to data rows
+ * store hints in the coordinator node instead of in the closest
+ replica (CASSANDRA-2914).
0.8.2
Modified: cassandra/trunk/src/java/org/apache/cassandra/db/RowMutation.java
URL:
http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/RowMutation.java?rev=1149426&r1=1149425&r2=1149426&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/RowMutation.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/RowMutation.java Fri Jul
22 01:13:06 2011
@@ -97,6 +97,23 @@ public class RowMutation implements IMut
return modifications_.values();
}
+ /**
+ * Returns mutation representing a Hints to be sent to <code>address</code>
+ * as soon as it becomes available.
+ * The format is the following:
+ *
+ * HintsColumnFamily: { // cf
+ * <dest ip>: { // key
+ * <uuid>: { // super-column
+ * table: <table> // columns
+ * key: <key>
+ * mutation: <mutation>
+ * version: <version>
+ * }
+ * }
+ * }
+ *
+ */
public static RowMutation hintFor(RowMutation mutation, ByteBuffer
address) throws IOException
{
RowMutation rm = new RowMutation(Table.SYSTEM_TABLE, address);
Modified:
cassandra/trunk/src/java/org/apache/cassandra/locator/AbstractReplicationStrategy.java
URL:
http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/locator/AbstractReplicationStrategy.java?rev=1149426&r1=1149425&r2=1149426&view=diff
==============================================================================
---
cassandra/trunk/src/java/org/apache/cassandra/locator/AbstractReplicationStrategy.java
(original)
+++
cassandra/trunk/src/java/org/apache/cassandra/locator/AbstractReplicationStrategy.java
Fri Jul 22 01:13:06 2011
@@ -157,10 +157,7 @@ public abstract class AbstractReplicatio
if (map.size() == targets.size() ||
!StorageProxy.isHintedHandoffEnabled())
return map;
- // assign dead endpoints to be hinted to the closest live one, or to
the local node
- // (since it is trivially the closest) if none are alive. This way,
the cost of doing
- // a hint is only adding the hint header, rather than doing a full
extra write, if any
- // destination nodes are alive.
+ // Assign dead endpoints to be hinted to the local node.
//
// we do a 2nd pass on targets instead of using temporary storage,
// to optimize for the common case (everything was alive).
@@ -176,10 +173,8 @@ public abstract class AbstractReplicatio
continue;
}
- InetAddress destination = map.isEmpty()
- ? localAddress
- :
snitch.getSortedListByProximity(localAddress, map.keySet()).get(0);
- map.put(destination, ep);
+ // We always store the hint on the coordinator node.
+ map.put(localAddress, ep);
}
return map;