Skip to content

Commit

Permalink
[Server] Implement simple g-stream monitoring for medium level repotr…
Browse files Browse the repository at this point in the history
…ing.
  • Loading branch information
abh3 authored and osschar committed Oct 10, 2019
1 parent e9d7760 commit 5d2ba41
Show file tree
Hide file tree
Showing 26 changed files with 812 additions and 200 deletions.
4 changes: 2 additions & 2 deletions src/XrdFfs/XrdFfsMisc.cc
Expand Up @@ -52,7 +52,7 @@
#include "XrdFfs/XrdFfsMisc.hh"
#include "XrdFfs/XrdFfsPosix.hh"
#include "XrdFfs/XrdFfsQueue.hh"
#include "XrdPosix/XrdPosixXrootd.hh"
#include "XrdPosix/XrdPosixConfig.hh"

#ifdef __cplusplus
extern "C" {
Expand Down Expand Up @@ -305,7 +305,7 @@ void XrdFfsMisc_xrd_init(const char *rdrurl, const char *urlcachelife, int start
// EnvPutInt(NAME_READAHEADSIZE,0);
// EnvPutInt(NAME_READCACHESIZE,0);
// EnvPutInt(NAME_REQUESTTIMEOUT, 30);
XrdPosixXrootd::setEnv("WorkerThreads", 50);
XrdPosixConfig::SetEnv("WorkerThreads", 50);

if (getenv("XROOTDFS_SECMOD") != NULL && !strcmp(getenv("XROOTDFS_SECMOD"), "sss"))
XrdFfsMisc_xrd_secsss_init();
Expand Down
4 changes: 4 additions & 0 deletions src/XrdHeaders.cmake
Expand Up @@ -70,6 +70,10 @@ set( XROOTD_PUBLIC_HEADERS
XrdSys/XrdSysXAttr.hh
XrdSys/XrdSysXSLock.hh
XrdXml/XrdXmlReader.hh
XrdXrootd/XrdXrootdMonData.hh
XrdXrootd/XrdXrootdGStream.hh
XrdXrootd/XrdXrootdBridge.hh
XrdHttp/XrdHttpSecXtractor.hh
)

if( NOT XRDCL_ONLY )
Expand Down
31 changes: 31 additions & 0 deletions src/XrdOss/XrdOss.hh
Expand Up @@ -246,6 +246,8 @@ virtual ~XrdOss() {}
//! @param parms -> Any parameters specified after the path on the
//! ofs.osslib directive. If there are no parameters, the
//! pointer may be zero.
//! @param envP -> **Version2 Only** pointer to environmental info.
//! This pointer may be nil if no such information exists.
//!
//! @return Success: -> an instance of the XrdOss object to be used as the
//! underlying storage system.
Expand All @@ -254,11 +256,40 @@ virtual ~XrdOss() {}
//! The object creation function must be declared as an extern "C" function
//! in the plug-in shared library as follows:
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
//! The typedef that describes the XRdOssStatInfoInit external.
//------------------------------------------------------------------------------

typedef XrdOss *(*XrdOssGetStorageSystem_t) (XrdOss *native_oss,
XrdSysLogger *Logger,
const char *config_fn,
const char *parms);

typedef XrdOss *(*XrdOssGetStorageSystem2_t)(XrdOss *native_oss,
XrdSysLogger *Logger,
const char *config_fn,
const char *parms,
XrdOucEnv *envP);

/*!
extern "C" XrdOss *XrdOssGetStorageSystem(XrdOss *native_oss,
XrdSysLogger *Logger,
const char *config_fn,
const char *parms);
An alternate entry point may be defined in lieu of the previous entry point.
The plug-in loaer looks for this entry point first before reverting to the
older version 1 entry point/ Version 2 differs in that an extra parameter,
the environmental pointer, is passed. Note that this pointer is also
supplied via the EnvInfo() method. This, many times, is not workable as
environmental information is needed as initialization time.
extern "C" XrdOss *XrdOssGetStorageSystem2(XrdOss *native_oss,
XrdSysLogger *Logger,
const char *config_fn,
const char *parms,
XrdOucEnv *envP);
*/

//------------------------------------------------------------------------------
Expand Down
29 changes: 20 additions & 9 deletions src/XrdOss/XrdOssApi.cc
Expand Up @@ -104,7 +104,6 @@ XrdOss *XrdOssGetSS(XrdSysLogger *Logger, const char *config_fn,
extern XrdSysError OssEroute;
XrdOucPinLoader *myLib;
XrdOss *ossP;
XrdOss *(*ep)(XrdOss *, XrdSysLogger *, const char *, const char *);

// Verify that versions are compatible.
//
Expand All @@ -123,16 +122,28 @@ XrdOss *XrdOssGetSS(XrdSysLogger *Logger, const char *config_fn,
OssEroute.logger(Logger);
if (!(myLib = new XrdOucPinLoader(&OssEroute, myOssSys.myVersion,
"osslib", OssLib))) return 0;
// Declare the interface versions
//
XrdOssGetStorageSystem_t getOSS1;
const char *epName1 = "XrdOssGetStorageSystem";
XrdOssGetStorageSystem2_t getOSS2;
const char *epName2 = "XrdOssGetStorageSystem2";

// First try finding version 2 of the initializer. If that fails try version 1.
// In the process, we will get an oss object if we succeed at all.
//
getOSS2 = (XrdOssGetStorageSystem2_t)myLib->Resolve(epName2);
if (getOSS2) ossP = getOSS2((XrdOss *)&myOssSys, Logger, config_fn,
OssParms, envP);
else {getOSS1 = (XrdOssGetStorageSystem_t)myLib->Resolve(epName1);
if (!getOSS1) return 0;
ossP = getOSS1((XrdOss *)&myOssSys, Logger, config_fn, OssParms);
}

// Now get the entry point of the object creator
//
ep = (XrdOss *(*)(XrdOss *, XrdSysLogger *, const char *, const char *))
(myLib->Resolve("XrdOssGetStorageSystem"));
if (!ep) return 0;

// Get the Object now
// Call the legacy EnvInfo() method and set what library we are using if it
// differs from what we wre passed.
//
if ((ossP = ep((XrdOss *)&myOssSys, Logger, config_fn, OssParms)) && envP)
if (ossP && envP)
{ossP->EnvInfo(envP);
if (envP && strcmp(OssLib, myLib->Path()))
envP->Put("oss.lib", myLib->Path());
Expand Down
8 changes: 7 additions & 1 deletion src/XrdOuc/XrdOucCache.hh
Expand Up @@ -279,6 +279,8 @@ virtual ~XrdOucCacheIO() {} // Always use Detach() instead of direct delete!
such associations.
*/

class XrdOucEnv;

class XrdOucCache
{
public:
Expand Down Expand Up @@ -405,7 +407,8 @@ virtual ~XrdOucCache() {}
{
XrdOucCache *XrdOucGetCache(XrdSysLogger *Logger, // Where messages go
const char *Config, // Config file used
const char *Parms); // Optional parm string
const char *Parms, // Optional parm string
XrdOucEnv *envP); // Optional environment
}
When Logger is null, you should use cerr to output messages. Otherwise,
Expand All @@ -419,4 +422,7 @@ virtual ~XrdOucCache() {}
a null pointer otherwise. The instance is used to create actual caches using
the object's Create() method.
*/

typedef XrdOucCache *(*XrdOucCache_t)(XrdSysLogger *, const char *,
const char *, XrdOucEnv *);
#endif
12 changes: 10 additions & 2 deletions src/XrdOuc/XrdOucCache2.hh
Expand Up @@ -368,6 +368,10 @@ virtual ~XrdOucCache2() {}
//! is no configuration file is present.
//! @param Parms Pointer to any parameters specified after the shared library
//! path. If Parms is null, there are no parameters.
//! @param envP Pointer to environmental information. The most relevant
//! is whether or not -stream monitoring is enabled.
//! XrdXrootdGStream *gstm = envP->(XrddXrootdGStream *)
//! GetPtr("pfc.gStream*");
//! @return A usable, fully configured, instance of an XrdOucCache2
//! object upon success and a null pointer otherwise. This
//! instance is used for all operations defined by methods in
Expand All @@ -377,6 +381,10 @@ virtual ~XrdOucCache2() {}
//! {
//! XrdOucCache2 *XrdOucGetCache2(XrdSysLogger *Logger, // Where messages go
//! const char *Config, // Config file used
//! const char *Parms); // Optional parm string
//! }
//! const char *Parms, // Optional parm string
//! } XrdOucEnv *envP); // Optional environment

typedef XrdOucCache2 *(*XrdOucCache2_t)(XrdSysLogger *, const char *,
const char *, XrdOucEnv *);

#endif
4 changes: 2 additions & 2 deletions src/XrdOuc/XrdOucCacheData.cc
Expand Up @@ -152,8 +152,8 @@ XrdOucCacheIO *XrdOucCacheData::Detach()
{char sBuff[4096];
snprintf(sBuff, sizeof(sBuff),
"Cache: Stats: %lld Read; %lld Get; %lld Pass; "
"%lld Write; %lld Put; %d Hits; %d Miss; "
"%lld pead; %d HitsPR; %d MissPR; Path %s\n",
"%lld Write; %lld Put; %lld Hits; %lld Miss; "
"%lld pead; %lld HitsPR; %lld MissPR; Path %s\n",
Statistics.BytesRead, Statistics.BytesGet,
Statistics.BytesPass, Statistics.BytesWrite,
Statistics.BytesPut,
Expand Down
8 changes: 4 additions & 4 deletions src/XrdOuc/XrdOucCacheStats.hh
Expand Up @@ -46,10 +46,10 @@ long long BytesGet; // Number of bytes delivered from the cache
long long BytesPass; // Number of bytes read but not cached
long long BytesWrite; // Total number of bytes written from the cache
long long BytesPut; // Number of bytes updated in the cache
int Hits; // Number of times wanted data was in the cache
int Miss; // Number of times wanted data was *not* in the cache
int HitsPR; // Number of pages wanted data was just preread
int MissPR; // Number of pages wanted data was just read
long long Hits; // Number of times wanted data was in the cache
long long Miss; // Number of times wanted data was *not* in the cache
long long HitsPR; // Number of pages wanted data was just preread
long long MissPR; // Number of pages wanted data was just read

inline void Get(XrdOucCacheStats &Dst)
{sMutex.Lock();
Expand Down
16 changes: 4 additions & 12 deletions src/XrdOuc/XrdOucPsx.cc
Expand Up @@ -185,22 +185,14 @@ bool XrdOucPsx::ConfigCache(XrdSysError &eDest)
// Get the Object now
//
if (isCache2)
{XrdOucCache2 *(*ep)(XrdSysLogger *, const char *, const char *);
ep = (XrdOucCache2 *(*)(XrdSysLogger *, const char *, const char *))
(myLib.Resolve(cName));

{XrdOucCache2_t ep = (XrdOucCache2_t)myLib.Resolve(cName);
if (!ep) return false;

theCache2 = (XrdOucCache2*)ep(eDest.logger(), configFN, cParm);
theCache2 = (XrdOucCache2*)ep(eDest.logger(), configFN, cParm, theEnv);
return theCache2 != 0;
} else {
XrdOucCache *(*ep)(XrdSysLogger *, const char *, const char *);
ep = (XrdOucCache *(*)(XrdSysLogger *, const char *, const char *))
(myLib.Resolve(cName));

XrdOucCache_t ep = (XrdOucCache_t)myLib.Resolve(cName);
if (!ep) return false;

theCache = (XrdOucCache*)ep(eDest.logger(), configFN, cParm);
theCache = (XrdOucCache*)ep(eDest.logger(), configFN, cParm, theEnv);
return theCache != 0;
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/XrdOuc/XrdOucPsx.hh
Expand Up @@ -94,8 +94,9 @@ bool xLfn2Pfn;
bool xPfn2Lfn;
bool xNameLib;

XrdOucPsx(XrdVersionInfo *vInfo, const char *cfn, XrdSysLogger *lp=0)
: configFN(strdup(cfn)), theLogger(lp), theEnv(0),
XrdOucPsx(XrdVersionInfo *vInfo, const char *cfn,
XrdSysLogger *lp=0, XrdOucEnv *vp=0)
: configFN(strdup(cfn)), theLogger(lp), theEnv(vp),
theN2N(0), theCache(0), theCache2(0), initCCM(0),
mCache(0), setFirst(0), setLast(0), maxRHCB(0),
traceLvl(0), debugLvl(0), cioWait(0), cioTries(0),
Expand Down
103 changes: 0 additions & 103 deletions src/XrdPosix/XrdPosixXrootd.cc
Expand Up @@ -1451,109 +1451,6 @@ long long XrdPosixXrootd::QueryOpaque(const char *path, char *value, int size)
//
return admin.Query(XrdCl::QueryCode::OpaqueFile, value, size);
}

/******************************************************************************/
/* Obsolete! s e t C a c h e */
/******************************************************************************/

void XrdPosixXrootd::setCache(XrdOucCache *cP) {XrdPosixGlobals::myCache =cP;}

void XrdPosixXrootd::setCache(XrdOucCache2 *cP) {XrdPosixGlobals::myCache2=cP;}

/******************************************************************************/
/* Obsolete! s e t D e b u g */
/******************************************************************************/

void XrdPosixXrootd::setDebug(int val, bool doDebug)
{
const std::string dbgType[] = {"Info", "Warning", "Error", "Debug", "Dump"};

// The default is none but once set it cannot be unset in the client
//
if (val > 0)
{if (doDebug) val = 4;
else if (val > 5) val = 5;
XrdCl::DefaultEnv::SetLogLevel(dbgType[val-1]);
}

// Now set the internal one which can be toggled
//
XrdPosixMap::SetDebug(val > 0);
}

/******************************************************************************/
/* Obsolete! s e t E n v */
/******************************************************************************/

void XrdPosixXrootd::setEnv(const char *kword, int kval)
{
XrdCl::Env *env = XrdCl::DefaultEnv::GetEnv();
static bool dlfSet = false;

// Check for internal envars before setting the external one
//
if (!strcmp(kword, "DirlistAll"))
{XrdPosixGlobals::dlFlag = (kval ? XrdCl::DirListFlags::Locate
: XrdCl::DirListFlags::None);
dlfSet = true;
}
else if (!strcmp(kword, "DirlistDflt"))
{if (!dlfSet)
XrdPosixGlobals::dlFlag = (kval ? XrdCl::DirListFlags::Locate
: XrdCl::DirListFlags::None);
}
else env->PutInt((std::string)kword, kval);
}

/******************************************************************************/
/* Obsolete! s e t I P V 4 */
/******************************************************************************/

void XrdPosixXrootd::setIPV4(bool usev4)
{
const char *ipmode = (usev4 ? "IPv4" : "IPAll");
XrdCl::Env *env = XrdCl::DefaultEnv::GetEnv();

// Set the env value
//
env->PutString((std::string)"NetworkStack", (const std::string)ipmode);
}

/******************************************************************************/
/* Obsolete! s e t L o g g e r */
/******************************************************************************/

void XrdPosixXrootd::setLogger(XrdSysLogger *logP)
{
XrdPosixGlobals::Trace.SetLogger(logP);
}

/******************************************************************************/
/* Obsolete! s e t N u m C B */
/******************************************************************************/

void XrdPosixXrootd::setNumCB(int numcb)
{
if (numcb >= 0) XrdPosixFileRH::SetMax(numcb);
}

/******************************************************************************/
/* Obsolete! S e t N 2 N */
/******************************************************************************/

void XrdPosixXrootd::setN2N(XrdOucName2Name *pN2N, int opts)
{
XrdPosixGlobals::theN2N = pN2N;
}

/******************************************************************************/
/* Obsolete! s e t S c h e d */
/******************************************************************************/

void XrdPosixXrootd::setSched(XrdScheduler *sP)
{
XrdPosixGlobals::schedP = sP;
}

/******************************************************************************/
/* P r i v a t e M e t h o d s */
Expand Down
14 changes: 0 additions & 14 deletions src/XrdPosix/XrdPosixXrootd.hh
Expand Up @@ -373,20 +373,6 @@ static bool myFD(int fd);
XrdPosixXrootd(int maxfd=255, int maxdir=0, int maxthr=0);
~XrdPosixXrootd();

// The following methods were always considered private. They are no longer
// used and will be removed on the next major release! They are only here for
// now to keep ABI compatability for the 4.x and prior releases.
//
static void setCache(XrdOucCache *cP);
static void setCache(XrdOucCache2 *cP);
static void setDebug(int val, bool doDebug=false);
static void setEnv(const char *kword, int kval);
static void setIPV4(bool userv4);
static void setLogger(XrdSysLogger *logP);
static void setNumCB(int numcb);
static void setN2N(XrdOucName2Name *pN2N, int opts=0);
static void setSched(XrdScheduler *sP);

private:

static int Fault(XrdPosixFile *fp, int ecode);
Expand Down

0 comments on commit 5d2ba41

Please sign in to comment.