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 {
|
2022-02-22 13:15:51 +08:00
|
|
|
// NewRegisterPolicy creates a new register policy.
|
2021-10-14 15:44:34 +08:00
|
|
|
NewRegisterPolicy() RegisterPolicy
|
2022-02-22 13:15:51 +08:00
|
|
|
// NewDeregisterPolicy creates a new deregister policy.
|
2021-10-14 15:44:34 +08:00
|
|
|
NewDeregisterPolicy() DeregisterPolicy
|
2022-02-22 13:15:51 +08:00
|
|
|
// NewAssignPolicy creates a new channel assign policy.
|
2021-10-14 15:44:34 +08:00
|
|
|
NewAssignPolicy() ChannelAssignPolicy
|
2022-02-22 13:15:51 +08:00
|
|
|
// NewReassignPolicy creates a new channel reassign policy.
|
2021-10-14 15:44:34 +08:00
|
|
|
NewReassignPolicy() ChannelReassignPolicy
|
2023-03-20 10:01:56 +08:00
|
|
|
// NewBalancePolicy creates a new channel balance policy.
|
|
|
|
NewBalancePolicy() BalanceChannelPolicy
|
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
|
|
|
}
|
|
|
|
|
2022-02-22 13:15:51 +08:00
|
|
|
// NewRegisterPolicy implementing ChannelPolicyFactory returns BufferChannelAssignPolicy.
|
2021-10-14 15:44:34 +08:00
|
|
|
func (f *ChannelPolicyFactoryV1) NewRegisterPolicy() RegisterPolicy {
|
2021-10-26 19:40:44 +08:00
|
|
|
return AvgAssignRegisterPolicy
|
2021-10-14 15:44:34 +08:00
|
|
|
}
|
|
|
|
|
2022-02-22 13:15:51 +08:00
|
|
|
// NewDeregisterPolicy implementing ChannelPolicyFactory returns AvgAssignUnregisteredChannels.
|
2021-10-14 15:44:34 +08:00
|
|
|
func (f *ChannelPolicyFactoryV1) NewDeregisterPolicy() DeregisterPolicy {
|
|
|
|
return AvgAssignUnregisteredChannels
|
|
|
|
}
|
|
|
|
|
2022-02-22 13:15:51 +08:00
|
|
|
// NewAssignPolicy implementing ChannelPolicyFactory returns AverageAssignPolicy.
|
2021-10-14 15:44:34 +08:00
|
|
|
func (f *ChannelPolicyFactoryV1) NewAssignPolicy() ChannelAssignPolicy {
|
|
|
|
return AverageAssignPolicy
|
|
|
|
}
|
|
|
|
|
2022-02-22 13:15:51 +08:00
|
|
|
// NewReassignPolicy implementing ChannelPolicyFactory returns AverageReassignPolicy.
|
2021-10-14 15:44:34 +08:00
|
|
|
func (f *ChannelPolicyFactoryV1) NewReassignPolicy() ChannelReassignPolicy {
|
|
|
|
return AverageReassignPolicy
|
|
|
|
}
|
|
|
|
|
2023-03-20 10:01:56 +08:00
|
|
|
func (f *ChannelPolicyFactoryV1) NewBalancePolicy() BalanceChannelPolicy {
|
|
|
|
return AvgBalanceChannelPolicy
|
2021-10-14 15:44:34 +08:00
|
|
|
}
|