raj-ummadisetty commented on code in PR #1926:
URL:
https://github.com/apache/cassandra-gocql-driver/pull/1926#discussion_r2829753412
##########
policies.go:
##########
@@ -447,43 +452,39 @@ func (t *tokenAwareHostPolicy) Init(s *Session) {
}
t.getKeyspaceMetadata = s.KeyspaceMetadata
t.getKeyspaceName = func() string { return s.cfg.Keyspace }
+ t.getSchemaMeta = s.schemaDescriber.getSchemaMetaForRead
t.logger = s.logger
}
func (t *tokenAwareHostPolicy) IsLocal(host *HostInfo) bool {
return t.fallback.IsLocal(host)
}
-func (t *tokenAwareHostPolicy) KeyspaceChanged(update KeyspaceUpdateEvent) {
+// replica map is updated through the SchemaRefreshed callback
+func (t *tokenAwareHostPolicy) KeyspaceChanged(update KeyspaceUpdateEvent) {}
+
+func (t *tokenAwareHostPolicy) SchemaRefreshed(schemaMeta *schemaMeta) {
t.mu.Lock()
defer t.mu.Unlock()
meta := t.getMetadataForUpdate()
- t.updateReplicas(meta, update.Keyspace)
+ t.updateReplicas(meta, schemaMeta)
t.metadata.Store(meta)
}
// updateReplicas updates replicas in clusterMeta.
// It must be called with t.mu mutex locked.
// meta must not be nil and it's replicas field will be updated.
-func (t *tokenAwareHostPolicy) updateReplicas(meta *clusterMeta, keyspace
string) {
- newReplicas := make(map[string]tokenRingReplicas, len(meta.replicas))
-
- ks, err := t.getKeyspaceMetadata(keyspace)
- if err == nil {
- strat := getStrategy(ks, t.logger)
+func (t *tokenAwareHostPolicy) updateReplicas(meta *clusterMeta, schemaMeta
*schemaMeta) {
+ schema := schemaMeta.keyspaceMeta
+ newReplicas := make(map[string]tokenRingReplicas, len(schema))
+ for keyspace, metadata := range schema {
+ strat := getStrategy(metadata, t.logger)
if strat != nil {
if meta != nil && meta.tokenRing != nil {
newReplicas[keyspace] =
strat.replicaMap(meta.tokenRing)
Review Comment:
I think we did discuss this previously and felt this can be handled as a
follow up. I'll take a stab
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]