Java 类com.datastax.driver.core.policies.WhiteListPolicy 实例源码
项目:cassandra-health-check
文件:CassandraHealthCheck.java
/**
* Connect to a cassandra cluster at a given host/port
*/
public void connect() {
try {
lock.lock();
} catch (IOException e) {
throw new IllegalStateException("There appears to be another health check running", e);
}
final List<InetSocketAddress> whiteList= new ArrayList<>();
whiteList.add(new InetSocketAddress(host, port));
final LoadBalancingPolicy loadBalancingPolicy = new WhiteListPolicy(new RoundRobinPolicy(), whiteList);
final Cluster.Builder cb = Cluster.builder()
.addContactPoint(host)
.withPort(port)
.withLoadBalancingPolicy(loadBalancingPolicy)
.withRetryPolicy(retryPolicy);
if (username != null) {
cb.withCredentials(username, password);
}
cluster = cb.build();
session = cluster.connect();
hosts = cluster.getMetadata().getAllHosts();
}
项目:cassandra-kmean
文件:JavaDriverClient.java
public JavaDriverClient(StressSettings settings, String host, int port, EncryptionOptions.ClientEncryptionOptions encryptionOptions)
{
this.host = host;
this.port = port;
this.username = settings.mode.username;
this.password = settings.mode.password;
this.authProvider = settings.mode.authProvider;
this.encryptionOptions = encryptionOptions;
if (settings.node.isWhiteList)
whitelist = new WhiteListPolicy(new DCAwareRoundRobinPolicy(), settings.node.resolveAll(settings.port.nativePort));
else
whitelist = null;
}
项目:scylla-tools-java
文件:JavaDriverClient.java
public JavaDriverClient(StressSettings settings, String host, int port, EncryptionOptions.ClientEncryptionOptions encryptionOptions)
{
this.protocolVersion = settings.mode.protocolVersion;
this.host = host;
this.port = port;
this.username = settings.mode.username;
this.password = settings.mode.password;
this.authProvider = settings.mode.authProvider;
this.encryptionOptions = encryptionOptions;
if (settings.node.isWhiteList)
whitelist = new WhiteListPolicy(DCAwareRoundRobinPolicy.builder().build(), settings.node.resolveAll(settings.port.nativePort));
else
whitelist = null;
connectionsPerHost = settings.mode.connectionsPerHost == null ? 8 : settings.mode.connectionsPerHost;
int maxThreadCount = 0;
if (settings.rate.auto)
maxThreadCount = settings.rate.maxThreads;
else
maxThreadCount = settings.rate.threadCount;
//Always allow enough pending requests so every thread can have a request pending
//See https://issues.apache.org/jira/browse/CASSANDRA-7217
int requestsPerConnection = (maxThreadCount / connectionsPerHost) + connectionsPerHost;
maxPendingPerConnection = settings.mode.maxPendingPerConnection == null ? Math.max(128, requestsPerConnection ) : settings.mode.maxPendingPerConnection;
}
项目:dropwizard-cassandra
文件:WhiteListPolicyFactoryTest.java
@Test
public void buildsPolicy() throws Exception {
final WhiteListPolicyFactory factory = new WhiteListPolicyFactory();
factory.setSubPolicy(subPolicyFactory);
factory.setWhiteList(Collections.singletonList(new InetSocketAddress("localhost", 9876)));
final WhiteListPolicy policy = (WhiteListPolicy) factory.build();
assertThat(policy.getChildPolicy()).isSameAs(subPolicy);
}
项目:GraphTrek
文件:JavaDriverClient.java
public JavaDriverClient(StressSettings settings, String host, int port, EncryptionOptions.ClientEncryptionOptions encryptionOptions)
{
this.host = host;
this.port = port;
this.encryptionOptions = encryptionOptions;
if (settings.node.isWhiteList)
whitelist = new WhiteListPolicy(new DCAwareRoundRobinPolicy(), settings.node.resolveAll(settings.port.nativePort));
else
whitelist = null;
}
项目:stratio-cassandra
文件:JavaDriverClient.java
public JavaDriverClient(StressSettings settings, String host, int port, EncryptionOptions.ClientEncryptionOptions encryptionOptions)
{
this.host = host;
this.port = port;
this.username = settings.mode.username;
this.password = settings.mode.password;
this.authProvider = settings.mode.authProvider;
this.encryptionOptions = encryptionOptions;
if (settings.node.isWhiteList)
whitelist = new WhiteListPolicy(new DCAwareRoundRobinPolicy(), settings.node.resolveAll(settings.port.nativePort));
else
whitelist = null;
}
项目:dropwizard-cassandra
文件:WhiteListPolicyFactory.java
@Override
public LoadBalancingPolicy build() {
return new WhiteListPolicy(subPolicy.build(), whiteList);
}