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 2014/02/28 16:46:38 UTC

[3/6] git commit: Pool CqlRecordWriter clients by inetaddress rather than Range patch by Christian Rolf; reviewed by jbellis for CASSANDRA-6665

Pool CqlRecordWriter clients by inetaddress rather than Range
patch by Christian Rolf; reviewed by jbellis for CASSANDRA-6665


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

Branch: refs/heads/trunk
Commit: cdd3625db6a2fed0735329cc1571c72dbab47b64
Parents: 33c75e9
Author: Jonathan Ellis <jb...@apache.org>
Authored: Fri Feb 28 09:44:51 2014 -0600
Committer: Jonathan Ellis <jb...@apache.org>
Committed: Fri Feb 28 09:44:51 2014 -0600

----------------------------------------------------------------------
 CHANGES.txt                                                 | 2 ++
 .../org/apache/cassandra/hadoop/cql3/CqlRecordWriter.java   | 9 +++++----
 2 files changed, 7 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/cdd3625d/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 8e439c6..65de68d 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,6 @@
 2.0.6
+ * Pool CqlRecordWriter clients by inetaddress rather than Range 
+   (CASSANDRA-6665)
  * Compare scores of full replica ordering in DES (CASSANDRA-6883)
  * fix CME in SessionInfo updateProgress affecting netstats (CASSANDRA-6577)
  * Allow repairing between specific replicas (CASSANDRA-6440)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/cdd3625d/src/java/org/apache/cassandra/hadoop/cql3/CqlRecordWriter.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/hadoop/cql3/CqlRecordWriter.java b/src/java/org/apache/cassandra/hadoop/cql3/CqlRecordWriter.java
index e2b90f1..690ef2e 100644
--- a/src/java/org/apache/cassandra/hadoop/cql3/CqlRecordWriter.java
+++ b/src/java/org/apache/cassandra/hadoop/cql3/CqlRecordWriter.java
@@ -65,7 +65,7 @@ final class CqlRecordWriter extends AbstractColumnFamilyRecordWriter<Map<String,
     private static final Logger logger = LoggerFactory.getLogger(CqlRecordWriter.class);
 
     // handles for clients for each range running in the threadpool
-    private final Map<Range, RangeClient> clients;
+    private final Map<InetAddress, RangeClient> clients;
 
     // host to prepared statement id mappings
     private ConcurrentHashMap<Cassandra.Client, Integer> preparedStatements = new ConcurrentHashMap<Cassandra.Client, Integer>();
@@ -98,7 +98,7 @@ final class CqlRecordWriter extends AbstractColumnFamilyRecordWriter<Map<String,
     CqlRecordWriter(Configuration conf)
     {
         super(conf);
-        this.clients = new HashMap<Range, RangeClient>();
+        this.clients = new HashMap<>();
 
         try
         {
@@ -163,13 +163,14 @@ final class CqlRecordWriter extends AbstractColumnFamilyRecordWriter<Map<String,
         Range<Token> range = ringCache.getRange(getPartitionKey(keyColumns));
 
         // get the client for the given range, or create a new one
-        RangeClient client = clients.get(range);
+	final InetAddress address = ringCache.getEndpoint(range).get(0);
+        RangeClient client = clients.get(address);
         if (client == null)
         {
             // haven't seen keys for this range: create new client
             client = new RangeClient(ringCache.getEndpoint(range));
             client.start();
-            clients.put(range, client);
+            clients.put(address, client);
         }
 
         // add primary key columns to the bind variables