forked from apache/cassandra-java-driver
-
Notifications
You must be signed in to change notification settings - Fork 38
Tablets 4.x #241
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Tablets 4.x #241
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
core/src/main/java/com/datastax/oss/driver/api/core/metadata/KeyspaceTableNamePair.java
This file contains hidden or 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,51 @@ | ||
package com.datastax.oss.driver.api.core.metadata; | ||
|
||
import com.datastax.oss.driver.api.core.CqlIdentifier; | ||
import edu.umd.cs.findbugs.annotations.NonNull; | ||
import java.util.Objects; | ||
|
||
/** Simple keyspace name and table name pair. */ | ||
public class KeyspaceTableNamePair { | ||
@NonNull private final CqlIdentifier keyspace; | ||
@NonNull private final CqlIdentifier tableName; | ||
|
||
public KeyspaceTableNamePair(@NonNull CqlIdentifier keyspace, @NonNull CqlIdentifier tableName) { | ||
this.keyspace = keyspace; | ||
this.tableName = tableName; | ||
} | ||
|
||
@NonNull | ||
public CqlIdentifier getKeyspace() { | ||
return keyspace; | ||
} | ||
|
||
@NonNull | ||
public CqlIdentifier getTableName() { | ||
return tableName; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "KeyspaceTableNamePair{" | ||
+ "keyspace='" | ||
+ keyspace | ||
+ '\'' | ||
+ ", tableName='" | ||
+ tableName | ||
+ '\'' | ||
+ '}'; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || !(o instanceof KeyspaceTableNamePair)) return false; | ||
KeyspaceTableNamePair that = (KeyspaceTableNamePair) o; | ||
return keyspace.equals(that.keyspace) && tableName.equals(that.tableName); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(keyspace, tableName); | ||
} | ||
} |
This file contains hidden or 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
37 changes: 37 additions & 0 deletions
37
core/src/main/java/com/datastax/oss/driver/api/core/metadata/Tablet.java
This file contains hidden or 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,37 @@ | ||
package com.datastax.oss.driver.api.core.metadata; | ||
|
||
import com.datastax.oss.driver.shaded.guava.common.annotations.Beta; | ||
import java.util.Set; | ||
|
||
/** | ||
* Represents a tablet as described in tablets-routing-v1 protocol extension with some additional | ||
* fields for ease of use. | ||
*/ | ||
@Beta | ||
public interface Tablet extends Comparable<Tablet> { | ||
/** | ||
* Returns left endpoint of an interval. This interval is left-open, meaning the tablet does not | ||
* own the token equal to the first token. | ||
* | ||
* @return {@code long} value representing first token. | ||
*/ | ||
public long getFirstToken(); | ||
|
||
/** | ||
* Returns right endpoint of an interval. This interval is right-closed, which means that last | ||
* token is owned by this tablet. | ||
* | ||
* @return {@code long} value representing last token. | ||
*/ | ||
public long getLastToken(); | ||
|
||
public Set<Node> getReplicaNodes(); | ||
|
||
/** | ||
* Looks up the shard number for specific replica Node. | ||
* | ||
* @param node one of the replica nodes of this tablet. | ||
* @return Shard number for the replica or -1 if no such Node found. | ||
*/ | ||
public int getShardForNode(Node node); | ||
} |
37 changes: 37 additions & 0 deletions
37
core/src/main/java/com/datastax/oss/driver/api/core/metadata/TabletMap.java
This file contains hidden or 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,37 @@ | ||
package com.datastax.oss.driver.api.core.metadata; | ||
|
||
import com.datastax.oss.driver.api.core.CqlIdentifier; | ||
import com.datastax.oss.driver.shaded.guava.common.annotations.Beta; | ||
import java.util.concurrent.ConcurrentMap; | ||
import java.util.concurrent.ConcurrentSkipListSet; | ||
|
||
/** Holds all currently known tablet metadata. */ | ||
@Beta | ||
public interface TabletMap { | ||
/** | ||
* Returns mapping from tables to the sets of their tablets. | ||
* | ||
* @return the Map keyed by (keyspace,table) pairs with Set of tablets as value type. | ||
*/ | ||
public ConcurrentMap<KeyspaceTableNamePair, ConcurrentSkipListSet<Tablet>> getMapping(); | ||
|
||
/** | ||
* Adds a single tablet to the map. Handles removal of overlapping tablets. | ||
* | ||
* @param keyspace target keyspace | ||
* @param table target table | ||
* @param tablet tablet instance to add | ||
*/ | ||
public void addTablet(CqlIdentifier keyspace, CqlIdentifier table, Tablet tablet); | ||
|
||
/** | ||
* Returns {@link Tablet} instance | ||
* | ||
* @param keyspace tablet's keyspace | ||
* @param table tablet's table | ||
* @param token target token | ||
* @return {@link Tablet} responsible for provided token or {@code null} if no such tablet is | ||
* present. | ||
*/ | ||
public Tablet getTablet(CqlIdentifier keyspace, CqlIdentifier table, long token); | ||
} |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.