XRootD
Loading...
Searching...
No Matches
XrdFrmAdmin Class Reference

#include <XrdFrmAdmin.hh>

+ Collaboration diagram for XrdFrmAdmin:

Public Member Functions

 XrdFrmAdmin ()
 
 ~XrdFrmAdmin ()
 
int Audit ()
 
int Chksum ()
 
int Copy ()
 
int Create ()
 
int Find ()
 
int Help ()
 
int MakeLF ()
 
int Mark ()
 
int Mmap ()
 
int Mv ()
 
int Pin ()
 
int Query ()
 
int Quit ()
 
int Reloc ()
 
int Remove ()
 
int Rename ()
 
void setArgs (char *argv)
 
void setArgs (int argc, char **argv)
 
int xeqArgs (char *Cmd)
 

Detailed Description

Definition at line 44 of file XrdFrmAdmin.hh.

Constructor & Destructor Documentation

◆ XrdFrmAdmin()

XrdFrmAdmin::XrdFrmAdmin ( )
inline

Definition at line 86 of file XrdFrmAdmin.hh.

86: frmProxy(0), frmProxz(0), finalRC(0) {}

Referenced by Query(), and xeqArgs().

+ Here is the caller graph for this function:

◆ ~XrdFrmAdmin()

XrdFrmAdmin::~XrdFrmAdmin ( )
inline

Definition at line 87 of file XrdFrmAdmin.hh.

87{}

Member Function Documentation

◆ Audit()

int XrdFrmAdmin::Audit ( )

Definition at line 71 of file XrdFrmAdmin.cc.

72{
73 static XrdOucArgs Spec(&Say, "frm_admin: ", "",
74 "fix", 3, "f",
75 "force", 1, "F",
76 "migratable", 1, "m",
77 "purgeable", 1, "p",
78 "recursive", 1, "r",
79 (const char *)0);
80
81 static const char *Reqs[] = {"type", 0};
82
83// Parse the request
84//
85 if (!Parse("audit ", Spec, Reqs)) return 1;
86 Opt.Args[1] = Spec.getarg();
87
88// Fan out based on the function
89//
90 if (!strcmp(Opt.Args[0], "usage")) return AuditUsage();
91 if (!Opt.Args[1]) Emsg("audit target not specified.");
92 else if (!strcmp(Opt.Args[0], "names")) return AuditNames();
93 else if (!strcmp(Opt.Args[0], "space")) return AuditSpace();
94 else Emsg("Unknown audit type - ", Opt.Args[0]);
95
96// Nothing we understand
97//
98 return 4;
99}
XrdOucPup XrdCmsParser::Pup & Say

References XrdOucArgs::getarg(), and Say.

Referenced by xeqArgs().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Chksum()

int XrdFrmAdmin::Chksum ( )

Definition at line 111 of file XrdFrmAdmin.cc.

