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 Sat May 31 14:48:45 PDT 1997 by heydon 00020 // Last modified on Tue Aug 3 13:55:44 EDT 2004 by ken@xorian.net 00021 // modified on Wed Jul 23 11:47:46 PDT 1997 by heydon 00022 00023 // CacheState.H -- a representation of various attributes of cache server state 00024 00025 #ifndef _CACHE_STATE_H 00026 #define _CACHE_STATE_H 00027 00028 #include <time.h> 00029 #include <Basics.H> 00030 #include <SRPC.H> 00031 00032 class CacheId { 00033 public: 00034 Text host; // host of machine on which cache is running 00035 Text port; // port on which cache is exporting its service 00036 Text stableDir; // directory of the cache server's stable cache 00037 Text cacheVersion; // version number of the cache server 00038 int intfVersion; // interface version 00039 time_t startTime; // time at which cache server became available 00040 00041 // print 00042 void Print(std::ostream &os, int indent = 0) const throw (); 00043 00044 // send/receive 00045 void Send(SRPC &srpc) const throw (SRPC::failure); 00046 void Recv(SRPC &srpc) throw (SRPC::failure); 00047 }; 00048 00049 class MethodCnts { 00050 public: 00051 int freeVarsCnt; // number of times "FreeVars" method called (*) 00052 int lookupCnt; // number of times "Lookup" method called (*) 00053 int addEntryCnt; // number of times "AddEntry" method called (*) 00054 00055 // (*) Each of these counts is the number of calls since the cache 00056 // server came up. 00057 00058 MethodCnts() throw () 00059 : freeVarsCnt(0), lookupCnt(0), addEntryCnt(0) { /* SKIP */ } 00060 00061 friend bool operator==(const MethodCnts &c1, const MethodCnts &c2) 00062 throw (); 00063 friend bool operator!=(const MethodCnts &c1, const MethodCnts &c2) throw () 00064 { return !(c1 == c2); } 00065 /* Return "true" iff the counts "c1" and "c2" are (not) identical. */ 00066 }; 00067 00068 class EntryState { 00069 public: 00070 int newEntryCnt; // number of "new" cache entries in memory 00071 int oldEntryCnt; // number of "old" cache entries in memory 00072 int newPklSize; // total size of "new" entry pickled values 00073 int oldPklSize; // total size of "old" entry pickled values 00074 00075 EntryState() throw () 00076 : newEntryCnt(0), oldEntryCnt(0), newPklSize(0), oldPklSize(0) 00077 { /* SKIP */ } 00078 00079 EntryState& operator+=(const EntryState &s) throw (); 00080 /* Increment this object's fields by those of "s". */ 00081 }; 00082 00083 class CacheState { 00084 public: 00085 unsigned int virtualSize; // size of cache server process image (bytes) 00086 unsigned int physicalSize; // size of cache resident in physical 00087 // memory (bytes) 00088 MethodCnts cnt; // number of times each method has been called 00089 unsigned int vmpkCnt; // number of volatile MPKFiles (in memory) 00090 unsigned int vpkCnt; // number of volatile PKFiles (in memory) 00091 unsigned int entryCnt; // total number of cache entries in cache 00092 EntryState s; // see EntryState above 00093 unsigned int hitFilterCnt; // number of indices in hit filter 00094 unsigned int delEntryCnt; // number of cache entries pending deletion 00095 unsigned int mpkWeedCnt; // number of MultiPKFiles remaining to be weeded 00096 00097 // print 00098 void Print(std::ostream &os, int indent = 0) const throw (); 00099 00100 // send/receive 00101 void Send(SRPC &srpc) const throw (SRPC::failure); 00102 void Recv(SRPC &srpc) throw (SRPC::failure); 00103 }; 00104 00105 #endif // _CACHE_STATE_H