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

ExpCache.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 // Last modified on Fri Apr 29 19:31:19 EDT 2005 by ken@xorian.net
00020 //      modified on Thu Feb 10 11:29:27 PST 2000 by heydon
00021 
00022 // vesta/basics
00023 #include <Basics.H>
00024 
00025 #include <sstream>
00026 
00027 // vesta/srpc
00028 #include <SRPC.H>
00029 #include <LimService.H>
00030 
00031 // vesta/fp
00032 #include <FP.H>
00033 
00034 // vesta/cache-common
00035 #include <PKPrefix.H>
00036 #include <BitVector.H>
00037 #include <CacheConfig.H>
00038 #include <CacheIntf.H>
00039 #include <Debug.H>
00040 #include <CacheState.H>
00041 #include <Model.H>
00042 #include <CacheIndex.H>
00043 #include <FV.H>
00044 #include <VestaVal.H>
00045 
00046 // local includes
00047 #include "CacheS.H"
00048 #include "ExpCache.H"
00049 
00050 using std::ostringstream;
00051 using std::cout;
00052 using std::cerr;
00053 using std::endl;
00054 
00055 void ExpCache_NewCall(SRPC *srpc, int procId, void *arg) throw (SRPC::failure)
00056 /* This is the callback procedure passed to the LimService constructor. */
00057 {
00058     ExpCache *csExp = ((ExpCache::CallArg *)arg)->expCache;
00059 
00060     switch (procId) {
00061       // evaluator client procs
00062       case CacheIntf::AddEntryProc:      csExp->AddEntry(srpc);         break;
00063       case CacheIntf::FreeVarsProc:      csExp->FreeVars(srpc);         break;
00064       case CacheIntf::LookupProc:        csExp->Lookup(srpc);           break;
00065       case CacheIntf::CheckpointProc:    csExp->Checkpoint(srpc);       break;
00066       case CacheIntf::RenewLeasesProc:   csExp->RenewLeases(srpc);      break;
00067       case CacheIntf::GetCacheInstanceProc:
00068                                          csExp->GetCacheInstance(srpc); break;
00069 
00070       // weeder client procs
00071       case CacheIntf::WeedRecoverProc:   csExp->WeederRecovering(srpc); break;
00072       case CacheIntf::StartMarkProc:     csExp->StartMark(srpc);        break;
00073       case CacheIntf::SetHitFilterProc:  csExp->SetHitFilter(srpc);     break;
00074       case CacheIntf::GetLeasesProc:     csExp->GetLeases(srpc);        break;
00075       case CacheIntf::ResumeLeasesProc:  csExp->ResumeLeaseExp(srpc);   break;
00076       case CacheIntf::EndMarkProc:       csExp->EndMark(srpc);          break;
00077       case CacheIntf::CommitChkptProc:   csExp->CommitChkpt(srpc);      break;
00078 
00079       // debugging client procs
00080       case CacheIntf::FlushAllProc:      csExp->FlushAll(srpc);         break;
00081       case CacheIntf::GetCacheIdProc:    csExp->GetCacheId(srpc);       break;
00082       case CacheIntf::GetCacheStateProc: csExp->GetCacheState(srpc);    break;
00083 
00084       // programmer error
00085       default:
00086         cerr << "Fatal ExpCache error: ";
00087         cerr << "Unknown method code " << procId << endl;
00088         assert(false);
00089     }
00090 }
00091 
00092 ExpCache::ExpCache(CacheS *cs, int maxRunning, int maxBlocked,
00093   LimService_FailureCallback failureCallback, const Text& hostName)
00094   throw ()
00095 : debug(cs->DebugLevel())
00096 {
00097   // initialize call argument
00098   CallArg *arg = NEW_CONSTR(ExpCache::CallArg, (this, cs));
00099 
00100   // initialize ExpCache
00101   this->cs = cs;
00102   this->ls = NEW_CONSTR(LimService,
00103                         (Config_Port, this->cs->Version(),
00104                          maxRunning, maxBlocked,
00105                          ExpCache_NewCall, failureCallback,
00106                          (void *)arg, /*stacksize=*/ -1, hostName));
00107 }
00108 
00109 void ExpCache::Run() throw (SRPC::failure)
00110 {
00111     this->ls->Run();
00112 }
00113 
00114 bool ExpCache::check_server_instance(SRPC *srpc,
00115                                      const FP::Tag &server_instance,
00116                                      const char *func_name)
00117      const
00118      throw(SRPC::failure)
00119 {
00120   // If we are not the cache server they are expecting...
00121   if(server_instance != cs->GetCacheInstance())
00122     {
00123       // Indicate to the client that we aren't and end the call.
00124       srpc->send_int(0);
00125       srpc->send_end();
00126 
00127       // Log this for debugging
00128       if (this->debug >= CacheIntf::OtherOps) {
00129         Debug::Lock();
00130         cout << Debug::Timestamp() << "CALLED -- " << func_name << endl;
00131         cout << "  server instance mismatch, call aborted" << endl
00132              << "  client = " << server_instance << endl
00133              << "  server = " << cs->GetCacheInstance() << endl;
00134         cout << endl;
00135         Debug::Unlock();
00136       }
00137 
00138       // Tell the caller that they should just return, as we've
00139       // already terminated the call.
00140       return false;
00141     }
00142 
00143   // Tell the caller to proceed as normal.
00144   return true;
00145 }
00146 
00147 void ExpCache::FreeVars(SRPC *srpc) throw (SRPC::failure)
00148 {
00149     // Get the server instance fingerprint.
00150     FP::Tag server_instance(*srpc);
00151 
00152     // get arguments
00153     FP::Tag pk(*srpc);
00154     srpc->recv_end();
00155 
00156     // If we have a server instance mismatch...
00157     if(!check_server_instance(srpc, server_instance, "FreeVariables"))
00158       {
00159         // Don't do anything else.
00160         return;
00161       }
00162 
00163     // pre debugging
00164     if (this->debug >= CacheIntf::OtherOps) {
00165         Debug::Lock();
00166         cout << Debug::Timestamp() << "CALLED -- FreeVariables" << endl;
00167         cout << "  pk = " << pk << endl;
00168         cout << endl;
00169         Debug::Unlock();
00170     }
00171 
00172     // call server function
00173     VPKFile *vf;
00174     cs->FreeVariables(pk, /*OUT*/ vf);
00175 
00176     // Indicate that this is the correct server instance
00177     srpc->send_int(1);
00178 
00179     try
00180       {
00181         // send results
00182         vf->SendAllNames(srpc, (bool)(this->debug >= CacheIntf::OtherOps));
00183         srpc->send_end();
00184       }
00185     // VPKFile::SendAllNames converts the FreeVariables to a CompactFV
00186     // which uses a PrefixTbl.  This can throw PrefixTbl::Overflow
00187     // indicating that we've exceeded the internal limits of the
00188     // PrefixTbl class (by trying to add the 2^16th entry).  If that
00189     // happens we convert it to an SRPC failure.
00190     catch (PrefixTbl::Overflow)
00191       {
00192         ostringstream l_msg;
00193         l_msg << "PrefixTbl overflow in sending result of FreeVariables"
00194               << endl
00195               << "  pk = " << pk << endl
00196               << "(This means you've exceeded internal limits of the" << endl
00197               << "cache server, and you may have to erase your cache.)";
00198         srpc->send_failure(SRPC::internal_trouble, Text(l_msg.str()));
00199       }
00200 }
00201 
00202 void ExpCache::Lookup(SRPC *srpc) throw (SRPC::failure)
00203 {
00204     // Get the server instance fingerprint.
00205     FP::Tag server_instance(*srpc);
00206 
00207     // get arguments
00208     FP::Tag pk(*srpc);
00209     FV::Epoch id = srpc->recv_int();
00210     FP::List fps(*srpc);
00211     srpc->recv_end();
00212 
00213     // If we have a server instance mismatch...
00214     if(!check_server_instance(srpc, server_instance, "Lookup"))
00215       {
00216         // Don't do anything else.
00217         return;
00218       }
00219 
00220     // pre debugging
00221     if (this->debug >= CacheIntf::OtherOps) {
00222         Debug::Lock();
00223         cout << Debug::Timestamp() << "CALLED -- Lookup" << endl;
00224         cout << "  pk = " << pk << endl;
00225         cout << "  epoch = " << id << endl;
00226         cout << "  fps =" << endl; fps.Print(cout, /*indent=*/ 4);
00227         cout << endl;
00228         Debug::Unlock();
00229     }
00230 
00231     // call server function
00232     CacheEntry::Index ci = 0;
00233     const VestaVal::T *value = (VestaVal::T *)NULL;
00234     CacheIntf::LookupRes res =
00235       cs->Lookup(pk, id, fps, /*OUT*/ ci, /*OUT*/ value);
00236 
00237     // post debugging
00238     if (this->debug >= CacheIntf::OtherOps) {
00239         Debug::Lock();
00240         cout << Debug::Timestamp() << "RETURNED -- Lookup" << endl;
00241         cout << "  result = " << CacheIntf::LookupResName(res) << endl;
00242         if (res == CacheIntf::Hit) {
00243             cout << "  index = " << ci << endl;
00244             cout << "  value =" << endl; value->Print(cout, /*indent=*/ 4);
00245         }
00246         cout << endl;
00247         Debug::Unlock();
00248     }
00249 
00250     // Indicate that this is the correct server instance
00251     srpc->send_int(1);
00252 
00253     // send results
00254     srpc->send_int((int)res);
00255     if (res == CacheIntf::Hit) {
00256         srpc->send_int(ci);
00257         value->Send(*srpc);
00258     }
00259     srpc->send_end();
00260 }
00261 
00262 void ExpCache::AddEntry(SRPC *srpc) throw (SRPC::failure)
00263 {
00264     // Get the server instance fingerprint.
00265     FP::Tag server_instance(*srpc);
00266 
00267     // get arguments
00268     FP::Tag* pk = NEW_PTRFREE_CONSTR(FP::Tag, (*srpc));
00269     FV::List *names = NEW_CONSTR(FV::List, (*srpc));
00270     FP::List *fps = NEW_CONSTR(FP::List, (*srpc));
00271     VestaVal::T *value = NEW_CONSTR(VestaVal::T, (*srpc));
00272     Model::T model = Model::Recv(*srpc);
00273     CacheEntry::Indices *kids = NEW_CONSTR(CacheEntry::Indices, (*srpc));
00274     Text sourceFunc;
00275     srpc->recv_Text(/*OUT*/ sourceFunc);
00276     srpc->recv_end();
00277 
00278     // If we have a server instance mismatch...
00279     if(!check_server_instance(srpc, server_instance, "AddEntry"))
00280       {
00281         // Don't do anything else.
00282         return;
00283       }
00284 
00285     // pre debugging
00286     if (this->debug >= CacheIntf::AddEntryOp) {
00287         Debug::Lock();
00288         cout << Debug::Timestamp() << "CALLED -- AddEntry" << endl;
00289         cout << "  pk = " << *pk << endl;
00290         cout << "  names =" << endl; names->Print(cout, /*indent=*/ 4);
00291         cout << "  fps =" << endl; fps->Print(cout, /*indent=*/ 4);
00292         cout << "  value =" << endl; value->Print(cout, /*indent=*/ 4);
00293         cout << "  model = " << model << endl;
00294         cout << "  kids = " << *kids << endl;
00295         cout << "  sourceFunc = " << sourceFunc << endl;
00296         cout << endl;
00297         Debug::Unlock();
00298     }
00299 
00300     // call server function
00301     CacheEntry::Index ci;
00302     CacheIntf::AddEntryRes res = cs->AddEntry(pk, names, fps,
00303       value, model, kids, sourceFunc, /*OUT*/ ci);
00304 
00305     // post debugging
00306     if (this->debug >= CacheIntf::AddEntryOp) {
00307         Debug::Lock();
00308         cout << Debug::Timestamp() << "RETURNED -- AddEntry" << endl;
00309         cout << "  result = " << CacheIntf::AddEntryResName(res) << endl;
00310         if (res == CacheIntf::EntryAdded) {
00311             cout << "  ci = " << ci << endl;
00312         }
00313         cout << endl;
00314         Debug::Unlock();
00315     }
00316 
00317     // Indicate that this is the correct server instance
00318     srpc->send_int(1);
00319 
00320     // send results
00321     srpc->send_int(ci);
00322     srpc->send_int((int)res);
00323     srpc->send_end();
00324 }
00325 
00326 void ExpCache::Checkpoint(SRPC *srpc) throw (SRPC::failure)
00327 {
00328     // Get the server instance fingerprint.
00329     FP::Tag server_instance(*srpc);
00330 
00331     // get arguments
00332     FP::Tag pkgVersion(*srpc);
00333     Model::T model = Model::Recv(*srpc);
00334     CacheEntry::Indices *cis = NEW_CONSTR(CacheEntry::Indices,(*srpc));
00335     bool done = (bool)srpc->recv_int();
00336     srpc->recv_end();
00337 
00338     // If we have a server instance mismatch...
00339     if(!check_server_instance(srpc, server_instance, "Checkpoint"))
00340       {
00341         // Don't do anything else.
00342         return;
00343       }
00344 
00345     // pre debugging
00346     if (this->debug >= CacheIntf::LogFlush) {
00347         Debug::Lock();
00348         cout << Debug::Timestamp() << "CALLED -- Checkpoint" << endl;
00349         cout << "  pkgVersion = " << pkgVersion << endl;
00350         cout << "  model = " << model << endl;
00351         cout << "  cis   = "; cis->Print(cout, /*indent=*/ 4);
00352         cout << "  done  = " << BoolName[done] << endl;
00353         cout << endl;
00354         Debug::Unlock();
00355     }
00356 
00357     // call server function
00358     cs->Checkpoint(pkgVersion, model, cis, done);
00359 
00360     // post debugging
00361     if (this->debug >= CacheIntf::LogFlush) {
00362         Debug::Lock();
00363         cout << Debug::Timestamp() << "RETURNED -- Checkpoint" << endl;
00364         cout << endl;
00365         Debug::Unlock();
00366     }
00367 
00368     // Indicate that this is the correct server instance
00369     srpc->send_int(1);
00370 
00371     // send results
00372     srpc->send_end();
00373 }
00374 
00375 void ExpCache::RenewLeases(SRPC *srpc) throw (SRPC::failure)
00376 {
00377     // Get the server instance fingerprint.
00378     FP::Tag server_instance(*srpc);
00379 
00380     // get arguments
00381     CacheEntry::Indices *cis = NEW_CONSTR(CacheEntry::Indices, (*srpc));
00382     srpc->recv_end();
00383 
00384     // If we have a server instance mismatch...
00385     if(!check_server_instance(srpc, server_instance, "RenewLeases"))
00386       {
00387         // Don't do anything else.
00388         return;
00389       }
00390 
00391     // pre debugging
00392     if (this->debug >= CacheIntf::LeaseExp) {
00393         Debug::Lock();
00394         cout << Debug::Timestamp() << "CALLED -- RenewLeases" << endl;
00395         cout << "  cis = " << *cis << endl;
00396         cout << endl;
00397         Debug::Unlock();
00398     }
00399 
00400     // call server function
00401     bool res = cs->RenewLeases(cis);
00402 
00403     // post debugging
00404     if (this->debug >= CacheIntf::LeaseExp) {
00405         Debug::Lock();
00406         cout << Debug::Timestamp() << "RETURNED -- RenewLeases" << endl;
00407         cout << "  result = " << BoolName[res] << endl;
00408         cout << endl;
00409         Debug::Unlock();
00410     }
00411 
00412     // Indicate that this is the correct server instance
00413     srpc->send_int(1);
00414 
00415     // send results
00416     srpc->send_int((int)res);
00417     srpc->send_end();
00418 }
00419 
00420 void ExpCache::WeederRecovering(SRPC *srpc) throw (SRPC::failure)
00421 {
00422     // Get the server instance fingerprint.
00423     FP::Tag server_instance(*srpc);
00424 
00425     // get arguments
00426     bool doneMarking = srpc->recv_int();
00427     srpc->recv_end();
00428 
00429     // If we have a server instance mismatch...
00430     if(!check_server_instance(srpc, server_instance, "WeederRecovering"))
00431       {
00432         // Don't do anything else.
00433         return;
00434       }
00435 
00436     // pre debugging
00437     if (this->debug >= CacheIntf::WeederOps) {
00438         Debug::Lock();
00439         cout << Debug::Timestamp() << "CALLED -- WeederRecovering" << endl;
00440         cout << "  doneMarking = " << BoolName[doneMarking] << endl;
00441         cout << endl;
00442         Debug::Unlock();
00443     }
00444 
00445     // call server function
00446     bool err = cs->WeederRecovering(srpc, doneMarking);
00447 
00448     // post debugging
00449     if (this->debug >= CacheIntf::WeederOps) {
00450         Debug::Lock();
00451         cout << Debug::Timestamp() << "RETURNED -- WeederRecovering" << endl;
00452         cout << "  err = " << BoolName[err] << endl;
00453         cout << endl;
00454         Debug::Unlock();
00455     }
00456 
00457     // Indicate that this is the correct server instance
00458     srpc->send_int(1);
00459 
00460     // send results
00461     srpc->send_int((int)err);
00462     srpc->send_end();
00463 }
00464 
00465 void ExpCache::StartMark(SRPC *srpc) throw (SRPC::failure)
00466 {
00467     // Get the server instance fingerprint.
00468     FP::Tag server_instance(*srpc);
00469 
00470     // get arguments
00471     srpc->recv_end();
00472 
00473     // If we have a server instance mismatch...
00474     if(!check_server_instance(srpc, server_instance, "StartMark"))
00475       {
00476         // Don't do anything else.
00477         return;
00478       }
00479 
00480     // pre debugging
00481     if (this->debug >= CacheIntf::WeederOps) {
00482         Debug::Lock();
00483         cout << Debug::Timestamp() << "CALLED -- StartMark" << endl;
00484         cout << endl;
00485         Debug::Unlock();
00486     }
00487 
00488     // call server function
00489     int newLogVer;
00490     BitVector *res = cs->StartMark(/*OUT*/ newLogVer);
00491 
00492     // post debugging
00493     if (this->debug >= CacheIntf::WeederOps) {
00494         Debug::Lock();
00495         cout << Debug::Timestamp() << "RETURNED -- StartMark" << endl;
00496         cout << "  initCIs = " << *res << endl;
00497         cout << "  newLogVer = " << newLogVer << endl;
00498         cout << endl;
00499         Debug::Unlock();
00500     }
00501 
00502     // Indicate that this is the correct server instance
00503     srpc->send_int(1);
00504 
00505     // send results
00506     res->Send(*srpc);
00507     srpc->send_int(newLogVer);
00508     srpc->send_end();
00509 }
00510 
00511 void ExpCache::SetHitFilter(SRPC *srpc) throw (SRPC::failure)
00512 {
00513     // Get the server instance fingerprint.
00514     FP::Tag server_instance(*srpc);
00515 
00516     // get arguments
00517     BitVector cis(*srpc);
00518     srpc->recv_end();
00519 
00520     // If we have a server instance mismatch...
00521     if(!check_server_instance(srpc, server_instance, "SetHitFilter"))
00522       {
00523         // Don't do anything else.
00524         return;
00525       }
00526 
00527     // pre debugging
00528     if (this->debug >= CacheIntf::WeederOps) {
00529         Debug::Lock();
00530         cout << Debug::Timestamp() << "CALLED -- SetHitFilter" << endl;
00531         cout << "  cis = " << cis << endl;
00532         cout << endl;
00533         Debug::Unlock();
00534     }
00535 
00536     // call server function
00537     cs->SetHitFilter(cis);
00538 
00539     // post debugging
00540     if (this->debug >= CacheIntf::WeederOps) {
00541         Debug::Lock();
00542         cout << Debug::Timestamp() << "RETURNED -- SetHitFilter" << endl;
00543         cout << endl;
00544         Debug::Unlock();
00545     }
00546 
00547     // Indicate that this is the correct server instance
00548     srpc->send_int(1);
00549 
00550     // send results
00551     srpc->send_end();
00552 }
00553 
00554 void ExpCache::GetLeases(SRPC *srpc) throw (SRPC::failure)
00555 {
00556     // Get the server instance fingerprint.
00557     FP::Tag server_instance(*srpc);
00558 
00559     // get arguments
00560     srpc->recv_end();
00561 
00562     // If we have a server instance mismatch...
00563     if(!check_server_instance(srpc, server_instance, "GetLeases"))
00564       {
00565         // Don't do anything else.
00566         return;
00567       }
00568 
00569     // pre debugging
00570     if (this->debug >= CacheIntf::WeederOps) {
00571         Debug::Lock();
00572         cout << Debug::Timestamp() << "CALLED -- GetLeases" << endl;
00573         cout << endl;
00574         Debug::Unlock();
00575     }
00576 
00577     // call server function
00578     BitVector *res = cs->GetLeases();
00579 
00580     // post debugging
00581     if (this->debug >= CacheIntf::WeederOps) {
00582         Debug::Lock();
00583         cout << Debug::Timestamp() << "RETURNED -- GetLeases" << endl;
00584         cout << "  cis = " << *res << endl;
00585         cout << endl;
00586         Debug::Unlock();
00587     }
00588 
00589     // Indicate that this is the correct server instance
00590     srpc->send_int(1);
00591 
00592     // send results
00593     res->Send(*srpc);
00594     srpc->send_end();
00595 }
00596 
00597 void ExpCache::ResumeLeaseExp(SRPC *srpc) throw (SRPC::failure)
00598 {
00599     // Get the server instance fingerprint.
00600     FP::Tag server_instance(*srpc);
00601 
00602     // get arguments
00603     srpc->recv_end();
00604 
00605     // If we have a server instance mismatch...
00606     if(!check_server_instance(srpc, server_instance, "ResumeLeaseExp"))
00607       {
00608         // Don't do anything else.
00609         return;
00610       }
00611 
00612     // pre debugging
00613     if (this->debug >= CacheIntf::WeederOps) {
00614         Debug::Lock();
00615         cout << Debug::Timestamp() << "CALLED -- ResumeLeaseExp" << endl;
00616         cout << endl;
00617         Debug::Unlock();
00618     }
00619 
00620     // call server function
00621     cs->ResumeLeaseExp();
00622 
00623     // post debugging
00624     if (this->debug >= CacheIntf::WeederOps) {
00625         Debug::Lock();
00626         cout << Debug::Timestamp() << "RETURNED -- ResumeLeaseExp" << endl;
00627         cout << endl;
00628         Debug::Unlock();
00629     }
00630 
00631     // Indicate that this is the correct server instance
00632     srpc->send_int(1);
00633 
00634     // send results
00635     srpc->send_end();
00636 }
00637 
00638 void ExpCache::EndMark(SRPC *srpc) throw (SRPC::failure)
00639 {
00640     // Get the server instance fingerprint.
00641     FP::Tag server_instance(*srpc);
00642 
00643     // get arguments
00644     BitVector cis(*srpc);
00645     PKPrefix::List pfxs(*srpc);
00646     srpc->recv_end();
00647 
00648     // If we have a server instance mismatch...
00649     if(!check_server_instance(srpc, server_instance, "EndMark"))
00650       {
00651         // Don't do anything else.
00652         return;
00653       }
00654 
00655     // pre debugging
00656     if (this->debug >= CacheIntf::WeederOps) {
00657         Debug::Lock();
00658         cout << Debug::Timestamp() << "CALLED -- EndMark" << endl;
00659         cout << "  cis = " << cis << endl;
00660         cout << "  prefixes ="; pfxs.Print(cout, /*indent=*/ 4);
00661         cout << endl;
00662         Debug::Unlock();
00663     }
00664 
00665     // call server function
00666     int chkptVer = cs->EndMark(cis, pfxs);
00667 
00668     // post debugging
00669     if (this->debug >= CacheIntf::WeederOps) {
00670         Debug::Lock();
00671         cout << Debug::Timestamp() << "RETURNED -- EndMark" << endl;
00672         cout << "  chkptVer = " << chkptVer << endl;
00673         cout << endl;
00674         Debug::Unlock();
00675     }
00676 
00677     // Indicate that this is the correct server instance
00678     srpc->send_int(1);
00679 
00680     // send results
00681     srpc->send_int(chkptVer);
00682     srpc->send_end();
00683 }
00684 
00685 void ExpCache::CommitChkpt(SRPC *srpc) throw (SRPC::failure)
00686 {
00687     // Get the server instance fingerprint.
00688     FP::Tag server_instance(*srpc);
00689 
00690     // get arguments
00691     Text chkptFileName;
00692     srpc->recv_Text(/*OUT*/ chkptFileName);
00693     srpc->recv_end();
00694 
00695     // If we have a server instance mismatch...
00696     if(!check_server_instance(srpc, server_instance, "CommitChkpt"))
00697       {
00698         // Don't do anything else.
00699         return;
00700       }
00701 
00702     // pre debugging
00703     if (this->debug >= CacheIntf::WeederOps) {
00704         Debug::Lock();
00705         cout << Debug::Timestamp() << "CALLED -- CommitChkpt" << endl;
00706         cout << "  chkptFileName = " << chkptFileName << endl;
00707         cout << endl;
00708         Debug::Unlock();
00709     }
00710 
00711     // call server function
00712     bool l_result = cs->CommitChkpt(chkptFileName);
00713 
00714     // post debugging
00715     if (this->debug >= CacheIntf::WeederOps) {
00716         Debug::Lock();
00717         cout << Debug::Timestamp() << "RETURNED -- CommitChkpt" << endl;
00718         cout << "  result: checkpoint " << (l_result?"accepted":"rejected")
00719              << endl;
00720         cout << endl;
00721         Debug::Unlock();
00722     }
00723 
00724     // Indicate that this is the correct server instance
00725     srpc->send_int(1);
00726 
00727     // send results
00728     srpc->send_int((int) l_result);
00729     srpc->send_end();
00730 }
00731 
00732 void ExpCache::FlushAll(SRPC *srpc) throw (SRPC::failure)
00733 {
00734     // get arguments
00735     srpc->recv_end();
00736 
00737     // pre debugging
00738     if (this->debug >= CacheIntf::MPKFileFlush) {
00739         Debug::Lock();
00740         cout << Debug::Timestamp() << "CALLED -- FlushAll" << endl;
00741         cout << endl;
00742         Debug::Unlock();
00743     }
00744 
00745     // call server function
00746     cs->FlushAll();
00747 
00748     // post debugging
00749     if (this->debug >= CacheIntf::MPKFileFlush) {
00750         Debug::Lock();
00751         cout << Debug::Timestamp() << "RETURNED -- FlushAll" << endl;
00752         cout << endl;
00753         Debug::Unlock();
00754     }
00755 
00756     // send results
00757     srpc->send_end();
00758 }
00759 
00760 void ExpCache::GetCacheId(SRPC *srpc) throw (SRPC::failure)
00761 {
00762     // get arguments
00763     srpc->recv_end();
00764 
00765     // pre debugging
00766     if (this->debug >= CacheIntf::OtherOps) {
00767         Debug::Lock();
00768         cout << Debug::Timestamp() << "CALLED -- GetCacheId" << endl;
00769         cout << endl;
00770         Debug::Unlock();
00771     }
00772 
00773     // call server function
00774     CacheId id;
00775     cs->GetCacheId(/*OUT*/ id);
00776 
00777     // post debugging
00778     if (this->debug >= CacheIntf::OtherOps) {
00779         Debug::Lock();
00780         cout << Debug::Timestamp() << "RETURNED -- GetCacheId" << endl;
00781         id.Print(cout, /*indent=*/ 2);
00782         cout << endl;
00783         Debug::Unlock();
00784     }
00785 
00786     // send results
00787     id.Send(*srpc);
00788     srpc->send_end();
00789 }
00790 
00791 void ExpCache::GetCacheInstance(SRPC *srpc) throw (SRPC::failure)
00792 {
00793     // get arguments
00794     srpc->recv_end();
00795 
00796     // pre debugging
00797     if (this->debug >= CacheIntf::OtherOps) {
00798         Debug::Lock();
00799         cout << Debug::Timestamp() << "CALLED -- GetCacheInstance" << endl;
00800         cout << endl;
00801         Debug::Unlock();
00802     }
00803 
00804     // call server function
00805     FP::Tag fp = cs->GetCacheInstance();
00806 
00807     // post debugging
00808     if (this->debug >= CacheIntf::OtherOps) {
00809         Debug::Lock();
00810         cout << Debug::Timestamp() << "RETURNED -- GetCacheInstance" << endl
00811              << "  " << fp << endl;;
00812         cout << endl;
00813         Debug::Unlock();
00814     }
00815 
00816     // send results
00817     fp.Send(*srpc);
00818     srpc->send_end();
00819 }
00820 
00821 void ExpCache::GetCacheState(SRPC *srpc) throw (SRPC::failure)
00822 {
00823     // get arguments
00824     srpc->recv_end();
00825 
00826     // pre debugging
00827     if (this->debug >= CacheIntf::OtherOps) {
00828         Debug::Lock();
00829         cout << Debug::Timestamp() << "CALLED -- GetCacheState" << endl;
00830         cout << endl;
00831         Debug::Unlock();
00832     }
00833 
00834     // call server function
00835     CacheState state;
00836     cs->GetCacheState(/*OUT*/ state);
00837 
00838     // post debugging
00839     if (this->debug >= CacheIntf::OtherOps) {
00840         Debug::Lock();
00841         cout << Debug::Timestamp() << "RETURNED -- GetCacheState" << endl;
00842         state.Print(cout, /*indent=*/ 2);
00843         cout << endl;
00844         Debug::Unlock();
00845     }
00846 
00847     // send results
00848     state.Send(*srpc);
00849     srpc->send_end();
00850 }
00851 

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