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

systems.composable.dropwizard.cassandra.loadbalancing.TokenAwarePolicyFactory 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.LoadBalancingPolicy;
import com.datastax.driver.core.policies.TokenAwarePolicy;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeName;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;

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

* Configuration Parameters: *

* * * * * * * * * * * * * * * *
NameDefaultDescription
subPolicyNo default. You must provide a child policy.The load balancing policy to wrap with token awareness.
shuffleReplicasNo default.Whether to shuffle the replicas returned by getRoutingKey.
*/ @JsonTypeName("tokenAware") public class TokenAwarePolicyFactory implements LoadBalancingPolicyFactory { @Valid @NotNull private LoadBalancingPolicyFactory subPolicy; private Boolean shuffleReplicas; @JsonProperty public LoadBalancingPolicyFactory getSubPolicy() { return subPolicy; } @JsonProperty public void setSubPolicy(LoadBalancingPolicyFactory subPolicy) { this.subPolicy = subPolicy; } @JsonProperty public Boolean getShuffleReplicas() { return shuffleReplicas; } @JsonProperty public void setShuffleReplicas(Boolean shuffleReplicas) { this.shuffleReplicas = shuffleReplicas; } @Override public LoadBalancingPolicy build() { return (shuffleReplicas == null) ? new TokenAwarePolicy(subPolicy.build()) : new TokenAwarePolicy(subPolicy.build(), shuffleReplicas); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy