builder.withLoadBalancingPolicy( new TokenAwarePolicy( new LatencyAwarePolicy.Builder( cassandra.localDc() != null ? DCAwareRoundRobinPolicy.builder().withLocalDc(cassandra.localDc()).build()
static Cluster buildCluster(CassandraStorage cassandra) { Cluster.Builder builder = Cluster.builder().withoutJMXReporting(); List<InetSocketAddress> contactPoints = parseContactPoints(cassandra); int defaultPort = findConnectPort(contactPoints); builder.addContactPointsWithPorts(contactPoints); builder.withPort(defaultPort); // This ends up protocolOptions.port if (cassandra.username != null && cassandra.password != null) { builder.withCredentials(cassandra.username, cassandra.password); } builder.withRetryPolicy(ZipkinRetryPolicy.INSTANCE); builder.withLoadBalancingPolicy( new TokenAwarePolicy( new LatencyAwarePolicy.Builder( cassandra.localDc != null ? DCAwareRoundRobinPolicy.builder().withLocalDc(cassandra.localDc).build() : new RoundRobinPolicy() // This can select remote, but LatencyAwarePolicy will prefer local ) .build())); builder.withPoolingOptions( new PoolingOptions() .setMaxConnectionsPerHost(HostDistance.LOCAL, cassandra.maxConnections)); if (cassandra.useSsl) { builder = builder.withSSL(); } return builder.build(); }
static Cluster buildCluster(CassandraStorage cassandra) { Cluster.Builder builder = Cluster.builder(); List<InetSocketAddress> contactPoints = parseContactPoints(cassandra); int defaultPort = findConnectPort(contactPoints); builder.addContactPointsWithPorts(contactPoints); builder.withPort(defaultPort); // This ends up protocolOptions.port if (cassandra.username != null && cassandra.password != null) { builder.withCredentials(cassandra.username, cassandra.password); } builder.withRetryPolicy(ZipkinRetryPolicy.INSTANCE); builder.withLoadBalancingPolicy(new TokenAwarePolicy(new LatencyAwarePolicy.Builder( cassandra.localDc != null ? DCAwareRoundRobinPolicy.builder().withLocalDc(cassandra.localDc).build() : new RoundRobinPolicy() // This can select remote, but LatencyAwarePolicy will prefer local ).build())); builder.withPoolingOptions(new PoolingOptions().setMaxConnectionsPerHost( HostDistance.LOCAL, cassandra.maxConnections )); if (cassandra.useSsl) { builder = builder.withSSL(); } return builder.build(); }
/** * Creates a new latency aware policy builder given the child policy * that the resulting policy should wrap. * * @param childPolicy the load balancing policy to wrap with latency * awareness. * @return the created builder. */ public static Builder builder(LoadBalancingPolicy childPolicy) { return new Builder(childPolicy); }
/** * Creates a new latency aware policy builder given the child policy * that the resulting policy should wrap. * * @param childPolicy the load balancing policy to wrap with latency * awareness. * @return the created builder. */ public static Builder builder(LoadBalancingPolicy childPolicy) { return new Builder(childPolicy); }
/** * Creates a new latency aware policy builder given the child policy * that the resulting policy should wrap. * * @param childPolicy the load balancing policy to wrap with latency * awareness. * @return the created builder. */ public static Builder builder(LoadBalancingPolicy childPolicy) { return new Builder(childPolicy); }
/** * Creates a new latency aware policy builder given the child policy * that the resulting policy should wrap. * * @param childPolicy the load balancing policy to wrap with latency * awareness. * @return the created builder. */ public static Builder builder(LoadBalancingPolicy childPolicy) { return new Builder(childPolicy); }
/** * Creates a new latency aware policy builder given the child policy that the resulting policy * should wrap. * * @param childPolicy the load balancing policy to wrap with latency awareness. * @return the created builder. */ public static Builder builder(LoadBalancingPolicy childPolicy) { return new Builder(childPolicy); }