Skip to content

Commit

Permalink
[lrs_store_per_cluster] c2
Browse files Browse the repository at this point in the history
  • Loading branch information
menghanl committed Sep 21, 2020
1 parent 3d0f704 commit f030469
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
7 changes: 3 additions & 4 deletions xds/internal/balancer/edsbalancer/xds_client_wrapper.go
Expand Up @@ -216,12 +216,11 @@ func (c *xdsclientWrapper) updateXDSClient(config *EDSConfig, attr *attributes.A
//
// This usually means load report needs to be restarted, but this function does
// NOT do that. Caller needs to call startLoadReport separately.
func (c *xdsclientWrapper) startEndpointsWatch(nameToWatch string) {
func (c *xdsclientWrapper) startEndpointsWatch() {
if c.xdsClient == nil {
return
}

c.edsServiceName = nameToWatch
if c.cancelEndpointsWatch != nil {
c.cancelEndpointsWatch()
}
Expand Down Expand Up @@ -260,7 +259,6 @@ func (c *xdsclientWrapper) loadStore() load.PerClusterReporter {
if c == nil || c.load.store == nil {
return nil
}
// return c.xdsClient.LoadStore().PerCluster(c.edsServiceName, "")
return c.load
}

Expand All @@ -273,7 +271,8 @@ func (c *xdsclientWrapper) handleUpdate(config *EDSConfig, attr *attributes.Attr
// - the xds_client is updated
// - the xds_client didn't change, but the edsServiceName changed
if clientChanged || c.edsServiceName != config.EDSServiceName {
c.startEndpointsWatch(config.EDSServiceName)
c.edsServiceName = config.EDSServiceName
c.startEndpointsWatch()
// TODO: this update for the LRS service name is too early. It should
// only apply to the new EDS response. But this is applied to the RPCs
// before the new EDS response. To fully fix this, the EDS balancer
Expand Down
8 changes: 4 additions & 4 deletions xds/internal/client/load/store.go
Expand Up @@ -27,7 +27,7 @@ const negativeOneUInt64 = ^uint64(0)
// A pair of cluster and service name. The same cluster can be used by multiple
// services, and one service can use multiple clusters. So we need a pair with
// both name to accurately indicate where the load belongs.
type clusterAndServiceNames struct {
type storeKey struct {
cluster string
service string
}
Expand All @@ -36,13 +36,13 @@ type clusterAndServiceNames struct {
// LRS. It is safe for concurrent use.
type Store struct {
mu sync.RWMutex
clusters map[clusterAndServiceNames]*PerClusterStore
clusters map[storeKey]*PerClusterStore
}

// NewStore creates a Store.
func NewStore() *Store {
return &Store{
clusters: make(map[clusterAndServiceNames]*PerClusterStore),
clusters: make(map[storeKey]*PerClusterStore),
}
}

Expand All @@ -53,7 +53,7 @@ func (ls *Store) PerCluster(clusterName, serviceName string) *PerClusterStore {
return nil
}

k := clusterAndServiceNames{
k := storeKey{
cluster: clusterName,
service: serviceName,
}
Expand Down

0 comments on commit f030469

Please sign in to comment.