Skip to content

Commit

Permalink
merge
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 12, 2023
1 parent 4ffccbc commit a915b08
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 205 deletions.
87 changes: 0 additions & 87 deletions pkg/mcs/resource_manager/client/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,93 +76,6 @@ func Sub(custom1 *rmpb.Consumption, custom2 *rmpb.Consumption) {
custom1.KvWriteRpcCount -= custom1.KvWriteRpcCount
}

// type ResourceCalculator interface {
// Trickle(map[rmpb.ResourceType]float64, map[rmpb.RequestUnitType]float64, *rmpb.Consumption, context.Context)
// BeforeKVRequest(map[rmpb.ResourceType]float64, map[rmpb.RequestUnitType]float64, *rmpb.Consumption, RequestInfo)
// AfterKVRequest(map[rmpb.ResourceType]float64, map[rmpb.RequestUnitType]float64, *rmpb.Consumption, RequestInfo, ResponseInfo)
// }

// type KVCalculator struct {
// *Config
// }

// func newKVCalculator(cfg *Config) *KVCalculator {
// return &KVCalculator{Config: cfg}
// }

// func (dwc *KVCalculator) Trickle(resource map[rmpb.ResourceType]float64, ru map[rmpb.RequestUnitType]float64, consumption *rmpb.Consumption, ctx context.Context) {
// }

// func (dwc *KVCalculator) BeforeKVRequest(resource map[rmpb.ResourceType]float64, ru map[rmpb.RequestUnitType]float64, consumption *rmpb.Consumption, req RequestInfo) {
// if req.IsWrite() {
// writeBytes := float64(req.WriteBytes())
// // for resource
// resource[rmpb.ResourceType_IOWriteFlow] += writeBytes
// // for RU
// wru := float64(dwc.WriteBytesCost) * writeBytes
// ru[rmpb.RequestUnitType_WRU] += wru
// // for consumption
// consumption.KvWriteRpcCount += 1
// consumption.WRU += wru
// consumption.WriteBytes += writeBytes

// } else {
// // none for resource
// // none for RU
// // for consumption
// consumption.KvReadRpcCount += 1
// }
// }
// func (dwc *KVCalculator) AfterKVRequest(resource map[rmpb.ResourceType]float64, ru map[rmpb.RequestUnitType]float64, consumption *rmpb.Consumption, req RequestInfo, res ResponseInfo) {
// readBytes := float64(res.ReadBytes())
// kvCPUms := float64(res.KVCPUms())
// // for resource
// resource[rmpb.ResourceType_IOReadFlow] += readBytes
// resource[rmpb.ResourceType_CPU] += kvCPUms
// // for RU
// ru_io := readBytes * float64(dwc.ReadBytesCost)
// ru_cpu := kvCPUms * float64(dwc.KVCPUMsCost)
// ru[rmpb.RequestUnitType_RRU] += ru_cpu + ru_io
// // for consumption
// consumption.RRU += ru_cpu + ru_io
// consumption.ReadBytes += readBytes
// consumption.TotalCpuTimeMs += kvCPUms
// }

// type SQLLayerCPUCalculateor struct {
// *Config
// }

// func newSQLLayerCPUCalculateor(cfg *Config) *SQLLayerCPUCalculateor {
// return &SQLLayerCPUCalculateor{Config: cfg}
// }

// func (dsc *SQLLayerCPUCalculateor) Trickle(resource map[rmpb.ResourceType]float64, ru map[rmpb.RequestUnitType]float64, consumption *rmpb.Consumption, ctx context.Context) {
// // TODO: SQL Layer RU/resource custom
// cpuFunc := func(ctx context.Context) float64 {
// return 0.
// }
// cpu := cpuFunc(ctx)
// // for resource
// resource[rmpb.ResourceType_CPU] += cpu
// // for RU
// ru_cpu := cpu * float64(dsc.SQLCPUSecondCost)
// // TODO: SQL Layer RU/resource custom type
// ru[rmpb.RequestUnitType_RRU] += ru_cpu / 2
// ru[rmpb.RequestUnitType_WRU] += ru_cpu / 2
// // for consumption
// // TODO: SQL Layer RU/resource custom type
// consumption.RRU += ru_cpu / 2
// consumption.RRU += ru_cpu / 2
// consumption.TotalCpuTimeMs += cpu
// consumption.SqlLayerCpuTimeMs += cpu
// }

// func (dsc *SQLLayerCPUCalculateor) BeforeKVRequest(resource map[rmpb.ResourceType]float64, ru map[rmpb.RequestUnitType]float64, consumption *rmpb.Consumption, req RequestInfo) {
// }
// func (dsc *SQLLayerCPUCalculateor) AfterKVRequest(resource map[rmpb.ResourceType]float64, ru map[rmpb.RequestUnitType]float64, consumption *rmpb.Consumption, req RequestInfo, res ResponseInfo) {
// }

type ResourceCalculator interface {
Trickle(*rmpb.Consumption, context.Context)
BeforeKVRequest(*rmpb.Consumption, RequestInfo)
Expand Down
118 changes: 0 additions & 118 deletions pkg/mcs/resource_manager/tenant_client/model.go

This file was deleted.

0 comments on commit a915b08

Please sign in to comment.