XRootD
XrdFrcReqAgent Class Reference

#include <XrdFrcReqAgent.hh>

+ Collaboration diagram for XrdFrcReqAgent:

Public Member Functions

 XrdFrcReqAgent (const char *Me, int qVal)
 
 ~XrdFrcReqAgent ()
 
void Add (XrdFrcRequest &Request)
 
void Del (XrdFrcRequest &Request)
 
int List (XrdFrcRequest::Item *Items, int Num)
 
int List (XrdFrcRequest::Item *Items, int Num, int Prty)
 
int NextLFN (char *Buff, int Bsz, int Prty, int &Offs)
 
void Ping (const char *Msg=0)
 
int Start (char *aPath, int aMode)
 

Detailed Description

Definition at line 36 of file XrdFrcReqAgent.hh.

Constructor & Destructor Documentation

◆ XrdFrcReqAgent()

XrdFrcReqAgent::XrdFrcReqAgent ( const char *  Me,
int  qVal 
)

Definition at line 60 of file XrdFrcReqAgent.cc.

61  : Persona(Me),myName(""),theQ(qVal)
62 {
63 // Set default ping message
64 //
65  switch(qVal)
66  {case XrdFrcRequest::getQ: pingMsg = "!<\n"; break;
67  case XrdFrcRequest::migQ: pingMsg = "!&\n"; break;
68  case XrdFrcRequest::stgQ: pingMsg = "!+\n"; break;
69  case XrdFrcRequest::putQ: pingMsg = "!>\n"; break;
70  default: pingMsg = "!\n" ; break;
71  }
72 }
static const int stgQ
static const int getQ
static const int migQ
static const int putQ

References XrdFrcRequest::getQ, XrdFrcRequest::migQ, XrdFrcRequest::putQ, and XrdFrcRequest::stgQ.

◆ ~XrdFrcReqAgent()

XrdFrcReqAgent::~XrdFrcReqAgent ( )
inline

Definition at line 54 of file XrdFrcReqAgent.hh.

54 {}

Member Function Documentation

◆ Add()

void XrdFrcReqAgent::Add ( XrdFrcRequest Request)

Definition at line 78 of file XrdFrcReqAgent.cc.

79 {
80 
81 // Complete the request including verifying the priority
82 //
83  if (Request.Prty > XrdFrcRequest::maxPrty)
84  Request.Prty = XrdFrcRequest::maxPrty;
85  else if (Request.Prty < 0)Request.Prty = 0;
86 
87 // Add time and instance name
88 //
89  Request.addTOD = time(0);
90  if (myName) strlcpy(Request.iName, myName, sizeof(Request.iName));
91 
92 // Now add it to the queue
93 //
94  rQueue[static_cast<int>(Request.Prty)]->Add(&Request);
95 
96 // Now wake the boss
97 //
98  Ping();
99 }
size_t strlcpy(char *dst, const char *src, size_t sz)
void Ping(const char *Msg=0)
void Add(XrdFrcRequest &Request)
char iName[32]
signed char Prty
static const int maxPrty
long long addTOD

References XrdFrcRequest::addTOD, XrdFrcRequest::iName, XrdFrcRequest::maxPrty, Ping(), XrdFrcRequest::Prty, and strlcpy().

+ Here is the call graph for this function:

◆ Del()

void XrdFrcReqAgent::Del ( XrdFrcRequest Request)

Definition at line 105 of file XrdFrcReqAgent.cc.

106 {
107  int i;
108 
109 // Remove all pending requests for this id
110 //
111  for (i = 0; i <= XrdFrcRequest::maxPrty; i++) rQueue[i]->Can(&Request);
112 }

References XrdFrcRequest::maxPrty.

◆ List() [1/2]

int XrdFrcReqAgent::List ( XrdFrcRequest::Item Items,
int  Num 
)

Definition at line 118 of file XrdFrcReqAgent.cc.

119 {
120  char myLfn[8192];
121  int i, Offs, n = 0;
122 
123 // List entries in each priority queue
124 //
125  for (i = 0; i <= XrdFrcRequest::maxPrty; i++)
126  {Offs = 0;
127  while(rQueue[i]->List(myLfn, sizeof(myLfn), Offs, Items, Num))
128  {std::cout <<myLfn <<std::endl; n++;}
129  }
130 // All done
131 //
132  return n;
133 }
int List(XrdFrcRequest::Item *Items, int Num)

References XrdFrcRequest::maxPrty.

Referenced by List().

+ Here is the caller graph for this function:

◆ List() [2/2]

int XrdFrcReqAgent::List ( XrdFrcRequest::Item Items,
int  Num,
int  Prty 
)

Definition at line 137 of file XrdFrcReqAgent.cc.

