Safe Haskell | Safe-Infered |
---|
Module describing a node.
All updates are functional (copy-based) and return a new node with updated value.
- type TagMap = Map String Int
- data Node = Node {
- name :: String
- alias :: String
- tMem :: Double
- nMem :: Int
- fMem :: Int
- xMem :: Int
- tDsk :: Double
- fDsk :: Int
- tCpu :: Double
- uCpu :: Int
- spindleCount :: Int
- pList :: [Idx]
- sList :: [Idx]
- idx :: Ndx
- peers :: PeerMap
- failN1 :: Bool
- rMem :: Int
- pMem :: Double
- pDsk :: Double
- pRem :: Double
- pCpu :: Double
- mDsk :: Double
- loDsk :: Int
- hiCpu :: Int
- hiSpindles :: Double
- instSpindles :: Double
- offline :: Bool
- isMaster :: Bool
- utilPool :: DynUtil
- utilLoad :: DynUtil
- pTags :: TagMap
- group :: Gdx
- iPolicy :: IPolicy
- type AssocList = [(Ndx, Node)]
- type List = Container Node
- type AllocElement = (List, Instance, [Node], Score)
- noSecondary :: Ndx
- addTag :: TagMap -> String -> TagMap
- addTags :: TagMap -> [String] -> TagMap
- delTag :: TagMap -> String -> TagMap
- delTags :: TagMap -> [String] -> TagMap
- rejectAddTags :: TagMap -> [String] -> Bool
- conflictingPrimaries :: Node -> Int
- incIf :: Num a => Bool -> a -> a -> a
- decIf :: Num a => Bool -> a -> a -> a
- create :: String -> Double -> Int -> Int -> Double -> Int -> Double -> Bool -> Int -> Gdx -> Node
- mDskToloDsk :: Double -> Double -> Int
- mCpuTohiCpu :: Double -> Double -> Int
- computeHiSpindles :: Double -> Int -> Double
- setIdx :: Node -> Ndx -> Node
- setAlias :: Node -> String -> Node
- setOffline :: Node -> Bool -> Node
- setMaster :: Node -> Bool -> Node
- setXmem :: Node -> Int -> Node
- setMdsk :: Node -> Double -> Node
- setMcpu :: Node -> Double -> Node
- setPolicy :: IPolicy -> Node -> Node
- computeMaxRes :: PeerMap -> Elem
- buildPeers :: Node -> List -> Node
- calcSpindleUse :: Node -> Instance -> Double
- setPri :: Node -> Instance -> Node
- setSec :: Node -> Instance -> Node
- computePDsk :: Int -> Double -> Double
- setFmem :: Node -> Int -> Node
- removePri :: Node -> Instance -> Node
- removeSec :: Node -> Instance -> Node
- addPri :: Node -> Instance -> OpResult Node
- addPriEx :: Bool -> Node -> Instance -> OpResult Node
- addSec :: Node -> Instance -> Ndx -> OpResult Node
- addSecEx :: Bool -> Node -> Instance -> Ndx -> OpResult Node
- availDisk :: Node -> Int
- iDsk :: Node -> Int
- availMem :: Node -> Int
- availCpu :: Node -> Int
- iMem :: Node -> Int
- instanceToEdges :: Instance -> [Edge]
- instancesToEdges :: List -> [Edge]
- nodesToBounds :: List -> Maybe Bounds
- mkNodeGraph :: List -> List -> Maybe Graph
- showField :: Node -> String -> String
- showHeader :: String -> (String, Bool)
- list :: [String] -> Node -> [String]
- defaultFields :: [String]
- computeGroups :: [Node] -> [(Gdx, [Node])]
Type declarations
The node type.
Node | |
|
type AllocElement = (List, Instance, [Node], Score)Source
A simple name for an allocation element (here just for logistic reasons).
Constant node index for a non-moveable instance.
Helper functions
rejectAddTags :: TagMap -> [String] -> BoolSource
Check if we can add a list of tags to a tagmap.
conflictingPrimaries :: Node -> IntSource
Check how many primary instances have conflicting tags. The algorithm to compute this is to sum the count of all tags, then subtract the size of the tag map (since each tag has at least one, non-conflicting instance); this is equivalent to summing the values in the tag map minus one.
Initialization functions
create :: String -> Double -> Int -> Int -> Double -> Int -> Double -> Bool -> Int -> Gdx -> NodeSource
Create a new node.
The index and the peers maps are empty, and will be need to be
update later via the setIdx
and buildPeers
functions.
mDskToloDsk :: Double -> Double -> IntSource
mCpuTohiCpu :: Double -> Double -> IntSource
computeHiSpindles :: Double -> Int -> DoubleSource
setIdx :: Node -> Ndx -> NodeSource
Changes the index.
This is used only during the building of the data structures.
setAlias :: Node -> String -> NodeSource
Changes the alias.
This is used only during the building of the data structures.
setOffline :: Node -> Bool -> NodeSource
Sets the offline attribute.
setMcpu :: Node -> Double -> NodeSource
Sets the max cpu usage ratio. This will update the node's ipolicy, losing sharing (but it should be a seldomly done operation).
computeMaxRes :: PeerMap -> ElemSource
buildPeers :: Node -> List -> NodeSource
Builds the peer map for a given node.
calcSpindleUse :: Node -> Instance -> DoubleSource
setPri :: Node -> Instance -> NodeSource
Assigns an instance to a node as primary and update the used VCPU count, utilisation data and tags map.
setSec :: Node -> Instance -> NodeSource
Assigns an instance to a node as secondary without other updates.
computePDsk :: Int -> Double -> DoubleSource
Update functions
:: Bool | Whether to override the N+1 and other soft checks, useful if we come from a worse status (e.g. offline) |
-> Node | The target node |
-> Instance | The instance to add |
-> OpResult Node | The result of the operation, either the new version of the node or a failure mode |
Adds a primary instance (extended version).
addSecEx :: Bool -> Node -> Instance -> Ndx -> OpResult NodeSource
Adds a secondary instance (extended version).
Stats functions
Node graph functions
Making of a Graph from a node/instance list
instanceToEdges :: Instance -> [Edge]Source
instancesToEdges :: List -> [Edge]Source
nodesToBounds :: List -> Maybe BoundsSource
mkNodeGraph :: List -> List -> Maybe GraphSource
Transform a Node + Instance list into a NodeGraph type. Returns Nothing if the node list is empty.
Display functions
:: Node | Node which we're querying |
-> String | Field name |
-> String | Field value as string |
Return a field for a given node.
showHeader :: String -> (String, Bool)Source
Returns the header and numeric propery of a field.
defaultFields :: [String]Source
Constant holding the fields we're displaying by default.
computeGroups :: [Node] -> [(Gdx, [Node])]Source
Split a list of nodes into a list of (node group UUID, list of associated nodes).