112{
113 static XrdOucArgs Spec(&Say, "frm_admin: ", "",
114 "force", 1, "f",
115 "pfn", 3, "p",
116 "type", 1, "t:",
117 "verbose", 1, "v", (const char *)0);
118
119 static const char *Reqs[] = {"function", "target", 0};
120 const char *csName;
121 char pfnbuf[MAXPATHLEN], *Pfn, *Lfn, *csFunc;
122 int rc = 0;
123
124// Check if this is even supported
125//
126 CksData.Reset();
127 if (!Config.CksMan || !(CksData.Length = Config.CksMan->Size()))
128 {Emsg("Checksum support has not been configured!"); return 8;}
129
130// Parse the request
131//
132 if (!Parse("chksum ", Spec, Reqs)) return 1;
133 csFunc = Opt.Args[0];
134 csName = CksData.Name;
135 if (!*CksData.Name) {Opt.All = 1; CksData.Set(Config.CksMan->Name());}
136
137// Check first for set or verify
138//
139 if (!strcmp (csFunc, "set") || Abbrev(csFunc, "verify", 3))
140 {int n = strlen(Opt.Args[1]);
141 if (n != CksData.Length*2 || !CksData.Set(Opt.Args[1], n))
142 {Emsg("Invalid ", csName, " checksum value - ", Opt.Args[1]);
143 return 4;
144 }
145 if (!(Opt.Args[1] = Spec.getarg()))
146 {Emsg("chksum target not specified."); return 4;}
147 }
148
149// Convert the lfn to a pfn if it has not been converted already
150//
151 Pfn = Lfn = Opt.Args[1];
152 if (Opt.MPType != 'p')
153 {if (!Config.LocalPath(Opt.Args[1], pfnbuf, sizeof(pfnbuf))) return 4;
154 Pfn = pfnbuf;
155 }
156
157// Process the request
158//
159 if (!strcmp(csFunc, "calc"))
160 {if (Opt.Force || Config.CksMan->Get(Pfn, CksData) <= 0)
161 rc = Config.CksMan->Calc(Pfn, CksData, 1);
162 if (rc >= 0) {ChksumPrint(Lfn, rc); return 0;}
163 }
164
165 else if (!strcmp("ls", csFunc))
166 {if (!(rc = ChksumList(Lfn, Pfn))) return 0;}
167
168 else if (!strcmp(csFunc, "set"))
169 {if (!(rc = Config.CksMan->Set(Pfn, CksData))) return 0;}
170
171 else if (!strcmp(csFunc, "unset"))
172 {if (!(rc = Config.CksMan->Del(Pfn, CksData))) return 0;}
173
174 else if (Abbrev(csFunc, "verify", 3))
175 {if ((rc = Config.CksMan->Ver(Pfn, CksData)) > 0)
176 {Say.Say(CksData.Name, " checksums match for ", Lfn); return 0;}
177 if (!rc)
178 {Say.Say(CksData.Name, " checksums differ for ",Lfn); return 1;}
179 }
180
181 else {Emsg("Unknown chksum function - ", csFunc); return 4;}
182
183// Determine name of the problem
184//
185 if (rc == -EDOM) Emsg("Invalid ", csName, " checksum length.");
186 else if (rc == -ENOTSUP) Emsg(csName, " checksums are not supported.");
187 else if (rc == -ESRCH) Emsg(csName, " checksum not set for ", Lfn);
188 else if (rc == -ESTALE) Emsg(csName, " checksum no longer valid for ", Lfn);
189 else Emsg(-rc, csFunc, " ", csName, " checksum");
190
191// Return failure
192//
193 return 4;
194}
virtual int Ver(const char *Xfn, XrdCksData &Cks)=0
virtual const char * Name(int seqNum=0)=0
virtual int Get(const char *Xfn, XrdCksData &Cks)=0
virtual int Del(const char *Xfn, XrdCksData &Cks)=0
virtual int Size(const char *Name=0)=0
virtual int Set(const char *Xfn, XrdCksData &Cks, int myTime=0)=0
virtual int Calc(const char *Xfn, XrdCksData &Cks, int doSet=1)=0
XrdCks * CksMan
int LocalPath(const char *oldp, char *newp, int newpsz)
XrdFrmConfig Config

References XrdFrm::Config, XrdOucArgs::getarg(), and Say.

Referenced by xeqArgs().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Copy()

int XrdFrmAdmin::Copy ( )

◆ Create()

int XrdFrmAdmin::Create ( )

◆ Find()

int XrdFrmAdmin::Find ( )

Definition at line 270 of file XrdFrmAdmin.cc.

271{
272 static XrdOucArgs Spec(&Say, "frm_admin: ", "",
273 "recursive", 1, "r", (const char *)0);
274
275 static const char *Reqs[] = {"type", "target", 0};
276
277// Parse the request
278//
279 if (!Parse("find ", Spec, Reqs)) return 1;
280
281// Process the correct find
282//
283 if (Abbrev(Opt.Args[0], "failfiles", 4)) return FindFail(Spec);
284 else if (Abbrev(Opt.Args[0], "mmapped", 4)) return FindMmap(Spec);
285 else if (Abbrev(Opt.Args[0], "nocs", 4)) return FindNocs(Spec);
286 else if (Abbrev(Opt.Args[0], "nochksum", 8)) return FindNocs(Spec);
287 else if (Abbrev(Opt.Args[0], "pinned", 3)) return FindPins(Spec);
288 else if (Abbrev(Opt.Args[0], "unmigrated",4)) return FindUnmi(Spec);
289
290// Nothing we understand
291//
292 Emsg("Unknown find type - ", Opt.Args[0]);
293 return 4;
294}

