Java 类com.datastax.driver.core.policies.RetryPolicy 实例源码

项目:cassandra-java-driver-examples    文件:RetryPolicyExample.java   
static Session connect() {
    String contactPoint = "localhost";
    String keySpace = "ks1";

    if(session == null) {

        RetryPolicy retryPolicy = new CustomRetryPolicy(3, 3, 2);

        cluster = Cluster.builder().addContactPoint(contactPoint)
                .withRetryPolicy(retryPolicy).build();
        cluster.init();
        for (Host host : cluster.getMetadata().getAllHosts()) {
            System.out.printf("Address: %s, Rack: %s, Datacenter: %s, Tokens: %s\n", host.getAddress(),
                    host.getDatacenter(), host.getRack(), host.getTokens());
        }
    }
    return session;
}
项目:heroic    文件:DatastaxMetricModule.java   
@JsonCreator
public DatastaxMetricModule(
    @JsonProperty("id") Optional<String> id, @JsonProperty("groups") Optional<Groups> groups,
    @JsonProperty("seeds") Optional<Set<String>> seeds,
    @JsonProperty("schema") Optional<SchemaModule> schema,
    @JsonProperty("configure") Optional<Boolean> configure,
    @JsonProperty("fetchSize") Optional<Integer> fetchSize,
    @JsonProperty("readTimeout") Optional<Duration> readTimeout,
    @JsonProperty("consistencyLevel") Optional<ConsistencyLevel> consistencyLevel,
    @JsonProperty("retryPolicy") Optional<RetryPolicy> retryPolicy,
    @JsonProperty("authentication") Optional<DatastaxAuthentication> authentication
) {
    this.id = id;
    this.groups = groups.orElseGet(Groups::empty).or("heroic");
    this.seeds = convert(seeds.orElse(DEFAULT_SEEDS));
    this.schema = schema.orElseGet(NextGenSchemaModule.builder()::build);
    this.configure = configure.orElse(DEFAULT_CONFIGURE);
    this.fetchSize = fetchSize.orElse(DEFAULT_FETCH_SIZE);
    this.readTimeout = readTimeout.orElse(DEFAULT_READ_TIMEOUT);
    this.consistencyLevel = consistencyLevel.orElse(ConsistencyLevel.ONE);
    this.retryPolicy = retryPolicy.orElse(DefaultRetryPolicy.INSTANCE);
    this.authentication = authentication.orElseGet(DatastaxAuthentication.None::new);
}
项目:AbacusUtil    文件:CassandraExecutor.java   
public StatementSettings(ConsistencyLevel consistency, ConsistencyLevel serialConsistency, boolean traceQuery, RetryPolicy retryPolicy, int fetchSize) {
    this.consistency = consistency;
    this.serialConsistency = serialConsistency;
    this.traceQuery = traceQuery;
    this.retryPolicy = retryPolicy;
    this.fetchSize = fetchSize;
}
项目:flipper-reverse-image-search    文件:CassandraProperties.java   
/**
 * Parse the RetryPolicy policy.
 */
public static RetryPolicy parseRetryPolicy(String retryPolicyString) throws InstantiationException,
    IllegalAccessException, ClassNotFoundException, NoSuchMethodException, SecurityException,
    IllegalArgumentException, InvocationTargetException, NoSuchFieldException {

    if (!retryPolicyString.contains(".")) {
        retryPolicyString = "com.datastax.driver.core.policies." + retryPolicyString;
        Class<?> clazz = Class.forName(retryPolicyString);
        Field field = clazz.getDeclaredField("INSTANCE");
        RetryPolicy policy = (RetryPolicy) field.get(null);
        return policy;
    }
    return null;
}
项目:heroic    文件:CassandraProfile.java   
private RetryPolicy convertRetryPolicy(final String policyName, final ExtraParameters params) {
    if ("aggressive".equals(policyName)) {
        final int numRetries = params.getInteger("numRetries").orElse(DEFAULT_NUM_RETRIES);
        final int rotateHost = params.getInteger("rotateHost").orElse(DEFAULT_ROTATE_HOST);
        return new AggressiveRetryPolicy(numRetries, rotateHost);
    }

    throw new IllegalArgumentException("Not a valid retry policy: " + policyName);
}
项目:ignite    文件:DataSource.java   
/**
 * Sets retry policy.
 *
 * @param plc Retry policy.
 */
