mirror of https://github.com/apache/cassandra
Fix stress smart Thrift client to pick servers correctly
patch by Benedict Elliott Smith; reviewed by Pavel Yaskevich for CASSANDRA-6848
This commit is contained in:
parent
d227aa0ec3
commit
df43d4e73d
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue