XRootD
XrdFrmFileset Class Reference

#include <XrdFrmFiles.hh>

+ Collaboration diagram for XrdFrmFileset:

Public Member Functions

 XrdFrmFileset (XrdFrmFileset *sP=0, XrdOucTList *diP=0)
 
 ~XrdFrmFileset ()
 
XrdOucNSWalk::NSEntbaseFile ()
 
const char * basePath ()
 
int dirPath (char *dBuff, int dBlen)
 
XrdOucNSWalk::NSEntfailFile ()
 
const char * failPath ()
 
XrdOucNSWalk::NSEntlockFile ()
 
const char * lockPath ()
 
XrdOucNSWalk::NSEntpfnFile ()
 
const char * pfnPath ()
 
XrdOucNSWalk::NSEntpinFile ()
 
const char * pinPath ()
 
int Refresh (int isMig=0, int doLock=1)
 
int Screen (int needLF=1)
 
int setCpyTime (int Refresh=0)
 
XrdOucNSWalk::NSEntxyzFile (XrdOssPath::theSfx sfx)
 
const char * xyzPath (XrdOssPath::theSfx sfx)
 

Static Public Member Functions

static void Purge ()
 

Public Attributes

int Age
 
XrdOucXAttr< XrdFrcXAttrCpycpyInfo
 
XrdFrmFilesetNext
 
XrdOucXAttr< XrdFrcXAttrPinpinInfo
 

Friends

class XrdFrmFiles
 

Detailed Description

Definition at line 48 of file XrdFrmFiles.hh.

Constructor & Destructor Documentation

◆ XrdFrmFileset()

XrdFrmFileset::XrdFrmFileset ( XrdFrmFileset sP = 0,
XrdOucTList diP = 0 
)

Definition at line 62 of file XrdFrmFiles.cc.

63  : Next(sP), dInfo(diP)
64 { memset(File, 0, sizeof(File));
65  if (diP) diP->ival[dRef]++;
66 }
XrdFrmFileset * Next
Definition: XrdFrmFiles.hh:90

◆ ~XrdFrmFileset()

XrdFrmFileset::~XrdFrmFileset ( )

Definition at line 72 of file XrdFrmFiles.cc.

73 {
74  int i;
75 
76 // Delete all the table entries
77 //
78  for (i = 0; i < XrdOssPath::sfxNum; i++) if(File[i]) delete File[i];
79 
80 // If there is a shared directory buffer, decrease reference count, delete if 0
81 //
82  if (dInfo && ((dInfo->ival[dRef] -= 1) <= 0)) delete dInfo;
83 }

References XrdOssPath::sfxNum.

Member Function Documentation

◆ baseFile()

XrdOucNSWalk::NSEnt* XrdFrmFileset::baseFile ( )
inline

Definition at line 60 of file XrdFrmFiles.hh.

60 {return File[XrdOssPath::isBase];}

References File, and XrdOssPath::isBase.

Referenced by XrdFrmTSort::Add(), basePath(), Refresh(), and Screen().

+ Here is the caller graph for this function:

◆ basePath()

const char* XrdFrmFileset::basePath ( )
inline

Definition at line 61 of file XrdFrmFiles.hh.

61 {return Mkfn(baseFile());}
XrdOucNSWalk::NSEnt * baseFile()
Definition: XrdFrmFiles.hh:60

References baseFile().

Referenced by XrdFrmMigrate::Queue(), Screen(), and setCpyTime().

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

◆ dirPath()

int XrdFrmFileset::dirPath ( char *  dBuff,
int  dBlen 
)

Definition at line 89 of file XrdFrmFiles.cc.

