Logo ROOT  
Reference Guide
TProofNodeInfo.cxx
Go to the documentation of this file.
1 // @(#)root/proof:$Id$
2 // Author: Paul Nilsson 7/12/2005
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2005, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 /** \class TProofNodeInfo
13 \ingroup proofkernel
14 
15 The purpose of this class is to provide a complete node description
16 for masters, submasters and workers.
17 
18 */
19 
20 #include "TProofNodeInfo.h"
21 
23 
24 ////////////////////////////////////////////////////////////////////////////////
25 /// Default constructor.
26 
28  : fNodeType(kWorker), fPort(-1), fPerfIndex(100), fNWrks(1)
29 {
30 }
31 
32 ////////////////////////////////////////////////////////////////////////////////
33 /// Constructor from a string containing all the information in a serialized
34 /// way. Used to decode thr information coming from the coordinator
35 /// <type>|<host@user>|<port>|<ord>|<id>|<perfidx>|<img>|<workdir>|<msd>|<cfg>
36 
38  : fNodeType(kWorker), fPort(-1), fPerfIndex(100), fNWrks(1)
39 {
40  // Needs a non empty string to do something
41  if (!str || strlen(str) <= 0)
42  return;
43 
44  TString ss(str), s;
45  Ssiz_t from = 0;
46  // NodeType
47  if (ss.Tokenize(s, from, "|") && !s.IsNull() && s != "-")
49  // NodeName
50  if (ss.Tokenize(s, from, "|") && !s.IsNull() && s != "-")
51  fNodeName = s;
52  // Port
53  if (ss.Tokenize(s, from, "|") && !s.IsNull() && s != "-")
54  if (s.IsDigit()) fPort = s.Atoi();
55  // Ordinal
56  if (ss.Tokenize(s, from, "|") && !s.IsNull() && s != "-")
57  fOrdinal = s;
58  // ID string
59  if (ss.Tokenize(s, from, "|") && !s.IsNull() && s != "-")
60  fId = s;
61  // Performance
62  if (ss.Tokenize(s, from, "|") && !s.IsNull() && s != "-")
63  if (s.IsDigit()) fPerfIndex = s.Atoi();
64  // Image
65  if (ss.Tokenize(s, from, "|") && !s.IsNull() && s != "-")
66  fImage = s;
67  // Working dir
68  if (ss.Tokenize(s, from, "|") && !s.IsNull() && s != "-")
69  fWorkDir = s;
70  // Mass Storage Domain
71  if (ss.Tokenize(s, from, "|") && !s.IsNull() && s != "-")
72  fMsd = s;
73  // Config file (master or submaster; for backward compatibility)
74  if (ss.Tokenize(s, from, "|") && !s.IsNull() && s != "-")
75  fConfig = s;
76  // Number of workers
77  if (ss.Tokenize(s, from, "|") && !s.IsNull() && s != "-")
78  if (s.IsDigit()) fNWrks = s.Atoi();
79 
80  // Set the name
81  fName.Form("%s:%d", fNodeName.Data(), fPort);
82 }
83 
84 ////////////////////////////////////////////////////////////////////////////////
85 /// Copy constructor.
86 
88 {
89  fName = nodeInfo.fName;
90  fNodeType = nodeInfo.fNodeType;
91  fNodeName = nodeInfo.fNodeName;
92  fWorkDir = nodeInfo.fWorkDir;
93  fOrdinal = nodeInfo.fOrdinal;
94  fImage = nodeInfo.fImage;
95  fId = nodeInfo.fId;
96  fConfig = nodeInfo.fConfig;
97  fMsd = nodeInfo.fMsd;
98  fPort = nodeInfo.fPort;
99  fPerfIndex = nodeInfo.fPerfIndex;
100  fNWrks = nodeInfo.fNWrks;
101 }
102 
103 ////////////////////////////////////////////////////////////////////////////////
104 /// Asssign content of node n to this node
105 
107 {
108  fName = n.fName;
109  fNodeType = n.fNodeType;
110  fNodeName = n.fNodeName;
111  fWorkDir = n.fWorkDir;
112  fOrdinal = n.fOrdinal;
113  fImage = n.fImage;
114  fId = n.fId;
115  fConfig = n.fConfig;
116  fMsd = n.fMsd;
117  fPort = n.fPort;
118  fPerfIndex = n.fPerfIndex;
119  fNWrks = n.fNWrks;
120 }
121 
122 ////////////////////////////////////////////////////////////////////////////////
123 /// Print the TProofNodeInfo structure.
124 
125 void TProofNodeInfo::Print(const Option_t *opt) const
126 {
127  if (opt[0] == 'c' || opt[0] == 'C') {
128  Printf("%d %s:%d %s %s", fNodeType, fNodeName.Data(), fPort,
129  fOrdinal.Data(), fWorkDir.Data());
130  } else {
131  Printf(" +++ TProofNodeInfo: %s +++", fName.Data());
132  Printf(" NodeName: %s, Port: %d, NodeType: %d, Ordinal: %s",
134  Printf(" WorkDir: %s, Image: %s", fWorkDir.Data(), fImage.Data());
135  Printf(" Id: %s, Config: %s", fId.Data(), fConfig.Data());
136  Printf(" Msd: %s", fMsd.Data());
137  Printf(" Performance: %d", fPerfIndex);
138  Printf(" NumberOfWrks: %d", fNWrks);
139  Printf("+++++++++++++++++++++++++++++++++++++++++++");
140  }
141 }
142 
143 ////////////////////////////////////////////////////////////////////////////////
144 /// Static method returning node type. Allowed input: "master", "submaster",
145 /// or anything else which will be interpreted as worker.
146 
148 {
149  ENodeType enType;
150 
151  if (type == "M" || type == "master") {
152  enType = kMaster;
153  }
154  else if (type == "S" || type == "submaster") {
155  enType = kSubMaster;
156  }
157  else { // [worker/slave or condorworker]
158  enType = kWorker;
159  }
160 
161  return enType;
162 }
n
const Int_t n
Definition: legend1.C:16
TProofNodeInfo::fWorkDir
TString fWorkDir
Definition: TProofNodeInfo.h:43
TProofNodeInfo::fNodeName
TString fNodeName
Definition: TProofNodeInfo.h:42
TString::Data
const char * Data() const
Definition: TString.h:369
TProofNodeInfo::fPerfIndex
Int_t fPerfIndex
Definition: TProofNodeInfo.h:50
ClassImp
#define ClassImp(name)
Definition: Rtypes.h:364
TProofNodeInfo.h
TGeant4Unit::s
static constexpr double s
Definition: TGeant4SystemOfUnits.h:168
TString
Definition: TString.h:136
TProofNodeInfo
Definition: TProofNodeInfo.h:32
TProofNodeInfo::fNodeType
ENodeType fNodeType
Definition: TProofNodeInfo.h:40
TString::Form
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Definition: TString.cxx:2289
Option_t
const typedef char Option_t
Definition: RtypesCore.h:66
TProofNodeInfo::kMaster
@ kMaster
Definition: TProofNodeInfo.h:37
TProofNodeInfo::kSubMaster
@ kSubMaster
Definition: TProofNodeInfo.h:37
TProofNodeInfo::fImage
TString fImage
Definition: TProofNodeInfo.h:45
TProofNodeInfo::TProofNodeInfo
TProofNodeInfo()
Default constructor.
Definition: TProofNodeInfo.cxx:27
TProofNodeInfo::GetNodeType
ENodeType GetNodeType() const
Definition: TProofNodeInfo.h:62
TProofNodeInfo::fId
TString fId
Definition: TProofNodeInfo.h:46
Printf
void Printf(const char *fmt,...)
TProofNodeInfo::fMsd
TString fMsd
Definition: TProofNodeInfo.h:48
TObject
Definition: TObject.h:37
TProofNodeInfo::fName
TString fName
Definition: TProofNodeInfo.h:41
TProofNodeInfo::Print
void Print(const Option_t *) const
Print the TProofNodeInfo structure.
Definition: TProofNodeInfo.cxx:125
TProofNodeInfo::fOrdinal
TString fOrdinal
Definition: TProofNodeInfo.h:44
TProofNodeInfo::kWorker
@ kWorker
Definition: TProofNodeInfo.h:37
TProofNodeInfo::fPort
Int_t fPort
Definition: TProofNodeInfo.h:49
TProofNodeInfo::Assign
void Assign(const TProofNodeInfo &n)
Asssign content of node n to this node.
Definition: TProofNodeInfo.cxx:106
TProofNodeInfo::fNWrks
Int_t fNWrks
Definition: TProofNodeInfo.h:51
TProofNodeInfo::ENodeType
ENodeType
Definition: TProofNodeInfo.h:37
type
int type
Definition: TGX11.cxx:121
TProofNodeInfo::fConfig
TString fConfig
Definition: TProofNodeInfo.h:47
int