Skip to content

Commit

Permalink
[Server] Add plug-in interface for performance reporting.
Browse files Browse the repository at this point in the history
  • Loading branch information
abh3 authored and osschar committed Oct 10, 2019
1 parent a65177c commit 623d314
Show file tree
Hide file tree
Showing 22 changed files with 724 additions and 170 deletions.
39 changes: 31 additions & 8 deletions src/XrdCms/XrdCmsAdmin.cc
Expand Up @@ -42,6 +42,7 @@
#include "XrdCms/XrdCmsAdmin.hh"
#include "XrdCms/XrdCmsConfig.hh"
#include "XrdCms/XrdCmsManager.hh"
#include "XrdCms/XrdCmsMeter.hh"
#include "XrdCms/XrdCmsPrepare.hh"
#include "XrdCms/XrdCmsState.hh"
#include "XrdCms/XrdCmsTrace.hh"
Expand Down Expand Up @@ -112,6 +113,8 @@ static XrdSysMutex QMutex;
static AdminReq *First;
static AdminReq *Last;
};

extern XrdCmsMeter Meter;
};

/******************************************************************************/
Expand Down Expand Up @@ -140,28 +143,31 @@ static AdminReq *Last;
/* E x t e r n a l T h r e a d I n t e r f a c e s */
/******************************************************************************/

void *XrdCmsAdminLogin(void *carg)
namespace
{
void *AdminLogin(void *carg)
{XrdCmsAdmin *Admin = new XrdCmsAdmin();
Admin->Login(*(int *)carg);
delete Admin;
return (void *)0;
}

void *XrdCmsAdminMonAds(void *carg)
void *AdminMonAds(void *carg)
{XrdCmsAdmin *Admin = (XrdCmsAdmin *)carg;
Admin->MonAds();
return (void *)0;
}

void *XrdCmsAdminMonARE(void *carg)
void *AdminMonARE(void *carg)
{XrdCmsAdmin::RelayAREvent();
return (void *)0;
}

void *XrdCmsAdminSend(void *carg)
void *AdminSend(void *carg)
{XrdCmsAdmin::Relay(0,0);
return (void *)0;
}
}

/******************************************************************************/
/* I n i t A R E v e n t s */
Expand All @@ -177,7 +183,7 @@ bool XrdCmsAdmin::InitAREvents(void *arFunc)

// Start the event relay
//
if (XrdSysThread::Run(&tid,XrdCmsAdminMonARE,(void *)0))
if (XrdSysThread::Run(&tid, AdminMonARE, (void *)0))
{Say.Emsg("InitAREvents", errno, "start arevent relay");
return false;
}
Expand Down Expand Up @@ -227,6 +233,8 @@ void XrdCmsAdmin::Login(int socknum)
}
else if (!strcmp("rmdid", tp)) do_RmDid(); // via lfn
else if (!strcmp("newfn", tp)) do_RmDud(); // via lfn
else if (!strcmp("perf", tp)) do_Perf();
else if (!strcmp("PERF", tp)) do_Perf(true);
else if (!strcmp("suspend", tp))
{if ((tp = Stream.GetToken()) && *tp == 't') sPerm = 0;
else sPerm = 1;
Expand Down Expand Up @@ -448,7 +456,7 @@ void *XrdCmsAdmin::Start(XrdNetSocket *AdminSock)

// Start the relay thread
//
if (XrdSysThread::Run(&tid,XrdCmsAdminSend,(void *)0))
if (XrdSysThread::Run(&tid, AdminSend, (void *)0))
Say.Emsg(epname, errno, "start admin relay");

// If we are in independent mode then let the caller continue
Expand All @@ -463,7 +471,7 @@ void *XrdCmsAdmin::Start(XrdNetSocket *AdminSock)
//
while(1) if ((InSock = AdminSock->Accept()) >= 0)
{XrdNetSocket::setOpts(InSock, 0);
if (XrdSysThread::Run(&tid,XrdCmsAdminLogin,(void *)&InSock))
if (XrdSysThread::Run(&tid, AdminLogin, (void *)&InSock))
{Say.Emsg(epname, errno, "start admin");
close(InSock);
}
Expand Down Expand Up @@ -513,7 +521,7 @@ void XrdCmsAdmin::BegAds()

// Start the connection/ping thread for the alternate data server
//
if (XrdSysThread::Run(&tid,XrdCmsAdminMonAds,(void *)this))
if (XrdSysThread::Run(&tid, AdminMonAds, (void *)this))
Say.Emsg(epname, errno, "start alternate data server monitor");
}

Expand Down Expand Up @@ -732,6 +740,21 @@ int XrdCmsAdmin::do_Login()
return 1;
}

/******************************************************************************/
/* d o _ P e r f */
/******************************************************************************/