@SuppressWarnings("UnusedDeclaration")
public void setRetryPolicy(RetryPolicy plc) {
    retryPlc = plc;

    invalidate();
}
项目:Troilus    文件:Context.java   
Context withRetryPolicy(RetryPolicy policy) {
    return new Context(dbSession,
                       catalog,
                       executionSpec.withRetryPolicy(policy),
                       interceptorRegistry,
                       beanMapper,
                       udtValueMapper,
                       executor);        
}
项目:Troilus    文件:Context.java   
public ExecutionSpecImpl(ConsistencyLevel consistencyLevel, 
                         ConsistencyLevel serialConsistencyLevel,
                         Integer ttlSec,
                         Long writetimeMicrosSinceEpoch,
                         Boolean enableTracking,
                         RetryPolicy retryPolicy) {
    this.consistencyLevel = consistencyLevel;
    this.serialConsistencyLevel = serialConsistencyLevel;
    this.ttlSec = ttlSec;
    this.writetimeMicrosSinceEpoch = writetimeMicrosSinceEpoch;
    this.enableTracing = enableTracking;
    this.retryPolicy = retryPolicy;
}
项目:Troilus    文件:Context.java   
public ExecutionSpec withRetryPolicy(RetryPolicy policy) {
    return new ExecutionSpecImpl(this.consistencyLevel,
                                 this.serialConsistencyLevel,
                                 this.ttlSec,
                                 this.writetimeMicrosSinceEpoch,
                                 this.enableTracing,
                                 policy);
}
项目:ob1k    文件:CqlSession.java   
public CqlSession(final String nodes, final int port, final String keyspace, final SocketOptions socketOptions,
                  final RetryPolicy retryPolicy, final QueryOptions queryOptions,
                  final LoadBalancingPolicy loadBalancingPolicy, final int maxConnectionsPerHost,
                  final MetricFactory metricFactory) {

  // this is temp. to reuse current hosts properties:
  final Iterable<String> nodesIter = Splitter.on(",").split(nodes);
  final String[] nodesArr = Iterables.toArray(
    StreamSupport.stream(nodesIter.spliterator(), false).map(input -> {
    if (input == null) return null;

    final int idx = input.lastIndexOf(":");
    return input.substring(0, idx);
  }).collect(Collectors.toList()), String.class);


  /*PoolingOptions poolingOptions = new PoolingOptions();
  poolingOptions.setMaxConnectionsPerHost(HostDistance.LOCAL, maxConnectionsPerHost);
  poolingOptions.setMaxConnectionsPerHost(HostDistance.REMOTE, maxConnectionsPerHost);*/


  final Cluster cluster = Cluster.builder().
          withPort(port).
          withSocketOptions(socketOptions).
          withQueryOptions(queryOptions).
          withLoadBalancingPolicy(loadBalancingPolicy).
          //  withPoolingOptions(poolingOptions).
                  addContactPoints(nodesArr).build();
  //cluster.init();
  this.session = cluster.connect(keyspace);
  this.retryPolicy = Preconditions.checkNotNull(retryPolicy);
  this.metricFactory = Preconditions.checkNotNull(metricFactory);
}
项目:blueflood    文件:RetryNTimesTest.java   
@Test
public void firstTimeRetryOnReadTimeout_shouldRetry() throws Exception {
    RetryNTimes retryPolicy = new RetryNTimes(3, 3, 3);
    Statement mockStatement = mock( Statement.class );
    RetryPolicy.RetryDecision retryResult = retryPolicy.onReadTimeout(mockStatement, ConsistencyLevel.LOCAL_ONE, 1, 0, false, 0);
    RetryPolicy.RetryDecision retryExpected = RetryPolicy.RetryDecision.retry(ConsistencyLevel.LOCAL_ONE);
    assertRetryDecisionEquals(retryExpected, retryResult);
}
项目:blueflood    文件:RetryNTimesTest.java   
@Test
public void maxTimeRetryOnReadTimeout_shouldRethrow() throws Exception {
    RetryNTimes retryPolicy = new RetryNTimes(3, 3, 3);
    Statement mockStatement = mock( Statement.class );

    RetryPolicy.RetryDecision retryResult = retryPolicy.onReadTimeout(mockStatement, ConsistencyLevel.LOCAL_ONE, 1, 0, false, 3);
    RetryPolicy.RetryDecision retryExpected = RetryPolicy.RetryDecision.rethrow();
    assertRetryDecisionEquals(retryExpected, retryResult);
}
项目:blueflood    文件:RetryNTimesTest.java   
@Test
public void firstTimeRetryOnWriteTimeout_shouldRetry() throws Exception {
    RetryNTimes retryPolicy = new RetryNTimes(3, 3, 3);
    Statement mockStatement = mock( Statement.class );
    RetryPolicy.RetryDecision retryResult = retryPolicy.onWriteTimeout(mockStatement, ConsistencyLevel.LOCAL_ONE, WriteType.BATCH, 1, 0, 0);
    RetryPolicy.RetryDecision retryExpected = RetryPolicy.RetryDecision.retry(ConsistencyLevel.LOCAL_ONE);
    assertRetryDecisionEquals(retryExpected, retryResult);
}
项目:blueflood    文件:RetryNTimesTest.java   
@Test
public void maxTimeRetryOnWriteTimeout_shouldRethrow() throws Exception {
    RetryNTimes retryPolicy = new RetryNTimes(3, 3, 3);
    Statement mockStatement = mock( Statement.class );

    RetryPolicy.RetryDecision retryResult = retryPolicy.onWriteTimeout(mockStatement, ConsistencyLevel.LOCAL_ONE, WriteType.BATCH, 1, 0, 3);
    RetryPolicy.RetryDecision retryExpected = RetryPolicy.RetryDecision.rethrow();
    assertRetryDecisionEquals(retryExpected, retryResult);
}
项目:blueflood    文件:RetryNTimesTest.java   
@Test
public void firstTimeRetryOnUnavailable_shouldRetry() throws Exception {
    RetryNTimes retryPolicy = new RetryNTimes(3, 3, 3);
    Statement mockStatement = mock( Statement.class );
    RetryPolicy.RetryDecision retryResult = retryPolicy.onUnavailable(mockStatement, ConsistencyLevel.LOCAL_ONE, 1, 0, 0);
    RetryPolicy.RetryDecision retryExpected = RetryPolicy.RetryDecision.retry(ConsistencyLevel.ONE);
    assertRetryDecisionEquals(retryExpected, retryResult);
}
项目:blueflood    文件:RetryNTimesTest.java   
@Test
public void maxTimeRetryOnUnavailable_shouldRethrow() throws Exception {
    RetryNTimes retryPolicy = new RetryNTimes(3, 3, 3);
    Statement mockStatement = mock( Statement.class );

    RetryPolicy.RetryDecision retryResult = retryPolicy.onUnavailable(mockStatement, ConsistencyLevel.LOCAL_ONE, 1, 0, 3);
    RetryPolicy.RetryDecision retryExpected = RetryPolicy.RetryDecision.rethrow();
    assertRetryDecisionEquals(retryExpected, retryResult);
}
项目:copper-engine    文件:CassandraStorage.java   
private void prepare(String cql, RetryPolicy petryPolicy) {
    logger.info("Preparing cql stmt {}", cql);
    PreparedStatement pstmt = session.prepare(cql);
    pstmt.setConsistencyLevel(consistencyLevel);
    pstmt.setRetryPolicy(petryPolicy);
    pstmt.setIdempotent(true);
    preparedStatements.put(cql, pstmt);
}
项目:Lagerta    文件:DataSource.java   
/**
 * Sets retry policy.
 *
 * @param plc Retry policy.
 */