References Say.

Referenced by xeqArgs().

+ Here is the caller graph for this function:

◆ Help()

int XrdFrmAdmin::Help ( )

Definition at line 304 of file XrdFrmAdmin.cc.

305{
306 static struct CmdInfo {const char *Name;
307 int minL;
308 int maxL;
309 const char *Help;
310 }
311 CmdTab[] = {{"audit", 5, 5, AuditHelp },
312 {"chksum", 6, 6, ChksumHelp },
313 {"find", 1, 4, FindHelp },
314 {"makelf", 6, 6, MakeLFHelp},
315 {"mark", 4, 4, MarkHelp },
316 {"mmap", 4, 4, MmapHelp },
317 {"mv", 2, 2, MvHelp },
318 {"pin", 3, 3, PinHelp },
319 {"query", 1, 5, QueryHelp },
320 {"reloc", 5, 5, RelocHelp },
321 {"rm", 2, 2, RemoveHelp}
322 };
323 static int CmdNum = sizeof(CmdTab)/sizeof(struct CmdInfo);
324 const char *theHelp = HelpHelp;
325 char *Cmd;
326 int i, n;
327
328// Get the next argument (array or string)
329//
330 if (!ArgS) Cmd = ArgV[0];
331 else {XrdOucTokenizer Tokens(ArgS);
332 if ((Cmd = Tokens.GetLine())) Cmd = Tokens.GetToken();
333 }
334
335// Try to give the correct help
336//
337 if (Cmd)
338 {n = strlen(Cmd);
339 for (i = 0; i < CmdNum; i++)
340 if (n <= CmdTab[i].maxL && n >= CmdTab[i].minL
341 && !strncmp(CmdTab[i].Name, Cmd, n)) break;
342 if (i < CmdNum) {Msg("Usage: ", CmdTab[i].Help); return 0;}
343 }
344 Emsg(0, "Usage: ", theHelp);
345 return 0;
346}
int Help

References XrdOucTokenizer::GetLine(), XrdOucTokenizer::GetToken(), and Help().

Referenced by Help(), and xeqArgs().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MakeLF()

int XrdFrmAdmin::MakeLF ( )

Definition at line 359 of file XrdFrmAdmin.cc.

360{
361 static XrdOucArgs Spec(&Say, "frm_admin: ", "",
362 "migratable", 1, "m",
363 "owner", 1, "o:",
364 "purgeable", 1, "p",
365 "recursive", 1, "r",
366 (const char *)0);
367
368 static const char *Reqs[] = {"lfn", 0};
369
370 char *lfn, buff[80], Resp;
371 int ok = 1;
372
373// Parse the request
374//
375 if (!Parse("makelf ", Spec, Reqs)) return 1;
376
377// Process all of the files
378//
379 numFiles = 0;
380 lfn = Opt.Args[0];
381 if (!Opt.MPType) Opt.MPType = 'm';
382 do {Opt.All = VerifyAll(lfn);
383 if ((Resp = VerifyMP("makelf", lfn)) == 'y') ok = mkLock(lfn);
384 } while(Resp != 'a' && ok && (lfn = Spec.getarg()));
385
386// All done
387//
388 if (Resp == 'a' || !ok) Msg("makelf aborted!");
389 sprintf(buff, "%d lock file%s made.", numFiles, (numFiles == 1 ? "" : "s"));
390 Msg(buff);
391 return 0;
392}

References XrdOucArgs::getarg(), and Say.

Referenced by xeqArgs().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Mark()

int XrdFrmAdmin::Mark ( )

Definition at line 404 of file XrdFrmAdmin.cc.

