You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+20-8Lines changed: 20 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,17 +1,29 @@
1
-
## My Project
1
+
#Amazon Keyspaces Java Driver Helpers
2
+
This repository contains driver policies, examples, and best practices when using the DataStax Java Driver with Amazon Keyspaces (for Apache Cassandra).
2
3
3
-
TODO: Fill this README out!
4
+
## Retry Policies
5
+
The DataStax java driver will attempt to retry idempotent request transparently to the application. If you are seeing NoHostAvailableException when using Amazon Keyspaces, replacing the default retry policy with the ones provided in this repository will be beneficial.
4
6
5
-
Be sure to:
7
+
Implementing a driver retry policy is not a replacement for an application level retry. Users of Apache Cassandra or Amazon Keyspaces should implement an application level retry mechanism for request that satisfy the applications business requirements. Additionally, adding complex logic, sleeps or blocking calls in a Driver retry policy should be used with caution.
6
8
7
-
* Change the title in this README
8
-
* Edit your repository description on GitHub
9
+
### AmazonKeyspacesRetryPolicy
10
+
The Amazon Keyspaces Retry Policy is an alternative to the DefaultRetryPolicy for the Cassandra Driver. The main difference from the DefaultRetryPolicy, is the AmazonKeyspacesRetryPolicy will retry request a configurable number of times. By default, we take a conservative approach of 3 retry attempts. This driver retry policy will not throw a NoHostAvailableException. Instead, this retry policy will pass back the original exception sent back from the service.
9
11
10
-
## Security
12
+
The following code shows how to include the AmazonKeyspacesRetryPolicy to existing configuration
13
+
14
+
```
15
+
#Set idempotence for all operations you application can change on request
16
+
basic.request.default-idempotence = true
17
+
advanced.retry-policy {
18
+
class = com.aws.ssa.keyspaces.retry.AmazonKeyspacesRetryPolicy
19
+
max-attempts = 3
20
+
}
21
+
```
22
+
23
+
# Security
11
24
12
25
See [CONTRIBUTING](CONTRIBUTING.md#security-issue-notifications) for more information.
13
26
14
-
##License
27
+
# License
15
28
16
29
This library is licensed under the MIT-0 License. See the LICENSE file.
* This is a conservative retry policy adapted for the Amazon Keyspaces Service.
19
+
* It allows for a configurable number of attempts, but by default the number of attempts is {@value KeyspacesRetryOption#DEFAULT_KEYSPACES_RETRY_MAX_ATTEMPTS}
20
+
* <p>
21
+
* This policy will either reattempt request on the same host or rethrow the exception to the calling thread. The main difference between
22
+
* this policy from the original {@link com.datastax.oss.driver.internal.core.retry.DefaultRetryPolicy} is that the {@link AmazonKeyspacesRetryPolicy} will call {@link RetryDecision#RETRY_SAME} instead of {@link RetryDecision#RETRY_NEXT}
23
+
* <p>
24
+
* In Amazon Keyspaces, it's likely that {@link WriteTimeoutException} or {@link ReadTimeoutException} is the result of exceeding current table
25
+
* capacity. Learn more about Amazon Keyspaces capacity here: @see <a href="https://docs.aws.amazon.com/keyspaces/latest/devguide/ReadWriteCapacityMode.html">Amazon Keyspaces CapacityModes</a>.
26
+
* In most cases you should allow for small number of retries, and handle the exception in your application threads.
27
+
*
28
+
* <p>To activate this policy, modify the {@code advanced.retry-policy} section in the driver
29
+
* configuration, for example:
30
+
*
31
+
* <pre>
32
+
* datastax-java-driver {
33
+
* advanced.retry-policy {
34
+
* class = com.aws.ssa.keyspaces.retry.AmazonKeyspacesRetryPolicy
publicstaticfinalStringRETRYING_ON_READ_TIMEOUT = "[{}] Retrying on read timeout on same host (consistency: {}, required responses: {}, received responses: {}, data retrieved: {}, retries: {})";
48
+
@VisibleForTesting
49
+
publicstaticfinalStringRETRYING_ON_WRITE_TIMEOUT = "[{}] Retrying on write timeout on same host (consistency: {}, write type: {}, required acknowledgments: {}, received acknowledgments: {}, retries: {})";
50
+
@VisibleForTesting
51
+
publicstaticfinalStringRETRYING_ON_UNAVAILABLE = "[{}] Retrying on unavailable exception on next host (consistency: {}, required replica: {}, alive replica: {}, retries: {})";
52
+
@VisibleForTesting
53
+
publicstaticfinalStringRETRYING_ON_ABORTED = "[{}] Retrying on aborted request on next host (retries: {})";
54
+
@VisibleForTesting
55
+
publicstaticfinalStringRETRYING_ON_ERROR = "[{}] Retrying on node error on next host (retries: {})";
0 commit comments