@SuppressWarnings("UnusedDeclaration")
public void setRetryPolicy(RetryPolicy plc) {
    this.retryPlc = plc;
    invalidate();
}
项目:ibm-performance-monitor    文件:ProfiledPreparedStatement.java   
@Override
public RetryPolicy getRetryPolicy() {
    return preparedStatement.getRetryPolicy();
}
项目:ibm-performance-monitor    文件:ProfiledPreparedStatement.java   
@Override
public PreparedStatement setRetryPolicy( RetryPolicy arg0 ) {
    return preparedStatement.setRetryPolicy( arg0 );
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:CassandraProperties.java   
public Class<? extends RetryPolicy> getRetryPolicy() {
    return this.retryPolicy;
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:CassandraProperties.java   
public void setRetryPolicy(Class<? extends RetryPolicy> retryPolicy) {
    this.retryPolicy = retryPolicy;
}
项目:AbacusUtil    文件:CassandraExecutor.java   
public RetryPolicy getRetryPolicy() {
    return retryPolicy;
}
项目:AbacusUtil    文件:CassandraExecutor.java   
public StatementSettings setRetryPolicy(RetryPolicy retryPolicy) {
    this.retryPolicy = retryPolicy;

    return this;
}
项目:spring-boot-concourse    文件:CassandraProperties.java   
public Class<? extends RetryPolicy> getRetryPolicy() {
    return this.retryPolicy;
}
项目:spring-boot-concourse    文件:CassandraProperties.java   
public void setRetryPolicy(Class<? extends RetryPolicy> retryPolicy) {
    this.retryPolicy = retryPolicy;
}
项目:contestparser    文件:CassandraProperties.java   
public Class<? extends RetryPolicy> getRetryPolicy() {
    return this.retryPolicy;
}
项目:contestparser    文件:CassandraProperties.java   
public void setRetryPolicy(Class<? extends RetryPolicy> retryPolicy) {
    this.retryPolicy = retryPolicy;
}
项目:cassandra-loader    文件:LoaderRetryPolicy.java   
public RetryPolicy.RetryDecision onRequestError(Statement statement,
                                                ConsistencyLevel cl,
                                                DriverException e,
                                                int nbRetry) {
    return RetryDecision.tryNextHost(cl);
}
项目:realtime-analytics    文件:CassandraConfig.java   
public RetryPolicy getRetryPolicy() {
    return retryPolicy;
}
项目:realtime-analytics    文件:CassandraConfig.java   
public void setRetryPolicy(RetryPolicy retryPolicy) {
    this.retryPolicy = retryPolicy;
}
项目:dropwizard-cassandra    文件:DowngradingConsistencyRetryPolicyFactory.java   
@Override
public RetryPolicy build() {
    return DowngradingConsistencyRetryPolicy.INSTANCE;
}
项目:dropwizard-cassandra    文件:LoggingRetryPolicyFactory.java   
@Override
public RetryPolicy build() {
    return new LoggingRetryPolicy(subPolicy.build());
}
项目:dropwizard-cassandra    文件:FallthroughRetryPolicyFactory.java   
@Override
public RetryPolicy build() {
    return FallthroughRetryPolicy.INSTANCE;
}
项目:dropwizard-cassandra    文件:DefaultRetryPolicyFactory.java   
@Override
public RetryPolicy build() {
    return DefaultRetryPolicy.INSTANCE;
}
项目:Troilus    文件:Mutations.java   
@Override
public Object withRetryPolicy(RetryPolicy policy) {
    return mutation.withRetryPolicy(policy);
}
项目:Troilus    文件:CounterMutationQueryAdapter.java   
@Override
public net.oneandone.troilus.java7.CounterMutation withRetryPolicy(RetryPolicy policy) {
    return (net.oneandone.troilus.java7.CounterMutation) mutation.withRetryPolicy(policy);
}
项目:Troilus    文件:CounterMutationQueryAdapter.java   
@Override
public CounterMutation withRetryPolicy(RetryPolicy policy) {
    return (CounterMutation) mutation.withRetryPolicy(policy);
}
项目:Troilus    文件:DaoImpl.java   
@Override
public Dao withRetryPolicy(RetryPolicy policy) {
    return new DaoImpl(ctx.withRetryPolicy(policy), this.tablename);
}
项目:Troilus    文件:Java7DaoImpl.java   
@Override
public Dao withRetryPolicy(RetryPolicy policy) {
    return new Java7DaoImpl(ctx.withRetryPolicy(policy), this.tablename);
}