Equalizer
1.2.1
|
Specialization of a local node. More...
#include <localNode.h>
Classes | |
class | CommandThread |
The command handler thread. | |
class | ReceiverThread |
The receiver thread. | |
Public Member Functions | |
CO_API void | ackRequest (NodePtr node, const uint32_t requestID) |
CO_API void | ping (NodePtr remoteNode) |
Request keep-alive update from the remote node. | |
CO_API bool | pingIdleNodes () |
Request updates from all nodes above keep-alive timeout. | |
State Changes | |
The following methods affect the state of the node by changing its connectivity to the network. | |
virtual CO_API bool | initLocal (const int argc, char **argv) |
Initialize the node. | |
virtual CO_API bool | listen () |
Open all connections and put this node into the listening state. | |
virtual CO_API bool | listen (ConnectionPtr connection) |
virtual CO_API bool | close () |
Close a listening node. | |
virtual bool | exitLocal () |
Close a listening node. | |
CO_API bool | connect (NodePtr node) |
Connect a proxy node to this listening node. | |
CO_API NodePtr | connect (const NodeID &nodeID) |
Create and connect a node given by an identifier. | |
virtual CO_API bool | disconnect (NodePtr node) |
Disconnects a connected node. | |
Object Registry | |
CO_API void | disableInstanceCache () |
Disable the instance cache of a stopped local node. | |
CO_API void | expireInstanceData (const int64_t age) |
CO_API void | enableSendOnRegister () |
Enable sending instance data after registration. | |
CO_API void | disableSendOnRegister () |
Disable sending data of newly registered objects when idle. | |
CO_API bool | registerObject (Object *object) |
Register a distributed object. | |
virtual CO_API void | deregisterObject (Object *object) |
Deregister a distributed object. | |
CO_API bool | mapObject (Object *object, const base::UUID &id, const uint128_t &version=VERSION_OLDEST) |
Map a distributed object. | |
bool | mapObject (Object *object, const ObjectVersion &v) |
Convenience wrapper for mapObject(). | |
CO_API uint32_t | mapObjectNB (Object *object, const base::UUID &id, const uint128_t &version=VERSION_OLDEST) |
Start mapping a distributed object. | |
CO_API uint32_t | mapObjectNB (Object *object, const base::UUID &id, const uint128_t &version, NodePtr master) |
Start mapping a distributed object from a known master. | |
CO_API bool | mapObjectSync (const uint32_t requestID) |
Finalize the mapping of a distributed object. | |
CO_API void | unmapObject (Object *object) |
Unmap a mapped object. | |
CO_API void | releaseObject (Object *object) |
Convenience method to deregister or unmap an object. | |
virtual CO_API void | objectPush (const uint128_t &groupID, const uint128_t &typeID, const uint128_t &objectID, DataIStream &istream) |
Handler for an Object::push operation. | |
CO_API void | swapObject (Object *oldObject, Object *newObject) |
Data Access | |
CO_API NodePtr | getNode (const NodeID &id) const |
Get a node by identifier. | |
void | getNodes (Nodes &nodes, const bool addSelf=true) const |
Assemble a vector of the currently connected nodes. | |
CO_API SendToken | acquireSendToken (NodePtr toNode) |
Acquire a singular send token from the given node. | |
CO_API void | releaseSendToken (SendToken &token) |
CommandQueue * | getCommandThreadQueue () |
Return the command queue to the command thread. | |
bool | inCommandThread () const |
int64_t | getTime64 () |
Operations | |
CO_API void | addListener (ConnectionPtr connection) |
Add a listening connection to this listening node. | |
CO_API uint32_t | removeListenerNB (ConnectionPtr connection) |
Remove a listening connection from this listening node. | |
void | flushCommands () |
Flush all pending commands on this listening node. | |
Command & | cloneCommand (Command &command) |
CO_API Command & | allocCommand (const uint64_t size) |
CO_API bool | dispatchCommand (Command &command) |
Dispatches a packet to the registered command queue. | |
Public Types | |
typedef NodePtr | SendToken |
An acquired send token. | |
Protected Member Functions | |
CO_API bool | connect (NodePtr node, ConnectionPtr connection) |
Connect a node proxy to this node. | |
virtual void | notifyDisconnect (NodePtr node) |
Notify remote node disconnection. | |
Friends | |
class | ObjectStore |
Specialization of a local node.
Local nodes listen on network connections, manage connections to other nodes and provide session registration, mapping and command dispatch.
Definition at line 47 of file localNode.h.
CO_API SendToken co::LocalNode::acquireSendToken | ( | NodePtr | toNode | ) |
Acquire a singular send token from the given node.
CO_API void co::LocalNode::addListener | ( | ConnectionPtr | connection | ) |
Add a listening connection to this listening node.
virtual CO_API bool co::LocalNode::close | ( | ) | [virtual] |
Close a listening node.
Disconnects all connected node proxies, closes the listening connections and terminates all threads created in listen().
true
if the node was stopped, false
if it was not stopped. Referenced by exitLocal().
CO_API bool co::LocalNode::connect | ( | NodePtr | node | ) |
Connect a proxy node to this listening node.
The connection descriptions of the node are used to connect the node. On success, the node is in the connected state, otherwise its state is unchanged.
This method is one-sided, that is, the node to be connected should not initiate a connection to this node at the same time. For concurrent connects use the other connect() method using node identifiers.
node | the remote node. |
CO_API NodePtr co::LocalNode::connect | ( | const NodeID & | nodeID | ) |
Create and connect a node given by an identifier.
This method is two-sided and thread-safe, that is, it can be called by multiple threads on the same node with the same nodeID, or concurrently on two nodes with each others' nodeID.
nodeID | the identifier of the node to connect. |
CO_API bool co::LocalNode::connect | ( | NodePtr | node, |
ConnectionPtr | connection | ||
) | [protected] |
Connect a node proxy to this node.
This node has to be in the listening state. The node proxy will be put in the connected state upon success. The connection has to be connected.
node | the remote node. |
connection | the connection to the remote node. |
true
if the node was connected correctly, false
otherwise. virtual CO_API void co::LocalNode::deregisterObject | ( | Object * | object | ) | [virtual] |
Deregister a distributed object.
object | the object instance. |
CO_API void co::LocalNode::disableInstanceCache | ( | ) |
Disable the instance cache of a stopped local node.
CO_API void co::LocalNode::disableSendOnRegister | ( | ) |
Disable sending data of newly registered objects when idle.
virtual CO_API bool co::LocalNode::disconnect | ( | NodePtr | node | ) | [virtual] |
Disconnects a connected node.
node | the remote node. |
true
if the node was disconnected correctly, false
otherwise. CO_API bool co::LocalNode::dispatchCommand | ( | Command & | command | ) | [virtual] |
Dispatches a packet to the registered command queue.
command | the command. |
Reimplemented from co::Dispatcher.
Reimplemented in eq::fabric::Client.
CO_API void co::LocalNode::enableSendOnRegister | ( | ) |
Enable sending instance data after registration.
Send-on-register starts transmitting instance data of registered objects directly after they have been registered. The data is cached on remote nodes and accelerates object mapping. Send-on-register should not be active when remote nodes are joining a multicast group of this node, since they will potentially read out-of-order data streams on the multicast connection.
Enable and disable are counted, that is, the last enable on a matched series of disable/enable will be effective. The disable is completely synchronous, that is, no more instance data will be sent after the first disable.
virtual bool co::LocalNode::exitLocal | ( | ) | [inline, virtual] |
Close a listening node.
Reimplemented in eq::Client.
Definition at line 114 of file localNode.h.
References close().
void co::LocalNode::flushCommands | ( | ) | [inline] |
Flush all pending commands on this listening node.
This causes the receiver thread to redispatch all pending commands, which are normally only redispatched when a new command is received.
Definition at line 346 of file localNode.h.
References co::ConnectionSet::interrupt().
CommandQueue* co::LocalNode::getCommandThreadQueue | ( | ) | [inline] |
Return the command queue to the command thread.
Definition at line 319 of file localNode.h.
CO_API NodePtr co::LocalNode::getNode | ( | const NodeID & | id | ) | const |
Get a node by identifier.
The node might not be connected.
id | the node identifier. |
void co::LocalNode::getNodes | ( | Nodes & | nodes, |
const bool | addSelf = true |
||
) | const |
Assemble a vector of the currently connected nodes.
bool co::LocalNode::inCommandThread | ( | ) | const [inline] |
Definition at line 326 of file localNode.h.
virtual CO_API bool co::LocalNode::initLocal | ( | const int | argc, |
char ** | argv | ||
) | [virtual] |
Initialize the node.
Parses the following command line options and calls listen() afterwards:
The '--eq-listen <connection description>' command line option is parsed by this method to add listening connections to this node. This parameter might be used multiple times. ConnectionDescription::fromString() is used to parse the provided description.
The '--co-globals <string>' option is used to initialize the Globals. The string is parsed used Globals::fromString().
Please note that further command line parameters are recognized by co::init().
argc | the command line argument count. |
argv | the command line argument values. |
true
if the client was successfully initialized, false
otherwise. Reimplemented in eq::Client.
virtual CO_API bool co::LocalNode::listen | ( | ) | [virtual] |
Open all connections and put this node into the listening state.
The node will spawn a receiver and command thread, and listen on all connections for incoming commands. The node will be in the listening state if the method completed successfully. A listening node can connect other nodes.
true
if the node could be initialized, false
if not. CO_API bool co::LocalNode::mapObject | ( | Object * | object, |
const base::UUID & | id, | ||
const uint128_t & | version = VERSION_OLDEST |
||
) |
Map a distributed object.
The mapped object becomes a slave instance of the master version which was registered with the provided identifier. The given version can be used to map a specific version.
If VERSION_NONE is provided, the slave instance is not initialized with any data from the master. This is useful if the object has been pre-initialized by other means, for example from a shared file system.
If VERSION_OLDEST is provided, the oldest available version is mapped.
If a concrete requested version no longer exists, mapObject() will map the oldest available version.
If the requested version is newer than the head version, mapObject() will block until the requested version is available.
Mapping an object is a potentially time-consuming operation. Using mapObjectNB() and mapObjectSync() to asynchronously map multiple objects in parallel improves performance of this operation.
object | the object. |
id | the master object identifier. |
version | the initial version. |
bool co::LocalNode::mapObject | ( | Object * | object, |
const ObjectVersion & | v | ||
) | [inline] |
Convenience wrapper for mapObject().
Definition at line 241 of file localNode.h.
References mapObject().
Referenced by mapObject().
CO_API uint32_t co::LocalNode::mapObjectNB | ( | Object * | object, |
const base::UUID & | id, | ||
const uint128_t & | version = VERSION_OLDEST |
||
) |
Start mapping a distributed object.
Referenced by eqPly::VertexBufferDist::applyInstanceData().
CO_API uint32_t co::LocalNode::mapObjectNB | ( | Object * | object, |
const base::UUID & | id, | ||
const uint128_t & | version, | ||
NodePtr | master | ||
) |
Start mapping a distributed object from a known master.
CO_API bool co::LocalNode::mapObjectSync | ( | const uint32_t | requestID | ) |
Finalize the mapping of a distributed object.
Referenced by eqPly::VertexBufferDist::applyInstanceData().
virtual CO_API void co::LocalNode::objectPush | ( | const uint128_t & | groupID, |
const uint128_t & | typeID, | ||
const uint128_t & | objectID, | ||
DataIStream & | istream | ||
) | [virtual] |
Handler for an Object::push operation.
Called at least on each node listed in an Object::push upon reception of the pushed data from the command thread. Called on all nodes of a multicast group, even on nodes not listed in the Object::push.
The default implementation is empty. Typically used to create an Object on a remote node, using the typeID for instantiation, the istream to initialize it and the objectID to map it using VERSION_NONE. The groupID may be used to differentiate multiple concurrent push operations.
groupID | The group identifier given to Object::push() |
typeID | The type identifier given to Object::push() |
objectID | The identifier of the pushed object |
istream | the input data stream containing the instance data. |
CO_API void co::LocalNode::ping | ( | NodePtr | remoteNode | ) |
Request keep-alive update from the remote node.
CO_API bool co::LocalNode::pingIdleNodes | ( | ) |
Request updates from all nodes above keep-alive timeout.
CO_API bool co::LocalNode::registerObject | ( | Object * | object | ) |
Register a distributed object.
Registering a distributed object makes this object the master version. The object's identifier is used to map slave instances of the object. Master versions of objects are typically writable and can commit new versions of the distributed object.
object | the object instance. |
CO_API void co::LocalNode::releaseObject | ( | Object * | object | ) |
Convenience method to deregister or unmap an object.
CO_API uint32_t co::LocalNode::removeListenerNB | ( | ConnectionPtr | connection | ) |
Remove a listening connection from this listening node.
CO_API void co::LocalNode::unmapObject | ( | Object * | object | ) |
Unmap a mapped object.
object | the mapped object. |