Skip to content

Commit

Permalink
Add README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
SiyaoIsHiding committed May 16, 2024
1 parent 4da5d32 commit 21f3df1
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 8 deletions.
35 changes: 29 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,29 @@
1. Doc
1.1 How to use
1.2 Advantages
1.3 Basic mechanism
2. Publish
2.1
# Complimentary Load Balancing Policies for Apache Cassandra Java Driver
This package contains two load balancing policies to be used with the [Apache Cassandra Java Driver](https://github.com/apache/cassandra-java-driver) (version 4.10.0+) - `LatencyAndInflightCountLoadBalancingPolicy` and `LatencySensitiveLoadBalancingPolicy`.

## Get Started
To use either of the policies, you need to include both the Java driver and this package as dependencies.
```xml
<dependency>
<groupId>org.apache.cassandra</groupId>
<artifactId>java-driver-core</artifactId>
<version>4.10.0</version>
</dependency>
<dependency>
<groupId>com.datastax.oss</groupId>
<artifactId>driver-load-balancing-policies</artifactId>
<version>1.0</version>
</dependency>
```

You also have to specify the name of the load balancing policy class in your `application.conf` (see [this](https://docs.datastax.com/en/developer/java-driver/4.17/manual/core/load_balancing/index.html#load-balancing)).
```conf
datastax-java-driver.basic.load-balancing-policy {
class = LatencySensitiveLoadBalancingPolicy
}
```

## How to Choose a Load Balancing Policy
We recommend the `DefaultLoadBalancingPolicy` that comes with the Java Driver for general use.
This policy leverages real-time measurements and swiftly responds to changes in node status at short intervals, such as those caused by garbage collection or compaction—common factors that can slow down nodes.
However, if you anticipate prolonged delays in node responsiveness, such as during network upgrades or heavy data migrations, you might consider opting for the `LatencyAndInflightCountLoadBalancingPolicy` or `LatencySensitiveLoadBalancingPolicy`.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.datastax.cassandra</groupId>
<groupId>com.datastax.oss</groupId>
<artifactId>driver-load-balancing-policies</artifactId>
<version>1.0-SNAPSHOT</version>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public void should_put_slowest_node_at_end_when_3_local_replicas() {
// Then
// nodes 1, 3 and 5 always first, round-robin on the rest
// node 3 faster -> swap
assertThat(plan1).containsExactly(node1, node3, node1, node2, node4);
assertThat(plan1).containsExactly(node5, node3, node1, node2, node4);
assertThat(plan2).containsExactly(node5, node3, node1, node4, node2);

then(latencyPolicy).should(times(2)).shuffleHead(any(), anyInt());
Expand Down

0 comments on commit 21f3df1

Please sign in to comment.