Skip to content
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

Implement ReplicationStateImpl to Manage and Cache Token Range to Replica Mappings #719

Closed
VictorCavichioli opened this issue Sep 19, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request PoC/Agent Tasks related to new generation of ecchronos as an agent

Comments

@VictorCavichioli
Copy link
Contributor

VictorCavichioli commented Sep 19, 2024

Story Description:
The ReplicationStateImpl class is responsible for managing the replication state of a Cassandra cluster by caching the mapping between token ranges and replicas across keyspaces. It leverages NodeResolver and CqlSession to resolve nodes and interact with cluster metadata, ensuring efficient lookups for replicas and nodes related to token ranges. The class must handle both cluster-wide and keyspace-specific replication mappings, caching results for better performance and reliability.

Key Responsibilities:

  1. Node Resolution: Resolves nodes from IP addresses using the NodeResolver when processing replicas, and retrieves metadata from CqlSession.
  2. Caching: Manages two caches for replication mappings:
  3. KEYSPACE_REPLICATION_CACHE for keyspace-specific mappings.
  4. CLUSTER_WIDE_KEYSPACE_REPLICATION_CACHE for cluster-wide mappings.
  5. Token Range Mapping: Builds token maps by converting TokenRange to LongTokenRange and assigning replicas to each token range. This is done both on a per-keyspace basis and cluster-wide.
  6. Token to Replica Conversion: Translates Cassandra TokenRange into a custom LongTokenRange and converts Node objects to DriverNode instances using the node resolver.

Acceptance Criteria:

  1. Correct Replica Assignment: The method getReplicas must correctly retrieve the set of replicas for a given table and token range using cached or dynamically built token maps.
  2. Caching Behavior: Both keyspace-specific and cluster-wide replication caches (KEYSPACE_REPLICATION_CACHE and CLUSTER_WIDE_KEYSPACE_REPLICATION_CACHE) must be correctly updated when changes are detected in the token map or node states.
  3. Concurrency and Logging: Ensure that caching operations are thread-safe, and relevant warnings (e.g., when nodes cannot be resolved) are logged correctly.

Definition of Done:

  1. The ReplicationStateImpl class is implemented with methods for retrieving replicas and nodes across both cluster-wide and keyspace-specific contexts.
  2. The caches for replication mappings are fully functional and update correctly upon changes in the token map or node states.
  3. Unit tests cover cases such as replica resolution, cache invalidation, and handling scenarios where nodes cannot be resolved.

Notes

Depends of #718
Related to #652

@VictorCavichioli VictorCavichioli added enhancement New feature or request PoC/Agent Tasks related to new generation of ecchronos as an agent labels Sep 19, 2024
@VictorCavichioli VictorCavichioli self-assigned this Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request PoC/Agent Tasks related to new generation of ecchronos as an agent
Projects
None yet
Development

No branches or pull requests

1 participant