|
CPN
Computational Process Networks
|
#include <RemoteContextDaemon.h>
Inheritance diagram for CPN::RemoteContextDaemon:
Collaboration diagram for CPN::RemoteContextDaemon:Classes | |
| class | Client |
Public Types | |
| typedef AutoLock< PthreadMutex > | ALock |
Public Member Functions | |
| RemoteContextDaemon (const SocketAddress &addr) | |
| RemoteContextDaemon (const SockAddrList &addrs) | |
| ~RemoteContextDaemon () | |
| void | Run () |
| Run the actual Context returns when the context is terminated and all clients have disconnected. More... | |
| bool | IsTerminated () const |
| int | DebugLevel () const |
| int | DebugLevel (int level) |
| void | Listen (const SocketAddress &addr, int queuelength=256) |
| void | Listen (const SockAddrList &addrs, int queuelength=256) |
| int | Accept (SocketAddress &addr) |
| int | Accept () |
| void | SetReuseAddr (bool reuse=true) |
| Turn on reuse of the address. Only takes effect if set before Listen. More... | |
| bool | GetReuseAddr () |
| int | Poll (double timeout) |
| bool | Readable (bool r) |
| Set that the file is currently readable or not. More... | |
| bool | Readable () const |
| Gives the current readability status of the file. More... | |
| bool | Writeable (bool w) |
| Set that this file is currently writeable or not. More... | |
| bool | Writeable () const |
| Gives the current writability status of the file. More... | |
| int | FD () const |
| int | FD (int filed) |
| Set the current file descriptor. More... | |
| bool | Eof () const |
| bool | Eof (bool e) |
| Set/reset the end of file condition. More... | |
| bool | Good () const |
| Convenience method for testing if the file this FileHandle has is open and not at end of file. More... | |
| bool | Closed () const |
| void | SetBlocking (bool blocking) |
| Manipulate how the current file handles blocking. More... | |
| bool | IsBlocking () const |
| Test if the current file is in blocking or non blocking mode. More... | |
| void | Reset () |
| Clear all internal state including the file descriptor! WARNING does not close the file! More... | |
| void | Close () |
| Close the file and reset the internal state. More... | |
| unsigned | Read (void *ptr, unsigned len) |
| Read data from the file descriptor. More... | |
| unsigned | Readv (const iovec *iov, int iovcnt) |
| scatter gather io version of Read More... | |
| unsigned | Write (const void *ptr, unsigned len) |
| Write data to the file descriptor. More... | |
| unsigned | Writev (const iovec *iov, int iovcnt) |
| scatter gather io version of Write More... | |
| void | Flush () |
| Tell the OS to flush any buffers it has. May not be supported for all file types. More... | |
Static Public Member Functions | |
| static int | Poll (IteratorRef< FileHandle * > begin, IteratorRef< FileHandle * > end, double timeout) |
| poll a list of FileHandles for any activity and call the appropriate On method. More... | |
| static void | SetBlocking (int fd, bool blocking) |
| a convenience method that allows one to set the same blocking parameters for a file descriptor without setting it inside a FileHandle. More... | |
| static bool | IsBlocking (int fd) |
| Test the given file descriptor if it is in blocking mode. More... | |
Protected Member Functions | |
| void | DispatchMessage (const std::string &sender, const Variant &msg) |
| Process the given message. More... | |
| void | dbprintf (int level, const char *fmt,...) |
| virtual void | OnReadable () |
| Called by Poll when it detects that the file is readable. More... | |
| virtual void | OnWriteable () |
| Called by Poll when it detects that the file is writeable. More... | |
Protected Attributes | |
| PthreadMutex | file_lock |
| int | fd |
| bool | readable |
| bool | writeable |
| bool | eof |
Private Types | |
| typedef std::tr1::shared_ptr < Client > | ClientPtr |
| typedef std::map< std::string, ClientPtr > | ClientMap |
Private Member Functions | |
| void | Terminate () |
| void | Terminate (const std::string &name) |
| void | Read () |
| void | SendMessage (const std::string &recipient, const Variant &msg) |
| Send the given message to the given client. More... | |
| void | BroadcastMessage (const Variant &msg) |
| Broadcast a message to all clients. More... | |
| void | LogMessage (const std::string &msg) |
| Log a message. More... | |
Private Attributes | |
| ClientMap | clients |
Friends | |
| class | Client |
The RemoteContextDaemon is an implementation of RemoteContextServer that uses simple tcp/ip and listens on an address you specify.
Definition at line 41 of file RemoteContextDaemon.h.
|
inherited |
Definition at line 43 of file FileHandle.h.
|
private |
Definition at line 75 of file RemoteContextDaemon.h.
|
private |
Definition at line 74 of file RemoteContextDaemon.h.
| CPN::RemoteContextDaemon::RemoteContextDaemon | ( | const SocketAddress & | addr | ) |
Definition at line 31 of file RemoteContextDaemon.cc.
References ServerSocketHandle::Listen(), and ServerSocketHandle::SetReuseAddr().
Here is the call graph for this function:| CPN::RemoteContextDaemon::RemoteContextDaemon | ( | const SockAddrList & | addrs | ) |
Definition at line 37 of file RemoteContextDaemon.cc.
References ServerSocketHandle::Listen(), and ServerSocketHandle::SetReuseAddr().
Here is the call graph for this function:| CPN::RemoteContextDaemon::~RemoteContextDaemon | ( | ) |
Definition at line 42 of file RemoteContextDaemon.cc.
|
inherited |
Accept an incoming connection.
| addr | a SocketAddress object to fill with the address of the connecting peer. |
| ErrnoException | for errors |
Definition at line 46 of file ServerSocketHandle.cc.
References ServerSocketHandle::Accept().
Referenced by CPN::ConnectionServer::Poll().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inherited |
Accept an incoming connection
Definition at line 50 of file ServerSocketHandle.cc.
Referenced by ServerSocketHandle::Accept(), and Read().
Here is the caller graph for this function:
|
privatevirtual |
Broadcast a message to all clients.
| msg | the message to send to all clients |
Implements CPN::RemoteContextServer.
Definition at line 125 of file RemoteContextDaemon.cc.
References clients, CPN::RemoteContextServer::dbprintf(), and CPN::RemoteContextServer::IsTerminated().
Here is the call graph for this function:
|
inherited |
Close the file and reset the internal state.
Definition at line 146 of file FileHandle.cc.
References FileHandle::eof, FileHandle::fd, FileHandle::file_lock, FileHandle::readable, and FileHandle::writeable.
Referenced by CPN::ConnectionServer::Close(), CPN::RemoteContext::EntryPoint(), CPN::RemoteQueue::HandleError(), CPN::RemoteQueue::InternalCheckStatus(), and Terminate().
Here is the caller graph for this function:
|
inlineinherited |
Definition at line 128 of file FileHandle.h.
References FileHandle::fd, and FileHandle::file_lock.
Referenced by SocketHandle::Connect(), CPN::ConnectionServer::ConnectReader(), CPN::ConnectionServer::ConnectWriter(), CPN::RemoteQueue::FileThreadEntryPoint(), CPN::RemoteQueue::InternalCheckStatus(), CPN::RemoteQueue::LogState(), CPN::ConnectionServer::LogState(), Run(), CPN::RemoteContextDaemon::Client::Send(), and CPN::RemoteContext::SendMessage().
Here is the caller graph for this function:
|
protectedinherited |
Definition at line 40 of file RemoteContextServer.cc.
References CPN::RemoteContextServer::debuglevel.
Referenced by BroadcastMessage(), CPN::RemoteContextDaemon::Client::Client(), CPN::RemoteContextServer::CreateNodeKey(), CPN::RemoteContextServer::DispatchMessage(), LogMessage(), Run(), SendMessage(), CPN::RemoteContextServer::SetupKernel(), CPN::RemoteContextServer::SignalKernelEnd(), CPN::RemoteContextServer::SignalKernelStart(), CPN::RemoteContextServer::SignalNodeEnd(), CPN::RemoteContextServer::SignalNodeStart(), and Terminate().
Here is the caller graph for this function:
|
inlineinherited |
Definition at line 126 of file RemoteContextServer.h.
References CPN::RemoteContextServer::debuglevel.
Definition at line 127 of file RemoteContextServer.h.
References CPN::RemoteContextServer::debuglevel.
|
protectedinherited |
Process the given message.
| sender | a string id for the client |
| msg | the message that the client sent |
Definition at line 49 of file RemoteContextServer.cc.
References ASSERT, CPN::RemoteContextServer::ConnectEndpoints(), CPN::RemoteContextServer::CreateNodeKey(), CPN::RemoteContextServer::dbprintf(), CPN::RemoteContextServer::GetCreateEndpointKey(), CPN::RemoteContextServer::GetEndpointInfo(), CPN::RemoteContextServer::GetKernelInfo(), CPN::RemoteContextServer::GetNodeInfo(), CPN::RemoteContextServer::GetNumNodeLive(), CPN::RemoteContextServer::IsTerminated(), CPN::RemoteContextServer::LogMessage(), CPN::RCTXMT_CONNECT_ENDPOINTS, CPN::RCTXMT_CREATE_NODE, CPN::RCTXMT_CREATE_NODE_KEY, CPN::RCTXMT_CREATE_QUEUE, CPN::RCTXMT_CREATE_READER, CPN::RCTXMT_CREATE_WRITER, CPN::RCTXMT_GET_CREATE_READER_KEY, CPN::RCTXMT_GET_CREATE_WRITER_KEY, CPN::RCTXMT_GET_KERNEL_INFO, CPN::RCTXMT_GET_NODE_INFO, CPN::RCTXMT_GET_NUM_NODE_LIVE, CPN::RCTXMT_GET_READER_INFO, CPN::RCTXMT_GET_WRITER_INFO, CPN::RCTXMT_LOG, CPN::RCTXMT_SETUP_KERNEL, CPN::RCTXMT_SIGNAL_KERNEL_END, CPN::RCTXMT_SIGNAL_KERNEL_START, CPN::RCTXMT_SIGNAL_NODE_END, CPN::RCTXMT_SIGNAL_NODE_START, CPN::RCTXMT_TERMINATE, CPN::RemoteContextServer::RouteKernelMessage(), CPN::RemoteContextServer::SetupKernel(), CPN::RemoteContextServer::SignalKernelEnd(), CPN::RemoteContextServer::SignalKernelStart(), CPN::RemoteContextServer::SignalNodeEnd(), CPN::RemoteContextServer::SignalNodeStart(), and CPN::RemoteContextServer::Terminate().
Here is the call graph for this function:
|
inlineinherited |
Definition at line 115 of file FileHandle.h.
References FileHandle::eof, and FileHandle::file_lock.
Referenced by CPN::RemoteQueue::EnqueuePacket(), CPN::RemoteContext::EntryPoint(), CPN::RemoteQueue::InternalCheckStatus(), CPN::RemoteContextDaemon::Client::Read(), and CPN::RemoteQueue::Read().
Here is the caller graph for this function:Set/reset the end of file condition.
| e | the new end of file condition |
Definition at line 120 of file FileHandle.h.
References FileHandle::eof, and FileHandle::file_lock.
|
inlineinherited |
Definition at line 106 of file FileHandle.h.
References FileHandle::fd, and FileHandle::file_lock.
Referenced by ServerSocketHandle::Accept(), CPN::RemoteContextDaemon::Client::Client(), SocketHandle::Connect(), CPN::ConnectionServer::ConnectWriter(), SocketHandle::CreatePair(), CPN::RemoteQueue::FileThreadEntryPoint(), FileHandle::Flush(), CPN::ConnectionServer::GetAddress(), SocketHandle::GetKeepAlive(), SocketHandle::GetLingerTimeout(), SocketHandle::GetNoDelay(), SocketHandle::GetPendingError(), SocketHandle::GetReceiveBufferSize(), SocketHandle::GetReceiveTimeout(), SocketHandle::GetSendBufferSize(), SocketHandle::GetSendTimeout(), FileHandle::IsBlocking(), ServerSocketHandle::Listen(), FileHandle::Poll(), Run(), FileHandle::SetBlocking(), SocketHandle::SetKeepAlive(), SocketHandle::SetLingerTimeout(), SocketHandle::SetNoDelay(), SocketHandle::SetReceiveBufferSize(), SocketHandle::SetReceiveTimeout(), SocketHandle::SetSendBufferSize(), SocketHandle::SetSendTimeout(), SocketHandle::ShutdownRead(), SocketHandle::ShutdownWrite(), and WakeupHandle::WakeupHandle().
Here is the caller graph for this function:Set the current file descriptor.
| filed | the new file descriptor |
Definition at line 111 of file FileHandle.h.
References FileHandle::fd, and FileHandle::file_lock.
|
inherited |
Tell the OS to flush any buffers it has. May not be supported for all file types.
Definition at line 293 of file FileHandle.cc.
References FileHandle::FD().
Here is the call graph for this function:
|
inlineinherited |
|
inlineinherited |
Convenience method for testing if the file this FileHandle has is open and not at end of file.
Definition at line 125 of file FileHandle.h.
References FileHandle::eof, FileHandle::fd, and FileHandle::file_lock.
Referenced by CPN::RemoteContext::EntryPoint(), and CPN::RemoteContextDaemon::Client::Read().
Here is the caller graph for this function:
|
inherited |
Test if the current file is in blocking or non blocking mode.
Definition at line 128 of file FileHandle.cc.
References FileHandle::FD().
Here is the call graph for this function:Test the given file descriptor if it is in blocking mode.
| fd | the file descriptor to test |
Definition at line 132 of file FileHandle.cc.
|
inlineinherited |
Definition at line 125 of file RemoteContextServer.h.
References CPN::RemoteContextServer::shutdown.
Referenced by BroadcastMessage(), CPN::RemoteContextServer::DispatchMessage(), Run(), SendMessage(), and Terminate().
Here is the caller graph for this function:
|
inherited |
Open a new socket and try to listen on the given SocketAddress.
Definition at line 30 of file ServerSocketHandle.cc.
Referenced by CPN::ConnectionServer::ConnectionServer(), ServerSocketHandle::Listen(), RemoteContextDaemon(), and ServerSocketHandle::ServerSocketHandle().
Here is the caller graph for this function:
|
inherited |
Open a new socket and try to listen on one of the addresses in the given list.
Definition at line 35 of file ServerSocketHandle.cc.
References ServerSocketHandle::Listen().
Here is the call graph for this function:
|
privatevirtual |
Log a message.
| msg | the message to be logged |
Implements CPN::RemoteContextServer.
Definition at line 138 of file RemoteContextDaemon.cc.
References CPN::RemoteContextServer::dbprintf().
Here is the call graph for this function:
|
inlineprotectedvirtualinherited |
Called by Poll when it detects that the file is readable.
Reimplemented in WakeupHandle.
Definition at line 210 of file FileHandle.h.
References FileHandle::Readable().
Referenced by FileHandle::Poll().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inlineprotectedvirtualinherited |
Called by Poll when it detects that the file is writeable.
Definition at line 212 of file FileHandle.h.
References FileHandle::Writeable().
Referenced by FileHandle::Poll().
Here is the call graph for this function:
Here is the caller graph for this function:
|
staticinherited |
poll a list of FileHandles for any activity and call the appropriate On method.
Definition at line 34 of file FileHandle.cc.
References FileHandle::FD(), FileHandle::fd, FileHandle::OnReadable(), FileHandle::OnWriteable(), FileHandle::Readable(), and FileHandle::Writeable().
Referenced by CPN::RemoteContext::EntryPoint(), CPN::RemoteQueue::FileThreadEntryPoint(), CPN::ConnectionServer::Poll(), FileHandle::Poll(), and Run().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inherited |
Poll the current file descriptor for activity specified by the current readable or writeable status, if false poll that value, and call one of OnWriteable or OnReadable whos default action is to set Readable or Writeable to true.
| timeout | -1 to wait forever for activity 0 to poll and return immediately or a time to wait in seconds. |
Definition at line 106 of file FileHandle.cc.
References FileHandle::Poll().
Here is the call graph for this function:
|
private |
Definition at line 104 of file RemoteContextDaemon.cc.
References ServerSocketHandle::Accept(), Client, clients, and FileHandle::Readable().
Referenced by Run().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inherited |
Read data from the file descriptor.
Will set the end of file condition if read detects end of file.
| ptr | pointer to write data to |
| len | the maximum number of bytes to write to ptr |
Definition at line 159 of file FileHandle.cc.
References FileHandle::eof, FileHandle::fd, FileHandle::file_lock, FileHandle::Readable(), and FileHandle::readable.
Referenced by CPN::RemoteQueue::D4RTagPacket(), and WakeupHandle::Read().
Here is the call graph for this function:
Here is the caller graph for this function:Set that the file is currently readable or not.
| r | true or false |
Definition at line 86 of file FileHandle.h.
References FileHandle::file_lock, and FileHandle::readable.
Referenced by CPN::RemoteContext::EntryPoint(), FileHandle::Poll(), CPN::ConnectionServer::Poll(), and CPN::RemoteQueue::Read().
Here is the caller graph for this function:
|
inlineinherited |
Gives the current readability status of the file.
Definition at line 91 of file FileHandle.h.
References FileHandle::file_lock, and FileHandle::readable.
Referenced by ServerSocketHandle::Accept(), CPN::RemoteContextDaemon::Client::Client(), FileHandle::OnReadable(), Read(), FileHandle::Read(), FileHandle::Readv(), SocketHandle::Recv(), Run(), and WakeupHandle::WakeupHandle().
Here is the caller graph for this function:
|
inherited |
scatter gather io version of Read
Definition at line 190 of file FileHandle.cc.
References FileHandle::eof, FileHandle::fd, FileHandle::file_lock, FileHandle::Readable(), and FileHandle::readable.
Referenced by CPN::RemoteQueue::EnqueuePacket().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inherited |
Clear all internal state including the file descriptor! WARNING does not close the file!
Definition at line 138 of file FileHandle.cc.
References FileHandle::eof, FileHandle::fd, FileHandle::file_lock, FileHandle::readable, and FileHandle::writeable.
Referenced by CPN::ConnectionServer::ConnectWriter(), CPN::RemoteQueue::FileThreadEntryPoint(), and FileHandle::~FileHandle().
Here is the caller graph for this function:| void CPN::RemoteContextDaemon::Run | ( | ) |
Run the actual Context returns when the context is terminated and all clients have disconnected.
Definition at line 45 of file RemoteContextDaemon.cc.
References clients, FileHandle::Closed(), CPN::RemoteContextServer::dbprintf(), FileHandle::FD(), SocketAddress::GetHostName(), SocketAddress::GetServName(), CPN::RemoteContextServer::IsTerminated(), FileHandle::Poll(), Read(), FileHandle::Readable(), SocketAddress::SetFromSockName(), and Terminate().
Here is the call graph for this function:
|
privatevirtual |
Send the given message to the given client.
| recipient | the id (previously used in DispatchMessage sender) |
| msg | the message to be sent to the client |
Implements CPN::RemoteContextServer.
Definition at line 113 of file RemoteContextDaemon.cc.
References ASSERT, clients, CPN::RemoteContextServer::dbprintf(), and CPN::RemoteContextServer::IsTerminated().
Here is the call graph for this function:
|
inherited |
Manipulate how the current file handles blocking.
| blocking | true to set to blocking mode (default) false to set to non blocking mode. |
In non blocking mode all reads and writes will not block. Use Poll to block.
Definition at line 111 of file FileHandle.cc.
References FileHandle::FD().
Referenced by WakeupHandle::WakeupHandle().
Here is the call graph for this function:
Here is the caller graph for this function:a convenience method that allows one to set the same blocking parameters for a file descriptor without setting it inside a FileHandle.
| fd | the file descriptor |
| blocking | true or false see SetBlock |
Definition at line 115 of file FileHandle.cc.
|
inlineinherited |
Turn on reuse of the address. Only takes effect if set before Listen.
Definition at line 70 of file ServerSocketHandle.h.
References ServerSocketHandle::reuse_addr.
Referenced by RemoteContextDaemon().
Here is the caller graph for this function:
|
privatevirtual |
Cause the context to go into the shutdown state.
Reimplemented from CPN::RemoteContextServer.
Definition at line 81 of file RemoteContextDaemon.cc.
References clients, FileHandle::Close(), CPN::RemoteContextServer::IsTerminated(), and CPN::RemoteContextServer::Terminate().
Referenced by Run().
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
Definition at line 99 of file RemoteContextDaemon.cc.
References clients, and CPN::RemoteContextServer::dbprintf().
Here is the call graph for this function:
|
inherited |
Write data to the file descriptor.
| ptr | pointer to beginning of data to write |
| len | length of data to write |
Definition at line 225 of file FileHandle.cc.
References FileHandle::fd, FileHandle::file_lock, and FileHandle::Writeable().
Referenced by CPN::ConnectionServer::ConnectWriter(), CPN::RemoteContextDaemon::Client::Send(), CPN::RemoteContext::SendMessage(), and CPN::RemoteQueue::WriteBytes().
Here is the call graph for this function:
Here is the caller graph for this function:Set that this file is currently writeable or not.
| w | true or false |
Definition at line 97 of file FileHandle.h.
References FileHandle::file_lock, and FileHandle::writeable.
Referenced by FileHandle::Poll().
Here is the caller graph for this function:
|
inlineinherited |
Gives the current writability status of the file.
Definition at line 102 of file FileHandle.h.
References FileHandle::file_lock, and FileHandle::writeable.
Referenced by FileHandle::OnWriteable(), SocketHandle::Send(), WakeupHandle::WakeupHandle(), FileHandle::Write(), and FileHandle::Writev().
Here is the caller graph for this function:
|
inherited |
scatter gather io version of Write
Definition at line 261 of file FileHandle.cc.
References FileHandle::fd, FileHandle::file_lock, and FileHandle::Writeable().
Referenced by CPN::RemoteQueue::WriteBytes().
Here is the call graph for this function:
Here is the caller graph for this function:
|
friend |
Definition at line 73 of file RemoteContextDaemon.h.
Referenced by Read().
|
private |
Definition at line 77 of file RemoteContextDaemon.h.
Referenced by BroadcastMessage(), Read(), Run(), SendMessage(), and Terminate().
|
protectedinherited |
Definition at line 217 of file FileHandle.h.
Referenced by FileHandle::Close(), FileHandle::Eof(), FileHandle::Good(), FileHandle::Read(), FileHandle::Readv(), SocketHandle::Recv(), and FileHandle::Reset().
|
protectedinherited |
Definition at line 214 of file FileHandle.h.
Referenced by FileHandle::Close(), FileHandle::Closed(), FileHandle::FD(), FileHandle::Good(), FileHandle::Poll(), FileHandle::Read(), FileHandle::Readv(), SocketHandle::Recv(), FileHandle::Reset(), SocketHandle::Send(), FileHandle::Write(), FileHandle::Writev(), and FileHandle::~FileHandle().
|
mutableprotectedinherited |
Definition at line 213 of file FileHandle.h.
Referenced by FileHandle::Close(), FileHandle::Closed(), FileHandle::Eof(), FileHandle::FD(), FileHandle::Good(), FileHandle::Read(), FileHandle::Readable(), FileHandle::Readv(), SocketHandle::Recv(), FileHandle::Reset(), SocketHandle::Send(), WakeupHandle::SendWakeup(), FileHandle::Write(), FileHandle::Writeable(), and FileHandle::Writev().
|
protectedinherited |
Definition at line 215 of file FileHandle.h.
Referenced by FileHandle::Close(), FileHandle::Read(), FileHandle::Readable(), FileHandle::Readv(), SocketHandle::Recv(), and FileHandle::Reset().
|
protectedinherited |
Definition at line 216 of file FileHandle.h.
Referenced by FileHandle::Close(), FileHandle::Reset(), and FileHandle::Writeable().
1.8.5