XRootD
XrdCmsClustID Class Reference

#include <XrdCmsClustID.hh>

+ Collaboration diagram for XrdCmsClustID:

Public Member Functions

 XrdCmsClustID ()
 
 ~XrdCmsClustID ()
 
bool AddNode (XrdCmsNode *nP, bool isMan)
 
bool Avail ()
 
bool Exists (XrdLink *lp, const char *nid, int port)
 
bool IsEmpty ()
 
bool IsSingle ()
 
XrdCmsNodeRemNode (XrdCmsNode *nP)
 
int Slot ()
 

Static Public Member Functions

static XrdCmsClustIDAddID (const char *cID)
 
static XrdCmsClustIDFind (const char *cID)
 
static SMask_t Mask (const char *cID)
 

Detailed Description

Definition at line 40 of file XrdCmsClustID.hh.

Constructor & Destructor Documentation

◆ XrdCmsClustID()

XrdCmsClustID::XrdCmsClustID ( )
inline

Definition at line 64 of file XrdCmsClustID.hh.

64  : cidMask(0), cidName(0), ntSlot(-1), npNum(0)
65  {memset(nodeP, 0, sizeof(nodeP));}

◆ ~XrdCmsClustID()

XrdCmsClustID::~XrdCmsClustID ( )
inline

Definition at line 67 of file XrdCmsClustID.hh.

67 {if (cidName) free(cidName);}

Member Function Documentation

◆ AddID()

XrdCmsClustID * XrdCmsClustID::AddID ( const char *  cID)
static

Definition at line 57 of file XrdCmsClustID.cc.

58 {
59  XrdCmsClustID *cidObj;
60  const char *cHN;
61  char *clustID;
62 
63 // Massage the clusterid (it's in bi-compatible format)
64 //
65  if ((cHN = rindex(cID, ' ')) && *(cHN+1)) cID = cHN+1;
66  clustID = strdup(cID);
67 
68 // Lock ourselves
69 //
70  cidMtx.Lock();
71 
72 // Allocate a new cluster ID object if we don't have one ready
73 //
74  if (!cidFree) cidFree = new XrdCmsClustID();
75 
76 // Attempt to add this object to our cid table
77 //
78  if (!(cidObj = cidTab.Add(clustID, cidFree, 0, Hash_keep)))
79  {cidObj = cidFree;
80  cidObj->cidName = clustID;
81  cidFree = new XrdCmsClustID();
82  } else free(clustID);
83 
84 // We can unlock now
85 //
86  cidMtx.UnLock();
87 
88 // Return the entry
89 //
90  return cidObj;
91 }
@ Hash_keep
Definition: XrdOucHash.hh:55

References Hash_keep.

Referenced by XrdCmsCluster::Add().

+ Here is the caller graph for this function:

◆ AddNode()

bool XrdCmsClustID::AddNode ( XrdCmsNode nP,
bool  isMan 
)

Definition at line 97 of file XrdCmsClustID.cc.

98 {
99  EPNAME("AddNode");
100  XrdSysMutexHelper cidHelper(cidMtx);
101  int iNum, sNum;
102 
103 // For servers we only add the identification mask
104 //
105  if (!isMan)
106  {cidMask |= nP->Mask();
107  DEBUG("srv " <<nP->Ident <<" cluster " <<cidName <<" anum=" <<npNum);
108  return true;
109  }
110 
111 // Make sure we have enough space in the table
112 //
113  if (npNum >= altMax)
114  {Say.Emsg("ClustID",cidName,"alternate table full; rejecting",nP->Name());
115  return false;
116  }
117 
118 // Make sure the slot numbers match for this node
119 //
120  sNum = nP->ID(iNum);
121  if (npNum > 0 && ntSlot != sNum)
122  {char buff[256];
123  sprintf(buff,"cluster slot mismatch: %d != %d; rejecting",sNum,ntSlot);
124  Say.Emsg("ClustID", cidName, buff, nP->Name());
125  return false;
126  }
127 
128 // Add the entry to the table
129 //
130  ntSlot = sNum;
131  cidMask |= nP->Mask();
132  nodeP[npNum++] = nP;
133  DEBUG("man " <<nP->Ident <<" cluster " <<cidName <<" anum=" <<npNum);
134  return true;
135 }
#define DEBUG(x)
Definition: XrdBwmTrace.hh:54
#define EPNAME(x)
Definition: XrdBwmTrace.hh:56
char * Ident
Definition: XrdCmsNode.hh:61
SMask_t Mask()
Definition: XrdCmsNode.hh:160
int ID(int &INum)
Definition: XrdCmsNode.hh:139
char * Name()
Definition: XrdCmsNode.hh:158
int Emsg(const char *esfx, int ecode, const char *text1, const char *text2=0)
Definition: XrdSysError.cc:95
XrdSysError Say

References DEBUG, XrdSysError::Emsg(), EPNAME, XrdCmsNode::ID(), XrdCmsNode::Ident, XrdCmsNode::Mask(), XrdCmsNode::Name(), and XrdCms::Say.

