|
CPN
Computational Process Networks
|
A local implementation of the Context interface. More...
#include <LocalContext.h>
Inheritance diagram for CPN::LocalContext:
Collaboration diagram for CPN::LocalContext:Classes | |
| struct | KernelInfo |
| struct | NodeInfo |
| struct | PortInfo |
Public Types | |
| typedef std::map< std::string, Key_t > | NameMap |
| typedef std::map< Key_t, shared_ptr< KernelInfo > > | KernelMap |
| typedef std::map< Key_t, shared_ptr< NodeInfo > > | NodeMap |
| typedef std::map< Key_t, shared_ptr< PortInfo > > | PortMap |
Public Member Functions | |
| LocalContext () | |
| virtual | ~LocalContext () |
| virtual void | Log (int level, const std::string &msg) |
| Log a message to this outputer. More... | |
| virtual int | LogLevel () const |
| virtual int | LogLevel (int level) |
| virtual Key_t | SetupKernel (const std::string &name, const std::string &hostname, const std::string &servname, KernelBase *kernel) |
| Called by the Kernel when it has successfully set it self up. This gives the Context a way to notify the Kernel of events and lets other Kernels look up the connection information for this Kernel. More... | |
| virtual Key_t | SetupKernel (const std::string &name, KernelBase *kernel) |
| Called by the kernel when it is not in remote mode. More... | |
| virtual Key_t | GetKernelKey (const std::string &kernel) |
| virtual std::string | GetKernelName (Key_t kernelkey) |
| virtual void | GetKernelConnectionInfo (Key_t kernelkey, std::string &hostname, std::string &servname) |
| obtain the connection information for the given kernel More... | |
| virtual void | SignalKernelEnd (Key_t kernelkey) |
| Signal to the Context that the given kernel is dead. More... | |
| virtual Key_t | WaitForKernelStart (const std::string &kernel) |
| Does not return until the given kernel has started. More... | |
| virtual void | SignalKernelStart (Key_t kernelkey) |
| Signal to the context that the given kernel has started. More... | |
| virtual void | SendCreateWriter (Key_t kernelkey, const SimpleQueueAttr &attr) |
| Tell a given kernel that it needs to create a queue write end. More... | |
| virtual void | SendCreateReader (Key_t kernelkey, const SimpleQueueAttr &attr) |
| Tell a given kernel that it needs to create a queue read end. More... | |
| virtual void | SendCreateQueue (Key_t kernelkey, const SimpleQueueAttr &attr) |
| Tell a given kernel that it needs to create a queue. More... | |
| virtual void | SendCreateNode (Key_t kernelkey, const NodeAttr &attr) |
| Tell a given kernel that it needs to create a node. More... | |
| virtual Key_t | CreateNodeKey (Key_t kernelkey, const std::string &nodename) |
| Tell the context to allocate a new node key and data structure for a node with nodename which is on kernelkey. More... | |
| virtual Key_t | GetNodeKey (const std::string &nodename) |
| virtual std::string | GetNodeName (Key_t nodekey) |
| virtual Key_t | GetNodeKernel (Key_t nodekey) |
| virtual void | SignalNodeStart (Key_t nodekey) |
| Called by the node startup routine to indicate that the node has started. More... | |
| virtual void | SignalNodeEnd (Key_t nodekey) |
| Called by the node cleanup routine to indicate that the node has ended. More... | |
| virtual Key_t | WaitForNodeStart (const std::string &nodename) |
| Waits until the node starts and returns the key, if the node is already started returns the key. More... | |
| virtual void | WaitForNodeEnd (const std::string &nodename) |
| Waits for the given node to signal end. More... | |
| virtual void | WaitForAllNodeEnd () |
| Convenience method which waits until there are no nodes running. If no node have started then this will return immediately. More... | |
| virtual Key_t | GetCreateReaderKey (Key_t nodekey, const std::string &portname) |
| Get the key associated with the given endpoint for the given node. Creates the information if it does not exist. More... | |
| virtual Key_t | GetReaderNode (Key_t portkey) |
| virtual Key_t | GetReaderKernel (Key_t portkey) |
| virtual std::string | GetReaderName (Key_t portkey) |
| virtual Key_t | GetCreateWriterKey (Key_t nodekey, const std::string &portname) |
| virtual Key_t | GetWriterNode (Key_t portkey) |
| virtual Key_t | GetWriterKernel (Key_t portkey) |
| virtual std::string | GetWriterName (Key_t portkey) |
| virtual void | ConnectEndpoints (Key_t writerkey, Key_t readerkey, const std::string &qname) |
| Called by the kernel when a queue is created. Note that the endpoints may have been created when the node requests them but the queue may be created long after that. More... | |
| virtual Key_t | GetReadersWriter (Key_t readerkey) |
| virtual Key_t | GetWritersReader (Key_t writerkey) |
| virtual void | Terminate () |
| Signal to the Context that the network is terminating. After this call most methods will throw a ShutdownException. More... | |
| virtual bool | IsTerminated () |
| void | CheckTerminated () |
| Convenience method that checks IsTerminated and if so throws a ShutdownException. More... | |
| virtual bool | RequireRemote () |
| Lets the kernel know that this context type requires remote activity. This overrides the kernel option for remote activity. Default value is false. More... | |
| virtual unsigned | CalculateGrowSize (unsigned currentsize, unsigned request) |
| Calculate the new queue size when a queue needs to grow. More... | |
Static Public Member Functions | |
| static shared_ptr< Context > | Local () |
| Create a local context. More... | |
Private Member Functions | |
| void | InternalCheckTerminated () |
| Key_t | NewKey () |
A local implementation of the Context interface.
Definition at line 40 of file LocalContext.h.
| typedef std::map< Key_t, shared_ptr<KernelInfo> > CPN::LocalContext::KernelMap |
Definition at line 74 of file LocalContext.h.
| typedef std::map< std::string, Key_t > CPN::LocalContext::NameMap |
Definition at line 42 of file LocalContext.h.
| typedef std::map< Key_t, shared_ptr<NodeInfo> > CPN::LocalContext::NodeMap |
Definition at line 75 of file LocalContext.h.
| typedef std::map< Key_t, shared_ptr<PortInfo> > CPN::LocalContext::PortMap |
Definition at line 76 of file LocalContext.h.
| CPN::LocalContext::LocalContext | ( | ) |
Definition at line 34 of file LocalContext.cc.
|
virtual |
Definition at line 38 of file LocalContext.cc.
|
inlinevirtualinherited |
|
inherited |
Convenience method that checks IsTerminated and if so throws a ShutdownException.
| ShutdownException |
Definition at line 44 of file Context.cc.
References CPN::Context::IsTerminated().
Here is the call graph for this function:
|
virtual |
Called by the kernel when a queue is created. Note that the endpoints may have been created when the node requests them but the queue may be created long after that.
| writerkey | the unique key for the writer endpoint |
| readerkey | the unique key for the reader endpoint |
| ShutdownException | |
| std::invalid_argument |
Implements CPN::Context.
Definition at line 428 of file LocalContext.cc.
References InternalCheckTerminated(), lock, readports, and writeports.
Here is the call graph for this function:Tell the context to allocate a new node key and data structure for a node with nodename which is on kernelkey.
| kernelkey | the id of the kernel that the node will run on |
| nodename | the name of the node |
| ShutdownException | |
| std::invalid_argument |
Implements CPN::Context.
Definition at line 217 of file LocalContext.cc.
References InternalCheckTerminated(), lock, NewKey(), nodemap, and nodenames.
Here is the call graph for this function:Get the key associated with the given endpoint for the given node. Creates the information if it does not exist.
| nodekey | the unique id for the node |
| portname | the name of the endpoint. |
| ShutdownException | |
| std::invalid_argument |
Implements CPN::Context.
Definition at line 334 of file LocalContext.cc.
References InternalCheckTerminated(), lock, NewKey(), nodemap, and readports.
Here is the call graph for this function:Implements CPN::Context.
Definition at line 381 of file LocalContext.cc.
References InternalCheckTerminated(), lock, NewKey(), nodemap, and writeports.
Here is the call graph for this function:
|
virtual |
obtain the connection information for the given kernel
| kernelkey | the unique id for the kernel |
| hostname | (output) string to be filled with the hostname |
| servname | (output) string to be filled with the service name |
| ShutdownException | |
| std::invalid_argument |
Implements CPN::Context.
Definition at line 120 of file LocalContext.cc.
References ASSERT, InternalCheckTerminated(), kernelmap, and lock.
Here is the call graph for this function:
|
virtual |
| kernel | the name of the kernel |
| ShutdownException | |
| std::invalid_argument |
Implements CPN::Context.
Definition at line 100 of file LocalContext.cc.
References InternalCheckTerminated(), kernelnames, and lock.
Here is the call graph for this function:
|
virtual |
| kernelkey | the key to the kernel |
| ShutdownException | |
| std::invalid_argument |
Implements CPN::Context.
Definition at line 110 of file LocalContext.cc.
References InternalCheckTerminated(), kernelmap, and lock.
Here is the call graph for this function:| nodekey | the unique key for the node |
| ShutdownException | |
| std::invalid_argument |
Implements CPN::Context.
Definition at line 324 of file LocalContext.cc.
References InternalCheckTerminated(), lock, and nodemap.
Referenced by GetReaderKernel(), and GetWriterKernel().
Here is the call graph for this function:
Here is the caller graph for this function:
|
virtual |
| ShutdownException | |
| std::invalid_argument |
Implements CPN::Context.
Definition at line 237 of file LocalContext.cc.
References InternalCheckTerminated(), lock, and nodenames.
Here is the call graph for this function:
|
virtual |
| ShutdownException | |
| std::invalid_argument |
Implements CPN::Context.
Definition at line 248 of file LocalContext.cc.
| portkey | the unique id for the port |
| ShutdownException | |
| std::invalid_argument |
Implements CPN::Context.
Definition at line 366 of file LocalContext.cc.
References GetNodeKernel(), and GetReaderNode().
Here is the call graph for this function:
|
virtual |
| portkey | the unique id for the port |
| ShutdownException | |
| std::invalid_argument |
Implements CPN::Context.
Definition at line 371 of file LocalContext.cc.
References InternalCheckTerminated(), lock, and readports.
Here is the call graph for this function:| portkey | the unique id for the port |
| ShutdownException | |
| std::invalid_argument |
Implements CPN::Context.
Definition at line 356 of file LocalContext.cc.
References InternalCheckTerminated(), lock, and readports.
Referenced by GetReaderKernel().
Here is the call graph for this function:
Here is the caller graph for this function:| readerkey | a unique reader key |
| ShutdownException | |
| std::invalid_argument |
Implements CPN::Context.
Definition at line 447 of file LocalContext.cc.
References InternalCheckTerminated(), lock, and readports.
Here is the call graph for this function:Implements CPN::Context.
Definition at line 413 of file LocalContext.cc.
References GetNodeKernel(), and GetWriterNode().
Here is the call graph for this function:
|
virtual |
Implements CPN::Context.
Definition at line 418 of file LocalContext.cc.
References InternalCheckTerminated(), lock, and writeports.
Here is the call graph for this function:Implements CPN::Context.
Definition at line 403 of file LocalContext.cc.
References InternalCheckTerminated(), lock, and writeports.
Referenced by GetWriterKernel().
Here is the call graph for this function:
Here is the caller graph for this function:| writerkey | a unique writer key |
| ShutdownException | |
| std::invalid_argument |
Implements CPN::Context.
Definition at line 457 of file LocalContext.cc.
References InternalCheckTerminated(), lock, and writeports.
Here is the call graph for this function:
|
private |
Definition at line 490 of file LocalContext.cc.
References shutdown.
Referenced by ConnectEndpoints(), CreateNodeKey(), GetCreateReaderKey(), GetCreateWriterKey(), GetKernelConnectionInfo(), GetKernelKey(), GetKernelName(), GetNodeKernel(), GetNodeKey(), GetReaderName(), GetReaderNode(), GetReadersWriter(), GetWriterName(), GetWriterNode(), GetWritersReader(), SendCreateNode(), SendCreateQueue(), SendCreateReader(), SendCreateWriter(), SetupKernel(), SignalKernelStart(), SignalNodeStart(), WaitForKernelStart(), and WaitForNodeStart().
Here is the caller graph for this function:
|
virtual |
Implements CPN::Context.
Definition at line 485 of file LocalContext.cc.
References lock, and shutdown.
|
staticinherited |
Create a local context.
Definition at line 29 of file Context.cc.
Referenced by CPN::Kernel::Kernel(), and CPN::VariantCPNLoader::LoadContext().
Here is the caller graph for this function:
|
virtual |
Log a message to this outputer.
| level | the level of this message |
| msg | the message |
Implements LoggerOutput.
Definition at line 41 of file LocalContext.cc.
References lock, and loglevel.
|
virtual |
Implements LoggerOutput.
Definition at line 48 of file LocalContext.cc.
References lock, and loglevel.
| level | the new log level |
Implements LoggerOutput.
Definition at line 53 of file LocalContext.cc.
References lock, and loglevel.
|
inlineprivate |
Definition at line 143 of file LocalContext.h.
Referenced by CreateNodeKey(), GetCreateReaderKey(), GetCreateWriterKey(), and SetupKernel().
Here is the caller graph for this function:
|
virtualinherited |
Lets the kernel know that this context type requires remote activity. This overrides the kernel option for remote activity. Default value is false.
Reimplemented in CPN::RemoteContextClient.
Definition at line 40 of file Context.cc.
Tell a given kernel that it needs to create a node.
| kernelkey | the id of the kernel |
| attr | the node attribute |
| ShutdownException |
Implements CPN::Context.
Definition at line 205 of file LocalContext.cc.
References ASSERT, InternalCheckTerminated(), kernelmap, lock, and CPN::KernelBase::RemoteCreateNode().
Here is the call graph for this function:
|
virtual |
Tell a given kernel that it needs to create a queue.
| kernelkey | the id of the kernel |
| attr | the queue attribute |
| ShutdownException |
Implements CPN::Context.
Definition at line 193 of file LocalContext.cc.
References ASSERT, InternalCheckTerminated(), kernelmap, lock, and CPN::KernelBase::RemoteCreateQueue().
Here is the call graph for this function:
|
virtual |
Tell a given kernel that it needs to create a queue read end.
| kernelkey | the id of the kernel |
| attr | the queue attribute |
| ShutdownException |
Implements CPN::Context.
Definition at line 181 of file LocalContext.cc.
References ASSERT, InternalCheckTerminated(), kernelmap, lock, and CPN::KernelBase::RemoteCreateReader().
Here is the call graph for this function:
|
virtual |
Tell a given kernel that it needs to create a queue write end.
| kernelkey | the id of the kernel |
| attr | the queue attribute |
| ShutdownException |
Implements CPN::Context.
Definition at line 169 of file LocalContext.cc.
References ASSERT, InternalCheckTerminated(), kernelmap, lock, and CPN::KernelBase::RemoteCreateWriter().
Here is the call graph for this function:
|
virtual |
Called by the Kernel when it has successfully set it self up. This gives the Context a way to notify the Kernel of events and lets other Kernels look up the connection information for this Kernel.
| name | the kernel name |
| hostname | the hostname to use to connect to this kernel |
| servname | the service name the kernel is listening on |
| kernel | callback reference |
| ShutdownException | |
| std::invalid_argument |
Implements CPN::Context.
Definition at line 58 of file LocalContext.cc.
References InternalCheckTerminated(), kernelmap, kernelnames, lock, and NewKey().
Here is the call graph for this function:
|
virtual |
Called by the kernel when it is not in remote mode.
| name | the kernel name |
| kernel | callback reference |
Implements CPN::Context.
Definition at line 80 of file LocalContext.cc.
References InternalCheckTerminated(), kernelmap, kernelnames, lock, and NewKey().
Here is the call graph for this function:
|
virtual |
Signal to the Context that the given kernel is dead.
| kernelkey | id of the kernel that died |
| std::invalid_argument |
Implements CPN::Context.
Definition at line 132 of file LocalContext.cc.
References PthreadCondition::Broadcast(), kernellivedead, kernelmap, and lock.
Here is the call graph for this function:
|
virtual |
Signal to the context that the given kernel has started.
| kernelkey | the id for the kernel |
| ShutdownException | |
| std::invalid_argument |
Implements CPN::Context.
Definition at line 158 of file LocalContext.cc.
References PthreadCondition::Broadcast(), InternalCheckTerminated(), kernellivedead, kernelmap, and lock.
Here is the call graph for this function:
|
virtual |
Called by the node cleanup routine to indicate that the node has ended.
| nodekey | the unique key for the node |
| std::invalid_argument |
Implements CPN::Context.
Definition at line 270 of file LocalContext.cc.
References PthreadCondition::Broadcast(), lock, nodelivedead, nodemap, and numlivenodes.
Here is the call graph for this function:
|
virtual |
Called by the node startup routine to indicate that the node has started.
| nodekey | the unique key for the node |
| ShutdownException | |
| std::invalid_argument |
Implements CPN::Context.
Definition at line 257 of file LocalContext.cc.
References PthreadCondition::Broadcast(), InternalCheckTerminated(), lock, nodelivedead, nodemap, and numlivenodes.
Here is the call graph for this function:
|
virtual |
Signal to the Context that the network is terminating. After this call most methods will throw a ShutdownException.
Implements CPN::Context.
Definition at line 467 of file LocalContext.cc.
References PthreadCondition::Broadcast(), kernellivedead, kernelmap, lock, nodelivedead, and shutdown.
Here is the call graph for this function:
|
virtual |
Convenience method which waits until there are no nodes running. If no node have started then this will return immediately.
| ShutdownException |
Implements CPN::Context.
Definition at line 317 of file LocalContext.cc.
References lock, nodelivedead, numlivenodes, shutdown, and PthreadCondition::Wait().
Here is the call graph for this function:
|
virtual |
Does not return until the given kernel has started.
| kernel | the name of the kernel (the key may not be known yet) |
| ShutdownException |
Implements CPN::Context.
Definition at line 142 of file LocalContext.cc.
References InternalCheckTerminated(), kernellivedead, kernelmap, kernelnames, lock, and PthreadCondition::Wait().
Here is the call graph for this function:
|
virtual |
Waits for the given node to signal end.
| nodename | the name of the node |
| ShutdownException |
Implements CPN::Context.
Definition at line 300 of file LocalContext.cc.
References ASSERT, lock, nodelivedead, nodemap, nodenames, shutdown, and PthreadCondition::Wait().
Here is the call graph for this function:
|
virtual |
Waits until the node starts and returns the key, if the node is already started returns the key.
| nodename | the name of the node to wait for |
| ShutdownException |
Implements CPN::Context.
Definition at line 282 of file LocalContext.cc.
References InternalCheckTerminated(), lock, nodelivedead, nodemap, nodenames, and PthreadCondition::Wait().
Here is the call graph for this function:
|
private |
Definition at line 144 of file LocalContext.h.
|
private |
Definition at line 133 of file LocalContext.h.
Referenced by SignalKernelEnd(), SignalKernelStart(), Terminate(), and WaitForKernelStart().
|
private |
Definition at line 136 of file LocalContext.h.
Referenced by GetKernelConnectionInfo(), GetKernelName(), SendCreateNode(), SendCreateQueue(), SendCreateReader(), SendCreateWriter(), SetupKernel(), SignalKernelEnd(), SignalKernelStart(), Terminate(), and WaitForKernelStart().
|
private |
Definition at line 134 of file LocalContext.h.
Referenced by GetKernelKey(), SetupKernel(), and WaitForKernelStart().
|
mutableprivate |
Definition at line 131 of file LocalContext.h.
Referenced by ConnectEndpoints(), CreateNodeKey(), GetCreateReaderKey(), GetCreateWriterKey(), GetKernelConnectionInfo(), GetKernelKey(), GetKernelName(), GetNodeKernel(), GetNodeKey(), GetNodeName(), GetReaderName(), GetReaderNode(), GetReadersWriter(), GetWriterName(), GetWriterNode(), GetWritersReader(), IsTerminated(), Log(), LogLevel(), SendCreateNode(), SendCreateQueue(), SendCreateReader(), SendCreateWriter(), SetupKernel(), SignalKernelEnd(), SignalKernelStart(), SignalNodeEnd(), SignalNodeStart(), Terminate(), WaitForAllNodeEnd(), WaitForKernelStart(), WaitForNodeEnd(), and WaitForNodeStart().
|
private |
Definition at line 130 of file LocalContext.h.
Referenced by Log(), and LogLevel().
|
private |
Definition at line 132 of file LocalContext.h.
Referenced by SignalNodeEnd(), SignalNodeStart(), Terminate(), WaitForAllNodeEnd(), WaitForNodeEnd(), and WaitForNodeStart().
|
private |
Definition at line 137 of file LocalContext.h.
Referenced by CreateNodeKey(), GetCreateReaderKey(), GetCreateWriterKey(), GetNodeKernel(), GetNodeName(), SignalNodeEnd(), SignalNodeStart(), WaitForNodeEnd(), and WaitForNodeStart().
|
private |
Definition at line 135 of file LocalContext.h.
Referenced by CreateNodeKey(), GetNodeKey(), WaitForNodeEnd(), and WaitForNodeStart().
|
private |
Definition at line 140 of file LocalContext.h.
Referenced by SignalNodeEnd(), SignalNodeStart(), and WaitForAllNodeEnd().
|
private |
Definition at line 138 of file LocalContext.h.
Referenced by ConnectEndpoints(), GetCreateReaderKey(), GetReaderName(), GetReaderNode(), and GetReadersWriter().
|
private |
Definition at line 141 of file LocalContext.h.
Referenced by InternalCheckTerminated(), IsTerminated(), Terminate(), WaitForAllNodeEnd(), and WaitForNodeEnd().
|
private |
Definition at line 139 of file LocalContext.h.
Referenced by ConnectEndpoints(), GetCreateWriterKey(), GetWriterName(), GetWriterNode(), and GetWritersReader().
1.8.5