public LoadBalancingPolicy getLoadBalancingPolicy() { if (this.loadBalancingPolicyName.equals(TokenAwarePolicy.class.getSimpleName())) { return new TokenAwarePolicy(new RoundRobinPolicy()); } if (this.loadBalancingPolicyName.equals(DCAwareRoundRobinPolicy.class.getSimpleName())) { Builder builder = DCAwareRoundRobinPolicy.builder(); if (StringUtils.isNotBlank(datacenterName)) { builder = builder.withLocalDc(this.datacenterName); } return new TokenAwarePolicy(builder.build()); } throw new IllegalArgumentException("Unknown cassandra load balancing policy " + this.loadBalancingPolicyName); }
DCAwareRoundRobinPolicy.Builder builder = DCAwareRoundRobinPolicy.builder() .withLocalDc(config.getDcAwareLocalDC()); if (config.getDcAwareUsedHostsPerRemoteDc() > 0) {
m_writeLoadBalancingPolicy = new TokenAwarePolicy((m_clusterConfiguration.getLocalDCName() == null) ? new RoundRobinPolicy() : DCAwareRoundRobinPolicy.builder().withLocalDc(m_clusterConfiguration.getLocalDCName()).build(), TokenAwarePolicy.ReplicaOrdering.TOPOLOGICAL); TokenAwarePolicy readLoadBalancePolicy = new TokenAwarePolicy((m_clusterConfiguration.getLocalDCName() == null) ? new RoundRobinPolicy() : DCAwareRoundRobinPolicy.builder().withLocalDc(m_clusterConfiguration.getLocalDCName()).build(), TokenAwarePolicy.ReplicaOrdering.RANDOM);
/** * The default load balancing policy. * * <p>The default load balancing policy is {@link DCAwareRoundRobinPolicy} with token awareness * (so {@code new TokenAwarePolicy(new DCAwareRoundRobinPolicy())}). * * <p>Note that this policy shuffles the replicas when token awareness is used, see {@link * TokenAwarePolicy#TokenAwarePolicy(LoadBalancingPolicy, boolean)} for an explanation of the * tradeoffs. * * @return the default load balancing policy. */ public static LoadBalancingPolicy defaultLoadBalancingPolicy() { // Note: balancing policies are stateful, so we can't store that in a static or that would screw // thing // up if multiple Cluster instance are started in the same JVM. return new TokenAwarePolicy(DCAwareRoundRobinPolicy.builder().build()); }
String allowRemoteDCsForLocalConsistencyLevel = (String) conProperties .get("allowRemoteDCsForLocalConsistencyLevel"); DCAwareRoundRobinPolicy.Builder policyBuilder = DCAwareRoundRobinPolicy.builder(); policyBuilder.withLocalDc(localdc == null ? "DC1" : localdc); policyBuilder.withUsedHostsPerRemoteDc(usedHostsPerRemoteDc != null ? Integer
DCAwareRoundRobinPolicy policy = spy(DCAwareRoundRobinPolicy.builder().build()); ScassandraCluster sCluster = ScassandraCluster.builder().withNodes(2, 2).build(); Cluster cluster =
spy(DCAwareRoundRobinPolicy.builder().withLocalDc(datacenter(3)).build()); Cluster cluster = builder()
public void should_use_local_dc_from_contact_points_when_not_explicitly_specified() { DCAwareRoundRobinPolicy policy = spy(DCAwareRoundRobinPolicy.builder().build()); ScassandraCluster sCluster = ScassandraCluster.builder().withNodes(2, 2).build(); Cluster cluster =
spy(DCAwareRoundRobinPolicy.builder().withLocalDc(datacenter(1)).build()); Cluster cluster = builder()
.withPort(sCluster.getBinaryPort()) .withLoadBalancingPolicy( DCAwareRoundRobinPolicy.builder().withUsedHostsPerRemoteDc(2).build()) .build();
private void configureLoadBalancingPolicy() { final String dataCenterNameConfiguration = (String) configuration.get(TRIDENT_CASSANDRA_LOCAL_DATA_CENTER_NAME); if (StringUtils.isNotEmpty(dataCenterNameConfiguration)) { final LoadBalancingPolicy loadBalancingPolicy = DCAwareRoundRobinPolicy.builder().withLocalDc(dataCenterNameConfiguration).build(); builder = builder.withLoadBalancingPolicy(loadBalancingPolicy); } }
.withPort(sCluster.getBinaryPort()) .withLoadBalancingPolicy( DCAwareRoundRobinPolicy.builder().withLocalDc(datacenter(1)).build()) .build(); try {
public LoadBalancingPolicy getLoadBalancingPolicy() { if (this.loadBalancingPolicyName.equals(TokenAwarePolicy.class.getSimpleName())) { return new TokenAwarePolicy(new RoundRobinPolicy()); } if (this.loadBalancingPolicyName.equals(DCAwareRoundRobinPolicy.class.getSimpleName())) { Builder builder = DCAwareRoundRobinPolicy.builder(); if (StringUtils.isNotBlank(datacenterName)) { builder = builder.withLocalDc(this.datacenterName); } return new TokenAwarePolicy(builder.build()); } throw new IllegalArgumentException("Unknown cassandra load balancing policy " + this.loadBalancingPolicyName); }
.withPort(sCluster.getBinaryPort()) .withLoadBalancingPolicy( DCAwareRoundRobinPolicy.builder() .allowRemoteDCsForLocalConsistencyLevel() .withUsedHostsPerRemoteDc(2)
.withPort(sCluster.getBinaryPort()) .withLoadBalancingPolicy( DCAwareRoundRobinPolicy.builder().withUsedHostsPerRemoteDc(2).build()) .build();
.withLoadBalancingPolicy( new TokenAwarePolicy( DCAwareRoundRobinPolicy.builder() .withLocalDc(ScassandraCluster.datacenter(2)) .withUsedHostsPerRemoteDc(3)
private void initLoadBalancingPolicy() { String localDC = envVarDelegate.get(ENV_VAR_LOCAL_DC); if (!Strings.isNullOrEmpty(localDC)) { logger.debug("Using environment config for Local DC of " + localDC); loadBalancingPolicy = DCAwareRoundRobinPolicy.builder() .withLocalDc(localDC) .build(); } else { logger.debug("No environment configuration found for local DC"); } }
.withPort(sCluster.getBinaryPort()) .withLoadBalancingPolicy( DCAwareRoundRobinPolicy.builder() .withLocalDc(datacenter(1)) .withUsedHostsPerRemoteDc(2)
LoadBalancingPolicy loadBalancingPolicy = HostFilterPolicy.fromDCBlackList( DCAwareRoundRobinPolicy.builder().withUsedHostsPerRemoteDc(2).build(), Lists.newArrayList(datacenter(2))); Cluster cluster =
LoadBalancingPolicy loadBalancingPolicy = HostFilterPolicy.fromDCWhiteList( DCAwareRoundRobinPolicy.builder().withUsedHostsPerRemoteDc(2).build(), Lists.newArrayList(datacenter(1), datacenter(2))); Cluster cluster =