All Downloads are FREE. Search and download functionalities are using the official Maven repository.

systems.composable.dropwizard.cassandra.loadbalancing.DCAwareRoundRobinPolicyFactory Maven / Gradle / Ivy

There is a newer version: 4.1.0
Show newest version
package systems.composable.dropwizard.cassandra.loadbalancing;

import com.datastax.driver.core.policies.DCAwareRoundRobinPolicy;
import com.datastax.driver.core.policies.LoadBalancingPolicy;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeName;

/**
 * A factory for configuring and building {@link com.datastax.driver.core.policies.DCAwareRoundRobinPolicy} instances.
 * 

* Configuration Parameters: *

* * * * * * * * * * * * * * * * * * * * *
NameDefaultDescription
localDCNo default.The name of the local datacenter (as known by Cassandra).
usedHostsPerRemoteDCNo default. May only be specified when localDC is specified.The number of host per remote datacenter that policies created by the returned factory should consider.
allowRemoteDCsForLocalConsistencyLevelNo default. May only be specified when localDC and usedHostsPerRemoteDC are specified.Whether or not the policy may return remote host when building query plan for query having consitency LOCAL_ONE and LOCAL_QUORUM.
*/ @JsonTypeName("dcAwareRoundRobin") public class DCAwareRoundRobinPolicyFactory implements LoadBalancingPolicyFactory { private String localDC; private Integer usedHostsPerRemoteDC; private Boolean allowRemoteDCsForLocalConsistencyLevel; @JsonProperty public String getLocalDC() { return localDC; } @JsonProperty public void setLocalDC(String localDC) { this.localDC = localDC; } @JsonProperty public Integer getUsedHostsPerRemoteDC() { return usedHostsPerRemoteDC; } @JsonProperty public void setUsedHostsPerRemoteDC(Integer usedHostsPerRemoteDC) { this.usedHostsPerRemoteDC = usedHostsPerRemoteDC; } @JsonProperty public Boolean getAllowRemoteDCsForLocalConsistencyLevel() { return allowRemoteDCsForLocalConsistencyLevel; } @JsonProperty public void setAllowRemoteDCsForLocalConsistencyLevel(Boolean allowRemoteDCsForLocalConsistencyLevel) { this.allowRemoteDCsForLocalConsistencyLevel = allowRemoteDCsForLocalConsistencyLevel; } @Override public LoadBalancingPolicy build() { DCAwareRoundRobinPolicy.Builder builder = DCAwareRoundRobinPolicy.builder(); if (allowRemoteDCsForLocalConsistencyLevel == Boolean.TRUE) { builder.allowRemoteDCsForLocalConsistencyLevel(); } if (localDC != null) { builder.withLocalDc(localDC); } if (usedHostsPerRemoteDC != null) { builder.withUsedHostsPerRemoteDc(usedHostsPerRemoteDC); } return builder.build(); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy