XRootD
Loading...
Searching...
No Matches
XrdCmsManTree Class Reference

#include <XrdCmsManTree.hh>

+ Collaboration diagram for XrdCmsManTree:

Public Types

enum  connStat {
  Aborted ,
  Active ,
  Connected ,
  None ,
  Pending ,
  Waiting
}
 

Public Member Functions

 XrdCmsManTree (int maxC)
 
 ~XrdCmsManTree ()
 
void Abort ()
 
int Connect (int nID, XrdCmsNode *nP)
 
void Disc (int nID)
 
int Register ()
 
int Trying (int nID, int Lvl)
 

Detailed Description

Definition at line 38 of file XrdCmsManTree.hh.

Member Enumeration Documentation

◆ connStat

Enumerator
Aborted 
Active 
Connected 
None 
Pending 
Waiting 

Definition at line 52 of file XrdCmsManTree.hh.

Constructor & Destructor Documentation

◆ XrdCmsManTree()

XrdCmsManTree::XrdCmsManTree ( int  maxC)

Definition at line 45 of file XrdCmsManTree.cc.

45 : maxTMI(0), numConn(0), maxConn(maxC),
46 atRoot(0), conLevel(0), conNID(-1),
47 numWaiting(0), myStatus(Active)
48{
49 snprintf(buff, sizeof(buff), "%d", maxC);
50}

◆ ~XrdCmsManTree()

XrdCmsManTree::~XrdCmsManTree ( )
inline

Definition at line 55 of file XrdCmsManTree.hh.

55{};

Member Function Documentation

◆ Abort()

void XrdCmsManTree::Abort ( )

Definition at line 56 of file XrdCmsManTree.cc.

57{
58 XrdSysMutexHelper Monitor(myMutex);
59
60// An abort may be issued to make sure no one is waiting to participate in
61// tree construction. It's usually issued when the manager object has been
62// permanently redirected.
63//
64 if (myStatus != Aborted && numWaiting)
65 {for (int i = 0; i < maxTMI; i++)
66 if (tmInfo[i].Status == Waiting) {tmInfo[i].Level = 0; Redrive(i);}
67 }
68
69// Indicate we have aborted
70//
71 myStatus = Aborted;
72}

References Aborted, and Waiting.

Referenced by XrdCmsManager::Rerun().

+ Here is the caller graph for this function:

◆ Connect()

int XrdCmsManTree::Connect ( int  nID,
XrdCmsNode nP 
)

Definition at line 78 of file XrdCmsManTree.cc.

79{
80 static CmsDiscRequest discRequest = {{0, kYR_disc, 0, 0}};
81 XrdSysMutexHelper Monitor(myMutex);
82 char mybuff[16];
83 int i;
84
85// Rule 0: If we aborted tell the client to just stop doing this
86//
87 if (myStatus == Aborted) return 0;
88
89// Rule 1: If we are already connected, thell the caller to disband the
90// connection as we must have a connection to an interior node.
91//
92 if (myStatus == Connected) return 0;
93 numConn++;
94 tmInfo[nID].nodeP = nP;
95
96// Rule 2: If we connected to a root node then consider ourselves connected
97// only if all connections are to the root.
98//
99 if (tmInfo[nID].Level == 0)
100 {if (numConn == maxConn)
101 {myStatus = Connected; conLevel = 0; atRoot = 1;
102 Say.Emsg("ManTree", "Now connected to", buff, "root node(s)");
103 }
104 tmInfo[nID].Status = Connected;
105 return 1;
106 }
107
108// Rule 3: We connected to an interior node. Disband all other existing
109// connections (these should only be to root nodes) and consider
110// ourselves connected.
111//
112 for (i = 0; i < maxTMI; i++)
113 if (i != nID && tmInfo[i].Status == Connected)
114 {tmInfo[i].nodeP->Send((char *)&discRequest, sizeof(discRequest));
115 tmInfo[i].Status = Pending;
116 }
117 myStatus = Connected;
118 conLevel = tmInfo[nID].Level;
119 conNID = nID;
120 atRoot = 0;
121
122// Document our connection configuration
123//
124 snprintf(mybuff, sizeof(mybuff), "%d", conLevel);
125 Say.Emsg("ManTree", "Now connected to supervisor at level", mybuff);
126 return 1;
127}
int Emsg(const char *esfx, int ecode, const char *text1, const char *text2=0)
XrdSysError Say

References Aborted, Connected, XrdSysError::Emsg(), XrdCms::kYR_disc, Pending, and XrdCms::Say.

+ Here is the call graph for this function:

◆ Disc()

void XrdCmsManTree::Disc ( int  nID)

Definition at line 133 of file XrdCmsManTree.cc.

134{
135
136// A connected caller has lost it's connection.
137//
138 myMutex.Lock();
139 if (tmInfo[nID].Status == Connected || tmInfo[nID].Status == Pending)
140 numConn--;
141 tmInfo[nID].Status = Active;
142 if (atRoot || (conLevel && conNID == nID)) myStatus = Active;
143 tmInfo[nID].nodeP = 0;
144 myMutex.UnLock();
145}

References Active, Connected, XrdSysMutex::Lock(), Pending, and XrdSysMutex::UnLock().

+ Here is the call graph for this function:

◆ Register()

int XrdCmsManTree::Register ( )

Definition at line 151 of file XrdCmsManTree.cc.

152{
153 int nID;
154
155// Add this server to the tree table. Register is called only once and there
156// can be no more than MTMax connections to a manager. Hence, we dispense with
157// error checking (how optimistic :-)
158//
159 myMutex.Lock();
160 tmInfo[maxTMI].Status= Active;
161 nID = maxTMI; maxTMI++;
162 myMutex.UnLock();
163 return nID;
164}

References Active, XrdSysMutex::Lock(), and XrdSysMutex::UnLock().

+ Here is the call graph for this function:

◆ Trying()

int XrdCmsManTree::Trying ( int  nID,
int  Lvl 
)

Definition at line 178 of file XrdCmsManTree.cc.

179{
180 int i;
181
182// Set the current status of the connection
183//
184 myMutex.Lock();
185 tmInfo[nID].Level = lvl;
186
187// Rule 0: If we aborted tell the client to just stop doing this
188//
189 if (myStatus == Aborted) return -1;
190
191// Rule 1: If we are already connected at level >0 then the caller must wait
192//
193 if (myStatus == Connected && conLevel > 0)
194 {Pause(nID);
195 return (lvl == tmInfo[nID].Level);
196 }
197
198// Rule 2: If the caller is trying level 0 then any waiting threads must be
199// allowed to continue but forced to level 0. This allows us to discover
200// all the supervisors connected to the root.
201//
202 if (!lvl)
203 {if (numWaiting)
204 {for (i = 0; i < maxTMI; i++)
205 if (i != nID && tmInfo[i].Status == Waiting)
206 {tmInfo[i].Level = 0; Redrive(i);}
207 }
208 myMutex.UnLock();
209 return 1;
210 }
211
212// Rule 3: If the caller is trying at a non-zero level (interior node) and
213// someone else is trying at a non-zero level, then the caller must
214// wait.
215//
216 for (i = 0; i < maxTMI; i++)
217 if (i != nID && tmInfo[i].Status == Active && tmInfo[i].Level) break;
218 if (i < maxTMI) Pause(nID);
219 else myMutex.UnLock();
220
221// The caller may continue. Indicate whether the caller must restart at the
222// root node. If the caller may continue trying to connect to an interior
223// node then it's the only thread trying to do so.
224//
225 return (lvl == tmInfo[nID].Level);
226}

References Aborted, Active, Connected, XrdSysMutex::Lock(), XrdSysMutex::UnLock(), and Waiting.

+ Here is the call graph for this function:

The documentation for this class was generated from the following files: