Documentation ¶
Overview ¶
Copyright 2022, 2023 The Multi-Cluster App Dispatcher Authors.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
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.
Copyright 2022, 2023 The Multi-Cluster App Dispatcher Authors.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
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.
Copyright 2022, 2023 The Multi-Cluster App Dispatcher Authors.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
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.
Copyright 2022, 2023 The Multi-Cluster App Dispatcher Authors.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
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.
Copyright 2022, 2023 The Multi-Cluster App Dispatcher Authors.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
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.
Copyright 2022, 2023 The Multi-Cluster App Dispatcher Authors.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
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.
Copyright 2022, 2023 The Multi-Cluster App Dispatcher Authors.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
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.
Index ¶
- func EqualStateControllers(c1 *Controller, c2 *Controller) bool
- func EqualStateForestControllers(fc1 *ForestController, fc2 *ForestController) bool
- func EqualStateQuotaNodes(qn1 *QuotaNode, qn2 *QuotaNode) bool
- func EqualStateQuotaTrees(qt1 *QuotaTree, qt2 *QuotaTree) bool
- type Allocation
- func (a *Allocation) Add(other *Allocation) bool
- func (a *Allocation) Clone() *Allocation
- func (a *Allocation) Equal(other *Allocation) bool
- func (a *Allocation) Fit(allocated *Allocation, capacity *Allocation) bool
- func (a *Allocation) GetSize() int
- func (a *Allocation) GetValue() []int
- func (a *Allocation) IsZero() bool
- func (a *Allocation) LessOrEqual(other *Allocation) bool
- func (a *Allocation) SameSize(other *Allocation) bool
- func (a *Allocation) SetValue(value []int)
- func (a *Allocation) String() string
- func (a *Allocation) StringPretty(resourceNames []string) string
- func (a *Allocation) Subtract(other *Allocation) bool
- type AllocationRecovery
- type AllocationResponse
- func (ar *AllocationResponse) Append(allocated bool, message string, preemptedIds *[]string)
- func (ar *AllocationResponse) GetConsumerID() string
- func (ar *AllocationResponse) GetMessage() string
- func (ar *AllocationResponse) GetPreemptedIds() []string
- func (ar *AllocationResponse) IsAllocated() bool
- func (ar *AllocationResponse) Merge(other *AllocationResponse)
- func (ar *AllocationResponse) SetAllocated(allocated bool)
- func (ar *AllocationResponse) SetMessage(message string)
- func (ar *AllocationResponse) String() string
- type ByID
- type Consumer
- func (c *Consumer) GetGroupID() string
- func (c *Consumer) GetID() string
- func (c *Consumer) GetNode() *QuotaNode
- func (c *Consumer) GetPriority() int
- func (c *Consumer) GetRequest() *Allocation
- func (c *Consumer) GetTreeID() string
- func (c *Consumer) GetType() int
- func (c *Consumer) IsAllocated() bool
- func (c *Consumer) IsUnPreemptable() bool
- func (c *Consumer) SetGroupID(groupID string)
- func (c *Consumer) SetNode(aNode *QuotaNode)
- func (c *Consumer) SetTreeID(treeID string)
- func (c *Consumer) SetUnPreemptable(unPreemptable bool)
- func (c *Consumer) String() string
- type ConsumerState
- type Controller
- func (controller *Controller) Allocate(consumer *Consumer) *AllocationResponse
- func (controller *Controller) DeAllocate(consumerID string) bool
- func (controller *Controller) ForceAllocate(consumer *Consumer, nodeID string) *AllocationResponse
- func (controller *Controller) GetConsumer(id string) *Consumer
- func (controller *Controller) GetConsumerIDs() []string
- func (controller *Controller) GetConsumers() map[string]*Consumer
- func (controller *Controller) GetPreemptedConsumers() []string
- func (controller *Controller) GetPreemptedConsumersArray() []*Consumer
- func (controller *Controller) GetQuotaSize() int
- func (controller *Controller) GetResourceNames() []string
- func (controller *Controller) GetTree() *QuotaTree
- func (controller *Controller) GetTreeName() string
- func (controller *Controller) IsAllocated() bool
- func (controller *Controller) IsConsumerAllocated(id string) bool
- func (controller *Controller) PrintState(c *Consumer, status bool)
- func (controller *Controller) Remove(id string) bool
- func (controller *Controller) String() string
- func (controller *Controller) TryAllocate(consumer *Consumer) *AllocationResponse
- func (controller *Controller) UndoAllocate(consumer *Consumer) bool
- func (controller *Controller) UpdateTree(treeCache *TreeCache) (unAllocatedConsumerIDs []string, response *TreeCacheCreateResponse)
- type ForestConsumer
- func NewForestConsumer(id string, consumers map[string]*Consumer) *ForestConsumer
- func NewForestConsumerFromFile(consumerFileName string, resourceNames map[string][]string) (*ForestConsumer, error)
- func NewForestConsumerFromString(consumerString string, resourceNames map[string][]string) (*ForestConsumer, error)
- func NewForestConsumerFromStruct(consumerJson utils.JConsumer, resourceNames map[string][]string) (*ForestConsumer, error)
- type ForestController
- func (fc *ForestController) AddController(controller *Controller) bool
- func (fc *ForestController) AddTree(tree *QuotaTree) bool
- func (fc *ForestController) Allocate(forestConsumer *ForestConsumer) *AllocationResponse
- func (fc *ForestController) DeAllocate(consumerID string) bool
- func (fc *ForestController) DeleteController(treeName string) bool
- func (fc *ForestController) DeleteTree(treeName string) bool
- func (fc *ForestController) ForceAllocate(forestConsumer *ForestConsumer, nodeIDs map[string]string) *AllocationResponse
- func (fc *ForestController) GetControllers() map[string]*Controller
- func (fc *ForestController) GetQuotaTrees() []*QuotaTree
- func (fc *ForestController) GetResourceNames() map[string][]string
- func (fc *ForestController) GetTreeNames() []string
- func (fc *ForestController) IsAllocated() bool
- func (fc *ForestController) IsConsumerAllocated(id string) bool
- func (fc *ForestController) IsReady() bool
- func (fc *ForestController) String() string
- func (fc *ForestController) TryAllocate(forestConsumer *ForestConsumer) *AllocationResponse
- func (fc *ForestController) UndoAllocate(forestConsumer *ForestConsumer) bool
- func (fc *ForestController) UpdateTrees(treeCacheList []*TreeCache) (unAllocatedConsumerIDs []string, ...)
- type NodeState
- type QuotaNode
- func (qn *QuotaNode) AddConsumer(c *Consumer) bool
- func (qn *QuotaNode) AddRequest(c *Consumer)
- func (qn *QuotaNode) Allocate(c *Consumer)
- func (qn *QuotaNode) CanFit(c *Consumer) bool
- func (qn *QuotaNode) GetAllocated() *Allocation
- func (qn *QuotaNode) GetConsumers() []*Consumer
- func (qn *QuotaNode) GetQuota() *Allocation
- func (qn *QuotaNode) HasLeaf(c *Consumer) bool
- func (qn *QuotaNode) IsHard() bool
- func (qn *QuotaNode) RemoveConsumer(c *Consumer) bool
- func (qn *QuotaNode) SetAllocated(alloc *Allocation)
- func (qn *QuotaNode) SetConsumers(consumers []*Consumer)
- func (qn *QuotaNode) SetQuota(quota *Allocation)
- func (qn *QuotaNode) SlideDown()
- func (qn *QuotaNode) SlideUp(c *Consumer, applyPriority bool, allocationRecovery *AllocationRecovery, ...) bool
- func (qn *QuotaNode) String(level int) string
- func (qn *QuotaNode) SubtractRequest(c *Consumer)
- type QuotaTree
- func (qt *QuotaTree) Allocate(c *Consumer, preemptedConsumers *[]string) bool
- func (qt *QuotaTree) DeAllocate(c *Consumer) bool
- func (qt *QuotaTree) ForceAllocate(c *Consumer, nodeID string) bool
- func (qt *QuotaTree) GetName() string
- func (qt *QuotaTree) GetNodes() map[string]*QuotaNode
- func (qt *QuotaTree) GetQuotaSize() int
- func (qt *QuotaTree) GetResourceNames() []string
- func (qt *QuotaTree) String() string
- func (qt *QuotaTree) StringSimply() string
- type TreeCache
- func (tc *TreeCache) AddNodeSpec(nodeName string, nodeSpec utils.JNodeSpec) error
- func (tc *TreeCache) AddNodeSpecs(nodeSpecs map[string]utils.JNodeSpec) error
- func (tc *TreeCache) AddNodeSpecsFromString(nodesInfo string) error
- func (tc *TreeCache) AddResourceName(name string)
- func (tc *TreeCache) AddResourceNames(names []string)
- func (tc *TreeCache) AddTreeInfoFromString(treeInfo string) error
- func (tc *TreeCache) Clear()
- func (tc *TreeCache) CreateTree() (*QuotaTree, *TreeCacheCreateResponse)
- func (tc *TreeCache) DeleteNode(nodeName string)
- func (tc *TreeCache) DeleteResourceName(name string)
- func (tc *TreeCache) FromFile(treeFileName string) error
- func (tc *TreeCache) FromString(treeString string) error
- func (tc *TreeCache) FromStruct(jQuotaTree utils.JQuotaTree) error
- func (tc *TreeCache) GetNodeNames() []string
- func (tc *TreeCache) GetNumResourceNames() int
- func (tc *TreeCache) GetRenamedNode(nodeName string) string
- func (tc *TreeCache) GetResourceNames() []string
- func (tc *TreeCache) GetTreeName() string
- func (tc *TreeCache) RenameNode(nodeName string, newNodeName string) error
- func (tc *TreeCache) SetDefaultResourceNames()
- func (tc *TreeCache) SetDefaultTreeName()
- func (tc *TreeCache) SetTreeName(name string)
- type TreeCacheCreateResponse
- type TreeSnapshot
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EqualStateControllers ¶ added in v1.34.0
func EqualStateControllers(c1 *Controller, c2 *Controller) bool
EqualStateControllers : check if two controllers have similar allocation state
func EqualStateForestControllers ¶ added in v1.34.0
func EqualStateForestControllers(fc1 *ForestController, fc2 *ForestController) bool
EqualStateControllers : check if two forest controllers have similar allocation state
func EqualStateQuotaNodes ¶ added in v1.34.0
EqualStateQuotaNodes : check if two quota nodes have similar allocation data
func EqualStateQuotaTrees ¶ added in v1.34.0
EqualStateQuotaTrees : check if two quota trees have similar allocation data
Types ¶
type Allocation ¶
type Allocation struct {
// contains filtered or unexported fields
}
Allocation : an allocation of an (ordered) array of resources (names of resources are left out for efficiency)
func NewAllocation ¶
func NewAllocation(size int) (*Allocation, error)
NewAllocation : create an empty allocation of a given size (length)
func NewAllocationCopy ¶
func NewAllocationCopy(value []int) (*Allocation, error)
NewAllocationCopy : create an allocation given an array of values
func (*Allocation) Add ¶
func (a *Allocation) Add(other *Allocation) bool
Add : add another allocation to this one (false if unequal lengths)
func (*Allocation) Equal ¶
func (a *Allocation) Equal(other *Allocation) bool
Equal : check if equals another allocation (false if unequal lengths)
func (*Allocation) Fit ¶
func (a *Allocation) Fit(allocated *Allocation, capacity *Allocation) bool
Fit : check if this allocation fits on an entity with a given capacity and already allocated values (false if unequal lengths)
func (*Allocation) GetSize ¶
func (a *Allocation) GetSize() int
GetSize : get the size (length) of the values array
func (*Allocation) GetValue ¶
func (a *Allocation) GetValue() []int
GetValue : get the array of values
func (*Allocation) IsZero ¶
func (a *Allocation) IsZero() bool
IsZero : check if values are zeros (all element values)
func (*Allocation) LessOrEqual ¶
func (a *Allocation) LessOrEqual(other *Allocation) bool
LessOrEqual : check if less or equal to another allocation (false if unequal lengths)
func (*Allocation) SameSize ¶
func (a *Allocation) SameSize(other *Allocation) bool
SameSize : check if same size (length) as another allocation
func (*Allocation) SetValue ¶
func (a *Allocation) SetValue(value []int)
SetValue : set the array of values (overwites previous values)
func (*Allocation) String ¶
func (a *Allocation) String() string
String : a print out of the allocation
func (*Allocation) StringPretty ¶
func (a *Allocation) StringPretty(resourceNames []string) string
StringPretty : a print out of the allocation with resource names (empty if unequal lengths)
func (*Allocation) Subtract ¶
func (a *Allocation) Subtract(other *Allocation) bool
Subtract : subtract another allocation to this one (false if unequal lengths)
type AllocationRecovery ¶
type AllocationRecovery struct {
// contains filtered or unexported fields
}
AllocationRecovery : Used to recover from failure after partial allocation
func NewAllocationRecovery ¶
func NewAllocationRecovery(consumer *Consumer) *AllocationRecovery
NewAllocationRecovery : create an allocation recovery for a consumer
func (*AllocationRecovery) AlteredConsumer ¶
func (ar *AllocationRecovery) AlteredConsumer(consumer *Consumer)
AlteredConsumer : mark a consumer as altered
func (*AllocationRecovery) AlteredNode ¶
func (ar *AllocationRecovery) AlteredNode(qn *QuotaNode)
AlteredNode : mark a node as altered
func (*AllocationRecovery) Recover ¶
func (ar *AllocationRecovery) Recover()
Recover : perform recovery actions
func (*AllocationRecovery) Reset ¶
func (ar *AllocationRecovery) Reset()
Reset : reset the allocation recovery
type AllocationResponse ¶
type AllocationResponse struct {
// contains filtered or unexported fields
}
AllocationResponse : A response object to a consumer allocation request
func NewAllocationResponse ¶
func NewAllocationResponse(consumerID string) *AllocationResponse
NewAllocationResponse : create an allocation response for a consumer
func (*AllocationResponse) Append ¶
func (ar *AllocationResponse) Append(allocated bool, message string, preemptedIds *[]string)
Append : append to the response
func (*AllocationResponse) GetConsumerID ¶
func (ar *AllocationResponse) GetConsumerID() string
GetConsumerID :
func (*AllocationResponse) GetMessage ¶
func (ar *AllocationResponse) GetMessage() string
GetMessage :
func (*AllocationResponse) GetPreemptedIds ¶
func (ar *AllocationResponse) GetPreemptedIds() []string
GetPreemptedIds :
func (*AllocationResponse) IsAllocated ¶
func (ar *AllocationResponse) IsAllocated() bool
IsAllocated :
func (*AllocationResponse) Merge ¶
func (ar *AllocationResponse) Merge(other *AllocationResponse)
Merge : merge another response into this
func (*AllocationResponse) SetAllocated ¶
func (ar *AllocationResponse) SetAllocated(allocated bool)
SetAllocated :
func (*AllocationResponse) SetMessage ¶
func (ar *AllocationResponse) SetMessage(message string)
SetMessage :
type ByID ¶ added in v1.34.0
type ByID []*Consumer
ByID implements sort.Interface based on the ID field.
type Consumer ¶
type Consumer struct {
// contains filtered or unexported fields
}
Consumer : A tree consumer
func NewConsumer ¶
func NewConsumer(id string, treeID string, groupID string, request *Allocation, priority int, cType int, unPreemptable bool) *Consumer
NewConsumer : create a consumer
func (*Consumer) GetGroupID ¶
GetGroupID : get the treeID of the consumer
func (*Consumer) GetPriority ¶
GetPriority : get the priority of the consumer
func (*Consumer) GetRequest ¶
func (c *Consumer) GetRequest() *Allocation
GetRequest : get the request demand of the consumer
func (*Consumer) IsAllocated ¶
IsAllocated : is consumer allocated on tree
func (*Consumer) IsUnPreemptable ¶
IsUnPreemptable : is the consumer preemptable
func (*Consumer) SetGroupID ¶
SetGroupID : set the groupID of the consumer
func (*Consumer) SetUnPreemptable ¶
SetUnPreemptable : set the consumer unpreemptability
type ConsumerState ¶ added in v1.34.0
type ConsumerState struct {
// contains filtered or unexported fields
}
ConsumerState : snapshot data about state of a consumer
type Controller ¶
type Controller struct {
// contains filtered or unexported fields
}
Controller : controller of a quota tree
func NewController ¶
func NewController(tree *QuotaTree) *Controller
NewController : create a quota controller
func (*Controller) Allocate ¶
func (controller *Controller) Allocate(consumer *Consumer) *AllocationResponse
Allocate : allocate a consumer
func (*Controller) DeAllocate ¶
func (controller *Controller) DeAllocate(consumerID string) bool
DeAllocate : deallocate a consumer
func (*Controller) ForceAllocate ¶
func (controller *Controller) ForceAllocate(consumer *Consumer, nodeID string) *AllocationResponse
ForceAllocate : force allocate a consumer on a given node
func (*Controller) GetConsumer ¶
func (controller *Controller) GetConsumer(id string) *Consumer
GetConsumer : retrieve a consumer by id
func (*Controller) GetConsumerIDs ¶
func (controller *Controller) GetConsumerIDs() []string
GetConsumerIDs : get IDs of all consumers allocated
func (*Controller) GetConsumers ¶ added in v1.34.0
func (controller *Controller) GetConsumers() map[string]*Consumer
GetConsumers : get a map of consumers in controller
func (*Controller) GetPreemptedConsumers ¶
func (controller *Controller) GetPreemptedConsumers() []string
GetPreemptedConsumers : get a list of the preempted consumer IDs
func (*Controller) GetPreemptedConsumersArray ¶
func (controller *Controller) GetPreemptedConsumersArray() []*Consumer
GetPreemptedConsumersArray : get a list of the preempted consumer objects
func (*Controller) GetQuotaSize ¶
func (controller *Controller) GetQuotaSize() int
GetQuotaSize : get dimension of quota array (number of resources)
func (*Controller) GetResourceNames ¶
func (controller *Controller) GetResourceNames() []string
GetResourceNames : get resource names (null if no tree)
func (*Controller) GetTree ¶
func (controller *Controller) GetTree() *QuotaTree
GetTree : the quota tree
func (*Controller) GetTreeName ¶
func (controller *Controller) GetTreeName() string
GetTreeName : the name of the quota tree, empty if nil
func (*Controller) IsAllocated ¶
func (controller *Controller) IsAllocated() bool
IsAllocated : check if there are consumers already allocated
func (*Controller) IsConsumerAllocated ¶
func (controller *Controller) IsConsumerAllocated(id string) bool
IsConsumerAllocated : check if a consumer is already allocated
func (*Controller) PrintState ¶
func (controller *Controller) PrintState(c *Consumer, status bool)
PrintState : print state of quota tree after consumer (de)allocation step
func (*Controller) Remove ¶
func (controller *Controller) Remove(id string) bool
Remove : remove a consumer
func (*Controller) TryAllocate ¶ added in v1.34.0
func (controller *Controller) TryAllocate(consumer *Consumer) *AllocationResponse
TryAllocate : try allocating a consumer by taking a snapshot before attempting allocation
func (*Controller) UndoAllocate ¶ added in v1.34.0
func (controller *Controller) UndoAllocate(consumer *Consumer) bool
UndoAllocate : undo the most recent allocation trial
func (*Controller) UpdateTree ¶
func (controller *Controller) UpdateTree(treeCache *TreeCache) (unAllocatedConsumerIDs []string, response *TreeCacheCreateResponse)
UpdateTree : update tree from cache; returns nil if able to allocate all consumers onto updated tree, otherwise a list of the IDs of unallocated consumers is returned
type ForestConsumer ¶
type ForestConsumer struct {
// contains filtered or unexported fields
}
ForestConsumer : A forest consumer (multiple tree consumers)
func NewForestConsumer ¶
func NewForestConsumer(id string, consumers map[string]*Consumer) *ForestConsumer
NewForestConsumer: create a forest consumer
func NewForestConsumerFromFile ¶
func NewForestConsumerFromFile(consumerFileName string, resourceNames map[string][]string) (*ForestConsumer, error)
NewForestConsumerFromFile : create a forest consumer from JSON file
func NewForestConsumerFromString ¶
func NewForestConsumerFromString(consumerString string, resourceNames map[string][]string) (*ForestConsumer, error)
NewForestConsumerFromString : create a forest consumer from JSON string spec
func NewForestConsumerFromStruct ¶
func NewForestConsumerFromStruct(consumerJson utils.JConsumer, resourceNames map[string][]string) (*ForestConsumer, error)
NewForestConsumerFromStruct : create a forest consumer from JSON struct
func (*ForestConsumer) GetConsumers ¶
func (fc *ForestConsumer) GetConsumers() map[string]*Consumer
GetConsumers : get the tree consumers
func (*ForestConsumer) GetID ¶
func (fc *ForestConsumer) GetID() string
GetID : get the id of the consumer
func (*ForestConsumer) GetTreeConsumer ¶
func (fc *ForestConsumer) GetTreeConsumer(treeName string) *Consumer
GetTreeConsumer : get the consumer of a given tree
func (*ForestConsumer) IsAllocated ¶
func (fc *ForestConsumer) IsAllocated() bool
IsAllocated : is consumer allocated on all trees in the forest
func (*ForestConsumer) String ¶
func (fc *ForestConsumer) String() string
String : a print out of the forest consumer
type ForestController ¶
type ForestController struct {
// contains filtered or unexported fields
}
ForestController : controller for multiple quota trees
func NewForestController ¶
func NewForestController() *ForestController
NewForestController : create a multiple tree controller
func (*ForestController) AddController ¶
func (fc *ForestController) AddController(controller *Controller) bool
AddController : add a quota tree controller
func (*ForestController) AddTree ¶
func (fc *ForestController) AddTree(tree *QuotaTree) bool
AddTree : add a quota tree
func (*ForestController) Allocate ¶
func (fc *ForestController) Allocate(forestConsumer *ForestConsumer) *AllocationResponse
Allocate : allocate a consumer
func (*ForestController) DeAllocate ¶
func (fc *ForestController) DeAllocate(consumerID string) bool
DeAllocate : deallocate a consumer
func (*ForestController) DeleteController ¶
func (fc *ForestController) DeleteController(treeName string) bool
DeleteController : delete a quota tree controller
func (*ForestController) DeleteTree ¶
func (fc *ForestController) DeleteTree(treeName string) bool
DeleteTree : delete a quota tree
func (*ForestController) ForceAllocate ¶
func (fc *ForestController) ForceAllocate(forestConsumer *ForestConsumer, nodeIDs map[string]string) *AllocationResponse
ForceAllocate : force allocate a consumer on a given set of nodes on trees; no recovery if not allocated on some trees; partial allocation allowed
func (*ForestController) GetControllers ¶
func (fc *ForestController) GetControllers() map[string]*Controller
GetControllers : get a map of tree controllers of the trees
func (*ForestController) GetQuotaTrees ¶
func (fc *ForestController) GetQuotaTrees() []*QuotaTree
GetQuotaTrees : get a list of the quota trees
func (*ForestController) GetResourceNames ¶
func (fc *ForestController) GetResourceNames() map[string][]string
GetResourceNames : get resource names (null if no tree)
func (*ForestController) GetTreeNames ¶
func (fc *ForestController) GetTreeNames() []string
GetTreeNames : get the names of the trees
func (*ForestController) IsAllocated ¶
func (fc *ForestController) IsAllocated() bool
IsAllocated : check if there are consumers already allocated
func (*ForestController) IsConsumerAllocated ¶
func (fc *ForestController) IsConsumerAllocated(id string) bool
IsConsumerAllocated : check if a consumer is already allocated
func (*ForestController) IsReady ¶
func (fc *ForestController) IsReady() bool
IsReady : check if tree(s) have been created
func (*ForestController) TryAllocate ¶ added in v1.34.0
func (fc *ForestController) TryAllocate(forestConsumer *ForestConsumer) *AllocationResponse
TryAllocate : try allocating a consumer by taking a snapshot before attempting allocation
func (*ForestController) UndoAllocate ¶ added in v1.34.0
func (fc *ForestController) UndoAllocate(forestConsumer *ForestConsumer) bool
UndoAllocate : undo the most recent allocation trial
func (*ForestController) UpdateTrees ¶
func (fc *ForestController) UpdateTrees(treeCacheList []*TreeCache) (unAllocatedConsumerIDs []string, responseMap map[string]*TreeCacheCreateResponse)
UpdateTrees : update all trees from caches; returns nil if able to allocate all consumers onto updated trees, otherwise a list of the IDs of unallocated consumers is returned
type NodeState ¶ added in v1.34.0
type NodeState struct {
// contains filtered or unexported fields
}
NodeState : snapshot data about state of a node
type QuotaNode ¶
QuotaNode : a node in the quota tree
func NewQuotaNode ¶
func NewQuotaNode(id string, quota *Allocation) (*QuotaNode, error)
NewQuotaNode : create a quota node
func NewQuotaNodeHard ¶
func NewQuotaNodeHard(id string, quota *Allocation, isHard bool) (*QuotaNode, error)
NewQuotaNodeHard : create a quota node
func (*QuotaNode) AddConsumer ¶
AddConsumer : add a consumer to the consumers list
func (*QuotaNode) AddRequest ¶
AddRequest : add request of consumer to allocated amount on this node (acquire)
func (*QuotaNode) Allocate ¶
Allocate : allocate a consumer on this node, assuming consumer request fits
func (*QuotaNode) HasLeaf ¶
HasLeaf : check if the leaf node of a consumer is also a leaf of the subtree formed from this node as a root
func (*QuotaNode) RemoveConsumer ¶
RemoveConsumer : remove a consumer from the consumers list
func (*QuotaNode) SetAllocated ¶ added in v1.34.0
func (qn *QuotaNode) SetAllocated(alloc *Allocation)
SetAllocated :
func (*QuotaNode) SetConsumers ¶ added in v1.34.0
SetConsumers :
func (*QuotaNode) SlideDown ¶
func (qn *QuotaNode) SlideDown()
SlideDown : slide down potential consumers from parent node
func (*QuotaNode) SlideUp ¶
func (qn *QuotaNode) SlideUp(c *Consumer, applyPriority bool, allocationRecovery *AllocationRecovery, preemptedConsumers *[]string) bool
SlideUp : slide up potential consumers to parent node; return true if able to fit given consumer on this node after sliding up other consumers
func (*QuotaNode) SubtractRequest ¶
SubtractRequest : subtract request of consumer from allocated amount on this node (release)
type QuotaTree ¶
QuotaTree : a quota tree
func NewQuotaTree ¶
NewQuotaTree : create a quota tree
func (*QuotaTree) DeAllocate ¶
DeAllocate : deallocate a consumer request
func (*QuotaTree) ForceAllocate ¶
ForceAllocate : force allocate a consumer request on a given node
func (*QuotaTree) GetResourceNames ¶
GetResourceNames :
type TreeCache ¶
type TreeCache struct {
// contains filtered or unexported fields
}
TreeCache : cache area for the parts of the quota tree (resources, nodes, topology) which may be updated; a quota tree may be created from the cache at any point
func (*TreeCache) AddNodeSpec ¶
AddNodeSpec : add a node spec to the cache; overrides earlier node spec with same name
{"parent": "Org-A", "hard": "true", "quota": { "cpu": "1" } }
func (*TreeCache) AddNodeSpecs ¶
AddNodeSpecs : add a map of node specs to the cache; invalid node specs are not added
func (*TreeCache) AddNodeSpecsFromString ¶
AddNodeSpecsFromString : add node specs by parsing string with one or more node information
{ "Root": { "parent": "nil", "quota": { "cpu": "10" } }, "Org-A": {"parent": "Root", "quota": { "cpu": "4" } } } { "Context-1": {"parent": "Org-A", "hard": "true", "quota": { "cpu": "1" } } }
func (*TreeCache) AddResourceName ¶
AddResourceName : add a resource name; overrides earlier name
func (*TreeCache) AddResourceNames ¶
AddResourceNames : add a list of resource names
func (*TreeCache) AddTreeInfoFromString ¶
AddTreeInfoFromString : add tree name and resource names by parsing tree information string;
{ "name": "ExampleTree", "resourceNames": [ "cpu", "memory" ] }
func (*TreeCache) CreateTree ¶
func (tc *TreeCache) CreateTree() (*QuotaTree, *TreeCacheCreateResponse)
CreateTree : create tree from cache
func (*TreeCache) DeleteNode ¶
DeleteNode : delete a node from the cache
func (*TreeCache) DeleteResourceName ¶
DeleteResourceName : delete a resource name
func (*TreeCache) FromString ¶
FromString : fill cache from the JSON string representation of the tree
func (*TreeCache) FromStruct ¶
func (tc *TreeCache) FromStruct(jQuotaTree utils.JQuotaTree) error
FromStruct : fill cache from the JSON struct of the tree
func (*TreeCache) GetNodeNames ¶
GetNodeNames : get a sorted list of node names in the cache
func (*TreeCache) GetNumResourceNames ¶
GetNumResourceNames : the number of resource names
func (*TreeCache) GetRenamedNode ¶
GetRenamedNode : get new name of node if renamed, otherwise emty
func (*TreeCache) GetResourceNames ¶
GetResourceNames : get a sorted list of resource names
func (*TreeCache) GetTreeName ¶
GetTreeName : get the name of the tree
func (*TreeCache) RenameNode ¶
RenameNode : rename a node in the cache
func (*TreeCache) SetDefaultResourceNames ¶
func (tc *TreeCache) SetDefaultResourceNames()
SetDefaultResourceNames : set resource names to the default ones
func (*TreeCache) SetDefaultTreeName ¶
func (tc *TreeCache) SetDefaultTreeName()
SetDefaultTreeName : set the name of the tree to the default name
func (*TreeCache) SetTreeName ¶
SetTreeName : set the name of the tree; overrides earlier name
type TreeCacheCreateResponse ¶
type TreeCacheCreateResponse struct { // the unique name of the tree TreeName string // name of root node, empty if missing root RootNodeName string // names of dangling nodes (nodes in the cache but not connected in the tree) DanglingNodeNames []string }
TreeCacheCreateResponse : response information of creating a tree from the cache
func (*TreeCacheCreateResponse) IsClean ¶
func (response *TreeCacheCreateResponse) IsClean() bool
IsClean : tree created from cache has a root and no dangling nodes
func (*TreeCacheCreateResponse) String ¶
func (response *TreeCacheCreateResponse) String() string
String : printout of TreeCacheCreateResponse
type TreeSnapshot ¶ added in v1.34.0
type TreeSnapshot struct {
// contains filtered or unexported fields
}
TreeSnapshot : A snapshot of a quota tree that could be used to undo a consumer allocation.
A snapshop of the tree state is taken before a consumer allocation trial, including only data that could potentially change during allocation of the target consumer. Reinstating the snapshot to the tree in case it is desired to undo the allocation.
func NewTreeSnapshot ¶ added in v1.34.0
func NewTreeSnapshot(tree *QuotaTree, consumer *Consumer) *TreeSnapshot
NewTreeSnapshot : create a new snapshot before allocating a consumer on a quota tree
func (*TreeSnapshot) Reinstate ¶ added in v1.34.0
func (ts *TreeSnapshot) Reinstate(controller *Controller)
Reinstate : reinstate the snapshot
func (*TreeSnapshot) Reset ¶ added in v1.34.0
func (ts *TreeSnapshot) Reset()
Reset : reset the snapshot data
func (*TreeSnapshot) Take ¶ added in v1.34.0
func (ts *TreeSnapshot) Take(controller *Controller, changedConsumers map[string]*Consumer) bool
Take : take a snapshot