#include "TObjArray.h"
#include "TObjString.h"
#include "TProofNodeInfo.h"
ClassImp(TProofNodeInfo)
TProofNodeInfo::TProofNodeInfo()
: fNodeType(kWorker), fPort(-1), fPerfIndex(100), fNWrks(1)
{
}
TProofNodeInfo::TProofNodeInfo(const char *str)
: fNodeType(kWorker), fPort(-1), fPerfIndex(100), fNWrks(1)
{
if (!str || strlen(str) <= 0)
return;
TString ss(str), s;
Ssiz_t from = 0;
if (ss.Tokenize(s, from, "|") && !s.IsNull() && s != "-")
fNodeType = GetNodeType(s);
if (ss.Tokenize(s, from, "|") && !s.IsNull() && s != "-")
fNodeName = s;
if (ss.Tokenize(s, from, "|") && !s.IsNull() && s != "-")
if (s.IsDigit()) fPort = s.Atoi();
if (ss.Tokenize(s, from, "|") && !s.IsNull() && s != "-")
fOrdinal = s;
if (ss.Tokenize(s, from, "|") && !s.IsNull() && s != "-")
fId = s;
if (ss.Tokenize(s, from, "|") && !s.IsNull() && s != "-")
if (s.IsDigit()) fPerfIndex = s.Atoi();
if (ss.Tokenize(s, from, "|") && !s.IsNull() && s != "-")
fImage = s;
if (ss.Tokenize(s, from, "|") && !s.IsNull() && s != "-")
fWorkDir = s;
if (ss.Tokenize(s, from, "|") && !s.IsNull() && s != "-")
fMsd = s;
if (ss.Tokenize(s, from, "|") && !s.IsNull() && s != "-")
fConfig = s;
if (ss.Tokenize(s, from, "|") && !s.IsNull() && s != "-")
if (s.IsDigit()) fNWrks = s.Atoi();
fName.Form("%s:%d", fNodeName.Data(), fPort);
}
TProofNodeInfo::TProofNodeInfo(const TProofNodeInfo &nodeInfo) : TObject(nodeInfo)
{
fName = nodeInfo.fName;
fNodeType = nodeInfo.fNodeType;
fNodeName = nodeInfo.fNodeName;
fWorkDir = nodeInfo.fWorkDir;
fOrdinal = nodeInfo.fOrdinal;
fImage = nodeInfo.fImage;
fId = nodeInfo.fId;
fConfig = nodeInfo.fConfig;
fMsd = nodeInfo.fMsd;
fPort = nodeInfo.fPort;
fPerfIndex = nodeInfo.fPerfIndex;
fNWrks = nodeInfo.fNWrks;
}
void TProofNodeInfo::Assign(const TProofNodeInfo &n)
{
fName = n.fName;
fNodeType = n.fNodeType;
fNodeName = n.fNodeName;
fWorkDir = n.fWorkDir;
fOrdinal = n.fOrdinal;
fImage = n.fImage;
fId = n.fId;
fConfig = n.fConfig;
fMsd = n.fMsd;
fPort = n.fPort;
fPerfIndex = n.fPerfIndex;
fNWrks = n.fNWrks;
}
void TProofNodeInfo::Print(const Option_t *opt) const
{
if (opt[0] == 'c' || opt[0] == 'C') {
Printf("%d %s:%d %s %s", fNodeType, fNodeName.Data(), fPort,
fOrdinal.Data(), fWorkDir.Data());
} else {
Printf(" +++ TProofNodeInfo: %s +++", fName.Data());
Printf(" NodeName: %s, Port: %d, NodeType: %d, Ordinal: %s",
fNodeName.Data(), fPort, fNodeType, fOrdinal.Data());
Printf(" WorkDir: %s, Image: %s", fWorkDir.Data(), fImage.Data());
Printf(" Id: %s, Config: %s", fId.Data(), fConfig.Data());
Printf(" Msd: %s", fMsd.Data());
Printf(" Performance: %d", fPerfIndex);
Printf(" NumberOfWrks: %d", fNWrks);
Printf("+++++++++++++++++++++++++++++++++++++++++++");
}
}
TProofNodeInfo::ENodeType TProofNodeInfo::GetNodeType(const TString &type)
{
ENodeType enType;
if (type == "M" || type == "master") {
enType = kMaster;
}
else if (type == "S" || type == "submaster") {
enType = kSubMaster;
}
else {
enType = kWorker;
}
return enType;
}