VR-Exchange 2.9 API Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Types | Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Private Member Functions
MAKVrExchange::DtQueueManager Class Reference

A DtQueueManager is responsible for creating and deleting all Shared memory Queues used by the portal. More...

Public Types

typedef void(* MessageCbFcn )(const DtPortalMessage &message, void *usr)
 

Public Member Functions

 DtQueueManager (DtU32 numberOfBucketsInQueue, DtU32 payloadSizePerBucket, int port, DtU16 brokerId, const DtString &objectQueueName, const DtString &interactionQueueName, const DtString &controlQueueName)
 The Default CTOR to create a DtQueueManager. More...
 
virtual ~DtQueueManager ()
 Destructor. More...
 
virtual void send (DtPortalControlMessage &message, bool global=false)
 
virtual void tick ()
 This class must be periodically ticked, no messages are read however, the queues are just drained. More...
 
virtual void requestBrokerShutdown ()
 Sends out a message asking all brokers to exit. More...
 
virtual void requestBrokerRestart (bool shouldMapMessagesOneToOne)
 Sends out a message asking all running brokers to restart. More...
 
virtual void brokerShutdownNotification (DtU32 brokerId)
 Used to report that a broker has reported that it is shutting down. More...
 
virtual int connectedBrokerCount ()
 Returns the number of known connected brokers. More...
 
virtual void pruneBrokerSocketMap ()
 This is called after a requestBrokerShutdown() call to prune dead brokers from the internal counter. More...
 
void processBrokerConnect (const DtBrokerStartedMessage &msg)
 
Message Queue Accessors

The following functions allow access to the individual message queues

virtual
DtSubscribableMessageQueue
getControlMessageQueue ()
 
virtual
DtSubscribableMessageQueue
getInteractionMessageQueue ()
 
virtual
DtSubscribableMessageQueue
getObjectMessageQueue ()
 

Static Public Member Functions

static DtQueueManagercreate (DtU32 numberOfBucketsInQueue, DtU32 payloadSizePerBucket, int port, DtU16 theBrokerId, const DtString &objectQueueName, const DtString &interactionQueueName, const DtString &controlQueueName)
 A static function to create a Queue Manager. More...
 

Protected Types

typedef std::set< DtU32 > BrokerShutdownNotificationSet
 
typedef std::map< int,
DtInetTcpSocket * > 
BrokerSocketMap
 
typedef std::map
< DtInetTcpSocket *, int > 
UnknownSocketMap
 
typedef std::map< int, int > BrokerIdTypeMap
 

Protected Member Functions

virtual void addSocket (DtInetTcpSocket *sock)
 adds a socket to the unknown list More...
 
virtual void removeSocket (DtInetTcpSocket *sock)
 removes knowledge of a socket cleanly More...
 
virtual void removeUnknownSocket (DtInetTcpSocket *sock)
 Removes socket from unknown list. More...
 
virtual void processUnknownSockets ()
 tries to move sockets from the unknown list to the known list, by attempting to read the broker Id from the socket More...
 
virtual void testKnownSockets ()
 tests if the known sockets are still connected. More...
 
void drainSockets ()
 Drains all known sockets so that we don't have memory leaks, or sockets that fill up. More...
 
virtual DtU8 getUnusedBrokerID ()
 

Static Protected Member Functions

static void getLicFilesInDir (const std::string &dir, std::list< std::string > &files)
 
static void searchForLicFile ()
 
static bool addSocketCb (DtInetSocket *sock, void *usr)
 
static bool removeSocketCb (DtInetSocket *sock, void *usr)
 

Protected Attributes

const DtU16 myBrokerId
 
DtU32 myControlSerialNumber
 
int myTickCountForSocketTest
 
int myTicksBeforeSocketTest
 
DtPortalMessageFactory myMessageFactory
 
DtMemoryManager myMemoryManager
 
DtSubscribableMessageQueuemyControlMessageQueue
 
DtSubscribableMessageQueuemyInteractionMessageQueue
 
DtSubscribableMessageQueuemyObjectMessageQueue
 
DtInetSocketMgr * myTcpSocketManager
 
DtClock myClock
 
DtTime myLastHeartbeatTime
 
BrokerShutdownNotificationSet myBrokerShutdownNotifications
 
BrokerSocketMap myBrokerSocketMap
 
