org.stuartgunter.dropwizard.cassandra.reconnection.ExponentialReconnectionPolicyFactory Maven / Gradle / Ivy
                 Go to download
                
        
                    Show more of this group  Show more artifacts with this name
Show all versions of dropwizard-cassandra Show documentation
                Show all versions of dropwizard-cassandra Show documentation
Dropwizard Bundle for Cassandra
                
             The newest version!
        
        package org.stuartgunter.dropwizard.cassandra.reconnection;
import com.datastax.driver.core.policies.ExponentialReconnectionPolicy;
import com.datastax.driver.core.policies.ReconnectionPolicy;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeName;
import io.dropwizard.util.Duration;
import javax.validation.constraints.NotNull;
/**
 * A factory for configuring and building {@link ExponentialReconnectionPolicy} instances.
 * 
 * Configuration Parameters:
 * 
 *     
 *         Name 
 *         Default 
 *         Description 
 *      
 *     
 *         baseDelay 
 *         No default. You must specify a base delay. 
 *         The base delay to use for the schedules created by this policy. 
 *      
 *     
 *         maxDelay 
 *         No default. You must specify a max delay. 
 *         The maximum delay to wait between two attempts. 
 *      
 * 
 */
@JsonTypeName("exponential")
public class ExponentialReconnectionPolicyFactory implements ReconnectionPolicyFactory {
    @NotNull
    private Duration baseDelay;
    @NotNull
    private Duration maxDelay;
    @JsonProperty
    public Duration getBaseDelay() {
        return baseDelay;
    }
    @JsonProperty
    public void setBaseDelay(Duration baseDelay) {
        this.baseDelay = baseDelay;
    }
    @JsonProperty
    public Duration getMaxDelay() {
        return maxDelay;
    }
    @JsonProperty
    public void setMaxDelay(Duration maxDelay) {
        this.maxDelay = maxDelay;
    }
    @Override
    public ReconnectionPolicy build() {
        return new ExponentialReconnectionPolicy(baseDelay.toMilliseconds(), maxDelay.toMilliseconds());
    }
}
    © 2015 - 2025 Weber Informatics LLC | Privacy Policy