405{
406 static XrdOucArgs Spec(&Say, "frm_admin: ", "",
407 "force", 1, "F",
408 "migratable", 1, "m",
409 "purgeable", 1, "p",
410 "recursive", 1, "r",
411 (const char *)0);
412
413 static const char *Reqs[] = {"lfn", 0};
414
415 char *lfn, buff[80], Resp;
416 int ok = 1;
417
418// Parse the request
419//
420 if (!Parse("mark ", Spec, Reqs)) return 1;
421
422// Process all of the files
423//
424 numFiles = 0;
425 lfn = Opt.Args[0];
426 if (!Opt.MPType) Opt.MPType = 'm';
427 do {Opt.All = VerifyAll(lfn);
428 if ((Resp = VerifyMP("mark", lfn)) == 'y') ok = mkMark(lfn);
429 } while(Resp != 'a' && ok && (lfn = Spec.getarg()));
430
431// All done
432//
433 if (Resp == 'a' || !ok) Msg("mark aborted!");
434 sprintf(buff, "%d file%s marked %s.", numFiles, (numFiles == 1 ? "" : "s"),
435 (Opt.MPType == 'm' ? "migratable" : "purgeable"));
436 Msg(buff);
437 return 0;
438}

References XrdOucArgs::getarg(), and Say.

Referenced by xeqArgs().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Mmap()

int XrdFrmAdmin::Mmap ( )

Definition at line 450 of file XrdFrmAdmin.cc.

451{
452 static XrdOucArgs Spec(&Say, "frm_admin: ", "",
453 "keep", 1, "K",
454 "lock", 1, "f",
455 "off", 1, "l",
456 "recursive", 1, "r",
457 (const char *)0);
458
459 static const char *Reqs[] = {"lfn", 0};
460
461 char *lfn, itbuff[80], Resp;
462 int ok = 1;
463
464// Parse the request
465//
466 if (!Parse("pin ", Spec, Reqs)) return 1;
467
468// Process all of the files
469//
470 numFiles = 0;
471 lfn = Opt.Args[0];
472 Opt.MPType = 'p';
473 do {Opt.All = VerifyAll(lfn);
474 if ((Resp = VerifyMP("mmap", lfn)) == 'y') ok = mkMmap(lfn);
475 } while(Resp != 'a' && ok && (lfn = Spec.getarg()));
476
477// All done
478//
479 if (Resp == 'a' || !ok) Msg("mmap aborted!");
480 sprintf(itbuff,"%d mmap%s processed.",numFiles,(numFiles==1?"":"s"));
481 Msg(itbuff);
482 return 0;
483}

References XrdOucArgs::getarg(), and Say.

Referenced by xeqArgs().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Mv()

int XrdFrmAdmin::Mv ( )

Definition at line 491 of file XrdFrmAdmin.cc.

492{
493 static XrdOucArgs Spec(&Say, "frm_admin: ", "", (const char *)0);
494
495 static const char *Reqs[] = {"oldlfn", "newlfn", 0};
496
497 int rc;
498
499// Parse the request and do it
500//
501 if (!Parse("mv ", Spec, Reqs)) return 1;
502
503// Simply invoke the reloc function in the underlying FS
504//
505 if ((rc = Config.ossFS->Rename(Opt.Args[0], Opt.Args[1])))
506 Emsg(-rc, "rename ", Opt.Args[0]);
507 else Msg(Opt.Args[0], " renamed to ", Opt.Args[1]);
508 return rc != 0;
509}
XrdOss * ossFS
virtual int Rename(const char *oPath, const char *nPath, XrdOucEnv *oEnvP=0, XrdOucEnv *nEnvP=0)=0

References XrdFrm::Config, and Say.

Referenced by xeqArgs().

+ Here is the caller graph for this function:

◆ Pin()

int XrdFrmAdmin::Pin ( )

Definition at line 523 of file XrdFrmAdmin.cc.

