Repository: cassandra
Updated Branches:
  refs/heads/cassandra-2.1 1fc8899e2 -> 3ba392f25


Potentially use non-local hosts in CqlConfigHelper

patch by jlewandowski; reviewed by alexliu68 for CASSANDRA-7906


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

Branch: refs/heads/cassandra-2.1
Commit: c1d2b86a4cc6e219eee1cd78c582d5dc2ed27234
Parents: f0d7802
Author: Sylvain Lebresne <sylv...@datastax.com>
Authored: Tue Sep 9 16:21:29 2014 -0700
Committer: Sylvain Lebresne <sylv...@datastax.com>
Committed: Tue Sep 9 16:21:29 2014 -0700

----------------------------------------------------------------------
 CHANGES.txt                                     |  1 +
 .../cassandra/hadoop/cql3/CqlConfigHelper.java  | 33 +++++++-------------
 2 files changed, 13 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/c1d2b86a/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 273fed9..2c0cae6 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 2.0.11:
+ * Potentially use non-local replicas in CqlConfigHelper (CASSANDRA-7906)
  * Explicitly disallowing mixing multi-column and single-column
    relations on clustering columns (CASSANDRA-7711)
  * Better error message when condition is set on PK column (CASSANDRA-7804)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/c1d2b86a/src/java/org/apache/cassandra/hadoop/cql3/CqlConfigHelper.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/hadoop/cql3/CqlConfigHelper.java 
b/src/java/org/apache/cassandra/hadoop/cql3/CqlConfigHelper.java
index 137bddf..2be811f 100644
--- a/src/java/org/apache/cassandra/hadoop/cql3/CqlConfigHelper.java
+++ b/src/java/org/apache/cassandra/hadoop/cql3/CqlConfigHelper.java
@@ -28,10 +28,7 @@ import java.security.NoSuchAlgorithmException;
 import java.security.SecureRandom;
 import java.security.UnrecoverableKeyException;
 import java.security.cert.CertificateException;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.Set;
+import java.util.Arrays;
 
 import javax.net.ssl.KeyManagerFactory;
 import javax.net.ssl.SSLContext;
@@ -45,18 +42,14 @@ import org.apache.hadoop.conf.Configuration;
 import com.datastax.driver.core.AuthProvider;
 import com.datastax.driver.core.PlainTextAuthProvider;
 import com.datastax.driver.core.Cluster;
-import com.datastax.driver.core.Host;
 import com.datastax.driver.core.HostDistance;
 import com.datastax.driver.core.PoolingOptions;
 import com.datastax.driver.core.ProtocolOptions;
 import com.datastax.driver.core.QueryOptions;
 import com.datastax.driver.core.SSLOptions;
 import com.datastax.driver.core.SocketOptions;
-import com.datastax.driver.core.Statement;
 import com.datastax.driver.core.policies.LoadBalancingPolicy;
 import com.google.common.base.Optional;
-import com.google.common.collect.Iterators;
-import com.google.common.collect.Sets;
 
 public class CqlConfigHelper
 {
@@ -424,19 +417,17 @@ public class CqlConfigHelper
         
         PoolingOptions poolingOptions = new PoolingOptions();
 
-        if (coreConnections.isPresent())
-            poolingOptions.setCoreConnectionsPerHost(HostDistance.LOCAL, 
coreConnections.get());
-        if (maxConnections.isPresent())
-            poolingOptions.setMaxConnectionsPerHost(HostDistance.LOCAL, 
maxConnections.get());
-        if (minSimultaneousRequests.isPresent())
-            
poolingOptions.setMinSimultaneousRequestsPerConnectionThreshold(HostDistance.LOCAL,
 minSimultaneousRequests.get());
-        if (maxSimultaneousRequests.isPresent())
-            
poolingOptions.setMaxSimultaneousRequestsPerConnectionThreshold(HostDistance.LOCAL,
 maxSimultaneousRequests.get());
-
-        poolingOptions.setCoreConnectionsPerHost(HostDistance.REMOTE, 0)
-                      .setMaxConnectionsPerHost(HostDistance.REMOTE, 0)
-                      
.setMinSimultaneousRequestsPerConnectionThreshold(HostDistance.REMOTE, 0)
-                      
.setMaxSimultaneousRequestsPerConnectionThreshold(HostDistance.REMOTE, 0);
+        for (HostDistance hostDistance : Arrays.asList(HostDistance.LOCAL, 
HostDistance.REMOTE))
+        {
+            if (coreConnections.isPresent())
+                poolingOptions.setCoreConnectionsPerHost(hostDistance, 
coreConnections.get());
+            if (maxConnections.isPresent())
+                poolingOptions.setMaxConnectionsPerHost(hostDistance, 
maxConnections.get());
+            if (minSimultaneousRequests.isPresent())
+                
poolingOptions.setMinSimultaneousRequestsPerConnectionThreshold(hostDistance, 
minSimultaneousRequests.get());
+            if (maxSimultaneousRequests.isPresent())
+                
poolingOptions.setMaxSimultaneousRequestsPerConnectionThreshold(hostDistance, 
maxSimultaneousRequests.get());
+        }
 
         return poolingOptions;
     }  

Reply via email to