Skip to content

Commit 1995860

Browse files
committed
Renamed retry policy functions and added header docs
1 parent 2134463 commit 1995860

File tree

3 files changed

+71
-9
lines changed

3 files changed

+71
-9
lines changed

include/cassandra.h

Lines changed: 61 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,9 @@ typedef struct CassSchemaMetaField_ CassSchemaMetaField;
346346
typedef struct CassUuidGen_ CassUuidGen;
347347

348348
/**
349+
* Policies that defined the behavior of a request when a server-side
350+
* read/write timeout or unavailable error occurs.
351+
*
349352
* @struct CassRetryPolicy
350353
*/
351354
typedef struct CassRetryPolicy_ CassRetryPolicy;
@@ -1202,7 +1205,7 @@ cass_cluster_set_tcp_keepalive(CassCluster* cluster,
12021205

12031206
/**
12041207
* Sets the retry policy used for all requests unless overridden by setting
1205-
* a retry policy on a statement.
1208+
* a retry policy on a statement or a batch.
12061209
*
12071210
* <b>Default:</b> default retry policy.
12081211
*
@@ -1212,6 +1215,7 @@ cass_cluster_set_tcp_keepalive(CassCluster* cluster,
12121215
* @param[in] retry_policy
12131216
*
12141217
* @see cass_statement_set_retry_policy()
1218+
* @see cass_batch_set_retry_policy()
12151219
*/
12161220
CASS_EXPORT void
12171221
cass_cluster_set_retry_policy(CassCluster* cluster,
@@ -3001,6 +3005,19 @@ CASS_EXPORT CassError
30013005
cass_batch_set_consistency(CassBatch* batch,
30023006
CassConsistency consistency);
30033007

3008+
/**
3009+
* Sets the batch's retry policy.
3010+
*
3011+
* @public @memberof CassBatch
3012+
*
3013+
* @param[in] batch
3014+
* @param[in] retry_policy
3015+
* @return CASS_OK if successful, otherwise an error occurred.
3016+
*/
3017+
CASS_EXPORT CassError
3018+
cass_batch_set_retry_policy(CassBatch* batch,
3019+
CassRetryPolicy* retry_policy);
3020+
30043021
/**
30053022
* Adds a statement to a batch.
30063023
*
@@ -5706,42 +5723,81 @@ cass_uuid_from_string_n(const char* str,
57065723
/**
57075724
* Creates a new default retry policy.
57085725
*
5726+
* This policy retries queries in the following cases:
5727+
* <ul>
5728+
* <li>On a read timeout, if enough replicas replied but data was not received.</li>
5729+
* <li>On a write timeout, if a timeout occurs while writing the distributed batch log</li>
5730+
* <li>On unavailble, it will move to the next host</li>
5731+
* </ul>
5732+
*
5733+
* In all other cases the error will be returned.
5734+
*
5735+
* This policy always uses the queries original consistency level.
5736+
*
57095737
* @public @memberof CassRetryPolicy
57105738
*
57115739
* @return Returns a retry policy that must be freed.
57125740
*
57135741
* @see cass_retry_policy_free()
57145742
*/
57155743
CASS_EXPORT CassRetryPolicy*
5716-
cass_default_retry_policy_new();
5744+
cass_retry_policy_default_new();
57175745

57185746
/**
57195747
* Creates a new downgrading consistency retry policy.
57205748
*
5749+
* <b>Important:</b> This policy may attempt to retry requests with a lower
5750+
* consistency level. Using this policy can break consistency guarantees.
5751+
*
5752+
* This policy will retry in the same scenarios as the default policy, but
5753+
* it will also retry in the following cases:
5754+
* <ul>
5755+
* <li>On a read timeout, if some replicas responded but is lower than
5756+
* required by the current consistency level then retry with a lower
5757+
* consistency level.</li>
5758+
* <li>On a write timeout, Retry unlogged batches at a lower consistency level
5759+
* if at least one replica responded. For single queries and batch if any
5760+
* replicas responded then consider the request successful and swallow the
5761+
* error.</li>
5762+
* <li>On unavailable, retry at a lower consistency if at lease one replica
5763+
* responded.</li>
5764+
* </ul>
5765+
*
5766+
* This goal of this policy is to attempt to save a request if there's any
5767+
* chance of success. A writes succeeds as long as there's a single copy
5768+
* persisted and a read will succeed if there's some data available even
5769+
* if it increases the risk of reading stale data.
5770+
*
57215771
* @public @memberof CassRetryPolicy
57225772
*
57235773
* @return Returns a retry policy that must be freed.
57245774
*
57255775
* @see cass_retry_policy_free()
57265776
*/
57275777
CASS_EXPORT CassRetryPolicy*
5728-
cass_downgrading_consistency_retry_policy_new();
5778+
cass_retry_policy_downgrading_consistency_new();
57295779

57305780
/**
57315781
* Creates a new fallthrough retry policy.
57325782
*
5783+
* This policy never retries or ignores a server-side failure. The error
5784+
* is always returned.
5785+
*
57335786
* @public @memberof CassRetryPolicy
57345787
*
57355788
* @return Returns a retry policy that must be freed.
57365789
*
57375790
* @see cass_retry_policy_free()
57385791
*/
57395792
CASS_EXPORT CassRetryPolicy*
5740-
cass_fallthrough_retry_policy_new();
5793+
cass_retry_policy_fallthrough_new();
57415794

57425795
/**
57435796
* Creates a new logging retry policy.
57445797
*
5798+
* This policy logs the retry decision of its child policy. Logging is
5799+
* done using CASS_LOG_INFO.
5800+
*
57455801
* @public @memberof CassRetryPolicy
57465802
*
57475803
* @param[in] child_retry_policy
@@ -5751,7 +5807,7 @@ cass_fallthrough_retry_policy_new();
57515807
* @see cass_retry_policy_free()
57525808
*/
57535809
CASS_EXPORT CassRetryPolicy*
5754-
cass_logging_retry_policy(CassRetryPolicy* child_retry_policy);
5810+
cass_retry_policy_logging_new(CassRetryPolicy* child_retry_policy);
57555811

57565812
/**
57575813
* Frees a retry policy instance.

src/batch_request.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ CassError cass_batch_set_consistency(CassBatch* batch,
4040
return CASS_OK;
4141
}
4242

43+
CassError cass_batch_set_retry_policy(CassBatch* batch,
44+
CassRetryPolicy* retry_policy) {
45+
batch->set_retry_policy(retry_policy);
46+
return CASS_OK;
47+
}
48+
4349
CassError cass_batch_add_statement(CassBatch* batch, CassStatement* statement) {
4450
batch->add_statement(statement);
4551
return CASS_OK;

src/retry_policy.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,25 +21,25 @@
2121

2222
extern "C" {
2323

24-
CassRetryPolicy* cass_default_retry_policy_new() {
24+
CassRetryPolicy* cass_retry_policy_default_new() {
2525
cass::RetryPolicy* policy = new cass::DefaultRetryPolicy();
2626
policy->inc_ref();
2727
return CassRetryPolicy::to(policy);
2828
}
2929

30-
CassRetryPolicy* cass_downgrading_consistency_retry_policy_new() {
30+
CassRetryPolicy* cass_retry_policy_downgrading_consistency_new() {
3131
cass::RetryPolicy* policy = new cass::DowngradingConsistencyRetryPolicy();
3232
policy->inc_ref();
3333
return CassRetryPolicy::to(policy);
3434
}
3535

36-
CassRetryPolicy* cass_fallthrough_retry_policy_new() {
36+
CassRetryPolicy* cass_retry_policy_fallthrough_new() {
3737
cass::RetryPolicy* policy = new cass::FallthroughRetryPolicy();
3838
policy->inc_ref();
3939
return CassRetryPolicy::to(policy);
4040
}
4141

42-
CassRetryPolicy* cass_logging_retry_policy(CassRetryPolicy* child_retry_policy) {
42+
CassRetryPolicy* cass_retry_policylogging_new(CassRetryPolicy* child_retry_policy) {
4343
if (child_retry_policy->type() == cass::RetryPolicy::LOGGING) {
4444
return NULL;
4545
}

0 commit comments

Comments
 (0)