524{
525 static XrdOucArgs Spec(&Say, "frm_admin: ", "",
526 "keep", 1, "k:",
527 "recursive", 1, "r",
528 (const char *)0);
529
530 static const char *Reqs[] = {"lfn", 0};
531
532 const char *Act;
533 char *lfn, itbuff[80], Resp;
534 int ok = 1;
535
536// Parse the request
537//
538 if (!Parse("pin ", Spec, Reqs)) return 1;
539
540// Process all of the files
541//
542 numFiles = 0;
543 lfn = Opt.Args[0];
544 Opt.MPType = 'p';
545 do {Opt.All = VerifyAll(lfn);
546 if ((Resp = VerifyMP("pin", lfn)) == 'y') ok = mkPin(lfn);
547 } while(Resp != 'a' && ok && (lfn = Spec.getarg()));
548
549// All done
550//
551 Act = (Opt.KeepTime || Opt.ktAlways ? "" : "un");
552 if (Resp == 'a' || !ok) Msg("pin aborted!");
553 sprintf(itbuff,"%d %spin%s processed.",numFiles,Act,(numFiles==1?"":"s"));
554 Msg(itbuff);
555 return 0;
556}

References XrdOucArgs::getarg(), and Say.

Referenced by xeqArgs().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Query()

int XrdFrmAdmin::Query ( )

Definition at line 571 of file XrdFrmAdmin.cc.

572{
573 static XrdOucArgs Spec(&Say, "frm_admin: ", "", (const char *)0);
574
575 static const char *Reqs[] = {"type", 0};
576 static struct CmdInfo {const char *Name;
577 int (XrdFrmAdmin::*Method)(XrdOucArgs &Spec);
578 }
579 CmdTab[] = {{"pfn", &XrdFrmAdmin::QueryPfn},
580 {"rfn", &XrdFrmAdmin::QueryRfn},
581 {"space", &XrdFrmAdmin::QuerySpace},
582 {"usage", &XrdFrmAdmin::QueryUsage},
583 {"xfrq", &XrdFrmAdmin::QueryXfrQ}
584 };
585 static int CmdNum = sizeof(CmdTab)/sizeof(struct CmdInfo);
586
587 int i;
588
589// Parse the request
590//
591 if (!Parse("query ", Spec, Reqs)) return 1;
592
593// Find the command
594//
595 for (i = 0; i < CmdNum; i++)
596 if (!strcmp(CmdTab[i].Name, Opt.Args[0])) break;
597
598// See if we found the command
599//
600 if (i >= CmdNum)
601 {Emsg("Invalid query type - ", Opt.Args[0]);
602 return 1;
603 }
604
605// Perform required function
606//
607 return (*this.*CmdTab[i].Method)(Spec);
608}

References XrdFrmAdmin(), and Say.

Referenced by xeqArgs().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Quit()

int XrdFrmAdmin::Quit ( )
inline

Definition at line 72 of file XrdFrmAdmin.hh.

72{exit(finalRC); return 0;}

Referenced by xeqArgs().

+ Here is the caller graph for this function:

◆ Reloc()

int XrdFrmAdmin::Reloc ( )

Definition at line 616 of file XrdFrmAdmin.cc.

617{
618 static XrdOucArgs Spec(&Say, "frm_admin: ", "", (const char *)0);
619
620 static const char *Reqs[] = {"lfn", "target", 0};
621
622 int rc;
623
624// Parse the request and do it
625//
626 if (!Parse("reloc ", Spec, Reqs)) return 1;
627
628// Simply invoke the reloc function in the underlying FS
629//
630 if ((rc = Config.ossFS->Reloc("admin", Opt.Args[0], Opt.Args[1])))
631 Emsg(-rc, "reloc ", Opt.Args[0]);
632 else Msg(Opt.Args[0], " relocated to space ", Opt.Args[1]);
633 return rc != 0;
634}
virtual int Reloc(const char *tident, const char *path, const char *cgName, const char *anchor=0)
Definition XrdOss.cc:76

References XrdFrm::Config, and Say.

Referenced by xeqArgs().

+ Here is the caller graph for this function:

◆ Remove()

int XrdFrmAdmin::Remove ( )

Definition at line 646 of file XrdFrmAdmin.cc.

