Holumbus-Distribution-0.1.0: intra- and inter-program communicationSource codeContentsIndex
Holumbus.Distribution.DNode.Base
Portabilityportable
Stabilityexperimental
MaintainerStefan Schmidt (stefanschmidt@web.de)
Contents
datatypes
Initializing and Deinitializing of the local node
adding, deleting other nodes
checking other nodes and resources
needed by the resources
Description

Version : 0.1

The main module for the implementation of the distributed data structures. It contains the DNode-datatype which is needed to register new local and remote resources. The main datatypes (Ids, Handlers, etc.) are also defined here.

The module should only be used from within this library. User applications should refer to Holumbus.Distribution.DNode.

Synopsis
data DistributedException = DistributedException {
distEx_msg :: String
distEx_fct :: String
distEx_mod :: String
}
data DNodeConfig = DNodeConfig {
dnc_Name :: String
dnc_MinPort :: Int
dnc_MaxPort :: Int
dnc_AccessDelay :: Int
dnc_PingDelay :: Int
}
defaultDNodeConfig :: String -> DNodeConfig
data DNodeId
mkDNodeId :: String -> DNodeId
data DNodeAddress
mkDNodeAddress :: String -> HostName -> Int -> DNodeAddress
data DHandlerId
data DResourceType
mkDResourceType :: String -> DResourceType
data DResourceId
data DResourceAddress
mkDResourceAddress :: DResourceType -> String -> String -> DResourceAddress
type DResourceDispatcher = DNodeId -> Handle -> IO ()
data DResourceEntry = DResourceEntry {
dre_Dispatcher :: DResourceDispatcher
}
initDNode :: DNodeConfig -> IO DNodeId
deinitDNode :: IO ()
addForeignDNode :: DNodeAddress -> IO ()
delForeignDNode :: DNodeId -> IO ()
checkForeignDNode :: DNodeId -> IO Bool
addForeignDNodeHandler :: Bool -> DNodeId -> DHandlerFunction -> IO (Maybe DHandlerId)
addForeignDResourceHandler :: Bool -> DResourceAddress -> DHandlerFunction -> IO (Maybe DHandlerId)
delForeignHandler :: DHandlerId -> IO ()
genLocalResourceAddress :: DResourceType -> String -> IO DResourceAddress
addLocalResource :: DResourceAddress -> DResourceEntry -> IO ()
delLocalResource :: DResourceAddress -> IO ()
delForeignResource :: DResourceAddress -> IO ()
safeAccessForeignResource :: DResourceAddress -> (Handle -> IO a) -> IO a
unsafeAccessForeignResource :: DResourceAddress -> (Handle -> IO a) -> IO a
getByteStringMessage :: Handle -> IO ByteString
putByteStringMessage :: ByteString -> Handle -> IO ()
getDNodeData :: IO DNodeData
datatypes
data DistributedException Source
The exception type, used by distributed communication
Constructors
DistributedException
distEx_msg :: Stringthe message of the exception
distEx_fct :: Stringthe function in which the exception was thrown
distEx_mod :: Stringthe module in which the exception was thrown
show/hide Instances
data DNodeConfig Source
The configuration of a DNode. You need it to create a DNode and you can use this data type it to alter its properties. This type is public to allow users to create their own configuration.
Constructors
DNodeConfig
dnc_Name :: String
dnc_MinPort :: Int
dnc_MaxPort :: Int
dnc_AccessDelay :: Int
dnc_PingDelay :: Int
show/hide Instances
defaultDNodeConfig :: String -> DNodeConfigSource
A good default configuration. To create an unnamed node, just leave the string empty.
data DNodeId Source
The DNode identifier. Every DNode has an Id, this could be named or randomly created. The id could not be used to address a DNode directly over a Network connection because the physical references are missing. The DNodeId is meant to create a declarative reference which could be used to lookup purposes. Think of the DNodeId as a domain name, without a DNS-Server to resolve the physical address, it is worthless to establish a communication.
show/hide Instances
mkDNodeId :: String -> DNodeIdSource
Use this to make a new DNodeId from a String
data DNodeAddress Source
The DNode address.
show/hide Instances
mkDNodeAddress :: String -> HostName -> Int -> DNodeAddressSource
use this to make a new DNodeAddress
data DHandlerId Source
The Id of a handler, is needed to stop the handler from further execution.
show/hide Instances
data DResourceType Source
The ressouce type, it is used to separate between different kinds of resources. The resource type is generated by the programmer of a resource
show/hide Instances
mkDResourceType :: String -> DResourceTypeSource
data DResourceId Source
The DResource Id.
show/hide Instances
data DResourceAddress Source
The DResource address
show/hide Instances
mkDResourceAddress :: DResourceType -> String -> String -> DResourceAddressSource
type DResourceDispatcher = DNodeId -> Handle -> IO ()Source
The DResource callback functions
data DResourceEntry Source
The container for the DResources
Constructors
DResourceEntry
dre_Dispatcher :: DResourceDispatcher
show/hide Instances
Initializing and Deinitializing of the local node
initDNode :: DNodeConfig -> IO DNodeIdSource
Initializes the DNode of the program. You have to call this function once BEFORE you can use other functions.
deinitDNode :: IO ()Source
deinitializes a DNode
adding, deleting other nodes
addForeignDNode :: DNodeAddress -> IO ()Source
Add a foreign DNode to the list of known DNodes. Only DNodes in this list could be reached by the local node.
delForeignDNode :: DNodeId -> IO ()Source
removes a foreign DNode entry. You should clean up the foreign DNode entries.
checking other nodes and resources
checkForeignDNode :: DNodeId -> IO BoolSource
Manually Checks, if another DNode is reachable. Returns true if this is the case, otherwise false. Always returns, does not throw an exception caused by network failures.
addForeignDNodeHandler :: Bool -> DNodeId -> DHandlerFunction -> IO (Maybe DHandlerId)Source
Adds a handler function which periodically checks the existences (or non-existence) of other DNodes. The first parameter indicates the type of the handler. If you want to install a handler which is fired when a Node becomes reachable (positive trigger), it needs to be true. If you want to monitor the event when a specific node disappears, pass false.
addForeignDResourceHandler :: Bool -> DResourceAddress -> DHandlerFunction -> IO (Maybe DHandlerId)Source
Adds a handler function which periodically checks the existences (or non-existence) of resources on other DNodes. The first parameter indicates the type of the handler. If you want to install a handler which is fired when a Node becomes reachable (positive trigger), it needs to be true. If you want to monitor the event when a specific node disappears, pass false.
delForeignHandler :: DHandlerId -> IO ()Source
Deletes a Handler from the system, will not be called anymore.
needed by the resources
genLocalResourceAddress :: DResourceType -> String -> IO DResourceAddressSource
addLocalResource :: DResourceAddress -> DResourceEntry -> IO ()Source
delLocalResource :: DResourceAddress -> IO ()Source
delForeignResource :: DResourceAddress -> IO ()Source
safeAccessForeignResource :: DResourceAddress -> (Handle -> IO a) -> IO aSource
unsafeAccessForeignResource :: DResourceAddress -> (Handle -> IO a) -> IO aSource
getByteStringMessage :: Handle -> IO ByteStringSource
Reads data from a stream. We define, that the first line of the message is the message header which tells us how much bytes we have to read.
putByteStringMessage :: ByteString -> Handle -> IO ()Source
Puts a bytestring to a handle. But to make the reading easier, we write the length of the data as a message-header to the handle, too.
getDNodeData :: IO DNodeDataSource
Produced by Haddock version 2.6.1