core

package
v1.40.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 18, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

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

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

func EqualStateQuotaNodes(qn1 *QuotaNode, qn2 *QuotaNode) bool

EqualStateQuotaNodes : check if two quota nodes have similar allocation data

func EqualStateQuotaTrees added in v1.34.0

func EqualStateQuotaTrees(qt1 *QuotaTree, qt2 *QuotaTree) bool

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) Clone

func (a *Allocation) Clone() *Allocation

Clone : create a copy

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 :

func (*AllocationResponse) String

func (ar *AllocationResponse) String() string

String

type ByID added in v1.34.0

type ByID []*Consumer

ByID implements sort.Interface based on the ID field.

func (ByID) Len added in v1.34.0

func (c ByID) Len() int

func (ByID) Less added in v1.34.0

func (c ByID) Less(i, j int) bool

func (ByID) Swap added in v1.34.0

func (c ByID) Swap(i, j int)

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

func (c *Consumer) GetGroupID() string

GetGroupID : get the treeID of the consumer

func (*Consumer) GetID

func (c *Consumer) GetID() string

GetID : get the id of the consumer

func (*Consumer) GetNode

func (c *Consumer) GetNode() *QuotaNode

GetNode : get the allocated node for the consumer

func (*Consumer) GetPriority

func (c *Consumer) GetPriority() int

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) GetTreeID

func (c *Consumer) GetTreeID() string

GetTreeID : get the treeID of the consumer

func (*Consumer) GetType

func (c *Consumer) GetType() int

GetType : get the type of the consumer

func (*Consumer) IsAllocated

func (c *Consumer) IsAllocated() bool

IsAllocated : is consumer allocated on tree

func (*Consumer) IsUnPreemptable

func (c *Consumer) IsUnPreemptable() bool

IsUnPreemptable : is the consumer preemptable

func (*Consumer) SetGroupID

func (c *Consumer) SetGroupID(groupID string)

SetGroupID : set the groupID of the consumer

func (*Consumer) SetNode

func (c *Consumer) SetNode(aNode *QuotaNode)

SetNode : set the allocated node for the consumer

func (*Consumer) SetTreeID

func (c *Consumer) SetTreeID(treeID string)

SetTreeID : set the groupID of the consumer

func (*Consumer) SetUnPreemptable

func (c *Consumer) SetUnPreemptable(unPreemptable bool)

SetUnPreemptable : set the consumer unpreemptability

func (*Consumer) String

func (c *Consumer) String() string

String : a print out of the consumer

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) String

func (controller *Controller) String() string

String : printout

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) String

func (fc *ForestController) String() string

String : printout

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

type QuotaNode struct {
	//extends Node
	tree.Node
	// contains filtered or unexported fields
}

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

func (qn *QuotaNode) AddConsumer(c *Consumer) bool

AddConsumer : add a consumer to the consumers list

func (*QuotaNode) AddRequest

func (qn *QuotaNode) AddRequest(c *Consumer)

AddRequest : add request of consumer to allocated amount on this node (acquire)

func (*QuotaNode) Allocate

func (qn *QuotaNode) Allocate(c *Consumer)

Allocate : allocate a consumer on this node, assuming consumer request fits

func (*QuotaNode) CanFit

func (qn *QuotaNode) CanFit(c *Consumer) bool

CanFit : check if a consumer request can fit on this node

func (*QuotaNode) GetAllocated

func (qn *QuotaNode) GetAllocated() *Allocation

GetAllocated :

func (*QuotaNode) GetConsumers

func (qn *QuotaNode) GetConsumers() []*Consumer

GetConsumers :

func (*QuotaNode) GetQuota

func (qn *QuotaNode) GetQuota() *Allocation

GetQuota :

func (*QuotaNode) HasLeaf

func (qn *QuotaNode) HasLeaf(c *Consumer) bool

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) IsHard

func (qn *QuotaNode) IsHard() bool

IsHard :

func (*QuotaNode) RemoveConsumer

func (qn *QuotaNode) RemoveConsumer(c *Consumer) bool

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

func (qn *QuotaNode) SetConsumers(consumers []*Consumer)

SetConsumers :

func (*QuotaNode) SetQuota

func (qn *QuotaNode) SetQuota(quota *Allocation)

SetQuota :

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) String

func (qn *QuotaNode) String(level int) string

String : print node with a specified level of indentation

func (*QuotaNode) SubtractRequest

func (qn *QuotaNode) SubtractRequest(c *Consumer)

