Safe Haskell | None |
---|
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.
- data DistributionTarget
- = Everywhere
- | ToGroups (Set String)
- data DaemonState = DaemonState {}
- dsTempResL :: Lens' DaemonState TempResState
- dsLockWaitingL :: Lens' DaemonState GanetiLockWaiting
- dsConfigStateL :: Lens' DaemonState ConfigState
- data DaemonHandle = DaemonHandle {
- dhDaemonState :: IORef DaemonState
- dhConfigPath :: FilePath
- dhSaveConfigWorker :: AsyncWorker (Any, DistributionTarget) ()
- dhSaveLocksWorker :: AsyncWorker () ()
- dhSaveTempResWorker :: AsyncWorker () ()
- dhLivelock :: Livelock
- mkDaemonHandle :: FilePath -> ConfigState -> GanetiLockWaiting -> TempResState -> (IO ConfigState -> [AsyncWorker DistributionTarget ()] -> ResultG (AsyncWorker (Any, DistributionTarget) ())) -> (IO ConfigState -> ResultG (AsyncWorker DistributionTarget ())) -> (IO ConfigState -> ResultG (AsyncWorker DistributionTarget ())) -> (IO GanetiLockWaiting -> ResultG (AsyncWorker () ())) -> (IO TempResState -> ResultG (AsyncWorker () ())) -> Livelock -> ResultG DaemonHandle
- type WConfdMonadIntType = ReaderT DaemonHandle IO
- newtype WConfdMonadInt a = WConfdMonadInt {}
- runWConfdMonadInt :: WConfdMonadInt a -> DaemonHandle -> IO a
- type WConfdMonad = ResultT GanetiException WConfdMonadInt
- type AtomicModifyMonad a = ResultT GanetiException WriterLog a
- daemonHandle :: WConfdMonad DaemonHandle
- readConfigState :: WConfdMonad ConfigState
- unpackConfigResult :: ClockTime -> ConfigState -> (a, ConfigState) -> ((a, Bool, Bool), ConfigState)
- modifyConfigStateErrWithImmediate :: (TempResState -> ConfigState -> AtomicModifyMonad (a, ConfigState)) -> WConfdMonad () -> WConfdMonad a
- modifyConfigStateErr :: (TempResState -> ConfigState -> AtomicModifyMonad (a, ConfigState)) -> WConfdMonad a
- modifyConfigStateErr_ :: (TempResState -> ConfigState -> AtomicModifyMonad ConfigState) -> WConfdMonad ()
- modifyConfigState :: (ConfigState -> (a, ConfigState)) -> WConfdMonad a
- modifyConfigStateWithImmediate :: (ConfigState -> (a, ConfigState)) -> WConfdMonad () -> WConfdMonad a
- forceConfigStateDistribution :: DistributionTarget -> WConfdMonad ()
- modifyConfigDataErr_ :: (TempResState -> ConfigData -> AtomicModifyMonad ConfigData) -> WConfdMonad ()
- modifyTempResStateErr :: (ConfigData -> StateT TempResState ErrorResult a) -> WConfdMonad a
- modifyTempResState :: (ConfigData -> State TempResState a) -> WConfdMonad a
- readTempResState :: WConfdMonad (ConfigData, TempResState)
- modifyLockWaiting :: (GanetiLockWaiting -> (GanetiLockWaiting, (a, Set ClientId))) -> WConfdMonad a
- modifyLockWaiting_ :: (GanetiLockWaiting -> (GanetiLockWaiting, Set ClientId)) -> WConfdMonad ()
- readLockWaiting :: WConfdMonad GanetiLockWaiting
- readLockAllocation :: WConfdMonad (LockAllocation GanetiLocks ClientId)
- modifyConfigAndReturnWithLock :: (TempResState -> ConfigState -> AtomicModifyMonad (a, ConfigState)) -> State TempResState () -> WConfdMonad (Maybe a)
- modifyConfigWithLock :: (TempResState -> ConfigState -> AtomicModifyMonad ConfigState) -> State TempResState () -> WConfdMonad (Maybe ())
Monoid of the locations to flush the configuration to
data DistributionTarget Source
Data type describing where the configuration has to be distributed to.
Everywhere | |
ToGroups (Set String) |
Show DistributionTarget | |
Monoid DistributionTarget |
Pure data types used in the monad
data DaemonState Source
dsTempResL :: Lens' DaemonState TempResStateSource
dsConfigStateL :: Lens' DaemonState ConfigStateSource
data DaemonHandle Source
DaemonHandle | |
|
:: FilePath | |
-> ConfigState | |
-> GanetiLockWaiting | |
-> TempResState | |
-> (IO ConfigState -> [AsyncWorker DistributionTarget ()] -> ResultG (AsyncWorker (Any, DistributionTarget) ())) | A function that creates a worker that asynchronously saves the configuration to the master file. |
-> (IO ConfigState -> ResultG (AsyncWorker DistributionTarget ())) | A function that creates a worker that asynchronously distributes the configuration to master candidates |
-> (IO ConfigState -> ResultG (AsyncWorker DistributionTarget ())) | 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
type WConfdMonadIntType = ReaderT DaemonHandle IOSource
newtype WConfdMonadInt a Source
The internal part of the monad without error handling.
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.
type AtomicModifyMonad a = ResultT GanetiException WriterLog aSource
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
modifyConfigStateErrWithImmediate :: (TempResState -> ConfigState -> AtomicModifyMonad (a, ConfigState)) -> WConfdMonad () -> WConfdMonad aSource
modifyConfigStateErr :: (TempResState -> ConfigState -> AtomicModifyMonad (a, ConfigState)) -> WConfdMonad aSource
modifyConfigStateErr_ :: (TempResState -> ConfigState -> AtomicModifyMonad ConfigState) -> WConfdMonad ()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 :: DistributionTarget -> 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.
modifyConfigAndReturnWithLock :: (TempResState -> ConfigState -> AtomicModifyMonad (a, ConfigState)) -> State TempResState () -> WConfdMonad (Maybe a)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.
modifyConfigWithLock :: (TempResState -> ConfigState -> AtomicModifyMonad ConfigState) -> State TempResState () -> WConfdMonad (Maybe ())Source