Permalink
Browse files

Pool CqlRecordWriter clients by inetaddress rather than Range

patch by Christian Rolf; reviewed by jbellis for CASSANDRA-6665
  • Loading branch information...
jbellis committed Feb 28, 2014
1 parent 33c75e9 commit cdd3625db6a2fed0735329cc1571c72dbab47b64
Showing with 7 additions and 4 deletions.
  1. +2 −0 CHANGES.txt
  2. +5 −4 src/java/org/apache/cassandra/hadoop/cql3/CqlRecordWriter.java
View
@@ -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)
@@ -65,7 +65,7 @@
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 @@
CqlRecordWriter(Configuration conf)
{
super(conf);
- this.clients = new HashMap<Range, RangeClient>();
+ this.clients = new HashMap<>();
try
{
@@ -163,13 +163,14 @@ public void write(Map<String, ByteBuffer> keyColumns, List<ByteBuffer> values) t
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

0 comments on commit cdd3625

Please sign in to comment.