forked from apache/cassandra-java-driver
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This PR introduces changes to the driver that are necessary for shard-awareness and token-awareness to work effectively with the tablets feature recently introduced to ScyllaDB. It overwrites the ring-based replica calculations on tablet-enabled keyspaces. Now if driver sends the request to the wrong node/shard it will get the correct tablet information from Scylla in custom payload. It uses this information to obtain target replicas and shard numbers for tables managed by tablet replication. This tablet information is then stored in the driver and is used for correctly routing all next requests.
- Loading branch information
1 parent
5d2fb2c
commit dbfe82a
Showing
13 changed files
with
718 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
driver-core/src/main/java/com/datastax/driver/core/TabletInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.datastax.driver.core; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
|
||
public class TabletInfo { | ||
private static final String SCYLLA_TABLETS_STARTUP_OPTION_KEY = "TABLETS_ROUTING_V1"; | ||
private static final String SCYLLA_TABLETS_STARTUP_OPTION_VALUE = ""; | ||
public static final String TABLETS_ROUTING_V1_CUSTOM_PAYLOAD_KEY = "tablets-routing-v1"; | ||
|
||
private boolean enabled = false; | ||
|
||
private TabletInfo(boolean enabled) { | ||
this.enabled = enabled; | ||
} | ||
|
||
// Currently pertains only to TABLETS_ROUTING_V1 | ||
public boolean isEnabled() { | ||
return enabled; | ||
} | ||
|
||
public static TabletInfo parseTabletInfo(Map<String, List<String>> supported) { | ||
List<String> values = supported.get(SCYLLA_TABLETS_STARTUP_OPTION_KEY); | ||
return new TabletInfo( | ||
values != null | ||
&& values.size() == 1 | ||
&& values.get(0).equals(SCYLLA_TABLETS_STARTUP_OPTION_VALUE)); | ||
} | ||
|
||
public static void addOption(Map<String, String> options) { | ||
options.put(SCYLLA_TABLETS_STARTUP_OPTION_KEY, SCYLLA_TABLETS_STARTUP_OPTION_VALUE); | ||
} | ||
} |
Oops, something went wrong.