XRootD
XrdFrcCID Class Reference

#include <XrdFrcCID.hh>

+ Collaboration diagram for XrdFrcCID:

Public Member Functions

 XrdFrcCID ()
 
 ~XrdFrcCID ()
 
int Add (const char *iName, const char *cName, time_t addT, pid_t Pid)
 
int Get (const char *iName, char *buff, int blen)
 
int Get (const char *iName, const char *vName, XrdOucEnv *evP)
 
int Init (const char *qPath)
 
void Ref (const char *iName)
 

Detailed Description

Definition at line 41 of file XrdFrcCID.hh.

Constructor & Destructor Documentation

◆ XrdFrcCID()

XrdFrcCID::XrdFrcCID ( )
inline

Definition at line 54 of file XrdFrcCID.hh.

54 : Dflt(0), First(0), cidFN(0), cidFN2(0) {}

◆ ~XrdFrcCID()

XrdFrcCID::~XrdFrcCID ( )
inline

Definition at line 55 of file XrdFrcCID.hh.

55 {}

Member Function Documentation

◆ Add()

int XrdFrcCID::Add ( const char *  iName,
const char *  cName,
time_t  addT,
pid_t  Pid 
)

Definition at line 64 of file XrdFrcCID.cc.

65 {
66  cidMon cidMonitor;
67  cidEnt *cP;
68  int ckp = 0;
69 
70 // If this is a new entry, create one
71 //
72  if (!(cP = Find(iName)))
73  {First = new cidEnt(First, iName, cName, addT, Pid);
74  if (!strcmp(iName, "anon")) Dflt = First;
75  Update();
76  return 1;
77  }
78 
79 // Ignore this update if this request is older than the previous one
80 //
81  if (cP->addT >= addT) return 0;
82 
83 // Update existing entry
84 //
85  if (strcmp(cP->cName, cName))
86  {free(cP->cName);
87  cP->cName = strdup(cName);
88  cP->cNLen = strlen(cName);
89  ckp = 1;
90  }
91  if (cP->Pid != Pid) {cP->Pid = Pid; ckp = 1;}
92  cP->addT = addT;
93  if (ckp) Update();
94  return ckp;
95 }

◆ Get() [1/2]

int XrdFrcCID::Get ( const char *  iName,
char *  buff,
int  blen 
)

Definition at line 124 of file XrdFrcCID.cc.

125 {
126  cidMon cidMonitor;
127  cidEnt *cP;
128 
129 // Find the entry
130 //
131  if (!(cP = Find(iName))) {*buff = 0; return 0;}
132 
133 // Copy out the cluster name
134 //
135  strlcpy(buff, cP->cName, blen);
136  return 1;
137 }
size_t strlcpy(char *dst, const char *src, size_t sz)

References strlcpy().

+ Here is the call graph for this function:

◆ Get() [2/2]

int XrdFrcCID::Get ( const char *  iName,
const char *  vName,
XrdOucEnv evP 
)

Definition at line 140 of file XrdFrcCID.cc.

141 {
142  cidMon cidMonitor;
143  cidEnt *cP;
144 
145 // Find the entry
146 //
147  if (!(cP = Find(iName))) return 0;
148 
149 // Set cluster name in the environment
150 //
151  if (vName && evP) evP->Put(vName, cP->cName);
152  return 1;
153 }
void Put(const char *varname, const char *value)
Definition: XrdOucEnv.hh:85

References XrdOucEnv::Put().

+ Here is the call graph for this function:

◆ Init()

int XrdFrcCID::Init ( const char *  qPath)

Definition at line 159 of file XrdFrcCID.cc.

160 {
161  EPNAME("Init");
162  XrdOucStream cidFile(&Say);
163  char Path[1024], *lP, *Pfn;
164  int cidFD, n, NoGo = 0;
165 
166 // Construct the appropriate file names
167 //
168  strcpy(Path, aPath);
169  n = strlen(aPath);
170  if (Path[n-1] != '/') Path[n++] = '/';
171  Pfn = Path+n;
172  strcpy(Pfn, "CIDS.new"); cidFN2 = strdup(Path);
173  strcpy(Pfn, "CIDS"); cidFN = strdup(Path);
174 
175 // Try to open the cluster checkpoint file.
176 //
177  if ( (cidFD = open(cidFN, O_RDONLY, 0)) < 0)
178  {if (errno == ENOENT) return 0;
179  Say.Emsg("Init", errno, "open cluster chkpnt file", cidFN);
180  return 1;
181  }
182  cidFile.Attach(cidFD);
183 
184 // Now start reading records until eof.
185 //
186  while((lP = cidFile.GetLine()))
187  if (*lP)
188  {DEBUG("Recovering cid entry: " <<lP);
189  NoGo |= Init(cidFile);
190  }
191 
192 // Now check if any errors occurred during file i/o
193 //
194  if (NoGo) Say.Emsg("Init", "Errors processing chkpnt file", cidFN);
195  else if ((n = cidFile.LastError()))
196  NoGo = Say.Emsg("Init", n, "read cluster chkpnt file", cidFN);
197  cidFile.Close();
198 
199 // Return final return code
200 //
201  return NoGo;
202 }
#define DEBUG(x)
Definition: XrdBwmTrace.hh:54
#define EPNAME(x)
Definition: XrdBwmTrace.hh:56
int open(const char *path, int oflag,...)
XrdOucString Path
int Init(const char *qPath)
Definition: XrdFrcCID.cc:159
int Emsg(const char *esfx, int ecode, const char *text1, const char *text2=0)
Definition: XrdSysError.cc:95
XrdSysError Say

References XrdOucStream::Attach(), XrdOucStream::Close(), DEBUG, XrdSysError::Emsg(), EPNAME, XrdOucStream::GetLine(), XrdOucStream::LastError(), open(), Path, and XrdFrc::Say.

Referenced by XrdFrmTransfer::Init().

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

◆ Ref()

void XrdFrcCID::Ref ( const char *  iName)

Definition at line 248 of file XrdFrcCID.cc.

249 {
250  cidMon cidMonitor;
251  cidEnt *cP;
252 
253 // Find the entry
254 //
255  if ((cP = Find(iName))) cP->useCnt = 1;
256 }

Referenced by XrdFrcReqFile::Init().

+ Here is the caller graph for this function:

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