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

项目:simulacron    文件:ActivityLogIntegrationTest.java   
private void primeAndExecuteQueries(String[] primed, String[] queries) throws Exception {
  SuccessResult result = getSampleSuccessResult();
  for (String primeQuery : primed) {
    server.prime(when(primeQuery).then(result));
  }

  try (com.datastax.driver.core.Cluster driverCluster =
      defaultBuilder(server.getCluster())
          .withRetryPolicy(FallthroughRetryPolicy.INSTANCE)
          .build()) {
    Session session = driverCluster.connect();
    server.getCluster().clearLogs();
    for (String executeQuery : queries) {
      SimpleStatement stmt = new SimpleStatement(executeQuery);
      stmt.setDefaultTimestamp(100);
      session.execute(stmt);
    }
  }
}
项目:simulacron    文件:ActivityLogIntegrationTest.java   
@Test
public void testShouldMarkPeerQueriesAsNonPrimed() throws Exception {
  server.getCluster().clearLogs();

  try (com.datastax.driver.core.Cluster driverCluster =
      defaultBuilder(server.getCluster())
          .withRetryPolicy(FallthroughRetryPolicy.INSTANCE)
          .build()) {
    driverCluster.init();
  }
  // verify for node level filter: primed.  This should be empty as no primed queries were made
  // other than internal.
  List<QueryLog> queryLogs =
      getAllQueryLogs(server.getLogs(server.getCluster().getName() + "?filter=primed"));
  assertThat(queryLogs).isEmpty();

  // non primed should have the internal peer queries.
  queryLogs =
      getAllQueryLogs(server.getLogs(server.getCluster().getName() + "?filter=nonprimed"));
  assertThat(queryLogs).isNotEmpty();
}
项目:emodb    文件:CassandraFactory.java   
public HintsPollerCQLSession cqlSessionForHintsPoller(CassandraConfiguration configuration) {
    // Nodes can register themselves in ZooKeeper to help figure out which hosts are in this data center.
    configuration.withZooKeeperHostDiscovery(_curator);

    // Hints Poller only need 1 connection per host since all this is used for is single-threaded polling of the hints table.
    // We could also have a new property in the CassandraConfiguration yaml's just for the HintsPoller sake.
    CqlCluster cqlCluster = configuration.cql()
            .metricRegistry(_metricRegistry)
            .disableClusterMetrics()
            .maxConnectionsPerHost(1)
            .coreConnectionsPerHost(1)
            .loadBalancingPolicy(new SelectedHostLoadBalancingPolicy())
            .retryPolicy(FallthroughRetryPolicy.INSTANCE)
            .cluster();

    _lifeCycle.manage(cqlCluster);

    return new HintsPollerCQLSession(_lifeCycle, cqlCluster);
}
项目:cassandra-jdbc-wrapper    文件:UtilsUnitTest.java   
@Test
public void testRetryPolicyParsing() throws Exception
{
    String retryPolicyStr = "DefaultRetryPolicy";
    System.out.println(retryPolicyStr);
    assertTrue(Utils.parseRetryPolicy(retryPolicyStr) instanceof DefaultRetryPolicy);
    System.out.println("====================");
    retryPolicyStr = "DowngradingConsistencyRetryPolicy";
    System.out.println(retryPolicyStr);
    assertTrue(Utils.parseRetryPolicy(retryPolicyStr) instanceof DowngradingConsistencyRetryPolicy);
    System.out.println("====================");
    retryPolicyStr = "FallthroughRetryPolicy";
    System.out.println(retryPolicyStr);
    assertTrue(Utils.parseRetryPolicy(retryPolicyStr) instanceof FallthroughRetryPolicy);
    System.out.println("====================");


}
项目:vertx-mod-cassandra-persistor    文件:CassandraPersistor.java   
/**
 * Derive the retry policy from the given string to the implementation. Defaults to {@link DefaultRetryPolicy}.
 * 
 * @param retryPolicy
 *            The name of the retry policy to use. Can be "downgrading" {@link DowngradingConsistencyRetryPolicy} or
 *            "fallthrough" {@link FallthroughRetryPolicy}. Everything else defaults to
 *            Policies.defaultRetryPolicy()
 */
