#include "Riostream.h"
#include "TProofResourcesStatic.h"
#include "TSystem.h"
#include "TInetAddress.h"
#include "TProofNodeInfo.h"
#include "TProofDebug.h"
#include "TUrl.h"
#include "TList.h"
#include "TObjArray.h"
#include "TObjString.h"
#include "TError.h"
ClassImp(TProofResourcesStatic)
TProofResourcesStatic::TProofResourcesStatic()
{
InitResources();
}
TProofResourcesStatic::TProofResourcesStatic(const char *confDir,
const char *fileName)
{
InitResources();
if (!ReadConfigFile(confDir, fileName)) {
PDB(kAll,1)
Info("TProofResourcesStatic", "error encountered while reading config file");
fValid = kFALSE;
}
}
TProofResourcesStatic::~TProofResourcesStatic()
{
delete fSubmasterList;
delete fWorkerList;
delete fMaster;
}
void TProofResourcesStatic::InitResources()
{
fMaster = new TProofNodeInfo();
fMaster->fNodeType = TProofNodeInfo::GetNodeType("master");
fFoundMaster = kFALSE;
fWorkerList = new TList();
fWorkerList->SetOwner();
fSubmasterList = new TList();
fSubmasterList->SetOwner();
fValid = kTRUE;
}
TProofNodeInfo *TProofResourcesStatic::GetMaster()
{
if (fFoundMaster)
return fMaster;
return 0;
}
TList *TProofResourcesStatic::GetSubmasters()
{
return fSubmasterList;
}
TList *TProofResourcesStatic::GetWorkers(void)
{
return fWorkerList;
}
Bool_t TProofResourcesStatic::ReadConfigFile(const char *confDir,
const char *fileName)
{
Bool_t status = kTRUE;
const char *p = (const char *) strstr(fileName,":");
if (p)
fileName = p+1;
const char *cf = gSystem->Getenv("ROOTPROOFCONF");
if (cf && !(gSystem->AccessPathName(cf, kReadPermission))) {
fFileName = cf;
} else {
if (cf)
PDB(kGlobal,1)
Info("ReadConfigFile", "file %s cannot be read:"
" check existence and/or permissions", cf);
if (fileName && strlen(fileName) > 0) {
fFileName.Form("%s/.%s", gSystem->HomeDirectory(), fileName);
PDB(kGlobal,2)
Info("ReadConfigFile", "checking PROOF config file %s", fFileName.Data());
if (gSystem->AccessPathName(fFileName, kReadPermission)) {
fFileName.Form("%s/etc/proof/%s", confDir, fileName);
PDB(kGlobal,2)
Info("ReadConfigFile", "checking PROOF config file %s", fFileName.Data());
if (gSystem->AccessPathName(fFileName, kReadPermission)) {
PDB(kAll,1)
Info("ReadConfigFile", "no PROOF config file found");
return kFALSE;
}
}
} else {
PDB(kAll,1)
Info("ReadConfigFile", "no PROOF config file specified");
return kFALSE;
}
}
PDB(kGlobal,1)
Info("ReadConfigFile", "using PROOF config file: %s", fFileName.Data());
fstream infile(fFileName.Data(), std::ios::in);
if (infile.is_open()) {
Bool_t isMaster = kFALSE;
Bool_t isSubmaster = kFALSE;
Bool_t isWorker = kFALSE;
TString line = "";
TString keyword = "";
TString allLines = "";
allLines.ReadString(infile);
TObjArray *lines = allLines.Tokenize("\n");
Int_t numberOfLines = lines->GetEntries();
for (Int_t j = 0; j < numberOfLines; j++) {
TObjString *objLine = (TObjString *)lines->At(j);
line = objLine->GetString();
line = line.Strip(TString::kBoth);
if ( !((line(0,1) == "#") || (line == "")) ) {
TProofNodeInfo *nodeinfo = 0;
isMaster = kFALSE;
isSubmaster = kFALSE;
isWorker = kFALSE;
TObjArray *tokens = line.Tokenize(" ");
Int_t n = tokens->GetEntries();
TString option;
TString value;
for (Int_t i = 0; i < n; i++) {
keyword = ((TObjString *)tokens->At(i))->GetString();
switch (GetInfoType(keyword)) {
case kNodeType: {
if (keyword == "master" || keyword == "node") {
nodeinfo = CreateNodeInfo(keyword);
isMaster = kTRUE;
}
else if (keyword == "submaster") {
nodeinfo = CreateNodeInfo(keyword);
isSubmaster = kTRUE;
} else {
nodeinfo = CreateNodeInfo(keyword);
isWorker = kTRUE;
}
break;
}
case kHost: {
if (nodeinfo) {
nodeinfo->fNodeName = keyword;
if (isMaster) {
TString node = TUrl(nodeinfo->fNodeName).GetHost();
nodeinfo->fImage = strstr(nodeinfo->fNodeName, node.Data());
} else {
TString tmp = nodeinfo->fNodeName;
const Ssiz_t equalPosition = tmp.Index("@", 1, 0, TString::kExact);
nodeinfo->fImage = tmp(equalPosition + 1, tmp.Length());
}
} else {
Error("ReadConfigFile","Command not recognized: %s (ignored)",
keyword.Data());
}
break;
}
case kOption: {
const Ssiz_t equalPosition =
keyword.Index("=", 1, 0, TString::kExact);
TString tmp = keyword;
option = tmp(0, equalPosition);
value = tmp(equalPosition + 1, tmp.Length());
SetOption(nodeinfo, option, value);
break;
}
default:
break;
}
}
if (isMaster) {
TString node = TUrl(nodeinfo->fNodeName).GetHost();
TString host = gSystem->GetHostByName(gSystem->HostName()).GetHostName();
TInetAddress inetaddr = gSystem->GetHostByName(node);
if (!host.CompareTo(inetaddr.GetHostName()) || (node == "localhost")) {
fFoundMaster = kTRUE;
fMaster->Assign(*nodeinfo);
}
}
if (isWorker) {
fWorkerList->Add(nodeinfo);
}
else if (isSubmaster) {
fSubmasterList->Add(nodeinfo);
}
}
}
infile.close();
if (!fFoundMaster) {
Error("ReadConfigFile","No master info found in config file");
status = kFALSE;
}
}
else {
status = kFALSE;
}
return status;
}
void TProofResourcesStatic::SetOption(TProofNodeInfo *nodeinfo,
const TString &option,
const TString &value)
{
if (!nodeinfo) return;
if (option == "workdir") {
nodeinfo->fWorkDir = value;
} else if (option == "image") {
nodeinfo->fImage = value;
} else if (option == "perf") {
nodeinfo->fPerfIndex = value.Atoi();
} else if (option == "config") {
nodeinfo->fConfig = value;
} else if (option == "msd") {
nodeinfo->fMsd = value;
} else if (option == "port") {
nodeinfo->fPort = value.Atoi();
} else {
::Error("SetOption","No such option [%s=%s]",option.Data(),value.Data());
}
}
TProofResourcesStatic::EInfoType TProofResourcesStatic::GetInfoType(const TString &word)
{
EInfoType type = kNodeType;
if ((word == "node") || (word == "master") || (word == "submaster") ||
(word == "worker") || (word == "slave") ||
(word == "condorworker") || (word == "condorslave")) {
type = kNodeType;
}
else if (word.Contains("=", TString::kExact)) {
type = kOption;
} else {
type = kHost;
}
return type;
}
TProofNodeInfo *TProofResourcesStatic::CreateNodeInfo(const TString &name)
{
TProofNodeInfo *nodeInfo = new TProofNodeInfo();
nodeInfo->fNodeType = TProofNodeInfo::GetNodeType(name);
nodeInfo->fNodeName = name;
nodeInfo->fPort = -1;
nodeInfo->fPerfIndex = 100;
return nodeInfo;
}
TProofResourcesStatic.cxx:1 TProofResourcesStatic.cxx:2 TProofResourcesStatic.cxx:3 TProofResourcesStatic.cxx:4 TProofResourcesStatic.cxx:5 TProofResourcesStatic.cxx:6 TProofResourcesStatic.cxx:7 TProofResourcesStatic.cxx:8 TProofResourcesStatic.cxx:9 TProofResourcesStatic.cxx:10 TProofResourcesStatic.cxx:11 TProofResourcesStatic.cxx:12 TProofResourcesStatic.cxx:13 TProofResourcesStatic.cxx:14 TProofResourcesStatic.cxx:15 TProofResourcesStatic.cxx:16 TProofResourcesStatic.cxx:17 TProofResourcesStatic.cxx:18 TProofResourcesStatic.cxx:19 TProofResourcesStatic.cxx:20 TProofResourcesStatic.cxx:21 TProofResourcesStatic.cxx:22 TProofResourcesStatic.cxx:23 TProofResourcesStatic.cxx:24 TProofResourcesStatic.cxx:25 TProofResourcesStatic.cxx:26 TProofResourcesStatic.cxx:27 TProofResourcesStatic.cxx:28 TProofResourcesStatic.cxx:29 TProofResourcesStatic.cxx:30 TProofResourcesStatic.cxx:31 TProofResourcesStatic.cxx:32 TProofResourcesStatic.cxx:33 TProofResourcesStatic.cxx:34 TProofResourcesStatic.cxx:35 TProofResourcesStatic.cxx:36 TProofResourcesStatic.cxx:37 TProofResourcesStatic.cxx:38 TProofResourcesStatic.cxx:39 TProofResourcesStatic.cxx:40 TProofResourcesStatic.cxx:41 TProofResourcesStatic.cxx:42 TProofResourcesStatic.cxx:43 TProofResourcesStatic.cxx:44 TProofResourcesStatic.cxx:45 TProofResourcesStatic.cxx:46 TProofResourcesStatic.cxx:47 TProofResourcesStatic.cxx:48 TProofResourcesStatic.cxx:49 TProofResourcesStatic.cxx:50 TProofResourcesStatic.cxx:51 TProofResourcesStatic.cxx:52 TProofResourcesStatic.cxx:53 TProofResourcesStatic.cxx:54 TProofResourcesStatic.cxx:55 TProofResourcesStatic.cxx:56 TProofResourcesStatic.cxx:57 TProofResourcesStatic.cxx:58 TProofResourcesStatic.cxx:59 TProofResourcesStatic.cxx:60 TProofResourcesStatic.cxx:61 TProofResourcesStatic.cxx:62 TProofResourcesStatic.cxx:63 TProofResourcesStatic.cxx:64 TProofResourcesStatic.cxx:65 TProofResourcesStatic.cxx:66 TProofResourcesStatic.cxx:67 TProofResourcesStatic.cxx:68 TProofResourcesStatic.cxx:69 TProofResourcesStatic.cxx:70 TProofResourcesStatic.cxx:71 TProofResourcesStatic.cxx:72 TProofResourcesStatic.cxx:73 TProofResourcesStatic.cxx:74 TProofResourcesStatic.cxx:75 TProofResourcesStatic.cxx:76 TProofResourcesStatic.cxx:77 TProofResourcesStatic.cxx:78 TProofResourcesStatic.cxx:79 TProofResourcesStatic.cxx:80 TProofResourcesStatic.cxx:81 TProofResourcesStatic.cxx:82 TProofResourcesStatic.cxx:83 TProofResourcesStatic.cxx:84 TProofResourcesStatic.cxx:85 TProofResourcesStatic.cxx:86 TProofResourcesStatic.cxx:87 TProofResourcesStatic.cxx:88 TProofResourcesStatic.cxx:89 TProofResourcesStatic.cxx:90 TProofResourcesStatic.cxx:91 TProofResourcesStatic.cxx:92 TProofResourcesStatic.cxx:93 TProofResourcesStatic.cxx:94 TProofResourcesStatic.cxx:95 TProofResourcesStatic.cxx:96 TProofResourcesStatic.cxx:97 TProofResourcesStatic.cxx:98 TProofResourcesStatic.cxx:99 TProofResourcesStatic.cxx:100 TProofResourcesStatic.cxx:101 TProofResourcesStatic.cxx:102 TProofResourcesStatic.cxx:103 TProofResourcesStatic.cxx:104 TProofResourcesStatic.cxx:105 TProofResourcesStatic.cxx:106 TProofResourcesStatic.cxx:107 TProofResourcesStatic.cxx:108 TProofResourcesStatic.cxx:109 TProofResourcesStatic.cxx:110 TProofResourcesStatic.cxx:111 TProofResourcesStatic.cxx:112 TProofResourcesStatic.cxx:113 TProofResourcesStatic.cxx:114 TProofResourcesStatic.cxx:115 TProofResourcesStatic.cxx:116 TProofResourcesStatic.cxx:117 TProofResourcesStatic.cxx:118 TProofResourcesStatic.cxx:119 TProofResourcesStatic.cxx:120 TProofResourcesStatic.cxx:121 TProofResourcesStatic.cxx:122 TProofResourcesStatic.cxx:123 TProofResourcesStatic.cxx:124 TProofResourcesStatic.cxx:125 TProofResourcesStatic.cxx:126 TProofResourcesStatic.cxx:127 TProofResourcesStatic.cxx:128 TProofResourcesStatic.cxx:129 TProofResourcesStatic.cxx:130 TProofResourcesStatic.cxx:131 TProofResourcesStatic.cxx:132 TProofResourcesStatic.cxx:133 TProofResourcesStatic.cxx:134 TProofResourcesStatic.cxx:135 TProofResourcesStatic.cxx:136 TProofResourcesStatic.cxx:137 TProofResourcesStatic.cxx:138 TProofResourcesStatic.cxx:139 TProofResourcesStatic.cxx:140 TProofResourcesStatic.cxx:141 TProofResourcesStatic.cxx:142 TProofResourcesStatic.cxx:143 TProofResourcesStatic.cxx:144 TProofResourcesStatic.cxx:145 TProofResourcesStatic.cxx:146 TProofResourcesStatic.cxx:147 TProofResourcesStatic.cxx:148 TProofResourcesStatic.cxx:149 TProofResourcesStatic.cxx:150 TProofResourcesStatic.cxx:151 TProofResourcesStatic.cxx:152 TProofResourcesStatic.cxx:153 TProofResourcesStatic.cxx:154 TProofResourcesStatic.cxx:155 TProofResourcesStatic.cxx:156 TProofResourcesStatic.cxx:157 TProofResourcesStatic.cxx:158 TProofResourcesStatic.cxx:159 TProofResourcesStatic.cxx:160 TProofResourcesStatic.cxx:161 TProofResourcesStatic.cxx:162 TProofResourcesStatic.cxx:163 TProofResourcesStatic.cxx:164 TProofResourcesStatic.cxx:165 TProofResourcesStatic.cxx:166 TProofResourcesStatic.cxx:167 TProofResourcesStatic.cxx:168 TProofResourcesStatic.cxx:169 TProofResourcesStatic.cxx:170 TProofResourcesStatic.cxx:171 TProofResourcesStatic.cxx:172 TProofResourcesStatic.cxx:173 TProofResourcesStatic.cxx:174 TProofResourcesStatic.cxx:175 TProofResourcesStatic.cxx:176 TProofResourcesStatic.cxx:177 TProofResourcesStatic.cxx:178 TProofResourcesStatic.cxx:179 TProofResourcesStatic.cxx:180 TProofResourcesStatic.cxx:181 TProofResourcesStatic.cxx:182 TProofResourcesStatic.cxx:183 TProofResourcesStatic.cxx:184 TProofResourcesStatic.cxx:185 TProofResourcesStatic.cxx:186 TProofResourcesStatic.cxx:187 TProofResourcesStatic.cxx:188 TProofResourcesStatic.cxx:189 TProofResourcesStatic.cxx:190 TProofResourcesStatic.cxx:191 TProofResourcesStatic.cxx:192 TProofResourcesStatic.cxx:193 TProofResourcesStatic.cxx:194 TProofResourcesStatic.cxx:195 TProofResourcesStatic.cxx:196 TProofResourcesStatic.cxx:197 TProofResourcesStatic.cxx:198 TProofResourcesStatic.cxx:199 TProofResourcesStatic.cxx:200 TProofResourcesStatic.cxx:201 TProofResourcesStatic.cxx:202 TProofResourcesStatic.cxx:203 TProofResourcesStatic.cxx:204 TProofResourcesStatic.cxx:205 TProofResourcesStatic.cxx:206 TProofResourcesStatic.cxx:207 TProofResourcesStatic.cxx:208 TProofResourcesStatic.cxx:209 TProofResourcesStatic.cxx:210 TProofResourcesStatic.cxx:211 TProofResourcesStatic.cxx:212 TProofResourcesStatic.cxx:213 TProofResourcesStatic.cxx:214 TProofResourcesStatic.cxx:215 TProofResourcesStatic.cxx:216 TProofResourcesStatic.cxx:217 TProofResourcesStatic.cxx:218 TProofResourcesStatic.cxx:219 TProofResourcesStatic.cxx:220 TProofResourcesStatic.cxx:221 TProofResourcesStatic.cxx:222 TProofResourcesStatic.cxx:223 TProofResourcesStatic.cxx:224 TProofResourcesStatic.cxx:225 TProofResourcesStatic.cxx:226 TProofResourcesStatic.cxx:227 TProofResourcesStatic.cxx:228 TProofResourcesStatic.cxx:229 TProofResourcesStatic.cxx:230 TProofResourcesStatic.cxx:231 TProofResourcesStatic.cxx:232 TProofResourcesStatic.cxx:233 TProofResourcesStatic.cxx:234 TProofResourcesStatic.cxx:235 TProofResourcesStatic.cxx:236 TProofResourcesStatic.cxx:237 TProofResourcesStatic.cxx:238 TProofResourcesStatic.cxx:239 TProofResourcesStatic.cxx:240 TProofResourcesStatic.cxx:241 TProofResourcesStatic.cxx:242 TProofResourcesStatic.cxx:243 TProofResourcesStatic.cxx:244 TProofResourcesStatic.cxx:245 TProofResourcesStatic.cxx:246 TProofResourcesStatic.cxx:247 TProofResourcesStatic.cxx:248 TProofResourcesStatic.cxx:249 TProofResourcesStatic.cxx:250 TProofResourcesStatic.cxx:251 TProofResourcesStatic.cxx:252 TProofResourcesStatic.cxx:253 TProofResourcesStatic.cxx:254 TProofResourcesStatic.cxx:255 TProofResourcesStatic.cxx:256 TProofResourcesStatic.cxx:257 TProofResourcesStatic.cxx:258 TProofResourcesStatic.cxx:259 TProofResourcesStatic.cxx:260 TProofResourcesStatic.cxx:261 TProofResourcesStatic.cxx:262 TProofResourcesStatic.cxx:263 TProofResourcesStatic.cxx:264 TProofResourcesStatic.cxx:265 TProofResourcesStatic.cxx:266 TProofResourcesStatic.cxx:267 TProofResourcesStatic.cxx:268 TProofResourcesStatic.cxx:269 TProofResourcesStatic.cxx:270 TProofResourcesStatic.cxx:271 TProofResourcesStatic.cxx:272 TProofResourcesStatic.cxx:273 TProofResourcesStatic.cxx:274 TProofResourcesStatic.cxx:275 TProofResourcesStatic.cxx:276 TProofResourcesStatic.cxx:277 TProofResourcesStatic.cxx:278 TProofResourcesStatic.cxx:279 TProofResourcesStatic.cxx:280 TProofResourcesStatic.cxx:281 TProofResourcesStatic.cxx:282 TProofResourcesStatic.cxx:283 TProofResourcesStatic.cxx:284 TProofResourcesStatic.cxx:285 TProofResourcesStatic.cxx:286 TProofResourcesStatic.cxx:287 TProofResourcesStatic.cxx:288 TProofResourcesStatic.cxx:289 TProofResourcesStatic.cxx:290 TProofResourcesStatic.cxx:291 TProofResourcesStatic.cxx:292 TProofResourcesStatic.cxx:293 TProofResourcesStatic.cxx:294 TProofResourcesStatic.cxx:295 TProofResourcesStatic.cxx:296 TProofResourcesStatic.cxx:297 TProofResourcesStatic.cxx:298 TProofResourcesStatic.cxx:299 TProofResourcesStatic.cxx:300 TProofResourcesStatic.cxx:301 TProofResourcesStatic.cxx:302 TProofResourcesStatic.cxx:303 TProofResourcesStatic.cxx:304 TProofResourcesStatic.cxx:305 TProofResourcesStatic.cxx:306 TProofResourcesStatic.cxx:307 TProofResourcesStatic.cxx:308 TProofResourcesStatic.cxx:309 TProofResourcesStatic.cxx:310 TProofResourcesStatic.cxx:311 TProofResourcesStatic.cxx:312 TProofResourcesStatic.cxx:313 TProofResourcesStatic.cxx:314 TProofResourcesStatic.cxx:315 TProofResourcesStatic.cxx:316 TProofResourcesStatic.cxx:317 TProofResourcesStatic.cxx:318 TProofResourcesStatic.cxx:319 TProofResourcesStatic.cxx:320 TProofResourcesStatic.cxx:321 TProofResourcesStatic.cxx:322 TProofResourcesStatic.cxx:323 TProofResourcesStatic.cxx:324 TProofResourcesStatic.cxx:325 TProofResourcesStatic.cxx:326 TProofResourcesStatic.cxx:327 TProofResourcesStatic.cxx:328 TProofResourcesStatic.cxx:329 TProofResourcesStatic.cxx:330 TProofResourcesStatic.cxx:331 TProofResourcesStatic.cxx:332 TProofResourcesStatic.cxx:333 TProofResourcesStatic.cxx:334 TProofResourcesStatic.cxx:335 TProofResourcesStatic.cxx:336 TProofResourcesStatic.cxx:337 TProofResourcesStatic.cxx:338 TProofResourcesStatic.cxx:339 TProofResourcesStatic.cxx:340 TProofResourcesStatic.cxx:341 TProofResourcesStatic.cxx:342 TProofResourcesStatic.cxx:343 TProofResourcesStatic.cxx:344 TProofResourcesStatic.cxx:345 TProofResourcesStatic.cxx:346 TProofResourcesStatic.cxx:347 TProofResourcesStatic.cxx:348 TProofResourcesStatic.cxx:349 TProofResourcesStatic.cxx:350 TProofResourcesStatic.cxx:351 TProofResourcesStatic.cxx:352 TProofResourcesStatic.cxx:353 TProofResourcesStatic.cxx:354 TProofResourcesStatic.cxx:355 TProofResourcesStatic.cxx:356 TProofResourcesStatic.cxx:357 TProofResourcesStatic.cxx:358 TProofResourcesStatic.cxx:359 TProofResourcesStatic.cxx:360 TProofResourcesStatic.cxx:361 TProofResourcesStatic.cxx:362 TProofResourcesStatic.cxx:363 TProofResourcesStatic.cxx:364 TProofResourcesStatic.cxx:365 TProofResourcesStatic.cxx:366 TProofResourcesStatic.cxx:367 TProofResourcesStatic.cxx:368 TProofResourcesStatic.cxx:369 TProofResourcesStatic.cxx:370 TProofResourcesStatic.cxx:371 TProofResourcesStatic.cxx:372 TProofResourcesStatic.cxx:373 TProofResourcesStatic.cxx:374 TProofResourcesStatic.cxx:375 TProofResourcesStatic.cxx:376 TProofResourcesStatic.cxx:377 TProofResourcesStatic.cxx:378 TProofResourcesStatic.cxx:379 TProofResourcesStatic.cxx:380 TProofResourcesStatic.cxx:381 TProofResourcesStatic.cxx:382 TProofResourcesStatic.cxx:383 TProofResourcesStatic.cxx:384 TProofResourcesStatic.cxx:385 TProofResourcesStatic.cxx:386 TProofResourcesStatic.cxx:387 TProofResourcesStatic.cxx:388