OmniEvents
OmniEvents::omniEventsLog Class Reference

#include <omniEventsLog.h>

Collaboration diagram for OmniEvents::omniEventsLog:

Classes

class  IOError
 

Public Member Functions

 omniEventsLog (const char *logdir=NULL)
 
virtual ~omniEventsLog ()
 
bool fileExists (const char *filename) const
 
const charactiveFilename () const
 
const charbackupFilename () const
 
PersistNodebootstrap (int port, const char *endPointNoListen)
 Creates an initialState from its arguments.
 
virtual PersistNodeparse ()
 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_ifactory ()
 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.
 

Protected 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 Protected Attributes

static omniEventsLogtheLog = NULL
 

Friends

class WriteLock
 

Detailed Description

Definition at line 137 of file omniEventsLog.h.

Constructor & Destructor Documentation

◆ omniEventsLog()

OmniEvents::omniEventsLog::omniEventsLog ( const char logdir = NULL)

Definition at line 283 of file omniEventsLog.cc.

References initializeFileNames(), and theLog.

◆ ~omniEventsLog()

OmniEvents::omniEventsLog::~omniEventsLog ( )
virtual

Definition at line 298 of file omniEventsLog.cc.

References _factory, DB, and theLog.

Member Function Documentation

◆ activeFilename()

const char * OmniEvents::omniEventsLog::activeFilename ( ) const
inline

Definition at line 150 of file omniEventsLog.h.

References _activeFilename.

◆ backupFilename()

const char * OmniEvents::omniEventsLog::backupFilename ( ) const
inline

Definition at line 151 of file omniEventsLog.h.

References _backupFilename.

◆ bootstrap()

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

References OmniEvents::PersistNode::addattr(), and OmniEvents::PersistNode::addnode().

◆ checkpoint()

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 433 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().

◆ exists()

◆ factory()

EventChannelFactory_i * OmniEvents::omniEventsLog::factory ( )
inline

accessor method

Definition at line 176 of file omniEventsLog.h.

References _factory.

◆ fileExists()

bool OmniEvents::omniEventsLog::fileExists ( const char filename) const

Definition at line 317 of file omniEventsLog.cc.

References STRUCT_STAT.

Referenced by incarnateFactory(), and parse().

◆ incarnateFactory()

void OmniEvents::omniEventsLog::incarnateFactory ( PersistNode initialState)

Constructs the EventChannelFactory from the information in the initialState parameter.

Definition at line 379 of file omniEventsLog.cc.

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

◆ initializeFileNames()

void OmniEvents::omniEventsLog::initializeFileNames ( const char logdir)
protectedvirtual

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 611 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().

◆ openOfstream()

void OmniEvents::omniEventsLog::openOfstream ( ofstream s,
const char filename,
int  flags = 0,
int fd = NULL 
)
protectedvirtual

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

Available flags are:

  • FLAG_TRUNCATE
  • FLAG_APPEND
  • FLAG_SYNC
Parameters
sreference to the ofstream object.
filenamethe name of the file to open.
flagssee description for available mode flags.
fdreference to a file descriptor. If used, this parameter is set to the fd that was opened, if any.

Definition at line 685 of file omniEventsLog.cc.

Referenced by checkpoint(), and incarnateFactory().

◆ output()

void OmniEvents::omniEventsLog::output ( ostream os)
virtual

Definition at line 426 of file omniEventsLog.cc.

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

Referenced by checkpoint().

◆ parse()

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

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

◆ runWorker()

void OmniEvents::omniEventsLog::runWorker ( )
virtual

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

Definition at line 414 of file omniEventsLog.cc.

References _factory, _workerThread, and checkpoint().

◆ setFilename()

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.

Parameters
filenameOUT parameter.

Definition at line 661 of file omniEventsLog.cc.

Referenced by initializeFileNames().

Friends And Related Symbol Documentation

◆ WriteLock

Definition at line 217 of file omniEventsLog.h.

Member Data Documentation

◆ _activeFilename

char* OmniEvents::omniEventsLog::_activeFilename
protected

◆ _backupFilename

char* OmniEvents::omniEventsLog::_backupFilename
protected

Definition at line 210 of file omniEventsLog.h.

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

◆ _checkpointFilename

char* OmniEvents::omniEventsLog::_checkpointFilename
protected

Definition at line 211 of file omniEventsLog.h.

Referenced by checkpoint(), and initializeFileNames().

◆ _checkpointNeeded

bool OmniEvents::omniEventsLog::_checkpointNeeded
protected

Definition at line 214 of file omniEventsLog.h.

Referenced by checkpoint(), and OmniEvents::WriteLock::~WriteLock().

◆ _factory

EventChannelFactory_i* OmniEvents::omniEventsLog::_factory
protected

Definition at line 213 of file omniEventsLog.h.

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

◆ _lock

omni_mutex OmniEvents::omniEventsLog::_lock
protected

Definition at line 215 of file omniEventsLog.h.

Referenced by checkpoint().

◆ _logstream

ofstream OmniEvents::omniEventsLog::_logstream
protected

Definition at line 208 of file omniEventsLog.h.

Referenced by checkpoint(), and incarnateFactory().

◆ _workerThread

omni_thread* OmniEvents::omniEventsLog::_workerThread
protected

In charge of checkpoints.

Definition at line 212 of file omniEventsLog.h.

Referenced by runWorker().

◆ theLog

omniEventsLog * OmniEvents::omniEventsLog::theLog = NULL
staticprotected

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