You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by xe...@apache.org on 2014/03/14 01:52:41 UTC
git commit: Fix stress smart Thrift client to pick servers correctly
patch by Benedict Elliott Smith;
reviewed by Pavel Yaskevich for CASSANDRA-6848
Repository: cassandra
Updated Branches:
refs/heads/cassandra-2.1 d227aa0ec -> df43d4e73
Fix stress smart Thrift client to pick servers correctly
patch by Benedict Elliott Smith; reviewed by Pavel Yaskevich for CASSANDRA-6848
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/df43d4e7
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/df43d4e7
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/df43d4e7
Branch: refs/heads/cassandra-2.1
Commit: df43d4e73d28bb2ad9c7377bdc2ab02cbcd80248
Parents: d227aa0
Author: Pavel Yaskevich <xe...@apache.org>
Authored: Thu Mar 13 17:51:57 2014 -0700
Committer: Pavel Yaskevich <xe...@apache.org>
Committed: Thu Mar 13 17:52:24 2014 -0700
----------------------------------------------------------------------
CHANGES.txt | 1 +
.../apache/cassandra/stress/util/SmartThriftClient.java | 12 +++++-------
2 files changed, 6 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/df43d4e7/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 4d9bc07..05f1048 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -17,6 +17,7 @@
* Change caching option syntax (CASSANDRA-6745)
* Fix stress to do proper counter reads (CASSANDRA-6835)
* Fix help message for stress counter_write (CASSANDRA-6824)
+ * Fix stress smart Thrift client to pick servers correctly (CASSANDRA-6848)
Merged from 2.0:
* Fix leaking validator FH in StreamWriter (CASSANDRA-6832)
* fix nodetool getsstables for blob PK (CASSANDRA-6803)
http://git-wip-us.apache.org/repos/asf/cassandra/blob/df43d4e7/tools/stress/src/org/apache/cassandra/stress/util/SmartThriftClient.java
----------------------------------------------------------------------
diff --git a/tools/stress/src/org/apache/cassandra/stress/util/SmartThriftClient.java b/tools/stress/src/org/apache/cassandra/stress/util/SmartThriftClient.java
index 48d8b64..2782a05 100644
--- a/tools/stress/src/org/apache/cassandra/stress/util/SmartThriftClient.java
+++ b/tools/stress/src/org/apache/cassandra/stress/util/SmartThriftClient.java
@@ -29,6 +29,7 @@ import java.util.concurrent.atomic.AtomicInteger;
import com.datastax.driver.core.Host;
import com.datastax.driver.core.Metadata;
+import com.google.common.collect.Iterators;
import org.apache.cassandra.stress.settings.StressSettings;
import org.apache.cassandra.thrift.*;
import org.apache.cassandra.utils.ByteBufferUtil;
@@ -108,13 +109,10 @@ public class SmartThriftClient implements ThriftClient
private Client get(ByteBuffer pk)
{
Set<Host> hosts = metadata.getReplicas(metadata.quote(keyspace), pk);
- int count = roundrobin.incrementAndGet() % hosts.size();
- if (count < 0)
- count = -count;
- Iterator<Host> iter = hosts.iterator();
- while (count > 0 && iter.hasNext())
- iter.next();
- Host host = iter.next();
+ int pos = roundrobin.incrementAndGet() % hosts.size();
+ if (pos < 0)
+ pos = -pos;
+ Host host = Iterators.get(hosts.iterator(), pos);
ConcurrentLinkedQueue<Client> q = cache.get(host);
if (q == null)
{