Logo ROOT   6.08/07
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 "TObjArray.h"
21 #include "TObjString.h"
22 #include "TProofNodeInfo.h"
23 
25 
26 ////////////////////////////////////////////////////////////////////////////////
27 /// Default constructor.
28 
30  : fNodeType(kWorker), fPort(-1), fPerfIndex(100), fNWrks(1)
31 {
32 }
33 
34 ////////////////////////////////////////////////////////////////////////////////
35 /// Constructor from a string containing all the information in a serialized
36 /// way. Used to decode thr information coming from the coordinator
37 /// <type>|<host@user>|<port>|<ord>|<id>|<perfidx>|<img>|<workdir>|<msd>|<cfg>
38 
40  : fNodeType(kWorker), fPort(-1), fPerfIndex(100), fNWrks(1)
41 {
42  // Needs a non empty string to do something
43  if (!str || strlen(str) <= 0)
44  return;
45 
46  TString ss(str), s;
47  Ssiz_t from = 0;
48  // NodeType
49  if (ss.Tokenize(s, from, "|") && !s.IsNull() && s != "-")
51  // NodeName
52  if (ss.Tokenize(s, from, "|") && !s.IsNull() && s != "-")
53  fNodeName = s;
54  // Port
55  if (ss.Tokenize(s, from, "|") && !s.IsNull() && s != "-")
56  if (s.IsDigit()) fPort = s.Atoi();
57  // Ordinal
58  if (ss.Tokenize(s, from, "|") && !s.IsNull() && s != "-")
59  fOrdinal = s;
60  // ID string
61  if (ss.Tokenize(s, from, "|") && !s.IsNull() && s != "-")
62  fId = s;
63  // Performance
64  if (ss.Tokenize(s, from, "|") && !s.IsNull() && s != "-")
65  if (s.IsDigit()) fPerfIndex = s.Atoi();
66  // Image
67  if (ss.Tokenize(s, from, "|") && !s.IsNull() && s != "-")
68  fImage = s;
69  // Working dir
70  if (ss.Tokenize(s, from, "|") && !s.IsNull() && s != "-")
71  fWorkDir = s;
72  // Mass Storage Domain
73  if (ss.Tokenize(s, from, "|") && !s.IsNull() && s != "-")
74  fMsd = s;
75  // Config file (master or submaster; for backward compatibility)
76  if (ss.Tokenize(s, from, "|") && !s.IsNull() && s != "-")
77  fConfig = s;
78  // Number of workers
79  if (ss.Tokenize(s, from, "|") && !s.IsNull() && s != "-")
80  if (s.IsDigit()) fNWrks = s.Atoi();
81 
82  // Set the name
83  fName.Form("%s:%d", fNodeName.Data(), fPort);
84 }
85 
86 ////////////////////////////////////////////////////////////////////////////////
87 /// Copy constructor.
88 
90 {
91  fName = nodeInfo.fName;
92  fNodeType = nodeInfo.fNodeType;
93  fNodeName = nodeInfo.fNodeName;
94  fWorkDir = nodeInfo.fWorkDir;
95  fOrdinal = nodeInfo.fOrdinal;
96  fImage = nodeInfo.fImage;
97  fId = nodeInfo.fId;
98  fConfig = nodeInfo.fConfig;
99  fMsd = nodeInfo.fMsd;
100  fPort = nodeInfo.fPort;
101  fPerfIndex = nodeInfo.fPerfIndex;
102  fNWrks = nodeInfo.fNWrks;
103 }
104 
105 ////////////////////////////////////////////////////////////////////////////////
106 /// Asssign content of node n to this node
107 
109 {
110  fName = n.fName;
111  fNodeType = n.fNodeType;
112  fNodeName = n.fNodeName;
113  fWorkDir = n.fWorkDir;
114  fOrdinal = n.fOrdinal;
115  fImage = n.fImage;
116  fId = n.fId;
117  fConfig = n.fConfig;
118  fMsd = n.fMsd;
119  fPort = n.fPort;
121  fNWrks = n.fNWrks;
122 }
123 
124 ////////////////////////////////////////////////////////////////////////////////
125 /// Print the TProofNodeInfo structure.
126 
127 void TProofNodeInfo::Print(const Option_t *opt) const
128 {
129  if (opt[0] == 'c' || opt[0] == 'C') {
130  Printf("%d %s:%d %s %s", fNodeType, fNodeName.Data(), fPort,
131  fOrdinal.Data(), fWorkDir.Data());
132  } else {
133  Printf(" +++ TProofNodeInfo: %s +++", fName.Data());
134  Printf(" NodeName: %s, Port: %d, NodeType: %d, Ordinal: %s",
136  Printf(" WorkDir: %s, Image: %s", fWorkDir.Data(), fImage.Data());
137  Printf(" Id: %s, Config: %s", fId.Data(), fConfig.Data());
138  Printf(" Msd: %s", fMsd.Data());
139  Printf(" Performance: %d", fPerfIndex);
140  Printf(" NumberOfWrks: %d", fNWrks);
141  Printf("+++++++++++++++++++++++++++++++++++++++++++");
142  }
143 }
144 
145 ////////////////////////////////////////////////////////////////////////////////
146 /// Static method returning node type. Allowed input: "master", "submaster",
147 /// or anything else which will be interpreted as worker.
148 
150 {
151  ENodeType enType;
152 
153  if (type == "M" || type == "master") {
154  enType = kMaster;
155  }
156  else if (type == "S" || type == "submaster") {
157  enType = kSubMaster;
158  }
159  else { // [worker/slave or condorworker]
160  enType = kWorker;
161  }
162 
163  return enType;
164 }
ENodeType GetNodeType() const
const char Option_t
Definition: RtypesCore.h:62
Basic string class.
Definition: TString.h:137
void Print(const Option_t *) const
Print the TProofNodeInfo structure.
The purpose of this class is to provide a complete node description for masters, submasters and worke...
ENodeType fNodeType
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Definition: TString.cxx:2322
#define Printf
Definition: TGeoToOCC.h:18
int Ssiz_t
Definition: RtypesCore.h:63
#define ClassImp(name)
Definition: Rtypes.h:279
int type
Definition: TGX11.cxx:120
Bool_t IsNull() const
Definition: TString.h:387
Mother of all ROOT objects.
Definition: TObject.h:37
Int_t Atoi() const
Return integer value of string.
Definition: TString.cxx:1965
Bool_t IsDigit() const
Returns true if all characters in string are digits (0-9) or white spaces, i.e.
Definition: TString.cxx:1807
TProofNodeInfo()
Default constructor.
void Assign(const TProofNodeInfo &n)
Asssign content of node n to this node.
const Int_t n
Definition: legend1.C:16
const char * Data() const
Definition: TString.h:349