UnknownSocketMap myUnknownBrokerSocketList
 
BrokerIdTypeMap myBrokerIdTypeMap
 

Private Member Functions

 DtQueueManager (const DtQueueManager &other)
 Copy Ctor Not implemented – Class Not Copyable. More...
 
DtQueueManageroperator= (const DtQueueManager &other)
 Assignment Operator Not implemented – Class Not Copyable. More...
 

Detailed Description

A DtQueueManager is responsible for creating and deleting all Shared memory Queues used by the portal.

The portal must run one instance of the DtQueueManager. This class is responsible for creating and initializing all shared memory message queues used by the MAK Portal. When the instance is destroyed it will send a message to shutdown all brokers, and clean up the queues It also maintains a TCP Socket connection to all the brokers, which can monitor the Socket for a shutdown of the DtQueueManager, or vice versa

Member Typedef Documentation

typedef std::map<int, int> MAKVrExchange::DtQueueManager::BrokerIdTypeMap
protected
typedef std::map<int,DtInetTcpSocket*> MAKVrExchange::DtQueueManager::BrokerSocketMap
protected
typedef void(* MAKVrExchange::DtQueueManager::MessageCbFcn)(const DtPortalMessage &message, void *usr)
typedef std::map<DtInetTcpSocket*,int> MAKVrExchange::DtQueueManager::UnknownSocketMap
protected

Constructor & Destructor Documentation

MAKVrExchange::DtQueueManager::DtQueueManager ( DtU32  numberOfBucketsInQueue,
DtU32  payloadSizePerBucket,
int  port,
DtU16  brokerId,
const DtString objectQueueName,
const DtString interactionQueueName,
const DtString controlQueueName 
)

The Default CTOR to create a DtQueueManager.

Parameters
port- the port to listen for brokers on if set to 0 then no port will be opened. The portal will still work, but brokers will not be able to know if the portal has died
virtual MAKVrExchange::DtQueueManager::~DtQueueManager ( )
virtual

Destructor.

The destructor will send a message to shutdown all brokers, then pause for one second to give them time to exit. If the user wants a more orderly shutdown the functions requestBrokerShutdown(), connectedBrokerCount() and pruneBrokerSocketMap() should be used.

MAKVrExchange::DtQueueManager::DtQueueManager ( const DtQueueManager other)
private

Copy Ctor Not implemented – Class Not Copyable.

Member Function Documentation

virtual void MAKVrExchange::DtQueueManager::addSocket ( DtInetTcpSocket *  sock)
protectedvirtual

adds a socket to the unknown list

static bool MAKVrExchange::DtQueueManager::addSocketCb ( DtInetSocket *  sock,
void *  usr 
)
staticprotected
virtual void MAKVrExchange::DtQueueManager::brokerShutdownNotification ( DtU32  brokerId)
virtual

Used to report that a broker has reported that it is shutting down.

Queue manager uses this to differentiate between expected and unexpected disconnects.

virtual int MAKVrExchange::DtQueueManager::connectedBrokerCount ( )
virtual

Returns the number of known connected brokers.

This can be called after requestBrokerShutdown() to determine if any brokers have actualy shutdown. A count of zero indicates no connected brokers. The user must be sure all shutdown sockets are properly cleaned by calling pruneBrokerSocketMap() before calling connectedBrokerCount().

static DtQueueManager* MAKVrExchange::DtQueueManager::create ( DtU32  numberOfBucketsInQueue,
DtU32  payloadSizePerBucket,
int  port,
DtU16  theBrokerId,
const DtString objectQueueName,
const DtString interactionQueueName,
const DtString controlQueueName 
)
static

A static function to create a Queue Manager.

void MAKVrExchange::DtQueueManager::drainSockets ( )
protected

Drains all known sockets so that we don't have memory leaks, or sockets that fill up.

This discards all info, and should be called AFTER processUnknownSockets.

virtual DtSubscribableMessageQueue* MAKVrExchange::DtQueueManager::getControlMessageQueue ( )
inlinevirtual
virtual DtSubscribableMessageQueue* MAKVrExchange::DtQueueManager::getInteractionMessageQueue ( )
inlinevirtual
static void MAKVrExchange::DtQueueManager::getLicFilesInDir ( const std::string &  dir,
std::list< std::string > &  files 
)
staticprotected
virtual DtSubscribableMessageQueue* MAKVrExchange::DtQueueManager::getObjectMessageQueue ( )
inlinevirtual
virtual DtU8 MAKVrExchange::DtQueueManager::getUnusedBrokerID ( )
protectedvirtual
DtQueueManager& MAKVrExchange::DtQueueManager::operator= ( const DtQueueManager other)
private