90 {
91  char *dP = 0;
92  int dN = 0, i;
93 
94 // If we have a shared directory pointer, use that as directory information
95 // Otherwise, get it from one of the files in the fileset.
96 //
97  if (dInfo) {dP = dInfo->text; dN = dInfo->ival[dLen];}
98  else {for (i = 0; i < XrdOssPath::sfxNum; i++)
99  if (File[i])
100  {dP = File[i]->Path;
101  dN = File[i]->File - File[i]->Path;
102  break;
103  }
104  }
105 
106 // Copy out the directory path
107 //
108  if (dBlen > dN && dP) strncpy(dBuff, dP, dN);
109  else dN = 0;
110  *(dBuff+dN) = '\0';
111  return dN;
112 }
char * text
Definition: XrdOucTList.hh:46

References XrdOucNSWalk::NSEnt::File, XrdOucNSWalk::NSEnt::Path, XrdOssPath::sfxNum, and XrdOucTList::text.

Referenced by Refresh().

+ Here is the caller graph for this function:

◆ failFile()

XrdOucNSWalk::NSEnt* XrdFrmFileset::failFile ( )
inline

Definition at line 62 of file XrdFrmFiles.hh.

62 {return File[XrdOssPath::isFail];}

References File, and XrdOssPath::isFail.

Referenced by failPath().

+ Here is the caller graph for this function:

◆ failPath()

const char* XrdFrmFileset::failPath ( )
inline

Definition at line 63 of file XrdFrmFiles.hh.

63 {return Mkfn(failFile());}
XrdOucNSWalk::NSEnt * failFile()
Definition: XrdFrmFiles.hh:62

References failFile().

+ Here is the call graph for this function:

◆ lockFile()

XrdOucNSWalk::NSEnt* XrdFrmFileset::lockFile ( )
inline

Definition at line 64 of file XrdFrmFiles.hh.

64 {return File[XrdOssPath::isLock];}

References File, and XrdOssPath::isLock.

Referenced by lockPath(), Refresh(), Screen(), and setCpyTime().

+ Here is the caller graph for this function:

◆ lockPath()

const char* XrdFrmFileset::lockPath ( )
inline

Definition at line 65 of file XrdFrmFiles.hh.

65 {return Mkfn(lockFile());}
XrdOucNSWalk::NSEnt * lockFile()
Definition: XrdFrmFiles.hh:64

References lockFile().

Referenced by Screen(), and setCpyTime().

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

◆ pfnFile()

XrdOucNSWalk::NSEnt* XrdFrmFileset::pfnFile ( )
inline

Definition at line 66 of file XrdFrmFiles.hh.

66 {return File[XrdOssPath::isPfn ];}

References File, and XrdOssPath::isPfn.

Referenced by pfnPath().

+ Here is the caller graph for this function:

◆ pfnPath()

const char* XrdFrmFileset::pfnPath ( )
inline

Definition at line 67 of file XrdFrmFiles.hh.

67 {return Mkfn(pfnFile());}
XrdOucNSWalk::NSEnt * pfnFile()
Definition: XrdFrmFiles.hh:66

References pfnFile().

+ Here is the call graph for this function:

◆ pinFile()

XrdOucNSWalk::NSEnt* XrdFrmFileset::pinFile ( )
inline

Definition at line 68 of file XrdFrmFiles.hh.

68 {return File[XrdOssPath::isPin ];}

References File, and XrdOssPath::isPin.

Referenced by pinPath(), and Screen().

+ Here is the caller graph for this function:

◆ pinPath()

const char* XrdFrmFileset::pinPath ( )
inline

Definition at line 69 of file XrdFrmFiles.hh.

69 {return Mkfn(pinFile());}
XrdOucNSWalk::NSEnt * pinFile()
Definition: XrdFrmFiles.hh:68

References pinFile().

Referenced by Screen().

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

◆ Purge()

static void XrdFrmFileset::Purge ( )
inlinestatic

Definition at line 77 of file XrdFrmFiles.hh.

77 {BadFiles.Purge();}
void Purge()
Definition: XrdOucHash.icc:193

References XrdOucHash< T >::Purge().

+ Here is the call graph for this function:

◆ Refresh()

int XrdFrmFileset::Refresh ( int  isMig = 0,
int  doLock = 1 
)