138 {
139  char myLfn[8192];
140  int Offs, n = 0;
141 
142 // List entries in each priority queue
143 //
144  if (Prty <= XrdFrcRequest::maxPrty)
145  {Offs = 0;
146  while(rQueue[Prty]->List(myLfn, sizeof(myLfn), Offs, Items, Num))
147  {std::cout <<myLfn <<std::endl; n++;}
148  }
149 
150 // All done
151 //
152  return n;
153 }

References List(), and XrdFrcRequest::maxPrty.

+ Here is the call graph for this function:

◆ NextLFN()

int XrdFrcReqAgent::NextLFN ( char *  Buff,
int  Bsz,
int  Prty,
int &  Offs 
)

Definition at line 159 of file XrdFrcReqAgent.cc.

160 {
161  static XrdFrcRequest::Item Items[1] = {XrdFrcRequest::getLFN};
162 
163 // Return entry, if it exists
164 //
165  return rQueue[Prty]->List(Buff, Bsz, Offs, Items, 1) != 0;
166 }
char * List(char *Buff, int bsz, int &Offs, XrdFrcRequest::Item *ITList=0, int ITNum=0)

References XrdFrcRequest::getLFN, and XrdFrcReqFile::List().

+ Here is the call graph for this function:

◆ Ping()

void XrdFrcReqAgent::Ping ( const char *  Msg = 0)

Definition at line 172 of file XrdFrcReqAgent.cc.

173 {
174  static XrdNetMsg udpMsg(&Say, c2sFN);
175  static int udpOK = 0;
176  struct stat buf;
177 
178 // Send given message or default message based on our persona
179 //
180  if (udpOK || !stat(c2sFN, &buf))
181  {udpMsg.Send(Msg ? Msg : pingMsg); udpOK = 1;}
182 }
int stat(const char *path, struct stat *buf)
XrdSysError Say

References XrdCms::Say, XrdNetMsg::Send(), and stat().

Referenced by Add(), and Start().

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

◆ Start()

int XrdFrcReqAgent::Start ( char *  aPath,
int  aMode 
)

Definition at line 188 of file XrdFrcReqAgent.cc.

189 {
190  XrdFrcRequest Request;
191  const char *myClid;
192  char buff[2048], *qPath;
193  int i;
194 
195 // Initialize the udp path for pings, if we have not done so
196 //
197  if (!c2sFN)
198  {sprintf(buff, "%sxfrd.udp", aPath);
199  c2sFN = strdup(buff);
200  }
201 
202 // Get the instance name
203 //
204  myName = XrdOucUtils::InstName(1);
205 
206 // Generate the queue directory path
207 //
208  if (!(qPath = XrdFrcUtils::makeQDir(aPath, aMode))) return 0;
209 
210 // Initialize the registration entry and register ourselves
211 //
212  if ((myClid = getenv("XRDCMSCLUSTERID")))
213  {int Uid = static_cast<int>(geteuid());
214  int Gid = static_cast<int>(getegid());
215  memset(&Request, 0, sizeof(Request));
216  strlcpy(Request.LFN, myClid, sizeof(Request.LFN));
217  sprintf(Request.User,"%d %d", Uid, Gid);
218  sprintf(Request.ID, "%d", static_cast<int>(getpid()));
219  strlcpy(Request.iName, myName, sizeof(Request.iName));
220  Request.addTOD = time(0);
222  Request.OPc = '@';
223  }
224 
225 // Initialize the request queues if all went well
226 //
227  for (i = 0; i <= XrdFrcRequest::maxPrty; i++)
228  {sprintf(buff, "%s%sQ.%d", qPath, Persona, i);
229  rQueue[i] = new XrdFrcReqFile(buff, 1);
230  if (!rQueue[i]->Init()) return 0;
231  if (myClid) rQueue[i]->Add(&Request);
232  }
233 
234 // All done
235 //
236  if (myClid) Ping();
237  free(qPath);
238  return 1;
239 }
void Add(XrdFrcRequest *rP)
char LFN[3072]
char User[256]
static const int Register
static char * makeQDir(const char *Path, int Mode)
Definition: XrdFrcUtils.cc:127
static const char * InstName(int TranOpt=0)
Definition: XrdOucUtils.cc:732

References XrdFrcReqFile::Add(), XrdFrcRequest::addTOD, XrdFrcRequest::ID, XrdFrcRequest::iName, XrdOucUtils::InstName(), XrdFrcRequest::LFN, XrdFrcUtils::makeQDir(), XrdFrcRequest::maxPrty, XrdFrcRequest::OPc, XrdFrcRequest::Options, Ping(), XrdFrcRequest::Register, strlcpy(), and XrdFrcRequest::User.

+ Here is the call graph for this function:

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