void XrdCmsAdmin::do_Perf(bool alert)
{
const char *epname = "do_Perf";
char buff[256];

if (!Stream.GetRest(buff, sizeof(buff)))
Say.Emsg(epname,"performance data is too long.");
else if (!Meter.Update(buff, alert))
Say.Emsg(epname,"performance data is invalid.");
}

/******************************************************************************/
/* d o _ R m D i d */
/******************************************************************************/
Expand Down
1 change: 1 addition & 0 deletions src/XrdCms/XrdCmsAdmin.hh
Expand Up @@ -75,6 +75,7 @@ void BegAds();
bool CheckVNid(const char *xNid);
int Con2Ads(const char *pname);
int do_Login();
void do_Perf(bool alert=false);
void do_RmDid(int dotrim=0);
void do_RmDud(int dotrim=0);

Expand Down
18 changes: 16 additions & 2 deletions src/XrdCms/XrdCmsClient.hh
Expand Up @@ -329,15 +329,29 @@ virtual int Release (int n=1) { (void)n; return 0;}
virtual int Space(XrdOucErrInfo &Resp, const char *path,
XrdOucEnv *Info=0) = 0;

//------------------------------------------------------------------------------
//! Report utilization of this server. This may be used in lieu of general
//! performance metric reporting. For consistent results use only one method.
//!
//! @param util A value from 0 to 100 representing utilization. Values
//! greater than 100 are set to be 100.
//! @param alert When true the utilization is forcibly report to the
//! cluster managers. Otherwise, reporting is done only when
//! it will significantly change server selection.
//------------------------------------------------------------------------------

virtual void Utilization(unsigned int util, bool alert=false)
{(void)util; (void)alert;}

//------------------------------------------------------------------------------
//! Constructor
//!
//! @param acting The type of function this object is performing.
//------------------------------------------------------------------------------

enum Persona {amLocal, //!< Not affiliated with a cluster
amRemote, //!< Am a manager an issue redirects
amTarget //!< Am a server an field redirects
amRemote, //!< Am a manager and issue redirects
amTarget //!< Am a server and field redirects
};

XrdCmsClient(Persona acting) : myPersona(acting) {}
Expand Down
92 changes: 89 additions & 3 deletions src/XrdCms/XrdCmsClientConfig.cc
Expand Up @@ -38,6 +38,7 @@

#include "XrdCms/XrdCmsClientConfig.hh"
#include "XrdCms/XrdCmsClientMsg.hh"
#include "XrdCms/XrdCmsPerfMon.hh"
#include "XrdCms/XrdCmsSecurity.hh"
#include "XrdCms/XrdCmsTrace.hh"
#include "XrdCms/XrdCmsUtils.hh"
Expand All @@ -49,6 +50,15 @@
#include "XrdOuc/XrdOucUtils.hh"
#include "XrdSys/XrdSysHeaders.hh"

/******************************************************************************/
/* G l o b a l s */
/******************************************************************************/

namespace XrdCms
{
extern XrdVersionInfo myVersion;
}

using namespace XrdCms;

/******************************************************************************/
Expand All @@ -69,6 +79,11 @@ XrdCmsClientConfig::~XrdCmsClientConfig()
while((tp = tpp)) {tpp = tp->next; delete tp;}
tpp = PanList;
while((tp = tpp)) {tpp = tp->next; delete tp;}

if (VNID_Lib) free(VNID_Lib);
if (VNID_Parms) free(VNID_Parms);
if (prfLib) free(prfLib);
if (prfParms) free(prfParms);
}

/******************************************************************************/
Expand Down Expand Up @@ -96,8 +111,9 @@ int XrdCmsClientConfig::Configure(const char *cfn, configWhat What,
if (!myHost) myHost = "localhost";
myName = XrdOucUtils::InstName(1);
CMSPath= strdup("/tmp/");
isMeta = How & configMeta;
isMan = What& configMan;
isMeta = (How & configMeta) != 0;
isMan = (What& configMan) != 0;
isServer = What == configServer;

// Process the configuration file
//
Expand Down Expand Up @@ -177,6 +193,17 @@ int XrdCmsClientConfig::Configure(const char *cfn, configWhat What,
NoGo = 1;
}

// Load the performance monitor (server pre-screened) if specified.
//
if (prfLib && cmsMon)
{perfMon = XrdCmsUtils::loadPerfMon(&Say, prfLib, XrdCms::myVersion);
if (!perfMon || !perfMon->Configure(cfn, prfParms, *Say.logger(),
*cmsMon, 0, false))
{Say.Emsg("Config","Unable to configure performance monitor plugin.");
NoGo = 1;
}
}

return NoGo;
}

Expand Down Expand Up @@ -273,10 +300,11 @@ int XrdCmsClientConfig::ConfigXeq(char *var, XrdOucStream &Config)

