#include <Persist.h>
Collaboration diagram for Omniifr::Persist:

Public Member Functions | |
| Persist (int checkpointPeriodSec) | |
| ~Persist () | |
| void | setdir (const char *dir) |
| Sets the directory used for persistency database files. | |
| void | startup () |
| Called by the Repository, when initial setup is complete. | |
| void | checkpoint () |
| [?? FUTURE:] Called by the checkpointing thread, and also when Omniifr_Ifr_checkpoint() receives SIGUSR2. | |
| ostream & | outstream () |
| Obtains an open output stream. | |
Private Attributes | |
| Repository_impl & | _ifr |
| omni_mutex | _lock |
| ofstream * | _outstream |
| bool | _checkpointNeeded |
| string | _dir |
Friends | |
| class | WriteLock |
Classes | |
| class | WriteLock |
| Obtains an output stream to the active persistancy file, and locks it for exclusive access. More... | |
Definition at line 48 of file Persist.h.
|
|
Definition at line 33 of file Persist.cc. 00034 : _ifr(Omniifr::Repository_impl::inst()), 00035 _lock(), 00036 _outstream(NULL), 00037 _checkpointNeeded(true), 00038 _dir("/var/lib/omniifr") 00039 {}
|
|
|
Definition at line 42 of file Persist.cc. References _outstream. 00043 {
00044 if(_outstream)
00045 {
00046 _outstream->close();
00047 delete _outstream;
00048 }
00049 }
|
|
|
[?? FUTURE:] Called by the checkpointing thread, and also when Omniifr_Ifr_checkpoint() receives SIGUSR2. Writes the entire contents of the repository to a clean database file. Definition at line 70 of file Persist.cc. References _ifr, Omniifr::Repository_impl::output(), and outstream(). Referenced by Omniifr_Ifr_checkpoint(). 00071 {
00072 // ?? This is a dummy implementation.
00073 // The real implementation should move aside the current database file
00074 // before replacing it with a new one. See the very robust (if a bit cruddy)
00075 // implementation in omniEvents.
00076 // ?? Furthermore, this is currently called from a signal handler - it would
00077 // be safer for that call to be replaced by a condition_variable wakeup.
00078 _ifr.output(outstream());
00079 outstream()<<flush;
00080 }
|
|
|
Obtains an open output stream.
Definition at line 83 of file Persist.cc. References _dir, and _outstream. Referenced by checkpoint(). 00084 {
00085 if(!_outstream)
00086 {
00087 string fname =_dir+"/omniifr.db";
00088 _outstream=new ofstream(fname.c_str());
00089 }
00090 return *_outstream;
00091 }
|
|
|
Sets the directory used for persistency database files.
Definition at line 55 of file Persist.h. References _dir. 00055 { _dir=dir; }
|
|
|
Called by the Repository, when initial setup is complete. Reincarnates the repository contents (if there is a database file from which to read) and [?? FUTURE:] starts the checkpointing thread. Definition at line 52 of file Persist.cc. References _dir, _ifr, _outstream, and Omniifr::Repository_impl::reincarnate(). Referenced by Omniifr::Repository_impl::init(). 00053 {
00054 assert(_outstream==NULL);
00055 {
00056 string fname =_dir+"/omniifr.db";
00057 ifstream instream(fname.c_str());
00058 if(instream)
00059 {
00060 auto_ptr<PersistNode> savedState( new PersistNode(instream) );
00061 instream.close();
00062 _ifr.reincarnate(*savedState);
00063 }
00064 }
00065
00066 // ?? START UP CHECKPOINTING HERE
00067 }
|
|
|
|
|
|
Definition at line 92 of file Persist.h. Referenced by Omniifr::Persist::WriteLock::~WriteLock(). |
|
|
Definition at line 93 of file Persist.h. Referenced by outstream(), setdir(), and startup(). |
|
|
Definition at line 89 of file Persist.h. Referenced by checkpoint(), and startup(). |
|
|
|
|
|
Definition at line 91 of file Persist.h. Referenced by outstream(), startup(), and ~Persist(). |
1.4.1