Documentation
¶
Index ¶
Constants ¶
const ( // SmallResourceThreshold is used to represent a resource which can be regarded as a small resource once the size is small than it. SmallResourceThreshold int64 = 20 // Unlimited is used to control the container limit. Here uses a big enough number to represent unlimited. Unlimited = float64(100000000) )
const ( // EmptyResourceApproximateSize is the resource approximate size of an empty resource // (heartbeat size <= 1MB). EmptyResourceApproximateSize = 1 )
Variables ¶
var ResourceInfluence = map[Type]int64{
AddPeer: 1000,
RemovePeer: 1000,
}
ResourceInfluence represents the influence of a operator step, which is used by container limit.
var SmallResourceInfluence = map[Type]int64{
AddPeer: 200,
RemovePeer: 200,
}
SmallResourceInfluence represents the influence of a operator step when the resource size is smaller than smallResourceThreshold, which is used by container limit.
var TypeNameValue = map[string]Type{ "add-peer": AddPeer, "remove-peer": RemovePeer, }
TypeNameValue indicates the name of container limit type and the enum value
Functions ¶
This section is empty.
Types ¶
type ContainerLimit ¶
type ContainerLimit struct {
// contains filtered or unexported fields
}
ContainerLimit limits the operators of a container
func NewContainerLimit ¶
func NewContainerLimit(ratePerSec float64, resourceInfluence int64) *ContainerLimit
NewContainerLimit returns a ContainerLimit object
func (*ContainerLimit) Available ¶
func (l *ContainerLimit) Available() int64
Available returns the number of available tokens
func (*ContainerLimit) Rate ¶
func (l *ContainerLimit) Rate() float64
Rate returns the fill rate of the bucket, in tokens per second.
type Scene ¶
Scene defines the container limitation on difference scenes Idle/Low/Normal/High indicates the load of the cluster, it is defined in cluster.State. See the details there for how to calculate the load. The values here defines the container-limit for each load. For example: Idle = 60, means that change the container-limit to 60 when the cluster is idle.
func DefaultScene ¶
DefaultScene returns Scene object with default values