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

io.dropwizard.cassandra.loadbalancing.TokenAwarePolicyFactory Maven / Gradle / Ivy

Go to download

Provides easy integration for Dropwizard applications with Apache Cassandra using the DataStax 4.x client

There is a newer version: 4.0.0
Show newest version
package io.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;

@JsonTypeName("tokenAware")
public class TokenAwarePolicyFactory implements LoadBalancingPolicyFactory {
    @Valid
    @NotNull
    @JsonProperty
    private LoadBalancingPolicyFactory subPolicy;

    @NotNull
    @JsonProperty
    private TokenAwarePolicy.ReplicaOrdering replicaOrdering = TokenAwarePolicy.ReplicaOrdering.RANDOM;

    public LoadBalancingPolicyFactory getSubPolicy() {
        return subPolicy;
    }

    public void setSubPolicy(LoadBalancingPolicyFactory subPolicy) {
        this.subPolicy = subPolicy;
    }

    public TokenAwarePolicy.ReplicaOrdering getReplicaOrdering() {
        return replicaOrdering;
    }

    public void setReplicaOrdering(final TokenAwarePolicy.ReplicaOrdering replicaOrdering) {
        this.replicaOrdering = replicaOrdering;
    }

    @Override
    public LoadBalancingPolicy build() {
        return new TokenAwarePolicy(subPolicy.build(), replicaOrdering);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy