Skip to content

Commit

Permalink
[xds_cluster_impl_balancer] c1
Browse files Browse the repository at this point in the history
  • Loading branch information
menghanl committed Feb 9, 2021
1 parent 7977985 commit b684f2e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 49 deletions.
27 changes: 13 additions & 14 deletions xds/internal/balancer/clusterimpl/clusterimpl.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,12 @@ var newXDSClient = func() (xdsClientInterface, error) { return xdsclient.New() }

type clusterImplBB struct{}

func (clusterImplBB) Build(cc balancer.ClientConn, _ balancer.BuildOptions) balancer.Balancer {
func (clusterImplBB) Build(cc balancer.ClientConn, bOpts balancer.BuildOptions) balancer.Balancer {
b := &clusterImplBalancer{
ClientConn: cc,
bOpts: bOpts,
closed: grpcsync.NewEvent(),
loadWrapper: loadstore.NewLoadStoreWrapper(),
loadWrapper: loadstore.NewWrapper(),
pickerUpdateCh: buffer.NewUnbounded(),
}
b.logger = prefixLogger(b)
Expand Down Expand Up @@ -88,15 +89,13 @@ type xdsClientInterface interface {

type clusterImplBalancer struct {
balancer.ClientConn

bOpts balancer.BuildOptions
closed *grpcsync.Event

logger *grpclog.PrefixLogger
xdsC xdsClientInterface

config *lbConfig
childLB balancer.Balancer

config *lbConfig
childLB balancer.Balancer
cancelLoadReport func()
clusterName string
edsServiceName string
Expand Down Expand Up @@ -128,14 +127,14 @@ func (cib *clusterImplBalancer) updateLoadStore(newConfig *lbConfig) error {
cib.edsServiceName = newConfig.EDSServiceName
}
if updateLoadClusterAndService {
// This updates the clusterName and serviceName that will reported for the
// loads. The update here is too early, the perfect timing is when the
// picker is updated with the new connection. But from this balancer's point
// of view, it's impossible to tell.
// This updates the clusterName and serviceName that will be reported
// for the loads. The update here is too early, the perfect timing is
// when the picker is updated with the new connection. But from this
// balancer's point of view, it's impossible to tell.
//
// On the other hand, this will almost never happen. Each LRS policy
// shouldn't get updated config. The parent should do a graceful switch when
// the clusterName or serviceName is changed.
// shouldn't get updated config. The parent should do a graceful switch
// when the clusterName or serviceName is changed.
cib.loadWrapper.UpdateClusterAndService(cib.clusterName, cib.edsServiceName)
}

Expand Down Expand Up @@ -220,7 +219,7 @@ func (cib *clusterImplBalancer) UpdateClientConnState(s balancer.ClientConnState
if cib.childLB != nil {
cib.childLB.Close()
}
cib.childLB = bb.Build(cib, balancer.BuildOptions{})
cib.childLB = bb.Build(cib, cib.bOpts)
}
cib.config = newConfig

Expand Down
32 changes: 0 additions & 32 deletions xds/internal/balancer/clusterimpl/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,38 +25,6 @@ import (
"google.golang.org/grpc/serviceconfig"
)

/*
message XdsClusterImplLoadBalancingPolicyConfig {
// Cluster name. Required.
string cluster = 1;
// EDS service name.
// Not set if cluster is not an EDS cluster or if it does not
// specify an EDS service name.
string eds_service_name = 2;
// Server to send load reports to.
// If unset, no load reporting is done.
// If set to empty string, load reporting will be sent to the same
// server as we are getting xds data from.
google.protobuf.String lrs_load_reporting_server_name = 3;
// Maximum number of outstanding requests can be made to the upstream cluster.
// Default is 1024.
google.protobuf.UInt32Value max_concurrent_requests = 4;
// Drop configuration.
message DropCategory {
string category = 1;
uint32 requests_per_million = 2;
}
repeated DropCategory drop_categories = 5;
// Child policy.
repeated LoadBalancingConfig child_policy = 6;
}
*/

type dropCategory struct {
Category string
RequestsPerMillion uint32
Expand Down
4 changes: 2 additions & 2 deletions xds/internal/balancer/loadstore/load_store_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ import (
"google.golang.org/grpc/xds/internal/client/load"
)

// NewLoadStoreWrapper creates a Wrapper.
func NewLoadStoreWrapper() *Wrapper {
// NewWrapper creates a Wrapper.
func NewWrapper() *Wrapper {
return &Wrapper{}
}

Expand Down
2 changes: 1 addition & 1 deletion xds/internal/balancer/lrs/balancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ type xdsClientWrapper struct {
func newXDSClientWrapper(c xdsClientInterface) *xdsClientWrapper {
return &xdsClientWrapper{
c: c,
loadWrapper: loadstore.NewLoadStoreWrapper(),
loadWrapper: loadstore.NewWrapper(),
}
}

Expand Down

0 comments on commit b684f2e

Please sign in to comment.