37 ClassImp(TProofResourcesStatic);
 
   44 TProofResourcesStatic::TProofResourcesStatic()
 
   55 TProofResourcesStatic::TProofResourcesStatic(
const char *confDir,
 
   62    if (!ReadConfigFile(confDir, fileName)) {
 
   64          Info("TProofResourcesStatic", "error encountered while reading config file");
 
   72 TProofResourcesStatic::~TProofResourcesStatic()
 
   74    delete fSubmasterList;
 
   83 void TProofResourcesStatic::InitResources()
 
   86    fMaster = 
new TProofNodeInfo();
 
   87    fMaster->fNodeType = TProofNodeInfo::GetNodeType(
"master");
 
   88    fFoundMaster = kFALSE; 
 
   91    fWorkerList = 
new TList();
 
   92    fWorkerList->SetOwner();
 
   95    fSubmasterList = 
new TList();
 
   96    fSubmasterList->SetOwner();
 
  106 TProofNodeInfo *TProofResourcesStatic::GetMaster()
 
  117 TList *TProofResourcesStatic::GetSubmasters()
 
  119    return fSubmasterList;
 
  125 TList *TProofResourcesStatic::GetWorkers(
void)
 
  133 Bool_t TProofResourcesStatic::ReadConfigFile(
const char *confDir,
 
  134                                              const char *fileName)
 
  136    Bool_t status = kTRUE;
 
  139    const char *p = (
const char *) strstr(fileName,
":");
 
  144    const char *cf = gSystem->Getenv(
"ROOTPROOFCONF");
 
  145    if (cf && !(gSystem->AccessPathName(cf, kReadPermission))) {
 
  150             Info("ReadConfigFile", "file %s cannot be read:"
 
  151                  " check existence and/or permissions", cf);
 
  152       if (fileName && strlen(fileName) > 0) {
 
  155          fFileName.Form(
"%s/.%s", gSystem->HomeDirectory(), fileName);
 
  157             Info("ReadConfigFile", "checking PROOF config file %s", fFileName.Data());
 
  158          if (gSystem->AccessPathName(fFileName, kReadPermission)) {
 
  159             fFileName.Form(
"%s/etc/proof/%s", confDir, fileName);
 
  161                Info("ReadConfigFile", "checking PROOF config file %s", fFileName.Data());
 
  162             if (gSystem->AccessPathName(fFileName, kReadPermission)) {
 
  164                   Info("ReadConfigFile", "no PROOF config file found");
 
  170             Info("ReadConfigFile", "no PROOF config file specified");
 
  175       Info("ReadConfigFile", "using PROOF config file: %s", fFileName.Data());
 
  178    std::fstream infile(fFileName.Data(), std::ios::in);
 
  179    if (infile.is_open()) {
 
  180       Bool_t isMaster = kFALSE;
 
  181       Bool_t isSubmaster = kFALSE;
 
  182       Bool_t isWorker = kFALSE;
 
  191       TString keyword = 
"";
 
  194       TString allLines = 
"";
 
  195       allLines.ReadString(infile);
 
  196       TObjArray *lines = allLines.Tokenize(
"\n");
 
  197       Int_t numberOfLines = lines->GetEntries();
 
  200       for (Int_t j = 0; j < numberOfLines; j++) {
 
  201          TObjString *objLine = (TObjString *)lines->At(j);
 
  202          line = objLine->GetString();
 
  203          line = line.Strip(TString::kBoth);
 
  206          if ( !((line(0,1) == 
"#") || (line == 
"")) ) {
 
  207             TProofNodeInfo *nodeinfo = 0;
 
  211             isSubmaster = kFALSE;
 
  215             TObjArray *tokens = line.Tokenize(
" ");
 
  216             Int_t n = tokens->GetEntries();
 
  219             for (Int_t i = 0; i < n; i++) {
 
  222                keyword = ((TObjString *)tokens->At(i))->GetString();
 
  225                switch (GetInfoType(keyword)) {
 
  227                   if (keyword == 
"master" || keyword == 
"node") {
 
  228                      nodeinfo = CreateNodeInfo(keyword);
 
  232                   else if (keyword == 
"submaster") {
 
  234                      nodeinfo = CreateNodeInfo(keyword);
 
  238                      nodeinfo = CreateNodeInfo(keyword);
 
  246                      nodeinfo->fNodeName = keyword;
 
  250                         TString node = TUrl(nodeinfo->fNodeName).GetHost();
 
  251                         nodeinfo->fImage = strstr(nodeinfo->fNodeName, node.Data());
 
  256                         TString tmp = nodeinfo->fNodeName;
 
  257                         const Ssiz_t equalPosition = tmp.Index(
"@", 1, 0, TString::kExact);
 
  260                         nodeinfo->fImage = tmp(equalPosition + 1, tmp.Length());
 
  263                      Error(
"ReadConfigFile",
"Command not recognized: %s (ignored)",
 
  270                   const Ssiz_t equalPosition =
 
  271                      keyword.Index(
"=", 1, 0, TString::kExact);
 
  274                   TString tmp = keyword;
 
  275                   option = tmp(0, equalPosition);
 
  276                   value = tmp(equalPosition + 1, tmp.Length());
 
  279                   SetOption(nodeinfo, option, value);
 
  291                TString node = TUrl(nodeinfo->fNodeName).GetHost();
 
  292                TString host = gSystem->GetHostByName(gSystem->HostName()).GetHostName();
 
  293                TInetAddress inetaddr = gSystem->GetHostByName(node);
 
  294                if (!host.CompareTo(inetaddr.GetHostName()) || (node == 
"localhost")) {
 
  295                   fFoundMaster = kTRUE;
 
  296                   fMaster->Assign(*nodeinfo);
 
  302                fWorkerList->Add(nodeinfo);
 
  304             else if (isSubmaster) {
 
  305                fSubmasterList->Add(nodeinfo);
 
  314          Error(
"ReadConfigFile",
"No master info found in config file");
 
  330 void TProofResourcesStatic::SetOption(TProofNodeInfo *nodeinfo,
 
  331                                       const TString &option,
 
  332                                       const TString &value)
 
  334    if (!nodeinfo) 
return;
 
  336    if (option == 
"workdir") {
 
  337       nodeinfo->fWorkDir = value;
 
  338    } 
else if (option == 
"image") {
 
  339       nodeinfo->fImage = value;
 
  340    } 
else if (option == 
"perf") {
 
  341       nodeinfo->fPerfIndex = value.Atoi();
 
  342    } 
else if (option == 
"config") {
 
  343       nodeinfo->fConfig = value;
 
  344    } 
else if (option == 
"msd") {
 
  345       nodeinfo->fMsd = value;
 
  346    } 
else if (option == 
"port") {
 
  347       nodeinfo->fPort = value.Atoi();
 
  349       ::Error(
"SetOption",
"No such option [%s=%s]",option.Data(),value.Data());
 
  356 TProofResourcesStatic::EInfoType TProofResourcesStatic::GetInfoType(
const TString &word)
 
  358    EInfoType type = kNodeType;
 
  360    if ((word == 
"node") || (word == 
"master") || (word == 
"submaster") ||
 
  361        (word == 
"worker") || (word == 
"slave") ||
 
  362        (word == 
"condorworker") || (word == 
"condorslave")) {
 
  365    else if (word.Contains(
"=", TString::kExact)) {
 
  377 TProofNodeInfo *TProofResourcesStatic::CreateNodeInfo(
const TString &name)
 
  379    TProofNodeInfo *nodeInfo = 
new TProofNodeInfo();
 
  380    nodeInfo->fNodeType  = TProofNodeInfo::GetNodeType(name);
 
  381    nodeInfo->fNodeName  = name;
 
  382    nodeInfo->fPort      = -1;
 
  383    nodeInfo->fPerfIndex = 100;