Assignment Operator Not implemented – Class Not Copyable.

void MAKVrExchange::DtQueueManager::processBrokerConnect ( const DtBrokerStartedMessage msg)
virtual void MAKVrExchange::DtQueueManager::processUnknownSockets ( )
protectedvirtual

tries to move sockets from the unknown list to the known list, by attempting to read the broker Id from the socket

virtual void MAKVrExchange::DtQueueManager::pruneBrokerSocketMap ( )
virtual

This is called after a requestBrokerShutdown() call to prune dead brokers from the internal counter.

This must be called to insure connectedBrokerCount() is valid.

virtual void MAKVrExchange::DtQueueManager::removeSocket ( DtInetTcpSocket *  sock)
protectedvirtual

removes knowledge of a socket cleanly

static bool MAKVrExchange::DtQueueManager::removeSocketCb ( DtInetSocket *  sock,
void *  usr 
)
staticprotected
virtual void MAKVrExchange::DtQueueManager::removeUnknownSocket ( DtInetTcpSocket *  sock)
protectedvirtual

Removes socket from unknown list.

virtual void MAKVrExchange::DtQueueManager::requestBrokerRestart ( bool  shouldMapMessagesOneToOne)
virtual

Sends out a message asking all running brokers to restart.

Called when a portal setting changes that requires all brokers to restart in order to take change into effect. Takes argument about whether restarted broker should use one to one mapping

virtual void MAKVrExchange::DtQueueManager::requestBrokerShutdown ( )
virtual

Sends out a message asking all brokers to exit.

Called from destructor but may also be called at anytime. Exit from this call does not mean that all brokers have shut down.

static void MAKVrExchange::DtQueueManager::searchForLicFile ( )
staticprotected
virtual void MAKVrExchange::DtQueueManager::send ( DtPortalControlMessage message,
bool  global = false 
)
virtual
virtual void MAKVrExchange::DtQueueManager::testKnownSockets ( )
protectedvirtual

tests if the known sockets are still connected.

If not, it sends a message to the control queue of a broker failure

virtual void MAKVrExchange::DtQueueManager::tick ( )
virtual

This class must be periodically ticked, no messages are read however, the queues are just drained.

Member Data Documentation

const DtU16 MAKVrExchange::DtQueueManager::myBrokerId
protected
BrokerIdTypeMap MAKVrExchange::DtQueueManager::myBrokerIdTypeMap
protected
BrokerShutdownNotificationSet MAKVrExchange::DtQueueManager::myBrokerShutdownNotifications
protected
BrokerSocketMap MAKVrExchange::DtQueueManager::myBrokerSocketMap
protected
DtClock MAKVrExchange::DtQueueManager::myClock
protected
DtSubscribableMessageQueue* MAKVrExchange::DtQueueManager::myControlMessageQueue
protected
DtU32 MAKVrExchange::DtQueueManager::myControlSerialNumber
protected
DtSubscribableMessageQueue* MAKVrExchange::DtQueueManager::myInteractionMessageQueue
protected
DtTime MAKVrExchange::DtQueueManager::myLastHeartbeatTime
protected
DtMemoryManager MAKVrExchange::DtQueueManager::myMemoryManager
protected
DtPortalMessageFactory MAKVrExchange::DtQueueManager::myMessageFactory
protected
DtSubscribableMessageQueue* MAKVrExchange::DtQueueManager::myObjectMessageQueue
protected
DtInetSocketMgr* MAKVrExchange::DtQueueManager::myTcpSocketManager
protected
int MAKVrExchange::DtQueueManager::myTickCountForSocketTest
protected
int MAKVrExchange::DtQueueManager::myTicksBeforeSocketTest
protected
UnknownSocketMap MAKVrExchange::DtQueueManager::myUnknownBrokerSocketList
protected

The documentation for this class was generated from the following file:

Document ID: Generated on Tue Jun 25 16:45:35 EDT 2024 from SVN revision 267383
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)