Skip to content

Commit

Permalink
address comment
Browse files Browse the repository at this point in the history
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
  • Loading branch information
CabinfeverB committed Jan 10, 2023
1 parent fc04c44 commit 3896b95
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions pkg/mcs/resource_manager/server/grpc_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,15 +156,15 @@ func (s *Service) AcquireTokenBuckets(stream rmpb.ResourceManager_AcquireTokenBu
}
switch rg.Mode {
case rmpb.GroupMode_RUMode:
var tokens *rmpb.GrantedRUTokenBucket
for _, re := range req.GetRuItems().GetRequestRU() {
switch re.Type {
case rmpb.RequestUnitType_RRU:
tokens := rg.RequestRRU(now, re.Value, targetPeriodMs)
resp.GrantedRUTokens = append(resp.GrantedRUTokens, tokens)
tokens = rg.RequestRRU(now, re.Value, targetPeriodMs)
case rmpb.RequestUnitType_WRU:
tokens := rg.RequestWRU(now, re.Value, targetPeriodMs)
resp.GrantedRUTokens = append(resp.GrantedRUTokens, tokens)
tokens = rg.RequestWRU(now, re.Value, targetPeriodMs)
}
resp.GrantedRUTokens = append(resp.GrantedRUTokens, tokens)
}
case rmpb.GroupMode_RawMode:
log.Warn("not supports the resource type", zap.String("resource-group", req.ResourceGroupName), zap.String("mode", rmpb.GroupMode_name[int32(rmpb.GroupMode_RawMode)]))
Expand Down
8 changes: 4 additions & 4 deletions pkg/mcs/resource_manager/server/token_bukets.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ const (
)

// GroupTokenBucket is a token bucket for a resource group.
// TODO: statistics Consumption
// TODO: statistics consumption @JmPotato
type GroupTokenBucket struct {
*rmpb.TokenBucket `json:"token_bucket,omitempty"`
// MaxTokens limits the number of tokens that can be accumulated
MaxTokens float64 `json:"max_tokens,omitempty"`

Consumption *rmpb.TokenBucketsRequest `json:"consumption,omitempty"`
LastUpdate *time.Time `json:"last_update,omitempty"`
Initialized bool `json:"initialized"`
Consumption *rmpb.Consumption `json:"consumption,omitempty"`
LastUpdate *time.Time `json:"last_update,omitempty"`
Initialized bool `json:"initialized"`
}

// NewGroupTokenBucket returns a new GroupTokenBucket
Expand Down

0 comments on commit 3896b95

Please sign in to comment.