XRootD
Loading...
Searching...
No Matches
XrdMapCluster.cc File Reference
#include <cerrno>
#include <getopt.h>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <strings.h>
#include <unistd.h>
#include <sys/param.h>
#include <sys/types.h>
#include "XProtocol/XProtocol.hh"
#include "XrdCl/XrdClEnv.hh"
#include "XrdCl/XrdClFileSystem.hh"
#include "XrdCl/XrdClDefaultEnv.hh"
#include "XrdNet/XrdNetAddr.hh"
#include "XrdOuc/XrdOucHash.hh"
#include "XrdSys/XrdSysHeaders.hh"
+ Include dependency graph for XrdMapCluster.cc:

Go to the source code of this file.

Macros

#define EMSG(x)
 
#define OPT_TYPE
 

Functions

int main (int argc, char *argv[])
 

Variables

int optind
 
int optopt
 

Macro Definition Documentation

◆ EMSG

#define EMSG ( x)
Value:
std::cerr <<"xrdmapc: " <<x <<std::endl

Definition at line 63 of file XrdMapCluster.cc.

Referenced by main().

◆ OPT_TYPE

#define OPT_TYPE

Definition at line 70 of file XrdMapCluster.cc.

Referenced by main().

Function Documentation

◆ main()

int main ( int argc,
char * argv[] )

Definition at line 475 of file XrdMapCluster.cc.

476{
477 const char *opLetters = ":hl:rv";
478 struct option opVec[] = // For getopt_long()
479 {
480 {OPT_TYPE "help", 0, 0, (int)'h'},
481 {OPT_TYPE "list", 1, 0, (int)'l'},
482 {OPT_TYPE "quiet", 0, 0, (int)'q'},
483 {OPT_TYPE "refresh", 0, 0, (int)'r'},
484 {OPT_TYPE "verify", 0, 0, (int)'v'},
485 {0, 0, 0, 0}
486 };
487 extern int optind, opterr;
488 extern char *optarg;
489 XrdNetAddr sPoint;
490 clMap *baseNode, *clNow;
491 const char *eMsg;
492 char opC;
493 int i;
494 bool doRefresh = false;
495
496// Process options
497//
498 opterr = 0;
499 optind = 1;
500 while((opC = getopt_long(argc, argv, opLetters, opVec, &i)) != (char)-1)
501 switch(opC)
502 {case 'h': Usage(0);
503 break;
504 case 'l': if (!strcmp("all",optarg))
505 {listMan = true; listSrv = true;}
506 else if (!strcmp("m", optarg))
507 {listMan = true; listSrv = false;}
508 else if (!strcmp("s", optarg))
509 {listMan = false; listSrv = true;}
510 else Usage("Invalid list argument.");
511 break;
512 case 'q': doHush = true;
513 break;
514 case 'r': doRefresh = true;
515 break;
516 case 'v': doVerify = true;
517 break;
518 case ':': EMSG("'" <<OpName(argv) <<"' argument missing.");
519 exit(2); break;
520 case '?': EMSG("Invalid option, '" <<OpName(argv) <<"'.");
521 exit(2); break;
522 default: EMSG("Internal error processing '" <<OpName(argv) <<"'.");
523 exit(2); break;
524 }
525
526// Make sure we have a starting point
527//
528 if (optind >= argc) Usage("Initial node not specified.");
529
530// Establish starting point
531//
532 if ((eMsg = sPoint.Set(argv[optind])))
533 {EMSG("Unable to validate initial node; " <<eMsg);
534 exit(2);
535 }
536
537// Make sure it's resolvable
538//
539 if (!sPoint.Name(0, &eMsg))
540 {EMSG("Unable to resolve " <<argv[optind] <<"; " <<eMsg);
541 exit(2);
542 }
543
544// Establish the base node
545//
546 baseNode = new clMap(argv[optind]);
547
548// Check if we will be checking a path
549//
550 if (optind+1 < argc) Path = argv[optind+1];
551 else doVerify = false;
552
553// Set default client values
554//
555 SetEnv();
556
557// Map the cluster
558//
559 MapCluster(baseNode, baseNode);
560
561// Check if we need to do a locate on a file and possibly verify results
562//
563 if (Path)
564 {MapPath(baseNode, Path, doRefresh);
565 eMsg = (doVerify ? "0*rv* " : "0*r** ");
566 } else eMsg = "0**** ";
567
568// Print the first line
569//
570 std::cout <<eMsg <<baseNode->name <<baseNode->state <<std::endl;
571 PrintMap(baseNode, 1);
572
573// Check if we have any phantom nodes
574//
575 if (Path && clLost)
576 {std::cerr <<"Warning! " <<baseNode->name
577 <<" referred to the following unconnected node:" <<std::endl;
578 clNow = clLost;
579 while(clNow)
580 {std::cerr <<"????? " <<clNow->name <<std::endl;
581 clNow = clNow->nextSrv;
582 }
583 }
584
585// All done
586//
587 exit(0);
588}
void Usage(const char *msg)
#define OPT_TYPE
int optind
#define EMSG(x)
XrdOucString Path
#define eMsg(x)
const char * Name(const char *eName=0, const char **eText=0)
const char * Set(const char *hSpec, int pNum=PortInSpec)

References EMSG, eMsg, XrdNetAddrInfo::Name(), OPT_TYPE, optind, Path, XrdNetAddr::Set(), and Usage().

+ Here is the call graph for this function:

Variable Documentation

◆ optind

◆ optopt

int optopt