107 std::set<std::string>::iterator it;
109 for (it = Contacts.begin(); it != Contacts.end(); it++)
110 {
if (Blab)
DMSG(
"Cleanup",
"Disconnecting " <<(*it).c_str());
111 PostMaster->ForceDisconnect(
XrdCl::URL(*it),
true);}
130 const std::string host = url->
GetHostId();
131 if (Blab)
DMSG(
"Tracker",
"Connecting to " <<host);
132 if (user.size()) sssCon.Contact(user, host);
136 ConTrack(ConCleanup &cm,
bool dbg) : sssCon(cm), Blab(dbg) {}
153 ConCleanup *cuHandler =
new ConCleanup(pm, dbg);
154 std::unique_ptr<ConTrack> ctHandler(
new ConTrack(*cuHandler, dbg));
192bool XrdPosixConfig::initCCM(
XrdOucPsx &parms)
195 const char *eTxt =
"Unable to initialize cache context manager in";
209 std::cerr <<
"Posix_InitCCM: " <<eTxt <<
' ' <<mPath <<std::endl;
237void XrdPosixConfig::initEnv(
char *eData)
248 initEnv(theEnv,
"aprcalc", Val);
if (Val >= 0) apParms.
prRecalc = Val;
249 initEnv(theEnv,
"aprminp", Val);
if (Val >= 0) apParms.
minPages = Val;
250 initEnv(theEnv,
"aprperf", Val);
if (Val >= 0) apParms.
minPerf = Val;
251 initEnv(theEnv,
"aprtrig", Val);
if (Val >= 0) apParms.
Trigger = Val;
252 initEnv(theEnv,
"cachesz", Val);
if (Val >= 0) myParms.
CacheSize = Val;
253 initEnv(theEnv,
"maxfiles", Val);
if (Val >= 0) myParms.
MaxFiles = Val;
254 initEnv(theEnv,
"max2cache", Val);
if (Val >= 0) myParms.
Max2Cache = Val;
255 initEnv(theEnv,
"minpages", Val);
if (Val >= 0)
256 {
if (Val > 32767) Val = 32767;
259 initEnv(theEnv,
"pagesz", Val);
if (Val >= 0) myParms.
PageSize = Val;
264 {
if (*tP >=
'0' && *tP <=
'3') myParms.
Options |= (*tP -
'0');
265 else DMSG(
"initEnv",
"'XRDPOSIX_CACHE=debug=" <<tP <<
"' is invalid.");
272 else if (*tP !=
'c')
DMSG(
"initEnv",
"'XRDPOSIX_CACHE=mode=" <<tP
278 if ((tP =
theEnv.
Get(
"optsf")) && *tP && *tP !=
'0')
283 else DMSG(
"initEnv",
"'XRDPOSIX_CACHE=optfs=" <<tP
289 if ((tP =
theEnv.
Get(
"optlg")) && *tP && *tP !=
'0')
291 if ((tP =
theEnv.
Get(
"optpr")) && *tP && *tP !=
'0')
305void XrdPosixConfig::initEnv(
XrdOucEnv &theEnv,
const char *vName,
long long &Dest)
312 if (!(tP =
theEnv.
Get(vName)) || !(*tP))
return;
317 Dest = strtoll(tP, &eP, 10);
318 if (Dest > 0 || (!errno && tP != eP))
320 if (*eP ==
'k' || *eP ==
'K') Dest *= 1024LL;
321 else if (*eP ==
'm' || *eP ==
'M') Dest *= 1024LL*1024LL;
322 else if (*eP ==
'g' || *eP ==
'G') Dest *= 1024LL*1024LL*1024LL;
323 else if (*eP ==
't' || *eP ==
'T') Dest *= 1024LL*1024LL*1024LL*1024LL;
326 {
DMSG(
"initEnv",
"'XRDPOSIX_CACHE=" <<vName <<
'=' <<tP
340 static dev_t st_rdev;
342 static uid_t myUID = getuid();
343 static gid_t myGID = getgid();
349 memset(buf, 0,
sizeof(
struct stat));
353 buf->st_blksize= 64*1024;
354 buf->st_dev = st_dev;
355 buf->st_rdev = st_rdev;
365void XrdPosixConfig::initXdev(dev_t &st_dev, dev_t &st_rdev)
367 static dev_t tDev, trDev;
368 static bool aOK =
false;
373 if (aOK) {st_dev = tDev; st_rdev = trDev;}
374 else if (
stat(
"/tmp", &buf)) {st_dev = 0; st_rdev = 0;}
375 else {st_dev = tDev = buf.st_dev;
376 st_rdev = trDev = buf.st_rdev;
393 {
if (*Info.cachePath && errno == 0 && Info.ffReady)
return true;
395 if (!errno) errno = ENOPROTOOPT;
425 SetIPV4(parms.
useV4);
466 {
if (*val ==
'1' || *val ==
'2')
468 if (*val ==
'2')
SetEnv(
"WantTlsOnNoPgrw", 1);
477 if (parms.
initCCM)
return initCCM(parms);
489void XrdPosixConfig::SetDebug(
int val)
491 const std::string dbgType[] = {
"Error",
"Warning",
"Info",
"Debug",
"Dump"};
496 {
if (val > 5) val = 5;
512 static bool dlfSet =
false;
516 if (!strcmp(kword,
"DirlistAll"))
522 else if (!strcmp(kword,
"DirlistDflt"))
528 else env->
PutInt((std::string)kword, kval);
535void XrdPosixConfig::SetIPV4(
bool usev4)
537 const char *ipmode = (usev4 ?
"IPv4" :
"IPAll");
542 env->
PutString((std::string)
"NetworkStack", (
const std::string)ipmode);
560 static const char stats1[] =
"<stats id=\"%s\">"
561 "<open>%lld<errs>%lld</errs></open>"
562 "<close>%lld<errs>%lld</errs></close>"
565 static const char stats2[] =
"<stats id=\"cache\" type=\"%s\">"
566 "<prerd><in>%lld</in><hits>%lld</hits><miss>%lld</miss></prerd>"
567 "<rd><in>%lld</in><out>%lld</out>"
568 "<hits>%lld</hits><miss>%lld</miss>"
570 "<pass>%lld<cnt>%lld</cnt></pass>"
571 "<wr><out>%lld</out><updt>%lld</updt></wr>"
572 "<saved>%lld</saved><purge>%lld</purge>"
573 "<files><opened>%lld</opened><closed>%lld</closed><new>%lld</new>"
574 "<del>%lld</del><now>%lld</now><full>%lld</full>"
576 "<store><size>%lld</size><used>%lld</used>"
577 "<min>%lld</min><max>%lld</max>"
579 "<mem><size>%lld</size><used>%lld</used><wq>%lld</wq></mem>"
580 "<opcl><odefer>%lld</odefer><defero>%lld</defero>"
581 "<cdefer>%lld</cdefer><clost>%lld</clost>"
589 int len1, digitsLL = strlen(
"9223372036854775807");
590 std::string fmt = stats1;
591 n = std::count(fmt.begin(), fmt.end(),
'%');
592 len1 = fmt.size() + (digitsLL*n) - (n*3) + strlen(theID);
595 n = std::count(fmt.begin(), fmt.end(),
'%');
596 return len1 + fmt.size() + (digitsLL*n) - (n*3) + 8;
606 int k = snprintf(buff, blen, stats1, theID,
612 buff += k; blen -= k;
638 return (n < blen ? n+k : 0);
static XrdSysError eDest(0,"crypto_")
const char * XrdSysE2T(int errcode)
static PostMaster * GetPostMaster()
Get default post master.
static void SetLogLevel(const std::string &level)
static Env * GetEnv()
Get default client environment.
bool PutInt(const std::string &key, int value)
bool PutString(const std::string &key, const std::string &value)
Interface for a job to be run by the job manager.
virtual void Run(void *arg)=0
The job logic.
A hub for dispatching and receiving messages.
void SetOnConnectHandler(std::unique_ptr< Job > onConnJob)
Set the global connection error handler.
std::string GetHostId() const
Get the host part of the URL (user:password@host:port)
const std::string & GetUserName() const
Get the username.
void Get(XrdOucCacheStats &D)
struct XrdOucCacheStats::CacheStats X
XrdOucCacheStats Statistics
char * Get(const char *varname)
void * GetPtr(const char *varname)
XrdOucCacheCMInit_t initCCM
const char * CCMInfo(const char *&path)
static void SetEnv(const char *kword, int kval)
static bool OpenFC(const char *path, int oflag, mode_t mode, XrdPosixInfo &Info)
static void setOids(bool isok)
static XrdSecsssCon * conTracker(bool debug=false)
static int Stats(const char *theID, char *buff, int blen)
static void initStat(struct stat *buf)
static void EnvInfo(XrdOucEnv &theEnv)
static bool SetConfig(XrdOucPsx &parms)
static void SetMax(int mval)
static void SetDebug(bool dbg)
void Get(XrdPosixStats &D)
struct XrdPosixStats::PosixStats X
static int Open(const char *path, int oflag, mode_t mode=0, XrdPosixCallBack *cbP=0)
static const int Serialized
Caller ensures MRSW semantics.
static XrdOucCache * Create(Parms &Params, XrdOucCacheIO::aprParms *aprP=0)
static const int logStats
Display statistics upon detach.
static const int isServer
This is server application; not a user application.
static const int isStructured
static const int canPreRead
Enable pre-read operations (o/w ignored)
bool Contact(const std::string &lgnid, const std::string &hostID)
virtual void Cleanup(const std::set< std::string > &Contacts, const XrdSecEntity &Entity)=0
int Emsg(const char *esfx, int ecode, const char *text1, const char *text2=0)
void SetLogger(XrdSysLogger *logp)
XrdCl::DirListFlags::Flags dlFlag
Parameters for a newly created memory cache.
int MaxFiles
Maximum number of files (default 256 or 8K)
int PageSize
Size of each page in bytes (default 32KB)
long long CacheSize
Size of cache in bytes (default 100MB)
int Max2Cache
Largest read to cache (default PageSize)
short minPages
Minimum number of pages (default 256)
int Options
Options as defined below (default r/o cache)