Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

OmniEvents::omniEventsLog Class Reference

#include <omniEventsLog.h>

Collaboration diagram for OmniEvents::omniEventsLog:

Collaboration graph
[legend]
List of all members.

Public Methods

 omniEventsLog (const char *logdir=NULL)
bool fileExists (const char *filename) const
const char * activeFilename () const
const char * backupFilename () const
PersistNodebootstrap (int port, const char *endPointNoListen)
 Creates an initialState from its arguments. More...

PersistNodeparse ()
 Creates an initialState from the logfile. More...

void incarnateFactory (PersistNode *initialState)
 Constructs the EventChannelFactory from the information in the initialState parameter. More...

void runWorker ()
 Kicks off the worker thread that periodically checkpoints the persistency logfile. More...

EventChannelFactory_ifactory ()
 accessor method. More...

void checkpoint (void)
 Entry point used by the omniEventsLogWorker to perform checkpointing. More...

void output (ostream &os)

Private Methods

void initializeFileNames (const char *logdir)
 Sets the values of 'active', 'backup' and 'checkpoint' file names. More...

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. More...

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. More...


Private Attributes

ofstream _logstream
char * _activeFilename
char * _backupFilename
char * _checkpointFilename
omni_thread * _workerThread
 In charge of checkpoints. More...

EventChannelFactory_i_factory
bool _checkpointNeeded
omni_mutex _lock

Static Private Attributes

omniEventsLog * theLog = NULL

Friends

class WriteLock

Constructor & Destructor Documentation

OmniEvents::omniEventsLog::omniEventsLog const char *    logdir = NULL
 

Definition at line 273 of file omniEventsLog.cc.

References initializeFileNames().


Member Function Documentation

const char* OmniEvents::omniEventsLog::activeFilename   const [inline]
 

Definition at line 130 of file omniEventsLog.h.

References _activeFilename.

const char* OmniEvents::omniEventsLog::backupFilename   const [inline]
 

Definition at line 131 of file omniEventsLog.h.

References _backupFilename.

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 295 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 403 of file omniEventsLog.cc.

References _activeFilename, _backupFilename, _checkpointFilename, _checkpointNeeded, _lock, _logstream, DB, OMNIEVENTS_LOG_CHECKPOINT_PERIOD, openOfstream(), output(), and OmniEvents::timestamp::t().

EventChannelFactory_i* OmniEvents::omniEventsLog::factory   [inline]
 

accessor method.

Definition at line 156 of file omniEventsLog.h.

References _factory.

bool OmniEvents::omniEventsLog::fileExists const char *    filename const
 

Definition at line 288 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 350 of file omniEventsLog.cc.

References _activeFilename, _factory, _logstream, OmniEvents::PersistNode::child(), fileExists(), and openOfstream().

void OmniEvents::omniEventsLog::initializeFileNames const char *    logdir [private]
 

Sets the values of 'active', 'backup' and 'checkpoint' file names.

The files are placed in the log file directory, that is specified by:

  • command line parameter -l, OR ELSE
  • OMNIEVENTS_LOGDIR_ENV_VAR env. var. (default `OMNIEVENTS_LOGDIR'), OR ELSE
  • OMNIEVENTS_LOG_DEFAULT_LOCATION (set in defaults.h), OR ELSE
  • Unix: /var/lib/omniEvents, Win32: C:\TEMP, VMS: []
The current hostname is incorporated into the file names.

Definition at line 581 of file omniEventsLog.cc.

References _activeFilename, _backupFilename, _checkpointFilename, gethostname(), MAXHOSTNAMELEN, OMNIEVENTS_LOG_DEFAULT_LOCATION, setFilename(), and VMS_SEMICOLON.

Referenced by omniEventsLog().

void OmniEvents::omniEventsLog::openOfstream ofstream &    s,
const char *    filename,
int    flags = 0,
int *    fd = NULL
[private]
 

Helper method that opens an output file stream using whatever method is available.

Available flags are:

  • FLAG_TRUNCATE
  • FLAG_APPEND
  • FLAG_SYNC
Parameters:
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 655 of file omniEventsLog.cc.

Referenced by checkpoint(), and incarnateFactory().

void OmniEvents::omniEventsLog::output ostream &    os
 

Definition at line 396 of file omniEventsLog.cc.

References _factory, and OmniEvents::EventChannelFactory_i::output().

Referenced by checkpoint().

PersistNode * OmniEvents::omniEventsLog::parse  
 

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 308 of file omniEventsLog.cc.

References _activeFilename, _backupFilename, OmniEvents::PersistNode::attrLong(), OmniEvents::PersistNode::child(), and fileExists().

void OmniEvents::omniEventsLog::runWorker  
 

Kicks off the worker thread that periodically checkpoints the persistency logfile.

Definition at line 384 of file omniEventsLog.cc.

References _factory, and _workerThread.

void OmniEvents::omniEventsLog::setFilename char *&    filename,
const char *    logdir,
const char *    sep,
const char *    logname,
const char *    hostname,
const char *    ext
[private]
 

Helper function that sets the value of the first parameter to the concatenation of all the subsequent parameters.

Parameters:
filename  OUT parameter.

Definition at line 631 of file omniEventsLog.cc.

Referenced by initializeFileNames().


Friends And Related Function Documentation

friend class WriteLock [friend]
 

Definition at line 198 of file omniEventsLog.h.


Member Data Documentation

char* OmniEvents::omniEventsLog::_activeFilename [private]
 

Definition at line 190 of file omniEventsLog.h.

Referenced by activeFilename(), checkpoint(), incarnateFactory(), initializeFileNames(), and parse().

char* OmniEvents::omniEventsLog::_backupFilename [private]
 

Definition at line 191 of file omniEventsLog.h.

Referenced by backupFilename(), checkpoint(), initializeFileNames(), and parse().

char* OmniEvents::omniEventsLog::_checkpointFilename [private]
 

Definition at line 192 of file omniEventsLog.h.

Referenced by checkpoint(), and initializeFileNames().

bool OmniEvents::omniEventsLog::_checkpointNeeded [private]
 

Definition at line 195 of file omniEventsLog.h.

Referenced by checkpoint().

EventChannelFactory_i* OmniEvents::omniEventsLog::_factory [private]
 

Definition at line 194 of file omniEventsLog.h.

Referenced by factory(), incarnateFactory(), output(), and runWorker().

omni_mutex OmniEvents::omniEventsLog::_lock [private]
 

Definition at line 196 of file omniEventsLog.h.

Referenced by checkpoint().

ofstream OmniEvents::omniEventsLog::_logstream [private]
 

Definition at line 189 of file omniEventsLog.h.

Referenced by checkpoint(), and incarnateFactory().

omni_thread* OmniEvents::omniEventsLog::_workerThread [private]
 

In charge of checkpoints.

Definition at line 193 of file omniEventsLog.h.

Referenced by runWorker().

omniEventsLog * OmniEvents::omniEventsLog::theLog = NULL [static, private]
 

Definition at line 271 of file omniEventsLog.cc.


The documentation for this class was generated from the following files:
Generated on Fri Oct 8 15:53:05 2004 for OmniEvents by doxygen1.2.15