-
Notifications
You must be signed in to change notification settings - Fork 354
Customizing calls
.
OperationResult<Void> result =
keyspace.prepareQuery(CF_STANDARD1)
.setConsistencyLevel(ConsistencyLevel.CL_ONE)
.getKey("Key1").copyTo(CF_STANDARD2, "Key2")
.execute();
Astyanax distinguishes between failover and retry. Failover is invoked within the context of selecting a connection from the connection pool or failing over if the connection is terminated or times out. Retry operates on top of the connection pool failover and retries the entire operation with a new failover context. Retry is useful when you want to retry after all lower level connection pool failovers have been exhausted. Retry implements backoff whereas failover in the connection pool waits for connections to be available. Use a retry policy when you want your app to be more resilient when there are lots of timeouts from cassandra, the connection pool is overwhelmed with requests of if there is a temporary cassandra outage. A retry policy may be added to a query or a mutation immediately after preparing the query or mutation object by calling withRetryPolicy. Astyanax provides the following retry policies: RunOnce (this is the default), RetryNTimes (no backoff), ConstantBackoff, ExponentialBackoff, BoundedExponentialBackoff.
ColumnList<String> result = keyspace.prepareQuery(CF_STANDARD1)
.withRetryPolicy(new ExponentialBackoff(250, 5))
.getKey(rowKey)
.execute().getResult();
if (!result.isEmpty()) {
...
}
A Netflix Original Production
Tech Blog | Twitter @NetflixOSS | Jobs
- Getting-Started
- Configuration
- Features
- Monitoring
- Thread Safety
- Timeouts
- Recipes
- Examples
- Javadoc
- Utilities
- Cassandra-Compatibility
- FAQ
- End-to-End Examples
- Astyanax Integration with Java Driver