com.datastax.driver.core.policies.ReconnectionPolicy Java Examples

The following examples show how to use com.datastax.driver.core.policies.ReconnectionPolicy. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CassandraSession.java    From presto with Apache License 2.0 5 votes vote down vote up
private <T> T executeWithSession(SessionCallable<T> sessionCallable)
{
    ReconnectionPolicy reconnectionPolicy = cluster.getConfiguration().getPolicies().getReconnectionPolicy();
    ReconnectionSchedule schedule = reconnectionPolicy.newSchedule();
    long deadline = System.currentTimeMillis() + noHostAvailableRetryTimeout.toMillis();
    while (true) {
        try {
            return sessionCallable.executeWithSession(session.get());
        }
        catch (NoHostAvailableException e) {
            long timeLeft = deadline - System.currentTimeMillis();
            if (timeLeft <= 0) {
                throw e;
            }
            else {
                long delay = Math.min(schedule.nextDelayMs(), timeLeft);
                log.warn(e.getCustomMessage(10, true, true));
                log.warn("Reconnecting in %dms", delay);
                try {
                    Thread.sleep(delay);
                }
                catch (InterruptedException interrupted) {
                    Thread.currentThread().interrupt();
                    throw new RuntimeException("interrupted", interrupted);
                }
            }
        }
    }
}
 
Example #2
Source File: DataSource.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    fetchSize = (Integer)in.readObject();
    readConsistency = (ConsistencyLevel)in.readObject();
    writeConsistency = (ConsistencyLevel)in.readObject();
    user = U.readString(in);
    pwd = U.readString(in);
    port = (Integer)in.readObject();
    contactPoints = (List<InetAddress>)in.readObject();
    contactPointsWithPorts = (List<InetSocketAddress>)in.readObject();
    maxSchemaAgreementWaitSeconds = (Integer)in.readObject();
    protoVer = (Integer)in.readObject();
    compression = U.readString(in);
    useSSL = (Boolean)in.readObject();
    collectMetrix = (Boolean)in.readObject();
    jmxReporting = (Boolean)in.readObject();
    creds = (Credentials)in.readObject();
    loadBalancingPlc = (LoadBalancingPolicy)readObject(in);
    reconnectionPlc = (ReconnectionPolicy)readObject(in);
    addrTranslator = (AddressTranslator)readObject(in);
    speculativeExecutionPlc = (SpeculativeExecutionPolicy)readObject(in);
    authProvider = (AuthProvider)readObject(in);
    sslOptions = (SSLOptions)readObject(in);
    poolingOptions = (PoolingOptions)readObject(in);
    sockOptions = (SocketOptions)readObject(in);
    nettyOptions = (NettyOptions)readObject(in);
}
 
Example #3
Source File: DataSource.java    From ignite with Apache License 2.0 4 votes vote down vote up
/**
 * Sets reconnection policy.
 *
 * @param plc Reconnection policy.
 */
public void setReconnectionPolicy(ReconnectionPolicy plc) {
    reconnectionPlc = plc;

    invalidate();
}
 
Example #4
Source File: CassandraConfig.java    From realtime-analytics with GNU General Public License v2.0 4 votes vote down vote up
public ReconnectionPolicy getReconnectionPolicy() {
    return reconnectionPolicy;
}
 
Example #5
Source File: CassandraConfig.java    From realtime-analytics with GNU General Public License v2.0 4 votes vote down vote up
public void setReconnectionPolicy(ReconnectionPolicy reconnectionPolicy) {
    this.reconnectionPolicy = reconnectionPolicy;
}
 
Example #6
Source File: ExponentialReconnectionPolicyFactory.java    From dropwizard-cassandra with Apache License 2.0 4 votes vote down vote up
@Override
public ReconnectionPolicy build() {
    return new ExponentialReconnectionPolicy(baseDelay.toMilliseconds(), maxDelay.toMilliseconds());
}
 
Example #7
Source File: ConstantReconnectionPolicyFactory.java    From dropwizard-cassandra with Apache License 2.0 4 votes vote down vote up
@Override
public ReconnectionPolicy build() {
    return new ConstantReconnectionPolicy(delay.toMilliseconds());
}
 
Example #8
Source File: CassandraClusterConfig.java    From spring-cloud-connectors with Apache License 2.0 4 votes vote down vote up
public ReconnectionPolicy getReconnectionPolicy() {
	return reconnectionPolicy;
}
 
Example #9
Source File: CassandraClusterConfig.java    From spring-cloud-connectors with Apache License 2.0 4 votes vote down vote up
public void setReconnectionPolicy(ReconnectionPolicy reconnectionPolicy) {
	this.reconnectionPolicy = reconnectionPolicy;
}
 
Example #10
Source File: ConnectionStateManager.java    From attic-apex-malhar with Apache License 2.0 2 votes vote down vote up
/**
 * Used to decide how to establish a connection to the cluster in case the current one fails.
 * The default if not set is to use an ExponentialRetry Policy.
 * The baseDelay and maxDelay are the two time windows that are used to specify the retry attempts
 * in an exponential manner
 * @param reconnectionPolicy
 * @return The builder instance as initially created updated with this value
 */
public ConnectionBuilder withReconnectionPolicy(ReconnectionPolicy reconnectionPolicy)
{
  this.reconnectionPolicy = reconnectionPolicy;
  return this;
}
 
Example #11
Source File: ReconnectionPolicyFactory.java    From dropwizard-cassandra with Apache License 2.0 votes vote down vote up
ReconnectionPolicy build();