SubtractRequest : subtract request of consumer from allocated amount on this node (release)

type QuotaTree

type QuotaTree struct {
	// extends tree
	tree.Tree
	// contains filtered or unexported fields
}

QuotaTree : a quota tree

func NewQuotaTree

func NewQuotaTree(name string, root *QuotaNode, resourceNames []string) *QuotaTree

NewQuotaTree : create a quota tree

func (*QuotaTree) Allocate

func (qt *QuotaTree) Allocate(c *Consumer, preemptedConsumers *[]string) bool

Allocate : allocate a consumer request

func (*QuotaTree) DeAllocate

func (qt *QuotaTree) DeAllocate(c *Consumer) bool

DeAllocate : deallocate a consumer request

func (*QuotaTree) ForceAllocate

func (qt *QuotaTree) ForceAllocate(c *Consumer, nodeID string) bool

ForceAllocate : force allocate a consumer request on a given node

func (*QuotaTree) GetName

func (qt *QuotaTree) GetName() string

GetName :

func (*QuotaTree) GetNodes added in v1.34.0

func (qt *QuotaTree) GetNodes() map[string]*QuotaNode

GetNodes : get a map of all quota nodes in the tree

func (*QuotaTree) GetQuotaSize

func (qt *QuotaTree) GetQuotaSize() int

GetQuotaSize :

func (*QuotaTree) GetResourceNames

func (qt *QuotaTree) GetResourceNames() []string

GetResourceNames :

func (*QuotaTree) String

func (qt *QuotaTree) String() string

String :

func (*QuotaTree) StringSimply

func (qt *QuotaTree) StringSimply() string

StringSimply :

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 NewTreeCache

func NewTreeCache() *TreeCache

NewTreeCache : create a tree cache

func (*TreeCache) AddNodeSpec

func (tc *TreeCache) AddNodeSpec(nodeName string, nodeSpec utils.JNodeSpec) error

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

func (tc *TreeCache) AddNodeSpecs(nodeSpecs map[string]utils.JNodeSpec) error

AddNodeSpecs : add a map of node specs to the cache; invalid node specs are not added

func (*TreeCache) AddNodeSpecsFromString

func (tc *TreeCache) AddNodeSpecsFromString(nodesInfo string) error

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

func (tc *TreeCache) AddResourceName(name string)

AddResourceName : add a resource name; overrides earlier name

func (*TreeCache) AddResourceNames

func (tc *TreeCache) AddResourceNames(names []string)

AddResourceNames : add a list of resource names

func (*TreeCache) AddTreeInfoFromString

func (tc *TreeCache) AddTreeInfoFromString(treeInfo string) error

AddTreeInfoFromString : add tree name and resource names by parsing tree information string;

{ "name": "ExampleTree", "resourceNames": [ "cpu", "memory" ] }

func (*TreeCache) Clear

func (tc *TreeCache) Clear()

Clear : clear the cache

func (*TreeCache) CreateTree

func (tc *TreeCache) CreateTree() (*QuotaTree, *TreeCacheCreateResponse)

CreateTree : create tree from cache

func (*TreeCache) DeleteNode

func (tc *TreeCache) DeleteNode(nodeName string)

DeleteNode : delete a node from the cache

func (*TreeCache) DeleteResourceName

func (tc *TreeCache) DeleteResourceName(name string)

DeleteResourceName : delete a resource name

func (*TreeCache) FromFile

func (tc *TreeCache) FromFile(treeFileName string) error

FromFile : fill cache from a JSON file

func (*TreeCache) FromString

func (tc *TreeCache) FromString(treeString string) error

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

func (tc *TreeCache) GetNodeNames() []string

GetNodeNames : get a sorted list of node names in the cache

func (*TreeCache) GetNumResourceNames

func (tc *TreeCache) GetNumResourceNames() int

GetNumResourceNames : the number of resource names

func (*TreeCache) GetRenamedNode

func (tc *TreeCache) GetRenamedNode(nodeName string) string

GetRenamedNode : get new name of node if renamed, otherwise emty

func (*TreeCache) GetResourceNames

func (tc *TreeCache) GetResourceNames() []string

GetResourceNames : get a sorted list of resource names

func (*TreeCache) GetTreeName

func (tc *TreeCache) GetTreeName() string

GetTreeName : get the name of the tree

func (*TreeCache) RenameNode

func (tc *TreeCache) RenameNode(nodeName string, newNodeName string) error

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

func (tc *TreeCache) SetTreeName(name string)

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL