2021-10-25 20:19:25 +08:00
|
|
|
// Licensed to the LF AI & Data foundation under one
|
|
|
|
// or more contributor license agreements. See the NOTICE file
|
|
|
|
// distributed with this work for additional information
|
|
|
|
// regarding copyright ownership. The ASF licenses this file
|
|
|
|
// to you under the Apache License, Version 2.0 (the
|
|
|
|
// "License"); you may not use this file except in compliance
|
2021-10-14 15:44:34 +08:00
|
|
|
// with the License. You may obtain a copy of the License at
|
|
|
|
//
|
2021-10-25 20:19:25 +08:00
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
2021-10-14 15:44:34 +08:00
|
|
|
//
|
2021-10-25 20:19:25 +08:00
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
2021-10-14 15:44:34 +08:00
|
|
|
|
|
|
|
package datacoord
|
|
|
|
|
2022-02-22 13:15:51 +08:00
|
|
|
// ChannelPolicyFactory is the abstract factory that creates policies for channel manager.
|
2021-10-14 15:44:34 +08:00
|
|
|
type ChannelPolicyFactory interface {
|
2023-03-20 10:01:56 +08:00
|
|
|
// NewBalancePolicy creates a new channel balance policy.
|
|
|
|
NewBalancePolicy() BalanceChannelPolicy
|
2024-07-09 18:26:12 +08:00
|
|
|
|
|
|
|
NewAssignPolicy() AssignPolicy
|
2021-10-14 15:44:34 +08:00
|
|
|
}
|
|
|
|
|
2021-10-14 20:28:33 +08:00
|
|
|
// ChannelPolicyFactoryV1 equal to policy batch
|
2024-05-07 15:49:30 +08:00
|
|
|
type ChannelPolicyFactoryV1 struct{}
|
2021-10-14 15:44:34 +08:00
|
|
|
|
2022-02-22 13:15:51 +08:00
|
|
|
// NewChannelPolicyFactoryV1 helper function creates a Channel policy factory v1 from kv.
|
2024-05-07 15:49:30 +08:00
|
|
|
func NewChannelPolicyFactoryV1() *ChannelPolicyFactoryV1 {
|
|
|
|
return &ChannelPolicyFactoryV1{}
|
2021-10-14 15:44:34 +08:00
|
|
|
}
|
|
|
|
|
2023-03-20 10:01:56 +08:00
|
|
|
func (f *ChannelPolicyFactoryV1) NewBalancePolicy() BalanceChannelPolicy {
|
|
|
|
return AvgBalanceChannelPolicy
|
2021-10-14 15:44:34 +08:00
|
|
|
}
|
2024-07-09 18:26:12 +08:00
|
|
|
|
|
|
|
func (f *ChannelPolicyFactoryV1) NewAssignPolicy() AssignPolicy {
|
|
|
|
return AvgAssignByCountPolicy
|
|
|
|
}
|
2024-11-07 10:26:26 +08:00
|
|
|
|
|
|
|
func NewEmptyChannelPolicyFactory() *EmptyChannelPolicyFactory {
|
|
|
|
return &EmptyChannelPolicyFactory{}
|
|
|
|
}
|
|
|
|
|
|
|
|
type EmptyChannelPolicyFactory struct{}
|
|
|
|
|
|
|
|
func (f *EmptyChannelPolicyFactory) NewBalancePolicy() BalanceChannelPolicy {
|
|
|
|
return EmptyBalancePolicy
|
|
|
|
}
|
|
|
|
|
|
|
|
func (f *EmptyChannelPolicyFactory) NewAssignPolicy() AssignPolicy {
|
|
|
|
return EmptyAssignPolicy
|
|
|
|
}
|