647{
648 static XrdOucArgs Spec(&Say, "frm_admin: ", "",
649 "echo", 1, "E",
650 "force", 1, "F",
651 "recursive", 1, "r",
652 (const char *)0);
653
654 static const char *Reqs[] = {"lfn", 0};
655
656 const char *Txt = "";
657 char buff[80];
658 int rc = 0, aOK = 1;
659
660// Parse the request
661//
662 if (!Parse("rm ", Spec, Reqs)) return 1;
663
664// Do some initialization
665//
666 numDirs = numFiles = numProb = 0;
667
668// Preform action
669//
670 do {Opt.All = VerifyAll(Opt.Args[0]);
671 if ((rc = Unlink(Opt.Args[0])) < 0) aOK = 0;
672 } while(rc && (Opt.Args[0] = Spec.getarg()));
673
674 if (!rc) {Txt = "rm aborted; only "; finalRC = 4;}
675 else if (numProb || !aOK) {Txt = "rm incomplete; only "; finalRC = 4;}
676
677// Compose message
678//
679 sprintf(buff, "%s%d %s and %d %s deleted.", Txt,
680 numFiles, (numFiles != 1 ? "files" : "file"),
681 numDirs, (numDirs != 1 ? "directories" : "directory"));
682 Msg(buff);
683 return 0;
684}

References XrdOucArgs::getarg(), and Say.

Referenced by xeqArgs().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Rename()

int XrdFrmAdmin::Rename ( )

◆ setArgs() [1/2]

void XrdFrmAdmin::setArgs ( char * argv)

Definition at line 696 of file XrdFrmAdmin.cc.

697{
698 ArgC = 0; ArgV = 0; ArgS = args;
699}

◆ setArgs() [2/2]

void XrdFrmAdmin::setArgs ( int argc,
char ** argv )

Definition at line 690 of file XrdFrmAdmin.cc.

691{
692 ArgC = argc; ArgV = argv; ArgS = 0;
693}

◆ xeqArgs()

int XrdFrmAdmin::xeqArgs ( char * Cmd)

Definition at line 705 of file XrdFrmAdmin.cc.

706{
707 static struct CmdInfo {const char *Name;
708 int minLen;
709 int maxLen;
710 int (XrdFrmAdmin::*Method)();
711 }
712 CmdTab[] = {{"audit", 5, 5, &XrdFrmAdmin::Audit},
713 {"chksum", 6, 6, &XrdFrmAdmin::Chksum},
714 {"exit", 4, 4, &XrdFrmAdmin::Quit},
715 {"find", 1, 4, &XrdFrmAdmin::Find},
716 {"help", 1, 4, &XrdFrmAdmin::Help},
717 {"makelf", 6, 6, &XrdFrmAdmin::MakeLF},
718 {"mark", 1, 4, &XrdFrmAdmin::Mark},
719 {"mmap", 1, 4, &XrdFrmAdmin::Mmap},
720 {"mv", 2, 2, &XrdFrmAdmin::Mv},
721 {"pin", 3, 3, &XrdFrmAdmin::Pin},
722 {"query", 1, 5, &XrdFrmAdmin::Query},
723 {"quit", 4, 4, &XrdFrmAdmin::Quit},
724 {"reloc", 5, 5, &XrdFrmAdmin::Reloc},
725 {"rm", 2, 2, &XrdFrmAdmin::Remove}
726 };
727 static int CmdNum = sizeof(CmdTab)/sizeof(struct CmdInfo);
728
729 int i, n = strlen(Cmd);
730
731// Find the command
732//
733 for (i = 0; i < CmdNum; i++)
734 if (n >= CmdTab[i].minLen && n <= CmdTab[i].maxLen
735 && !strncmp(CmdTab[i].Name, Cmd, n)) break;
736
737// See if we found the command
738//
739 if (i >= CmdNum)
740 {Emsg("Invalid command - ", Cmd);
741 return 1;
742 }
743
744// Perform required function
745//
746 return (*this.*CmdTab[i].Method)();
747}

References XrdFrmAdmin(), Audit(), Chksum(), Find(), Help(), MakeLF(), Mark(), Mmap(), Mv(), Pin(), Query(), Quit(), Reloc(), and Remove().

+ Here is the call graph for this function:

The documentation for this class was generated from the following files: