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

The following examples show how to use com.datastax.driver.core.policies.FallthroughRetryPolicy. 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: CassandraConfig.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example #2
Source File: ActivityLogIntegrationTest.java    From simulacron with Apache License 2.0 6 votes vote down vote up
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);
    }
  }
}
 
Example #3
Source File: ActivityLogIntegrationTest.java    From simulacron with Apache License 2.0 6 votes vote down vote up
@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();
}
 
Example #4
Source File: CassandraFactory.java    From emodb with Apache License 2.0 6 votes vote down vote up
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);
}
 
Example #5
Source File: UtilsUnitTest.java    From cassandra-jdbc-wrapper with Apache License 2.0 6 votes vote down vote up
@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("====================");
	    	

}
 
Example #6
Source File: ActivityLogIntegrationTest.java    From simulacron with Apache License 2.0 5 votes vote down vote up
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);
  }
}
 
Example #7
Source File: ErrorResultIntegrationTest.java    From simulacron with Apache License 2.0 5 votes vote down vote up
private PreparedStatement prepare() throws Exception {
  try (com.datastax.driver.core.Cluster driverCluster =
      defaultBuilder(server.getCluster())
          .withRetryPolicy(FallthroughRetryPolicy.INSTANCE)
          .build()) {
    return driverCluster.connect().prepare(query);
  }
}
 
Example #8
Source File: ErrorResultIntegrationTest.java    From simulacron with Apache License 2.0 5 votes vote down vote up
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());
  }
}
 
Example #9
Source File: ErrorResultIntegrationTest.java    From simulacron with Apache License 2.0 5 votes vote down vote up
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);
  }
}
 
Example #10
Source File: FallthroughRetryPolicyFactoryTest.java    From dropwizard-cassandra with Apache License 2.0 5 votes vote down vote up
@Test
public void returnsFallthroughRetryPolicyInstance() throws Exception {
    final FallthroughRetryPolicyFactory factory = new FallthroughRetryPolicyFactory();

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

    assertThat(policy).isSameAs(FallthroughRetryPolicy.INSTANCE);
}
 
Example #11
Source File: FallthroughRetryPolicyFactory.java    From dropwizard-cassandra with Apache License 2.0 4 votes vote down vote up
@Override
public RetryPolicy build() {
    return FallthroughRetryPolicy.INSTANCE;
}