#include <omniEventsLog.h>
Collaboration diagram for OmniEvents::omniEventsLog:

Public Member Functions | |
| omniEventsLog (const char *logdir=NULL) | |
| virtual | ~omniEventsLog () |
| bool | fileExists (const char *filename) const |
| const char * | activeFilename () const |
| const char * | backupFilename () const |
| PersistNode * | bootstrap (int port, const char *endPointNoListen) |
| Creates an initialState from its arguments. | |
| virtual PersistNode * | parse () |
| Creates an initialState from the logfile. | |
| void | incarnateFactory (PersistNode *initialState) |
| Constructs the EventChannelFactory from the information in the initialState parameter. | |
| virtual void | runWorker () |
| Kicks off the worker thread that periodically checkpoints the persistency logfile. | |
| EventChannelFactory_i * | factory () |
| accessor method | |
| void | checkpoint (void) |
| Entry point used by the omniEventsLogWorker to perform checkpointing. | |
| virtual void | output (ostream &os) |
Static Public Member Functions | |
| static bool | exists () |
| Library code may create Event Service objects without the need for persistency. | |
Protected Member Functions | |
| virtual void | initializeFileNames (const char *logdir) |
| Sets the values of 'active', 'backup' and 'checkpoint' file names. | |
| void | setFilename (char *&filename, const char *logdir, const char *sep, const char *logname, const char *hostname, const char *ext) |
| Helper function that sets the value of the first parameter to the concatenation of all the subsequent parameters. | |
| virtual void | openOfstream (ofstream &s, const char *filename, int flags=0, int *fd=NULL) |
| Helper method that opens an output file stream using whatever method is available. | |
Private Attributes | |
| ofstream | _logstream |
| char * | _activeFilename |
| char * | _backupFilename |
| char * | _checkpointFilename |
| omni_thread * | _workerThread |
| In charge of checkpoints. | |
| EventChannelFactory_i * | _factory |
| bool | _checkpointNeeded |
| omni_mutex | _lock |
Static Private Attributes | |
| static omniEventsLog * | theLog = NULL |
Friends | |
| class | WriteLock |
Classes | |
| class | IOError |
Definition at line 131 of file omniEventsLog.h.
| OmniEvents::omniEventsLog::omniEventsLog | ( | const char * | logdir = NULL |
) |
| OmniEvents::omniEventsLog::~omniEventsLog | ( | ) | [virtual] |
| const char* OmniEvents::omniEventsLog::activeFilename | ( | ) | const [inline] |
| const char* OmniEvents::omniEventsLog::backupFilename | ( | ) | const [inline] |
| PersistNode * OmniEvents::omniEventsLog::bootstrap | ( | int | port, | |
| const char * | endPointNoListen | |||
| ) |
Creates an initialState from its arguments.
Used when the server is cold started with no saved state. Aborts with an error if there are any logfiles in the log directory.
Definition at line 305 of file omniEventsLog.cc.
References OmniEvents::PersistNode::addattr(), and OmniEvents::PersistNode::addnode().
| void OmniEvents::omniEventsLog::checkpoint | ( | void | ) |
Entry point used by the omniEventsLogWorker to perform checkpointing.
The active logfile is moved to backup, and a new active logfile is created.
Definition at line 413 of file omniEventsLog.cc.
References _activeFilename, _backupFilename, _checkpointFilename, _checkpointNeeded, _lock, _logstream, DB, mutex, OMNIEVENTS_LOG_CHECKPOINT_PERIOD, openOfstream(), output(), OmniEvents::timestamp::t(), and OmniEvents::ts.
Referenced by runWorker().
| static bool OmniEvents::omniEventsLog::exists | ( | ) | [inline, static] |
Library code may create Event Service objects without the need for persistency.
We use this method to check for the log object, before attempting to write out state changes.
Definition at line 138 of file omniEventsLog.h.
References theLog.
Referenced by OmniEvents::ProxyPushSupplier_i::callback(), OmniEvents::ProxyPushConsumer_i::Connection::callback(), OmniEvents::ProxyPullSupplier_i::connect_pull_consumer(), OmniEvents::ProxyPullConsumer_i::connect_pull_supplier(), OmniEvents::ProxyPushSupplier_i::connect_push_consumer(), OmniEvents::ProxyPushConsumer_i::connect_push_supplier(), OmniEvents::ProxyPushConsumer_i::disconnect_push_consumer(), OmniEvents::Proxy::eraseKey(), and OmniEvents::EventChannel_i::run().
| EventChannelFactory_i* OmniEvents::omniEventsLog::factory | ( | ) | [inline] |
| bool OmniEvents::omniEventsLog::fileExists | ( | const char * | filename | ) | const |
Definition at line 298 of file omniEventsLog.cc.
References STRUCT_STAT.
Referenced by incarnateFactory(), and parse().
| void OmniEvents::omniEventsLog::incarnateFactory | ( | PersistNode * | initialState | ) |
Constructs the EventChannelFactory from the information in the initialState parameter.
Definition at line 360 of file omniEventsLog.cc.
References _activeFilename, _factory, _logstream, OmniEvents::PersistNode::child(), fileExists(), OMNIEVENTS_LOGDIR_ENV_VAR, and openOfstream().
| void OmniEvents::omniEventsLog::initializeFileNames | ( | const char * | logdir | ) | [protected, virtual] |
Sets the values of 'active', 'backup' and 'checkpoint' file names.
The files are placed in the log file directory, that is specified by:
The current hostname is incorporated into the file names.
Definition at line 591 of file omniEventsLog.cc.
References _activeFilename, _backupFilename, _checkpointFilename, gethostname(), MAXHOSTNAMELEN, OMNIEVENTS_LOG_DEFAULT_LOCATION, OMNIEVENTS_LOGDIR_ENV_VAR, setFilename(), and VMS_SEMICOLON.
Referenced by omniEventsLog().
| void OmniEvents::omniEventsLog::openOfstream | ( | ofstream & | s, | |
| const char * | filename, | |||
| int | flags = 0, |
|||
| int * | fd = NULL | |||
| ) | [protected, virtual] |
Helper method that opens an output file stream using whatever method is available.
Available flags are:
| s | reference to the ofstream object. | |
| filename | the name of the file to open. | |
| flags | see description for available mode flags. | |
| fd | reference to a file descriptor. If used, this parameter is set to the fd that was opened, if any. |
Definition at line 665 of file omniEventsLog.cc.
Referenced by checkpoint(), and incarnateFactory().
| void OmniEvents::omniEventsLog::output | ( | ostream & | os | ) | [virtual] |
Definition at line 406 of file omniEventsLog.cc.
References _factory, and OmniEvents::EventChannelFactory_i::output().
Referenced by checkpoint().
| PersistNode * OmniEvents::omniEventsLog::parse | ( | ) | [virtual] |
Creates an initialState from the logfile.
Used when the server is warm started. Aborts with an error if there is no logfile in the log directory.
Definition at line 318 of file omniEventsLog.cc.
References _activeFilename, _backupFilename, OmniEvents::PersistNode::attrLong(), OmniEvents::PersistNode::child(), and fileExists().
| void OmniEvents::omniEventsLog::runWorker | ( | ) | [virtual] |
Kicks off the worker thread that periodically checkpoints the persistency logfile.
Definition at line 394 of file omniEventsLog.cc.
References _factory, _workerThread, and checkpoint().
| void OmniEvents::omniEventsLog::setFilename | ( | char *& | filename, | |
| const char * | logdir, | |||
| const char * | sep, | |||
| const char * | logname, | |||
| const char * | hostname, | |||
| const char * | ext | |||
| ) | [protected] |
Helper function that sets the value of the first parameter to the concatenation of all the subsequent parameters.
| filename | OUT parameter. |
Definition at line 641 of file omniEventsLog.cc.
Referenced by initializeFileNames().
friend class WriteLock [friend] |
Definition at line 212 of file omniEventsLog.h.
char* OmniEvents::omniEventsLog::_activeFilename [private] |
Definition at line 204 of file omniEventsLog.h.
Referenced by activeFilename(), checkpoint(), incarnateFactory(), initializeFileNames(), and parse().
char* OmniEvents::omniEventsLog::_backupFilename [private] |
Definition at line 205 of file omniEventsLog.h.
Referenced by backupFilename(), checkpoint(), initializeFileNames(), and parse().
char* OmniEvents::omniEventsLog::_checkpointFilename [private] |
Definition at line 206 of file omniEventsLog.h.
Referenced by checkpoint(), and initializeFileNames().
bool OmniEvents::omniEventsLog::_checkpointNeeded [private] |
Definition at line 209 of file omniEventsLog.h.
Referenced by checkpoint(), and OmniEvents::WriteLock::~WriteLock().
Definition at line 208 of file omniEventsLog.h.
Referenced by factory(), incarnateFactory(), output(), and runWorker().
omni_mutex OmniEvents::omniEventsLog::_lock [private] |
ofstream OmniEvents::omniEventsLog::_logstream [private] |
omni_thread* OmniEvents::omniEventsLog::_workerThread [private] |
In charge of checkpoints.
Definition at line 207 of file omniEventsLog.h.
Referenced by runWorker().
omniEventsLog * OmniEvents::omniEventsLog::theLog = NULL [static, private] |
Definition at line 201 of file omniEventsLog.h.
Referenced by exists(), omniEventsLog(), ~omniEventsLog(), and OmniEvents::WriteLock::~WriteLock().
1.4.7