00001 // Copyright (C) 2001, Compaq Computer Corporation 00002 // 00003 // This file is part of Vesta. 00004 // 00005 // Vesta is free software; you can redistribute it and/or 00006 // modify it under the terms of the GNU Lesser General Public 00007 // License as published by the Free Software Foundation; either 00008 // version 2.1 of the License, or (at your option) any later version. 00009 // 00010 // Vesta is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 // Lesser General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU Lesser General Public 00016 // License along with Vesta; if not, write to the Free Software 00017 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00018 00019 // Created on Fri Mar 7 13:32:11 PST 1997 by heydon 00020 00021 // Last modified on Thu Jul 15 16:38:23 EDT 2004 by ken@xorian.net 00022 // modified on Wed Sep 6 16:24:35 PDT 2000 by mann 00023 // modified on Thu Mar 13 13:49:10 PST 1997 by heydon 00024 00025 // VestaLogSeq.H -- a wrapper for a VestaLog that provides a uniform 00026 // interface for accessing the log's checkpoint and subsequent logs 00027 // as a sequence of RecoveryReader's. 00028 00029 #ifndef _VESTA_LOG_SEQ_H 00030 #define _VESTA_LOG_SEQ_H 00031 00032 #include <Basics.H> 00033 #include <FS.H> 00034 #include "VestaLog.H" 00035 #include "Recovery.H" 00036 00037 /* The methods of a VestaLogSeq are unmonitored. */ 00038 00039 class VestaLogSeq { 00040 public: 00041 VestaLogSeq(char *dir) throw () 00042 : dir(dir), opened(false) { /* SKIP */ } 00043 /* Create a new VestaLogSeq on the log represented in the filesystem by 00044 directory "dir". */ 00045 00046 void Open(int startVer = -1, bool readonly = false) 00047 throw (VestaLog::Error); 00048 /* Open the VestaLogSeq starting at the checkpoint named by 00049 "ver". A value of "-1" for "ver" means to recover from the 00050 latest checkpoint. If ver != -1, the specified checkpoint must 00051 exist. If "readonly" is "true", fewer access permissions are 00052 required. */ 00053 00054 RecoveryReader* Next(int endVer = -1) throw (VestaLog::Error, FS::Failure); 00055 /* By default, return a new RecoveryReader on the initial checkpoint or 00056 the next log file in the sequence, or NULL if there are no more log 00057 files. If "endVer" is non-negative, return NULL if the next log in the 00058 sequence has a version number at least "endVer" (that is, only return 00059 non-NULL if the next log version is strictly less than "endVer"). The 00060 returned RecoveryReader should be read until end-of-file before "Next" 00061 is called again. After "Next" returns "NULL", call the "Close" method 00062 below. */ 00063 00064 void Close() throw (); 00065 /* Close the VestaLogSeq. The log sequence may be re-opened by a 00066 subsequent call to "Open". */ 00067 00068 private: 00069 VestaLog vlog; // the underlying VestaLog object 00070 char *dir; // name of directory that contains the log 00071 bool opened; // is the VestaLog open? 00072 bool readChkpt; // has the checkpoint been opened? 00073 std::fstream *chkptFS; // fstream on checkpoint file 00074 RecoveryReader *rr; // recovery reader on log files; NULL for first one 00075 }; 00076 00077 #endif // _VESTA_LOG_SEQ_H