Skip to content

Commit

Permalink
Rename schemaDescriber to metadataDescriber
Browse files Browse the repository at this point in the history
  • Loading branch information
sylwiaszunejko committed Nov 29, 2024
1 parent 4693b69 commit 6b25456
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 31 deletions.
2 changes: 1 addition & 1 deletion conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -1522,7 +1522,7 @@ func (c *Conn) executeQuery(ctx context.Context, qry *Query) *Iter {
tablet.keyspaceName = qry.routingInfo.keyspace
tablet.tableName = qry.routingInfo.table

c.session.schemaDescriber.addTablet(&tablet)
c.session.metadataDescriber.addTablet(&tablet)
}
}

Expand Down
14 changes: 7 additions & 7 deletions events.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,32 +110,32 @@ func (s *Session) handleSchemaEvent(frames []frame) {
for _, frame := range frames {
switch f := frame.(type) {
case *schemaChangeKeyspace:
s.schemaDescriber.clearSchema(f.keyspace)
s.metadataDescriber.clearSchema(f.keyspace)
s.handleKeyspaceChange(f.keyspace, f.change)
case *schemaChangeTable:
s.schemaDescriber.clearSchema(f.keyspace)
s.metadataDescriber.clearSchema(f.keyspace)
s.handleTableChange(f.keyspace, f.object, f.change)
case *schemaChangeAggregate:
s.schemaDescriber.clearSchema(f.keyspace)
s.metadataDescriber.clearSchema(f.keyspace)
case *schemaChangeFunction:
s.schemaDescriber.clearSchema(f.keyspace)
s.metadataDescriber.clearSchema(f.keyspace)
case *schemaChangeType:
s.schemaDescriber.clearSchema(f.keyspace)
s.metadataDescriber.clearSchema(f.keyspace)
}
}
}

func (s *Session) handleKeyspaceChange(keyspace, change string) {
s.control.awaitSchemaAgreement()
if change == "DROPPED" || change == "UPDATED" {
s.schemaDescriber.removeTabletsWithKeyspace(keyspace)
s.metadataDescriber.removeTabletsWithKeyspace(keyspace)
}
s.policy.KeyspaceChanged(KeyspaceUpdateEvent{Keyspace: keyspace, Change: change})
}

func (s *Session) handleTableChange(keyspace, table, change string) {
if change == "DROPPED" || change == "UPDATED" {
s.schemaDescriber.removeTabletsWithTable(keyspace, table)
s.metadataDescriber.removeTabletsWithTable(keyspace, table)
}
}

Expand Down
2 changes: 1 addition & 1 deletion host_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -877,7 +877,7 @@ func refreshRing(r *ringDescriber) error {
}

for _, host := range prevHosts {
r.session.schemaDescriber.removeTabletsWithHost(host)
r.session.metadataDescriber.removeTabletsWithHost(host)
r.session.removeHost(host)
}

Expand Down
24 changes: 12 additions & 12 deletions metadata_scylla.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ type Metadata struct {
}