public void setRetryPolicy(String retryPolicy) {
    switch(retryPolicy) {
        case "downgrading":
            setRetryPolicy(DowngradingConsistencyRetryPolicy.INSTANCE);
            break;

        case "fallthrough":
            setRetryPolicy(FallthroughRetryPolicy.INSTANCE);
            break;

        default:
            setRetryPolicy(Policies.defaultRetryPolicy());
            break;
    }
}
项目:carbon-data    文件:CassandraConfig.java   
private Builder populateRetrytPolicy(Map<String, String> properties, Builder builder) throws DataServiceFault {
    String retryPolicy = properties.get(DBConstants.Cassandra.RETRY_POLICY);
    if (retryPolicy != null) {
        if ("DefaultRetryPolicy".equals(retryPolicy)) {
            builder = builder.withRetryPolicy(DefaultRetryPolicy.INSTANCE);
        } else if ("DowngradingConsistencyRetryPolicy".equals(retryPolicy)) {
            builder = builder.withRetryPolicy(DowngradingConsistencyRetryPolicy.INSTANCE);
        } else if ("FallthroughRetryPolicy".equals(retryPolicy)) {
            builder = builder.withRetryPolicy(FallthroughRetryPolicy.INSTANCE);
        } else if ("LoggingDefaultRetryPolicy".equals(retryPolicy)) {
            builder = builder.withRetryPolicy(new LoggingRetryPolicy(DefaultRetryPolicy.INSTANCE));
        } else if ("LoggingDowngradingConsistencyRetryPolicy".equals(retryPolicy)) {
            builder = builder.withRetryPolicy(new LoggingRetryPolicy(DowngradingConsistencyRetryPolicy.INSTANCE));                
        } else if ("LoggingFallthroughRetryPolicy".equals(retryPolicy)) {
            builder = builder.withRetryPolicy(new LoggingRetryPolicy(FallthroughRetryPolicy.INSTANCE));                
        } else {
            throw new DataServiceFault("Invalid Cassandra retry policy: " + retryPolicy);
        }
    }
    return builder;
}
项目:simulacron    文件:ActivityLogIntegrationTest.java   
private void query(String statement, ClusterSpec cluster) throws Exception {
  try (com.datastax.driver.core.Cluster driverCluster =
      com.datastax.driver.core.Cluster.builder()
          .addContactPointsWithPorts(cluster.node(0).inetSocketAddress())
          .withNettyOptions(SimulacronDriverSupport.nonQuietClusterCloseOptions)
          .withRetryPolicy(FallthroughRetryPolicy.INSTANCE)
          .build()) {
    driverCluster.connect().execute(statement);
  }
}
项目:simulacron    文件:ErrorResultIntegrationTest.java   
private PreparedStatement prepare() throws Exception {
  try (com.datastax.driver.core.Cluster driverCluster =
      defaultBuilder(server.getCluster())
          .withRetryPolicy(FallthroughRetryPolicy.INSTANCE)
          .build()) {
    return driverCluster.connect().prepare(query);
  }
}
项目:simulacron    文件:ErrorResultIntegrationTest.java   
private ResultSet prepareAndQuery() throws Exception {
  try (com.datastax.driver.core.Cluster driverCluster =
      defaultBuilder(server.getCluster())
          .withRetryPolicy(FallthroughRetryPolicy.INSTANCE)
          .build()) {
    Session session = driverCluster.connect();
    PreparedStatement prepared = session.prepare(query);
    return session.execute(prepared.bind());
  }
}
项目:simulacron    文件:ErrorResultIntegrationTest.java   
private ResultSet query(Statement statement) throws Exception {
  try (com.datastax.driver.core.Cluster driverCluster =
      defaultBuilder(server.getCluster())
          .withRetryPolicy(FallthroughRetryPolicy.INSTANCE)
          .build()) {
    return driverCluster.connect().execute(statement);
  }
}
项目:dropwizard-cassandra    文件:FallthroughRetryPolicyFactoryTest.java   
@Test
public void returnsFallthroughRetryPolicyInstance() throws Exception {
    final FallthroughRetryPolicyFactory factory = new FallthroughRetryPolicyFactory();

    final FallthroughRetryPolicy policy = (FallthroughRetryPolicy) factory.build();

    assertThat(policy).isSameAs(FallthroughRetryPolicy.INSTANCE);
}
项目:gora    文件:CassandraClient.java   
private Cluster.Builder populateRetrytPolicy(Properties properties, Cluster.Builder builder) {
  String retryPolicy = properties.getProperty(CassandraStoreParameters.RETRY_POLICY);
  if (retryPolicy != null) {
    switch (retryPolicy) {
      case "DefaultRetryPolicy":
        builder = builder.withRetryPolicy(DefaultRetryPolicy.INSTANCE);
        break;
      case "DowngradingConsistencyRetryPolicy":
        builder = builder.withRetryPolicy(DowngradingConsistencyRetryPolicy.INSTANCE);
        break;
      case "FallthroughRetryPolicy":
        builder = builder.withRetryPolicy(FallthroughRetryPolicy.INSTANCE);
        break;
      case "LoggingDefaultRetryPolicy":
        builder = builder.withRetryPolicy(new LoggingRetryPolicy(DefaultRetryPolicy.INSTANCE));
        break;
      case "LoggingDowngradingConsistencyRetryPolicy":
        builder = builder.withRetryPolicy(new LoggingRetryPolicy(DowngradingConsistencyRetryPolicy.INSTANCE));
        break;
      case "LoggingFallthroughRetryPolicy":
        builder = builder.withRetryPolicy(new LoggingRetryPolicy(FallthroughRetryPolicy.INSTANCE));
        break;
      default:
        LOG.error("Unsupported retry policy : {} ", retryPolicy);
        break;
    }
  }
  return builder;
}
项目:dropwizard-cassandra    文件:FallthroughRetryPolicyFactory.java   
@Override
public RetryPolicy build() {
    return FallthroughRetryPolicy.INSTANCE;
}