35 #include <sys/param.h>
36 #include <sys/types.h>
62 int XrdFrmMigrate::numMig = 0;
76 if ((Why = Eligible(sP, xTime)))
84 if (xTime <
Config.IdleHold) Defer(sP);
92 int XrdFrmMigrate::Advance()
100 {xTime =
static_cast<int>(time(0) - fsDefer->baseFile()->Stat.st_mtime);
101 if (xTime <
Config.IdleHold)
break;
102 fP = fsDefer; fsDefer = fsDefer->
Next;
109 return fsDefer ?
Config.IdleHold - xTime : 0;
124 {pfP = fP; fP = fP->
Next;}
129 if (pfP) pfP->
Next = sP;
144 Say.
Say(
"=====> ",
"Migrate configuration:");
149 {
Say.
Say(
"=====> ",
"Scanning ", (vP->
Val?
"r/w: ":
"r/o: "), vP->
Name);
151 while(tP) {
Say.
Say(
"=====> ",
"Excluded ", tP->
text); tP = tP->
next;}
160 const char *XrdFrmMigrate::Eligible(
XrdFrmFileset *sP, time_t &xTime)
164 time_t mTimeBF, mTimeLK, nowTime = time(0);
170 if (!mTimeLK)
return "migration deferred";
174 mTimeBF = baseFile->
Stat.st_mtime;
175 if (mTimeLK >= mTimeBF)
return "file unchanged";
184 xTime =
static_cast<int>(nowTime - mTimeBF);
215 Say.
Emsg(
"Migrate", retc,
"create migrtion thread");
223 do{migWait =
Config.WaitMigr; numMig = 0;
225 while((wTime = Advance()))
226 {
if ((migWait -= wTime) <= 0)
break;
229 while(fsDefer) {fP = fsDefer; fsDefer = fsDefer->
Next;
delete fP;}
230 sprintf(buff,
"%d file%s selected for transfer.",numMig,(numMig==1?
"":
"s"));
242 static int reqID = 0;
247 memset(&myReq, 0,
sizeof(myReq));
249 sprintf(myReq.
ID,
"Internal%d", reqID++);
251 myReq.
addTOD =
static_cast<long long>(time(0));
264 void XrdFrmMigrate::Scan()
268 static time_t lastHP = time(0), nowT = time(0);
274 int ec = 0, Bad = 0, aFiles = 0, bFiles = 0;
282 VMSG(
"Scan",
"Name space scan started. . .");
287 while((sP = fP->
Get(
ec,1)))
289 if (sP->
Screen()) Add(sP);
290 else {
delete sP; bFiles++;}
294 }
while((vP = vP->
Next));
298 sprintf(buff,
"%d file%s with %d error%s", aFiles, (aFiles != 1 ?
"s":
""),
299 bFiles, (bFiles != 1 ?
"s":
""));
300 VMSG(
"Scan",
"Name space scan ended;", buff);
304 if (Bad)
Say.
Emsg(
"Scan",
"Errors encountered while scanning for "
305 "migratable files.");
void * XrdMigrateStart(void *parg)
#define XRDSYSTHREAD_BIND
static const int CompressD
static const int NoAutoDel
XrdFrmFileset * Get(int &rc, int noBase=0)
static const int Recursive
int Refresh(int isMig=0, int doLock=1)
XrdOucXAttr< XrdFrcXAttrCpy > cpyInfo
XrdOucNSWalk::NSEnt * baseFile()
XrdOucNSWalk::NSEnt * failFile()
static void Queue(XrdFrmFileset *sP)
static void Migrate(int doinit=1)
static const char * checkFF(const char *Path)
static int Add(XrdFrcRequest *rP, XrdFrcReqFile *reqF, int theQ)
int Emsg(const char *esfx, int ecode, const char *text1, const char *text2=0)
void Say(const char *text1, const char *text2=0, const char *txt3=0, const char *text4=0, const char *text5=0, const char *txt6=0)
static int Run(pthread_t *, void *(*proc)(void *), void *arg, int opts=0, const char *desc=0)
static void Snooze(int seconds)