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