ganeti

Safe HaskellNone

Ganeti.WConfd.Monad

Contents

Description

All RPC calls are run within this monad.

It encapsulates:

  • IO operations, * failures, * working with the daemon state.

Code that is specific either to the configuration or the lock management, should go into their corresponding dedicated modules.

Synopsis

Pure data types used in the monad

data DaemonHandle Source

Constructors

DaemonHandle 

Fields

dhDaemonState :: IORef DaemonState
 
dhConfigPath :: FilePath

The configuration file path all static information that doesn't change during the life-time of the daemon should go here; all IDs of threads that do asynchronous work should probably also go here

dhSaveConfigWorker :: AsyncWorker Any ()
 
dhSaveLocksWorker :: AsyncWorker () ()
 
dhSaveTempResWorker :: AsyncWorker () ()
 
dhLivelock :: Livelock
 

mkDaemonHandleSource

Arguments

:: FilePath 
-> ConfigState 
-> GanetiLockWaiting 
-> TempResState 
-> (IO ConfigState -> [AsyncWorker () ()] -> ResultG (AsyncWorker Any ()))

A function that creates a worker that asynchronously saves the configuration to the master file.

-> (IO ConfigState -> ResultG (AsyncWorker () ()))

A function that creates a worker that asynchronously distributes the configuration to master candidates

-> (IO ConfigState -> ResultG (AsyncWorker () ()))

A function that creates a worker that asynchronously distributes SSConf to nodes

-> (IO GanetiLockWaiting -> ResultG (AsyncWorker () ()))

A function that creates a worker that asynchronously saves the lock allocation state.

-> (IO TempResState -> ResultG (AsyncWorker () ()))

A function that creates a worker that asynchronously saves the temporary reservations state.

-> Livelock 
-> ResultG DaemonHandle 

The monad and its instances

newtype WConfdMonadInt a Source

The internal part of the monad without error handling.

Instances

Monad WConfdMonadInt 
Functor WConfdMonadInt 
Applicative WConfdMonadInt 
MonadIO WConfdMonadInt 
MonadLog WConfdMonadInt 
MonadBase IO WConfdMonadInt 
MonadBaseControl IO WConfdMonadInt 

runWConfdMonadInt :: WConfdMonadInt a -> DaemonHandle -> IO aSource

Runs the internal part of the WConfdMonad monad on a given daemon handle.

type WConfdMonad = ResultT GanetiException WConfdMonadIntSource

The complete monad with error handling.

Basic functions in the monad

daemonHandle :: WConfdMonad DaemonHandleSource

Returns the daemon handle.

readConfigState :: WConfdMonad ConfigStateSource

Returns the current configuration, given a handle

unpackConfigResult :: ClockTime -> ConfigState -> (a, ConfigState) -> ((a, Bool, Bool), ConfigState)Source

modifyConfigState :: (ConfigState -> (a, ConfigState)) -> WConfdMonad aSource

Atomically modifies the configuration state in the WConfdMonad.

modifyConfigStateWithImmediate :: (ConfigState -> (a, ConfigState)) -> WConfdMonad () -> WConfdMonad aSource

Atomically modifies the configuration state in WConfdMonad; immediately afterwards (while the config write-out is not necessarily finished) do another acation.

forceConfigStateDistribution :: WConfdMonad ()Source

Force the distribution of configuration without actually modifying it.

We need a separate call for this operation, because modifyConfigState only triggers the distribution when the configuration changes.

modifyConfigDataErr_ :: (TempResState -> ConfigData -> AtomicModifyMonad ConfigData) -> WConfdMonad ()Source

Atomically modifies the configuration data in the WConfdMonad with a computation that can possibly fail.

modifyTempResStateErr :: (ConfigData -> StateT TempResState ErrorResult a) -> WConfdMonad aSource

Atomically modifies the state of temporary reservations in WConfdMonad in the presence of possible errors.

modifyTempResState :: (ConfigData -> State TempResState a) -> WConfdMonad aSource

Atomically modifies the state of temporary reservations in WConfdMonad.

readTempResState :: WConfdMonad (ConfigData, TempResState)Source

Reads the state of of the configuration and temporary reservations in WConfdMonad.

modifyLockWaiting :: (GanetiLockWaiting -> (GanetiLockWaiting, (a, Set ClientId))) -> WConfdMonad aSource

Atomically modifies the lock waiting state in WConfdMonad.

modifyLockWaiting_ :: (GanetiLockWaiting -> (GanetiLockWaiting, Set ClientId)) -> WConfdMonad ()Source

Atomically modifies the lock allocation state in WConfdMonad, not producing any result

readLockWaiting :: WConfdMonad GanetiLockWaitingSource

Read the lock waiting state in WConfdMonad.

readLockAllocation :: WConfdMonad (LockAllocation GanetiLocks ClientId)Source

Read the underlying lock allocation.

modifyConfigWithLock :: (TempResState -> ConfigState -> AtomicModifyMonad ConfigState) -> State TempResState () -> WConfdMonad (Maybe ())Source

Modify the configuration while temporarily acquiring the configuration lock. If the configuration lock is held by someone else, nothing is changed and Nothing is returned.