// Process items. for either a local or a remote configuration
//
TS_Xeq("adminpath", xapath);
TS_Xeq("cidtag", xcidt);
TS_Xeq("conwait", xconw);
TS_Xeq("manager", xmang);
TS_Xeq("adminpath", xapath);
TS_Xeq("perf", xperf);
TS_Xeq("request", xreqs);
TS_Xeq("trace", xtrac);
TS_Xeq("vnid", xvnid);
Expand Down Expand Up @@ -487,6 +515,64 @@ int XrdCmsClientConfig::xmang(XrdOucStream &Config)
return (XrdCmsUtils::ParseMan(&Say, theList, hSpec, hPort, 0) ? 0 : 1);
}


/******************************************************************************/
/* x p e r f */
/******************************************************************************/

/* Function: xperf
Purpose: To parse the directive: perf [xrootd] [int <sec>]
[lib <lib> [<parms>] | pgm <pgm>]
int <time> estimated time (seconds, M, H) between reports by <pgm>
lib <lib> the shared library holding the XrdCmsPerf object that
reports perf values. It must be the last option.
pgm <pgm> program to start that will write perf values to standard
out. It must be the last option. This is not supported
when xrootd is specified.
xrootd This directive only applies to the cms xrootd plugin.
Type: Server only, non-dynamic.
Output: 0 upon success or !0 upon failure. Ignored by manager.
*/

int XrdCmsClientConfig::xperf(XrdOucStream &Config)
{ char *val;

if (!isServer) return Config.noEcho();

if (!(val = Config.GetWord()))
{Say.Emsg("Config", "perf options not specified"); return 1;}

if (strcmp("xrootd", val)) return Config.noEcho();
perfInt = 3*60;

do { if (!strcmp("int", val))
{if (!(val = Config.GetWord()))
{Say.Emsg("Config", "perf int value not specified");
return 1;
}
if (XrdOuca2x::a2tm(Say,"perf int",val,&perfInt,0)) return 1;
}
else if (!strcmp("lib", val))
{return (XrdOucUtils::parseLib(Say, Config, "perf lib",
prfLib, &prfParms) ? 0 : 1);
break;
}
else if (!strcmp("pgm", val))
{Say.Emsg("Config", "perf pgm is not supported for xrootd.");
return 1;
}
else Say.Say("Config warning: ignoring invalid perf option '",val,"'.");
} while((val = Config.GetWord()));

// All done.
//
return 0;
}

/******************************************************************************/
/* x r e q s */
/******************************************************************************/
Expand Down
21 changes: 17 additions & 4 deletions src/XrdCms/XrdCmsClientConfig.hh
Expand Up @@ -33,6 +33,7 @@
#include "XrdOuc/XrdOucTList.hh"
#include "XrdOuc/XrdOuca2x.hh"

class XrdCmsPerfMon;
class XrdOucStream;
class XrdSysError;

Expand Down Expand Up @@ -65,27 +66,38 @@ const char *myName;

XrdOucTList *ManList; // List of managers for remote redirection
XrdOucTList *PanList; // List of managers for proxy redirection
XrdCmsPerfMon *perfMon; // Performance monitor plugin
int perfInt; // Performance poll interval
unsigned char SMode; // Manager selection mode
unsigned char SModeP; // Manager selection mode (proxy)

enum {FailOver = 'f', RoundRob = 'r'};

XrdCmsClientConfig() : ConWait(10), RepWait(3), RepWaitMS(3000),
XrdCmsClientConfig(XrdCmsPerfMon *cmsmon=0)
: ConWait(10), RepWait(3), RepWaitMS(3000),
RepDelay(5), RepNone(8), PrepWait(33),
FwdWait(0), haveMeta(0), CMSPath(0),
myHost(0), myName(0), myVNID(0),
cidTag(0), ManList(0), PanList(0),
perfMon(0), perfInt(3*60),
SMode(FailOver), SModeP(FailOver),
VNID_Lib(0), VNID_Parms(0),
isMeta(0), isMan(0) {}
prfLib(0), prfParms(0), cmsMon(cmsmon),
isMeta(false), isMan(false), isServer(false) {}
~XrdCmsClientConfig();

private:

char *VNID_Lib;
char *VNID_Parms;
char *prfLib;
char *prfParms;

XrdCmsPerfMon *cmsMon;

int isMeta; // We are a meta manager
int isMan; // We are a manager
bool isMeta; // We are a meta manager
bool isMan; // We are a manager
bool isServer; // We are a server

int ConfigProc(const char *cfn);
bool ConfigSID(const char *cFile, XrdOucTList *tpl, char sfx);
Expand All @@ -94,6 +106,7 @@ int xapath(XrdOucStream &Config);
int xcidt(XrdOucStream &Config);
int xconw(XrdOucStream &Config);
int xmang(XrdOucStream &Config);
int xperf(XrdOucStream &Config);
int xreqs(XrdOucStream &Config);
int xtrac(XrdOucStream &Config);
int xvnid(XrdOucStream &Config);
Expand Down

0 comments on commit 623d314

Please sign in to comment.