Referenced by XrdCmsCluster::Add().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Avail()

bool XrdCmsClustID::Avail ( )
inline

Definition at line 48 of file XrdCmsClustID.hh.

48 {return npNum < altMax;}

◆ Exists()

bool XrdCmsClustID::Exists ( XrdLink lp,
const char *  nid,
int  port 
)

Definition at line 141 of file XrdCmsClustID.cc.

142 {
143  XrdSysMutexHelper cidHelper(cidMtx);
144 
145 // Simply scan the table to see if this node is present
146 //
147  for (int i = 0; i <npNum; i++)
148  {if (nodeP[i]->isNode(lp, nid, port)) return true;}
149  return false;
150 }

◆ Find()

XrdCmsClustID * XrdCmsClustID::Find ( const char *  cID)
static

Definition at line 156 of file XrdCmsClustID.cc.

157 {
158  XrdCmsClustID *cidObj;
159  const char *cHN;
160 
161 // Massage the clusterid (it's in bi-compatible format)
162 //
163  if ((cHN = rindex(cID, ' ')) && *(cHN+1)) cID = cHN+1;
164 
165 // Lock ourselves
166 //
167  cidMtx.Lock();
168 
169 // Attempt to find the cluster object
170 //
171  cidObj = cidTab.Find(cID);
172 
173 // We can unlock now
174 //
175  cidMtx.UnLock();
176 
177 // Return the entry
178 //
179  return cidObj;
180 }
static XrdCmsClustID * Find(const char *cID)

References Find().

Referenced by XrdCmsCluster::Add(), Find(), and Mask().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ IsEmpty()

bool XrdCmsClustID::IsEmpty ( )
inline

Definition at line 56 of file XrdCmsClustID.hh.

56 {return npNum < 1;}

Referenced by XrdCmsCluster::Add().

+ Here is the caller graph for this function:

◆ IsSingle()

bool XrdCmsClustID::IsSingle ( )
inline

Definition at line 58 of file XrdCmsClustID.hh.

58 {return npNum == 1;}

Referenced by XrdCmsCluster::Remove().

+ Here is the caller graph for this function:

◆ Mask()

SMask_t XrdCmsClustID::Mask ( const char *  cID)
static

Definition at line 186 of file XrdCmsClustID.cc.

187 {
188  XrdCmsClustID *cidObj;
189  SMask_t theMask;
190  const char *cHN;
191 
192 // Massage the clusterid (it's in bi-compatible format)
193 //
194  if ((cHN = rindex(cID, ' ')) && *(cHN+1)) cID = cHN+1;
195 
196 // Lock ourselves
197 //
198  cidMtx.Lock();
199 
200 // Attempt to find the cluster object
201 //
202  if ((cidObj = cidTab.Find(cID))) theMask = cidObj->cidMask;
203  else theMask = 0;
204 
205 // We can unlock now
206 //
207  cidMtx.UnLock();
208 
209 // Return the mask
210 //
211  return theMask;
212 }
unsigned long long SMask_t
Definition: XrdCmsTypes.hh:33

References Find().

Referenced by XrdCmsCluster::getMask().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ RemNode()

XrdCmsNode * XrdCmsClustID::RemNode ( XrdCmsNode nP)

Definition at line 218 of file XrdCmsClustID.cc.

219 {
220  EPNAME("RemNode");
221  bool didRM = false;
222 
223 // For servers we only need to remove the mask
224 //
225  if (!(nP->isMan | nP->isPeer))
226  {cidMask &= ~(nP->Mask());
227  DEBUG("srv " <<nP->Ident <<" cluster " <<cidName <<" anum=" <<npNum);
228  return 0;
229  }
230 
231 // Find the node to remove. This may require a fill in.
232 //
233  for (int i = 0; i < npNum; i++)
234  if (nP == nodeP[i])
235  {npNum--;
236  if (i < npNum && npNum) nodeP[i] = nodeP[npNum];
237  else nodeP[i] = 0;
238  didRM = true;
239  break;
240  }
241 
242 // If there are no more nodes in this table, then remove the id mask
243 //
244  if (!npNum) cidMask &= ~(nP->Mask());
245 
246 // Do some debugging and return what we have in the table
247 //
248  DEBUG("man " <<nP->Ident <<" cluster " <<cidName <<" anum=" <<npNum
249  <<(didRM ? "" : " n/p"));
250  return (npNum ? nodeP[0] : 0);
251 }
char isPeer
Definition: XrdCmsNode.hh:68
char isMan
Definition: XrdCmsNode.hh:67

References DEBUG, EPNAME, XrdCmsNode::Ident, XrdCmsNode::isMan, XrdCmsNode::isPeer, and XrdCmsNode::Mask().

Referenced by XrdCmsCluster::Remove().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Slot()

int XrdCmsClustID::Slot ( )
inline

Definition at line 62 of file XrdCmsClustID.hh.

62 {return ntSlot;}

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