Definition at line 118 of file XrdFrmFiles.cc.

119 {
120  class fdClose
121  {public:
122  int Num;
123  fdClose() : Num(-1) {}
124  ~fdClose() {if (Num >= 0) close(Num);}
125  } fnFD;
126  XrdOucNSWalk::NSEnt *lP, *bP = baseFile();
127  char pBuff[MAXPATHLEN+1], *fnP, *pnP = pBuff;
128  int n, lkFD = -1;
129 
130 // Get the directory path for this entry
131 //
132  if (!(n = dirPath(pBuff, sizeof(pBuff)-1))) return 0;
133  fnP = pBuff+n;
134 
135 // If we need to lock the entry, do so. We also check if file is in use
136 //
137  if (doLock && bP)
138  {strcpy(fnP, baseFile()->File);
139  if (!(lkFD = chkLock(pBuff))) return 0;
140  fnFD.Num = lkFD;
141  }
142 
143 // Do a new stat call on each relevant file (pin file excluded for isMig)
144 //
145  if (bP)
146  {if (bP->Link) pnP = bP->Link;
147  else strcpy(fnP, bP->File);
148  if (stat(pnP, &(bP->Stat)))
149  {Say.Emsg("Refresh", errno, "stat", pnP); return 0;}
150  }
151 
152  if (!isMig) pinInfo.Get(pnP, lkFD);
153 
154  if ((lP = lockFile()))
155  {strcpy(fnP, lP->File);
156  if (stat(pBuff, &(lP->Stat)))
157  {Say.Emsg("Refresh", errno, "stat", pBuff); return 0;}
158  cpyInfo.Attr.cpyTime = static_cast<long long>(lP->Stat.st_mtime);
159  } else if (cpyInfo.Get(pnP, lkFD) <= 0) cpyInfo.Attr.cpyTime = 0;
160 
161 // All done
162 //
163  return 1;
164 }
int stat(const char *path, struct stat *buf)
#define close(a)
Definition: XrdPosix.hh:43
long long cpyTime
Definition: XrdFrcXAttr.hh:55
XrdOucXAttr< XrdFrcXAttrCpy > cpyInfo
Definition: XrdFrmFiles.hh:55
int dirPath(char *dBuff, int dBlen)
Definition: XrdFrmFiles.cc:89
XrdOucXAttr< XrdFrcXAttrPin > pinInfo
Definition: XrdFrmFiles.hh:56
int Get(const char *Path, int fd=-1)
Definition: XrdOucXAttr.hh:128
int Emsg(const char *esfx, int ecode, const char *text1, const char *text2=0)
Definition: XrdSysError.cc:95
XrdSysError Say

References XrdOucXAttr< T >::Attr, baseFile(), close, cpyInfo, XrdFrcXAttrCpy::cpyTime, dirPath(), XrdSysError::Emsg(), XrdOucNSWalk::NSEnt::File, XrdOucXAttr< T >::Get(), XrdOucNSWalk::NSEnt::Link, lockFile(), pinInfo, XrdCms::Say, XrdOucNSWalk::NSEnt::Stat, and stat().

Referenced by setCpyTime().

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

◆ Screen()

int XrdFrmFileset::Screen ( int  needLF = 1)

Definition at line 170 of file XrdFrmFiles.cc.

