Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
15The purpose of this class is to provide a complete node description
16for 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
125void 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,
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}
const char Option_t
Definition RtypesCore.h:66
#define ClassImp(name)
Definition Rtypes.h:364
int type
Definition TGX11.cxx:121
void Printf(const char *fmt,...)
Mother of all ROOT objects.
Definition TObject.h:41
The purpose of this class is to provide a complete node description for masters, submasters and worke...
void Print(const Option_t *) const
Print the TProofNodeInfo structure.
TProofNodeInfo()
Default constructor.
ENodeType fNodeType
void Assign(const TProofNodeInfo &n)
Asssign content of node n to this node.
ENodeType GetNodeType() const
Basic string class.
Definition TString.h:136
Int_t Atoi() const
Return integer value of string.
Definition TString.cxx:1946
const char * Data() const
Definition TString.h:369
Bool_t IsDigit() const
Returns true if all characters in string are digits (0-9) or white spaces, i.e.
Definition TString.cxx:1788
Bool_t IsNull() const
Definition TString.h:407
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Definition TString.cxx:2314
const Int_t n
Definition legend1.C:16