00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #include <Basics.H>
00029
00030
00031 #include <CacheConfig.H>
00032 #include <Model.H>
00033 #include <CacheIndex.H>
00034 #include <Debug.H>
00035
00036
00037 #include "CacheC.H"
00038
00039 using std::ostream;
00040 using std::cout;
00041 using std::cerr;
00042 using std::endl;
00043
00044 static void ExitClient() throw ()
00045 {
00046 cerr << "SYNTAX: ChkptCache [ -n ]" << endl;
00047 cerr.flush();
00048 exit(1);
00049 }
00050
00051 static void PrintSRPCFailure(ostream &os, SRPC::failure &f) throw ()
00052 {
00053 os << "SRPC Failure (code " << f.r << "):" << endl;
00054 os << " " << f.msg << endl << endl;
00055 os.flush();
00056 }
00057
00058 static void Chkpt() throw ()
00059 {
00060 FP::Tag pkgVersion("", 0);
00061 Model::T model = 0;
00062 CacheEntry::Indices cis;
00063 bool done = false;
00064
00065
00066 cout << Debug::Timestamp() << "CALLING Checkpoint" << endl;
00067 cout << " pkgVersion = " << pkgVersion << endl;
00068 cout << " model = " << model << endl;
00069 cout << " cis = " << cis << endl;
00070 cout << " done = " << BoolName[done] << endl;
00071 cout << endl;
00072
00073
00074 try {
00075 CacheC client;
00076
00077 client.Checkpoint(pkgVersion, model, cis, done);
00078 } catch (SRPC::failure &f) {
00079 PrintSRPCFailure(cerr, f);
00080 }
00081
00082 cout << Debug::Timestamp() << "RETURNED Checkpoint" << endl;
00083 cout << endl;
00084 }
00085
00086 int main(int argc, char *argv[])
00087 {
00088 bool doIt = true;
00089
00090
00091 if (argc > 4) {
00092 cerr << "Error: too many arguments" << endl;
00093 ExitClient();
00094 }
00095 for (int arg = 1; arg < argc; arg++) {
00096 if (!strcmp(argv[arg], "-n")) {
00097 doIt = false;
00098 } else if (*argv[arg] == '-') {
00099 cerr << "Error: unrecognized option: " << argv[arg] << endl;
00100 ExitClient();
00101 } else {
00102 cerr << "Error: invalid command-line" << endl;
00103 ExitClient();
00104 }
00105 }
00106
00107
00108 cout << Debug::Timestamp() << "Checkpointing cache:" << endl;
00109 cout << " Host = " << Config_Host << endl;
00110 cout << " Port = " << Config_Port << endl << endl;
00111 cout.flush();
00112
00113
00114 if (doIt) {
00115 Chkpt();
00116 cout << Debug::Timestamp() << "Done!" << endl;
00117 cout.flush();
00118 } else {
00119 cout << "NOTE: No action taken at your request." << endl;
00120 cout.flush();
00121 }
00122 return 0;
00123 }