Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

CacheState.C

Go to the documentation of this file.
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 15:01:29 PDT 1997 by heydon
00020 // Last modified on Sun Jun  5 18:43:25 EDT 2005 by ken@xorian.net
00021 //      modified on Sun Aug 22 15:17:49 PDT 1999 by heydon
00022 
00023 #include <Basics.H>
00024 
00025 #include <time.h>
00026 // necessary to make up for broken header file
00027 extern "C" char* _Pctime_r(const time_t *timer, char *buffer);
00028 
00029 #include <SRPC.H>
00030 #include "CacheState.H"
00031 
00032 using std::ostream;
00033 using std::endl;
00034 
00035 inline void Indent(ostream &os, int indent) throw ()
00036 {
00037     for (int i = 0; i < indent; i++) os << " ";
00038 }
00039 
00040 void CacheId::Print(ostream &os, int k) const throw ()
00041 {
00042     Indent(os, k); os << "Hostname:      " << this->host << endl;
00043     Indent(os, k); os << "Port number:   " << this->port << endl;
00044     Indent(os, k); os << "Stable cache:  " << this->stableDir << endl;
00045     Indent(os, k); os << "Cache version: " << this->cacheVersion << endl;
00046     Indent(os, k); os << "Intf version:  " << this->intfVersion << endl;
00047     char buffer[64];
00048     Indent(os, k); os << "Up since:      ";
00049     os << ctime_r(&(this->startTime), buffer);
00050     Indent(os, k); os << "Current time:  ";
00051     time_t now = time((time_t *)NULL);
00052     assert(now >= 0);
00053     os << ctime_r(&now, buffer);
00054 }
00055 
00056 void CacheId::Send(SRPC &srpc) const throw (SRPC::failure)
00057 {
00058     srpc.send_Text(this->host);
00059     srpc.send_Text(this->port);
00060     srpc.send_Text(this->stableDir);
00061     srpc.send_Text(this->cacheVersion);
00062     srpc.send_int(this->intfVersion);
00063     srpc.send_int((int)(this->startTime));
00064 }
00065 
00066 void CacheId::Recv(SRPC &srpc) throw (SRPC::failure)
00067 {
00068     srpc.recv_Text(/*OUT*/ this->host);
00069     srpc.recv_Text(/*OUT*/ this->port);
00070     srpc.recv_Text(/*OUT*/ this->stableDir);
00071     srpc.recv_Text(/*OUT*/ this->cacheVersion);
00072     this->intfVersion = srpc.recv_int();
00073     this->startTime = (time_t)(srpc.recv_int());
00074 }
00075 
00076 bool operator==(const MethodCnts &c1, const MethodCnts &c2) throw ()
00077 {
00078     return ((c1.freeVarsCnt == c2.freeVarsCnt)
00079             && (c1.lookupCnt == c2.lookupCnt)
00080             && (c1.addEntryCnt == c2.addEntryCnt));
00081 }
00082 
00083 EntryState& EntryState::operator+=(const EntryState &s) throw ()
00084 {
00085     this->newEntryCnt += s.newEntryCnt;
00086     this->oldEntryCnt += s.oldEntryCnt;
00087     this->newPklSize += s.newPklSize;
00088     this->oldPklSize += s.oldPklSize;
00089     return *this;
00090 }
00091 
00092 void CacheState::Print(ostream &os, int k) const throw ()
00093 {
00094     Indent(os, k); os <<"Image size:           "<< this->virtualSize << endl;
00095     Indent(os, k); os <<"Resident size:        "<< this->physicalSize<< endl;
00096     Indent(os, k); os <<"FreeVars calls:       "<< this->cnt.freeVarsCnt<<endl;
00097     Indent(os, k); os <<"Lookup calls:         "<< this->cnt.lookupCnt << endl;
00098     Indent(os, k); os <<"AddEntry calls:       "<< this->cnt.addEntryCnt<<endl;
00099     Indent(os, k); os <<"Num VMultiPKFiles:    "<< this->vmpkCnt << endl;
00100     Indent(os, k); os <<"Num VPKFiles:         "<< this->vpkCnt << endl;
00101     Indent(os, k); os <<"Num total entries:    "<< this->entryCnt << endl;
00102     Indent(os, k); os <<"Num new entries:      "<< this->s.newEntryCnt << endl;
00103     Indent(os, k); os <<"Num old entries:      "<< this->s.oldEntryCnt << endl;
00104     Indent(os, k); os <<"New pickle size:      "<< this->s.newPklSize << endl;
00105     Indent(os, k); os <<"Old pickle size:      "<< this->s.oldPklSize << endl;
00106     Indent(os, k); os <<"HitFilter size:       "<< this->hitFilterCnt << endl;
00107     Indent(os, k); os <<"Num entries to del:   "<< this->delEntryCnt << endl;
00108     Indent(os, k); os <<"Num MPKFiles to weed: "<< this->delEntryCnt << endl;
00109 }
00110 
00111 void CacheState::Send(SRPC &srpc) const throw (SRPC::failure)
00112 {
00113     srpc.send_int(this->virtualSize);
00114     srpc.send_int(this->physicalSize);
00115     srpc.send_int(this->cnt.freeVarsCnt);
00116     srpc.send_int(this->cnt.lookupCnt);
00117     srpc.send_int(this->cnt.addEntryCnt);
00118     srpc.send_int(this->vmpkCnt);
00119     srpc.send_int(this->vpkCnt);
00120     srpc.send_int(this->entryCnt);
00121     srpc.send_int(this->s.newEntryCnt);
00122     srpc.send_int(this->s.oldEntryCnt);
00123     srpc.send_int(this->s.newPklSize);
00124     srpc.send_int(this->s.oldPklSize);
00125     srpc.send_int(this->hitFilterCnt);
00126     srpc.send_int(this->delEntryCnt);
00127     srpc.send_int(this->mpkWeedCnt);
00128 }
00129 
00130 void CacheState::Recv(SRPC &srpc) throw (SRPC::failure)
00131 {
00132     this->virtualSize = srpc.recv_int();
00133     this->physicalSize = srpc.recv_int();
00134     this->cnt.freeVarsCnt = srpc.recv_int();
00135     this->cnt.lookupCnt = srpc.recv_int();
00136     this->cnt.addEntryCnt = srpc.recv_int();
00137     this->vmpkCnt = srpc.recv_int();
00138     this->vpkCnt = srpc.recv_int();
00139     this->entryCnt = srpc.recv_int();
00140     this->s.newEntryCnt = srpc.recv_int();
00141     this->s.oldEntryCnt = srpc.recv_int();
00142     this->s.newPklSize = srpc.recv_int();
00143     this->s.oldPklSize = srpc.recv_int();
00144     this->hitFilterCnt = srpc.recv_int();
00145     this->delEntryCnt = srpc.recv_int();
00146     this->mpkWeedCnt = srpc.recv_int();
00147 }

Generated on Mon May 8 00:48:31 2006 for Vesta by  doxygen 1.4.2