// queries the cluster for schema information for a specific keyspace and for tablets
type schemaDescriber struct {
type metadataDescriber struct {
session *Session
mu sync.Mutex

Expand All @@ -286,16 +286,16 @@ type schemaDescriber struct {

// creates a session bound schema describer which will query and cache
// keyspace metadata and tablets metadata
func newSchemaDescriber(session *Session) *schemaDescriber {
return &schemaDescriber{
func newMetadataDescriber(session *Session) *metadataDescriber {
return &metadataDescriber{
session: session,
metadata: &Metadata{},
}
}

// returns the cached KeyspaceMetadata held by the describer for the named
// keyspace.
func (s *schemaDescriber) getSchema(keyspaceName string) (*KeyspaceMetadata, error) {
func (s *metadataDescriber) getSchema(keyspaceName string) (*KeyspaceMetadata, error) {
s.mu.Lock()
defer s.mu.Unlock()

Expand All @@ -316,21 +316,21 @@ func (s *schemaDescriber) getSchema(keyspaceName string) (*KeyspaceMetadata, err
return metadata, nil
}

func (s *schemaDescriber) setTablets(tablets TabletInfoList) {
func (s *metadataDescriber) setTablets(tablets TabletInfoList) {
s.mu.Lock()
defer s.mu.Unlock()

s.metadata.tabletsMetadata.set(tablets)
}

func (s *schemaDescriber) getTablets() TabletInfoList {
func (s *metadataDescriber) getTablets() TabletInfoList {
s.mu.Lock()
defer s.mu.Unlock()

return s.metadata.tabletsMetadata.get()
}

func (s *schemaDescriber) addTablet(tablet *TabletInfo) error {
func (s *metadataDescriber) addTablet(tablet *TabletInfo) error {
tablets := s.getTablets()
tablets = tablets.addTabletToTabletsList(tablet)

Expand All @@ -339,7 +339,7 @@ func (s *schemaDescriber) addTablet(tablet *TabletInfo) error {
return nil
}

func (s *schemaDescriber) removeTabletsWithHost(host *HostInfo) error {
func (s *metadataDescriber) removeTabletsWithHost(host *HostInfo) error {
tablets := s.getTablets()
tablets = tablets.removeTabletsWithHostFromTabletsList(host)

Expand All @@ -348,7 +348,7 @@ func (s *schemaDescriber) removeTabletsWithHost(host *HostInfo) error {
return nil
}

func (s *schemaDescriber) removeTabletsWithKeyspace(keyspace string) error {
func (s *metadataDescriber) removeTabletsWithKeyspace(keyspace string) error {
tablets := s.getTablets()
tablets = tablets.removeTabletsWithKeyspaceFromTabletsList(keyspace)

Expand All @@ -357,7 +357,7 @@ func (s *schemaDescriber) removeTabletsWithKeyspace(keyspace string) error {
return nil
}

func (s *schemaDescriber) removeTabletsWithTable(keyspace string, table string) error {
func (s *metadataDescriber) removeTabletsWithTable(keyspace string, table string) error {
tablets := s.getTablets()
tablets = tablets.removeTabletsWithTableFromTabletsList(keyspace, table)

Expand All @@ -367,7 +367,7 @@ func (s *schemaDescriber) removeTabletsWithTable(keyspace string, table string)
}

// clears the already cached keyspace metadata
func (s *schemaDescriber) clearSchema(keyspaceName string) {
func (s *metadataDescriber) clearSchema(keyspaceName string) {
s.mu.Lock()
defer s.mu.Unlock()

Expand All @@ -376,7 +376,7 @@ func (s *schemaDescriber) clearSchema(keyspaceName string) {

// forcibly updates the current KeyspaceMetadata held by the schema describer
// for a given named keyspace.
func (s *schemaDescriber) refreshSchema(keyspaceName string) error {
func (s *metadataDescriber) refreshSchema(keyspaceName string) error {
var err error

// query the system keyspace for schema data
Expand Down
2 changes: 1 addition & 1 deletion policies.go
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,7 @@ func (t *tokenAwareHostPolicy) Pick(qry ExecutableQuery) NextHost {
var replicas []*HostInfo

if session := qry.GetSession(); session != nil && session.tabletsRoutingV1 {
tablets := session.schemaDescriber.getTablets()
tablets := session.metadataDescriber.getTablets()

// Search for tablets with Keyspace and Table from the Query
l, r := tablets.findTablets(qry.Keyspace(), qry.Table())
Expand Down
2 changes: 1 addition & 1 deletion recreate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func TestRecreateSchema(t *testing.T) {

// Exec dumped queries to check if they are CQL-correct
cleanup(t, session, test.Keyspace)
session.schemaDescriber.clearSchema(test.Keyspace)
session.metadataDescriber.clearSchema(test.Keyspace)

for _, q := range trimQueries(strings.Split(dump, ";")) {
qr := session.Query(q, nil)
Expand Down
4 changes: 2 additions & 2 deletions schema_queries_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ func TestSchemaQueries(t *testing.T) {
session := createSessionFromCluster(cluster, t)
defer session.Close()

keyspaceMetadata, err := session.schemaDescriber.getSchema("gocql_test")
keyspaceMetadata, err := session.metadataDescriber.getSchema("gocql_test")
if err != nil {
t.Fatal("unable to get keyspace metadata for keyspace: ", err)
}
assertTrue(t, "keyspace present in schemaDescriber", keyspaceMetadata.Name == "gocql_test")
assertTrue(t, "keyspace present in metadataDescriber", keyspaceMetadata.Name == "gocql_test")
}
12 changes: 6 additions & 6 deletions session.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ type Session struct {
pageSize int
prefetch float64
routingKeyInfoCache routingKeyInfoLRU
schemaDescriber *schemaDescriber
metadataDescriber *metadataDescriber
trace Tracer
queryObserver QueryObserver
batchObserver BatchObserver
Expand Down Expand Up @@ -144,7 +144,7 @@ func NewSession(cfg ClusterConfig) (*Session, error) {
}
}()

s.schemaDescriber = newSchemaDescriber(s)
s.metadataDescriber = newMetadataDescriber(s)

s.nodeEvents = newEventDebouncer("NodeEvents", s.handleNodeEvent, s.logger)
s.schemaEvents = newEventDebouncer("SchemaEvents", s.handleSchemaEvent, s.logger)
Expand Down Expand Up @@ -277,7 +277,7 @@ func (s *Session) init() error {

if s.tabletsRoutingV1 {
tablets := TabletInfoList{}
s.schemaDescriber.setTablets(tablets)
s.metadataDescriber.setTablets(tablets)
}
}
}
Expand Down Expand Up @@ -603,7 +603,7 @@ func (s *Session) KeyspaceMetadata(keyspace string) (*KeyspaceMetadata, error) {
return nil, ErrNoKeyspace
}

return s.schemaDescriber.getSchema(keyspace)
return s.metadataDescriber.getSchema(keyspace)
}

// TabletsMetadata returns the metadata about tablets
Expand All @@ -615,7 +615,7 @@ func (s *Session) TabletsMetadata() (TabletInfoList, error) {
return nil, ErrTabletsNotUsed
}

return s.schemaDescriber.getTablets(), nil
return s.metadataDescriber.getTablets(), nil
}

func (s *Session) getConn() *Conn {
Expand All @@ -637,7 +637,7 @@ func (s *Session) getConn() *Conn {
}

func (s *Session) getTablets() TabletInfoList {
return s.schemaDescriber.getTablets()
return s.metadataDescriber.getTablets()
}

// returns routing key indexes and type info
Expand Down

0 comments on commit 6b25456

Please sign in to comment.