171 {
172  const char *What = 0, *badFN = 0;
173 
174 // Verify that we have all the relevant files (old mode only)
175 //
176  if (!Config.runNew && !baseFile())
177  {if (Config.Fix)
178  {if (lockFile()) Remfix("Lock", lockPath());
179  if ( pinFile()) Remfix("Pin", pinPath());
180  return 0;
181  }
182  if (lockFile()) badFN = lockPath();
183  else if ( pinFile()) badFN = pinPath();
184  else return 0;
185  What = "No base file for";
186  }
187 
188 // If no errors from above, try to get the copy time for this file
189 //
190  if (!What)
191  {if (!needLF || setCpyTime()) return 1;
192  What = Config.runNew ? "no copy time xattr for" : "no lock file for";
193  badFN = basePath();
194  }
195 
196 // Issue message if we haven't issued one before
197 //
198  if (!BadFiles.Add(badFN, 0, 0, Hash_data_is_key))
199  Say.Emsg("Screen", What, badFN);
200  return 0;
201 }
@ Hash_data_is_key
Definition: XrdOucHash.hh:52
int setCpyTime(int Refresh=0)
Definition: XrdFrmFiles.cc:207
const char * lockPath()
Definition: XrdFrmFiles.hh:65
const char * basePath()
Definition: XrdFrmFiles.hh:61
const char * pinPath()
Definition: XrdFrmFiles.hh:69
T * Add(const char *KeyVal, T *KeyData, const int LifeTime=0, XrdOucHash_Options opt=Hash_default)
Definition: XrdOucHash.icc:61
XrdCmsConfig Config

References XrdOucHash< T >::Add(), baseFile(), basePath(), XrdCms::Config, XrdSysError::Emsg(), Hash_data_is_key, lockFile(), lockPath(), pinFile(), pinPath(), XrdCms::Say, and setCpyTime().

+ Here is the call graph for this function:

◆ setCpyTime()

int XrdFrmFileset::setCpyTime ( int  Refresh = 0)

Definition at line 207 of file XrdFrmFiles.cc.

208 {
210 
211 // In new run mode the copy time comes from the extended attributes
212 //
213  if (Config.runNew) return cpyInfo.Get(basePath()) > 0;
214 
215 // If there is no lock file, indicate so
216 //
217  if (!(lP = lockFile())) return 0;
218 
219 // Use the lock file as the source of information
220 //
221  if (Refresh && stat(lockPath(), &(lP->Stat)))
222  {Say.Emsg("setCpyTime", errno, "stat", lockPath()); return 0;}
223  cpyInfo.Attr.cpyTime = static_cast<long long>(lP->Stat.st_mtime);
224  return 1;
225 }
int Refresh(int isMig=0, int doLock=1)
Definition: XrdFrmFiles.cc:118

References XrdOucXAttr< T >::Attr, basePath(), XrdCms::Config, cpyInfo, XrdFrcXAttrCpy::cpyTime, XrdSysError::Emsg(), XrdOucXAttr< T >::Get(), lockFile(), lockPath(), Refresh(), XrdCms::Say, XrdOucNSWalk::NSEnt::Stat, and stat().

Referenced by XrdFrmFiles::Get(), and Screen().

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

◆ xyzFile()

XrdOucNSWalk::NSEnt* XrdFrmFileset::xyzFile ( XrdOssPath::theSfx  sfx)
inline

Definition at line 71 of file XrdFrmFiles.hh.

71 {return File[sfx];}

References File.

◆ xyzPath()

const char* XrdFrmFileset::xyzPath ( XrdOssPath::theSfx  sfx)
inline

Definition at line 72 of file XrdFrmFiles.hh.

73  {return Mkfn(File[sfx]);}

References File.

Friends And Related Function Documentation

◆ XrdFrmFiles

friend class XrdFrmFiles
friend

Definition at line 51 of file XrdFrmFiles.hh.

Member Data Documentation

◆ Age

int XrdFrmFileset::Age

Definition at line 91 of file XrdFrmFiles.hh.

Referenced by XrdFrmTSort::Add().

◆ cpyInfo

XrdOucXAttr<XrdFrcXAttrCpy> XrdFrmFileset::cpyInfo

Definition at line 55 of file XrdFrmFiles.hh.

Referenced by Refresh(), and setCpyTime().

◆ Next

◆ pinInfo

XrdOucXAttr<XrdFrcXAttrPin> XrdFrmFileset::pinInfo

Definition at line 56 of file XrdFrmFiles.hh.

Referenced by Refresh().


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