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 // Last modified on Thu Nov 8 12:40:11 EST 2001 by ken@xorian.net 00020 // modified on Fri Feb 4 17:24:03 PST 2000 by heydon 00021 00022 // WeederC -- the weeder client interface to the Vesta-2 cache server 00023 00024 /* The class "WeederC" provides a client connection to one or more running 00025 instances of the Vesta-2 cache server. It provides operations required by 00026 the Vesta-2 weeder. */ 00027 00028 #ifndef _WEEDER_C_H 00029 #define _WEEDER_C_H 00030 00031 #include <Basics.H> 00032 #include <Table.H> 00033 #include <SRPC.H> 00034 #include <MultiSRPC.H> 00035 #include <CacheIntf.H> 00036 #include <BitVector.H> 00037 #include <PKPrefix.H> 00038 00039 // for use by "EndMark" method below 00040 typedef Table<PKPrefix::T,char>::Default PKPrefixTbl; 00041 typedef Table<PKPrefix::T,char>::Iterator PKPrefixIter; 00042 00043 class WeederC { 00044 public: 00045 // Constructor: initialize the client 00046 WeederC(CacheIntf::DebugLevel debug = CacheIntf::None) throw (SRPC::failure); 00047 00048 // Destructor: close and free any open connections to servers 00049 ~WeederC() throw (); 00050 00051 bool WeederRecovering(bool doneMarking) const throw (SRPC::failure); 00052 /* Indicate that the weeder is in the process of recovering, and set the 00053 cache server's state accordingly. "doneMarking" should be true iff the 00054 weeder's "weeded" set is non-empty, i.e., if the weeder had completed 00055 its mark phase but not the subsequent deletion phase. Returns true 00056 iff there is already a weeder running, in which case no action is 00057 taken and the weeder should immediately abort. */ 00058 00059 BitVector* StartMark(/*OUT*/ int &newLogVer) const throw (SRPC::failure); 00060 /* Indicate that the weeder is starting its mark phase. This blocks if the 00061 cache server is still in the middle of doing deletions from a previous 00062 weed. Then it disables lease expiration, and flushes the graphLog. 00063 It then checkpoints the graph log, and sets "newLogVer" to the version 00064 number of the new graphLog file. The weeder should read all versions up 00065 to (but not including) "newLogVer". Finally, this method returns the 00066 bit vector of cache indices in use at the time of the call. */ 00067 00068 void SetHitFilter(const BitVector &cis) const throw (SRPC::failure); 00069 /* Set the cache server's hit filter set to "cis". The hit filter is the 00070 set of cache entries that may soon be deleted, so hits on them by the 00071 cache server's "Lookup" method will be disabled. This method requires 00072 that the cache server is not currently doing deletions from a previous 00073 weed. */ 00074 00075 BitVector* GetLeases() const throw (SRPC::failure); 00076 /* Return a newly allocated bit vector corresponding to the cache entries 00077 that are currently leased. */ 00078 00079 void ResumeLeaseExp() const throw (SRPC::failure); 00080 /* Re-enable lease expiration disabled by the "StartMark" method above. */ 00081 00082 int EndMark(const BitVector &cis, const PKPrefixTbl &pfxs) const 00083 throw (SRPC::failure); 00084 /* Indicate that the weeder's mark phase has completed, and that "cis" are 00085 the indices of the cache entries to delete. The list "pfxs" contains 00086 the union of the prefixes of the PK's of all these entries. 00087 00088 The cache server's hit filter is set to "cis", and the cache server 00089 will fork a background thread to delete these entries. The number of 00090 the checkpoint file into which the weeder should write the ``clean'' 00091 version of the graphLog is returned. */ 00092 00093 bool CommitChkpt(const Text &chkptFileName) const throw (SRPC::failure); 00094 /* Inform the cache server that the weeder has finished writing the 00095 graphLog checkpoint, and that the checkpoint should be committed. 00096 00097 Pass the file to which we've written the graphLog checkpoint, 00098 which is the "real" checkpoint name plus a suffix to make it 00099 unique. This file is renamed to take the place of the actual 00100 checkpoint. This guards against a case where two weeders are 00101 both trying to checkpoint the graph log of the same cache 00102 server. 00103 00104 The return value indicates whether the cache server accepted 00105 the checkpoint. Unless it wasn't expecting one, it will. */ 00106 00107 protected: 00108 // The client maintains a cache of connections in a "Connections" object 00109 MultiSRPC *conns; 00110 00111 // Read-only after initialization 00112 CacheIntf::DebugLevel debug; 00113 00114 // The cache server instance identifier. Read-only after 00115 // initialization 00116 FP::Tag server_instance; 00117 00118 private: 00119 void NullCall(CacheIntf::ProcIds id, char *name, 00120 CacheIntf::DebugLevel level) const throw (SRPC::failure); 00121 /* Make the remote call to procedure "id" with no arguments or return 00122 value. */ 00123 00124 // hide copy constructor from clients 00125 WeederC(const WeederC&); 00126 00127 // Intialize the server instance fingerprint. Should only called 00128 // by constructors. 00129 void init_server_instance() throw(SRPC::failure); 00130 00131 // Recieve the server instance check response for an SRPC call 00132 // guarded by such a check. Either return to indicate that the 00133 // call should continue, or throw SRPC::failure to indicate that a 00134 // server mismatch. 00135 void recv_server_instance_check(SRPC *srpc, const char *func_name) 00136 const throw(SRPC::failure); 00137 }; 00138 00139 #endif // _WEEDER_C_H