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
00029 #include "SRPC.H"
00030 #include "MultiSRPC.H"
00031 #include "VestaSource.H"
00032 #include "VestaSourceSRPC.H"
00033 #include "VDirSurrogate.H"
00034 #include "VestaSourceAtomic.H"
00035
00036
00037 VestaSourceAtomic::VestaSourceAtomic(AccessControl::Identity who)
00038 throw (SRPC::failure)
00039 {
00040 id = VestaSourceSRPC::Start(srpc);
00041 srpc->start_call(VestaSourceSRPC::Atomic,
00042 VestaSourceSRPC::version);
00043 VestaSourceSRPC::send_identity(srpc, who);
00044 nsteps = 0;
00045 nobjects = 0;
00046 target1 = VestaSource::ok;
00047 target2 = VestaSource::ok;
00048 ndone = 0;
00049 lasterr = VestaSource::ok;
00050 okreplace = VestaSource::ok;
00051 names = NEW(NameSeq);
00052 }
00053
00054
00055 VestaSourceAtomic::VestaSourceAtomic(const Text& host, const Text& port,
00056 AccessControl::Identity who)
00057 throw (SRPC::failure)
00058 {
00059 id = VestaSourceSRPC::Start(srpc, host, port);
00060 srpc->start_call(VestaSourceSRPC::Atomic,
00061 VestaSourceSRPC::version);
00062 VestaSourceSRPC::send_identity(srpc, who);
00063 nsteps = 0;
00064 nobjects = 0;
00065 target1 = VestaSource::ok;
00066 target2 = VestaSource::ok;
00067 ndone = 0;
00068 lasterr = VestaSource::ok;
00069 okreplace = VestaSource::ok;
00070 names = NEW(NameSeq);
00071 }
00072
00073
00074
00075 VestaSourceAtomic::~VestaSourceAtomic() throw ()
00076 {
00077 try {
00078 cancel();
00079 } catch (SRPC::failure) {
00080
00081 }
00082 }
00083
00084
00085
00086
00087 bool
00088 VestaSourceAtomic::run()
00089 throw (SRPC::failure)
00090 {
00091 assert(srpc != NULL);
00092 srpc->send_int(VestaSourceSRPC::AtomicRun);
00093 srpc->send_end();
00094 ndone = srpc->recv_int();
00095 lasterr = (VestaSource::errorCode) srpc->recv_int();
00096 okreplace = (VestaSource::errorCode) srpc->recv_int();
00097 bool ret = (bool) srpc->recv_int();
00098 srpc->recv_end();
00099 VestaSourceSRPC::End(id);
00100 srpc = NULL;
00101 return ret;
00102 }
00103
00104
00105
00106
00107
00108
00109
00110 void
00111 VestaSourceAtomic::cancel()
00112 throw (SRPC::failure)
00113 {
00114 if (names) {
00115 delete names;
00116 names = NULL;
00117 }
00118 if (srpc) {
00119 srpc->send_int(VestaSourceSRPC::AtomicCancel);
00120 srpc->send_end();
00121 srpc->recv_end();
00122 VestaSourceSRPC::End(id);
00123 srpc = NULL;
00124 }
00125 }
00126
00127
00128
00129 Text
00130 VestaSourceAtomic::name(int step) throw ()
00131 {
00132 return names->get(step);
00133 }
00134
00135
00136 void
00137 VestaSourceAtomic::setTarget(const Text& stepname,
00138 VestaSource::errorCode target1,
00139 VestaSource::errorCode target2,
00140 VestaSource::errorCode okreplace)
00141 throw (SRPC::failure)
00142 {
00143 names->addhi(stepname);
00144 srpc->send_int(VestaSourceSRPC::AtomicTarget);
00145 srpc->send_int((int) target1);
00146 srpc->send_int((int) target2);
00147 srpc->send_int((int) okreplace);
00148 this->target1 = target1;
00149 this->target2 = target2;
00150 this->okreplace = okreplace;
00151 nsteps++;
00152 }
00153
00154
00155
00156
00157
00158 VestaSourceAtomic::VSIndex
00159 VestaSourceAtomic::decl(const Text& stepname, VestaSource* vs)
00160 throw (SRPC::failure)
00161 {
00162 names->addhi(stepname);
00163 srpc->send_int(VestaSourceSRPC::AtomicDeclare);
00164 srpc->send_bytes((const char*) &vs->longid.value,
00165 sizeof(vs->longid.value));
00166 nsteps++;
00167 return nobjects++;
00168 }
00169
00170
00171 void
00172 VestaSourceAtomic::resync(const Text& stepname, VestaSourceAtomic::VSIndex vsi)
00173 throw (SRPC::failure)
00174 {
00175 names->addhi(stepname);
00176 srpc->send_int(VestaSourceSRPC::AtomicResync);
00177 srpc->send_int((int) vsi);
00178 nsteps++;
00179 }
00180
00181
00182 void
00183 VestaSourceAtomic::setTimestamp(const Text& stepname,
00184 VestaSourceAtomic::VSIndex vsi, time_t ts)
00185 throw (SRPC::failure)
00186 {
00187 names->addhi(stepname);
00188 srpc->send_int(VestaSourceSRPC::SetTimestamp);
00189 srpc->send_int((int) vsi);
00190 srpc->send_int((int) ts);
00191 nsteps++;
00192 }
00193
00194
00195 VestaSourceAtomic::VSIndex
00196 VestaSourceAtomic::lookup(const Text& stepname, VestaSourceAtomic::VSIndex vsi,
00197 const Text& arc)
00198 throw (SRPC::failure)
00199 {
00200 names->addhi(stepname);
00201 srpc->send_int(VestaSourceSRPC::Lookup);
00202 srpc->send_int((int) vsi);
00203 srpc->send_chars(arc.cchars());
00204 nsteps++;
00205 return nobjects++;
00206 }
00207
00208
00209 VestaSourceAtomic::VSIndex
00210 VestaSourceAtomic::lookupPathname(const Text& stepname,
00211 VestaSourceAtomic::VSIndex vsi,
00212 const Text& pathname,
00213 char pathnameSep)
00214 throw (SRPC::failure)
00215 {
00216 names->addhi(stepname);
00217 srpc->send_int(VestaSourceSRPC::LookupPathname);
00218 srpc->send_int((int) vsi);
00219 srpc->send_chars(pathname.cchars());
00220 srpc->send_int((int)pathnameSep);
00221 nsteps++;
00222 return nobjects++;
00223 }
00224
00225
00226 VestaSourceAtomic::VSIndex
00227 VestaSourceAtomic::lookupIndex(const Text& stepname,
00228 VestaSourceAtomic::VSIndex vsi,
00229 unsigned int index)
00230 throw (SRPC::failure)
00231 {
00232 names->addhi(stepname);
00233 srpc->send_int(VestaSourceSRPC::LookupIndex);
00234 srpc->send_int((int) vsi);
00235 srpc->send_int((int) index);
00236 nsteps++;
00237 return nobjects++;
00238 }
00239
00240
00241 void
00242 VestaSourceAtomic::reallyDelete(const Text& stepname,
00243 VestaSourceAtomic::VSIndex vsi,
00244 const Text& arc,
00245 bool existCheck, time_t timestamp)
00246 throw (SRPC::failure)
00247 {
00248 names->addhi(stepname);
00249 srpc->send_int(VestaSourceSRPC::ReallyDelete);
00250 srpc->send_int((int) vsi);
00251 srpc->send_chars(arc.cchars());
00252 srpc->send_int((int) existCheck);
00253 srpc->send_int((int) timestamp);
00254 nsteps++;
00255 }
00256
00257
00258 VestaSourceAtomic::VSIndex
00259 VestaSourceAtomic::insertFile(const Text& stepname,
00260 VestaSourceAtomic::VSIndex vsi,
00261 const Text& arc,
00262 ShortId sid, bool master,
00263 VestaSource::dupeCheck chk,
00264 time_t timestamp, FP::Tag* fptag)
00265 throw (SRPC::failure)
00266 {
00267 names->addhi(stepname);
00268 srpc->send_int(VestaSourceSRPC::InsertFile);
00269 srpc->send_int((int) vsi);
00270 srpc->send_chars(arc.cchars());
00271 srpc->send_int((int) sid);
00272 srpc->send_int((int) master);
00273 srpc->send_int((int) chk);
00274 srpc->send_int((int) timestamp);
00275 if (fptag == NULL) {
00276 srpc->send_bytes(NULL, 0);
00277 } else {
00278 fptag->Send(*srpc);
00279 }
00280 nsteps++;
00281 return nobjects++;
00282 }
00283
00284
00285 VestaSourceAtomic::VSIndex
00286 VestaSourceAtomic::insertMutableFile(const Text& stepname,
00287 VestaSourceAtomic::VSIndex vsi,
00288 const Text& arc, ShortId sid, bool master,
00289 VestaSource::dupeCheck chk,
00290 time_t timestamp, FP::Tag* fptag)
00291 throw (SRPC::failure)
00292 {
00293 names->addhi(stepname);
00294 srpc->send_int(VestaSourceSRPC::InsertMutableFile);
00295 srpc->send_int((int) vsi);
00296 srpc->send_chars(arc.cchars());
00297 srpc->send_int((int) sid);
00298 srpc->send_int((int) master);
00299 srpc->send_int((int) chk);
00300 srpc->send_int((int) timestamp);
00301 nsteps++;
00302 return nobjects++;
00303 }
00304
00305
00306
00307 VestaSourceAtomic::VSIndex
00308 VestaSourceAtomic::insertImmutableDirectory(const Text& stepname,
00309 VestaSourceAtomic::VSIndex parenti,
00310 const Text& arc,
00311 VestaSourceAtomic::VSIndex diri,
00312 bool master,
00313 VestaSource::dupeCheck chk,
00314 time_t timestamp, FP::Tag* fptag)
00315 throw (SRPC::failure)
00316 {
00317 names->addhi(stepname);
00318 srpc->send_int(VestaSourceSRPC::InsertImmutableDirectory);
00319 srpc->send_int((int) parenti);
00320 srpc->send_chars(arc.cchars());
00321 srpc->send_int((int) diri);
00322 srpc->send_int((int) master);
00323 srpc->send_int((int) chk);
00324 srpc->send_int((int) timestamp);
00325 if (fptag == NULL) {
00326 srpc->send_bytes(NULL, 0);
00327 } else {
00328 fptag->Send(*srpc);
00329 }
00330 nsteps++;
00331 return nobjects++;
00332 }
00333
00334 VestaSourceAtomic::VSIndex
00335 VestaSourceAtomic::insertAppendableDirectory(const Text& stepname,
00336 VestaSourceAtomic::VSIndex vsi,
00337 const Text& arc, bool master,
00338 VestaSource::dupeCheck chk,
00339 time_t timestamp)
00340 throw (SRPC::failure)
00341 {
00342 names->addhi(stepname);
00343 srpc->send_int(VestaSourceSRPC::InsertAppendableDirectory);
00344 srpc->send_int((int) vsi);
00345 srpc->send_chars(arc.cchars());
00346 srpc->send_int((int) master);
00347 srpc->send_int((int) chk);
00348 srpc->send_int((int) timestamp);
00349 nsteps++;
00350 return nobjects++;
00351 }
00352
00353
00354
00355 VestaSourceAtomic::VSIndex
00356 VestaSourceAtomic::insertMutableDirectory(const Text& stepname,
00357 VestaSourceAtomic::VSIndex parenti,
00358 const Text& arc,
00359 VestaSourceAtomic::VSIndex diri,
00360 bool master,
00361 VestaSource::dupeCheck chk,
00362 time_t timestamp)
00363 throw (SRPC::failure)
00364 {
00365 names->addhi(stepname);
00366 srpc->send_int(VestaSourceSRPC::InsertMutableDirectory);
00367 srpc->send_int((int) parenti);
00368 srpc->send_chars(arc.cchars());
00369 srpc->send_int((int) diri);
00370 srpc->send_int((int) master);
00371 srpc->send_int((int) chk);
00372 srpc->send_int((int) timestamp);
00373 nsteps++;
00374 return nobjects++;
00375 }
00376
00377
00378 VestaSourceAtomic::VSIndex
00379 VestaSourceAtomic::insertGhost(const Text& stepname,
00380 VestaSourceAtomic::VSIndex vsi,
00381 const Text& arc,
00382 bool master, VestaSource::dupeCheck chk,
00383 time_t timestamp)
00384 throw (SRPC::failure)
00385 {
00386 names->addhi(stepname);
00387 srpc->send_int(VestaSourceSRPC::InsertGhost);
00388 srpc->send_int((int) vsi);
00389 srpc->send_chars(arc.cchars());
00390 srpc->send_int((int) master);
00391 srpc->send_int((int) chk);
00392 srpc->send_int((int) timestamp);
00393 nsteps++;
00394 return nobjects++;
00395 }
00396
00397
00398 VestaSourceAtomic::VSIndex
00399 VestaSourceAtomic::insertStub(const Text& stepname,
00400 VestaSourceAtomic::VSIndex vsi,
00401 const Text& arc,
00402 bool master, VestaSource::dupeCheck chk,
00403 time_t timestamp)
00404 throw (SRPC::failure)
00405 {
00406 names->addhi(stepname);
00407 srpc->send_int(VestaSourceSRPC::InsertStub);
00408 srpc->send_int((int) vsi);
00409 srpc->send_chars(arc.cchars());
00410 srpc->send_int((int) master);
00411 srpc->send_int((int) chk);
00412 srpc->send_int((int) timestamp);
00413 nsteps++;
00414 return nobjects++;
00415 }
00416
00417
00418 void
00419 VestaSourceAtomic::renameTo(const Text& stepname,
00420 VestaSourceAtomic::VSIndex vsi,
00421 const Text& arc,
00422 VestaSourceAtomic::VSIndex fromDirI,
00423 const Text& fromArc,
00424 VestaSource::dupeCheck chk, time_t timestamp)
00425 throw (SRPC::failure)
00426 {
00427 names->addhi(stepname);
00428 srpc->send_int(VestaSourceSRPC::RenameTo);
00429 srpc->send_int((int) vsi);
00430 srpc->send_chars(arc.cchars());
00431 srpc->send_int((int) fromDirI);
00432 srpc->send_chars(fromArc.cchars());
00433 srpc->send_int((int) chk);
00434 srpc->send_int((int) timestamp);
00435 nsteps++;
00436 }
00437
00438
00439 void
00440 VestaSourceAtomic::makeFilesImmutable(const Text& stepname,
00441 VestaSourceAtomic::VSIndex vsi,
00442 unsigned int threshold)
00443 throw (SRPC::failure)
00444 {
00445 names->addhi(stepname);
00446 srpc->send_int(VestaSourceSRPC::MakeFilesImmutable);
00447 srpc->send_int((int) vsi);
00448 srpc->send_int((int) threshold);
00449 nsteps++;
00450 }
00451
00452
00453 void
00454 VestaSourceAtomic::testMaster(const Text& stepname,
00455 VestaSourceAtomic::VSIndex vsi, bool state,
00456 VestaSource::errorCode err)
00457 throw (SRPC::failure)
00458 {
00459 names->addhi(stepname);
00460 srpc->send_int(VestaSourceSRPC::AtomicTestMaster);
00461 srpc->send_int((int) vsi);
00462 srpc->send_int((int) state);
00463 srpc->send_int((int) err);
00464 nsteps++;
00465 }
00466
00467 void
00468 VestaSourceAtomic::setMaster(const Text& stepname,
00469 VestaSourceAtomic::VSIndex vsi, bool state)
00470 throw (SRPC::failure)
00471 {
00472 names->addhi(stepname);
00473 srpc->send_int(VestaSourceSRPC::AtomicSetMaster);
00474 srpc->send_int((int) vsi);
00475 srpc->send_int((int) state);
00476 nsteps++;
00477 }
00478
00479
00480 void
00481 VestaSourceAtomic::inAttribs(const Text& stepname,
00482 VestaSourceAtomic::VSIndex vsi,
00483 const Text& name, const Text& value,
00484 bool expected, VestaSource::errorCode err)
00485 throw (SRPC::failure)
00486 {
00487 names->addhi(stepname);
00488 srpc->send_int(VestaSourceSRPC::InAttribs);
00489 srpc->send_int((int) vsi);
00490 srpc->send_chars(name.cchars());
00491 srpc->send_chars(value.cchars());
00492 srpc->send_int((int) expected);
00493 srpc->send_int((int) err);
00494 nsteps++;
00495 }
00496
00497
00498 void
00499 VestaSourceAtomic::writeAttrib(const Text& stepname,
00500 VestaSourceAtomic::VSIndex vsi,
00501 VestaSource::attribOp op,
00502 const Text& name, const Text& value,
00503 time_t timestamp)
00504 throw (SRPC::failure)
00505 {
00506 names->addhi(stepname);
00507 srpc->send_int(VestaSourceSRPC::WriteAttrib);
00508 srpc->send_int((int) vsi);
00509 srpc->send_int((int) op);
00510 srpc->send_chars(name.cchars());
00511 srpc->send_chars(value.cchars());
00512 srpc->send_int((int) timestamp);
00513 nsteps++;
00514 }
00515
00516 void
00517 VestaSourceAtomic::mergeAttrib(const Text& stepname,
00518 VestaSourceAtomic::VSIndex fromvsi,
00519 VestaSourceAtomic::VSIndex tovsi,
00520 const Text& name,
00521 time_t timestamp)
00522 throw (SRPC::failure)
00523 {
00524 names->addhi(stepname);
00525 srpc->send_int(VestaSourceSRPC::AtomicMergeAttrib);
00526 srpc->send_int((int) fromvsi);
00527 srpc->send_int((int) tovsi);
00528 srpc->send_chars(name.cchars());
00529 srpc->send_int((int) timestamp);
00530 nsteps++;
00531 }
00532
00533 void
00534 VestaSourceAtomic::accessCheck(const Text& stepname,
00535 VestaSourceAtomic::VSIndex vsi,
00536 AccessControl::Class cls, bool expected,
00537 VestaSource::errorCode err)
00538 throw (SRPC::failure)
00539 {
00540 names->addhi(stepname);
00541 srpc->send_int(VestaSourceSRPC::AtomicAccessCheck);
00542 srpc->send_int((int) vsi);
00543 srpc->send_int((int) cls);
00544 srpc->send_int((int) expected);
00545 srpc->send_int((int) err);
00546 nsteps++;
00547 }
00548
00549 void
00550 VestaSourceAtomic::typeCheck(const Text& stepname,
00551 VSIndex vsi, unsigned int allowed,
00552 VestaSource::errorCode err)
00553 throw (SRPC::failure)
00554 {
00555 names->addhi(stepname);
00556 srpc->send_int(VestaSourceSRPC::AtomicTypeCheck);
00557 srpc->send_int((int) vsi);
00558 srpc->send_int((int) allowed);
00559 srpc->send_int((int) err);
00560 nsteps++;
00561 }
00562