XRootD
Loading...
Searching...
No Matches
XrdOfsPrepGPIReal::PrepGPI Class Reference
+ Inheritance diagram for XrdOfsPrepGPIReal::PrepGPI:
+ Collaboration diagram for XrdOfsPrepGPIReal::PrepGPI:

Public Member Functions

 PrepGPI (PrepGRun &gRun)
 
virtual ~PrepGPI ()
 
int begin (XrdSfsPrep &pargs, XrdOucErrInfo &eInfo, const XrdSecEntity *client=0) override
 
int cancel (XrdSfsPrep &pargs, XrdOucErrInfo &eInfo, const XrdSecEntity *client=0) override
 
int query (XrdSfsPrep &pargs, XrdOucErrInfo &eInfo, const XrdSecEntity *client=0) override
 
- Public Member Functions inherited from XrdOfsPrepare
 XrdOfsPrepare ()
 Constructor.
 
virtual ~XrdOfsPrepare ()
 Destructor.
 

Detailed Description

Definition at line 331 of file XrdOfsPrepGPI.cc.

Constructor & Destructor Documentation

◆ PrepGPI()

XrdOfsPrepGPIReal::PrepGPI::PrepGPI ( PrepGRun & gRun)
inline

Definition at line 347 of file XrdOfsPrepGPI.cc.

347: qryRunner(gRun) {}

◆ ~PrepGPI()

virtual XrdOfsPrepGPIReal::PrepGPI::~PrepGPI ( )
inlinevirtual

Definition at line 349 of file XrdOfsPrepGPI.cc.

349{}

Member Function Documentation

◆ begin()

int XrdOfsPrepGPIReal::PrepGPI::begin ( XrdSfsPrep & pargs,
XrdOucErrInfo & eInfo,
const XrdSecEntity * client = 0 )
overridevirtual

Execute a prepare request.

Parameters
pargs- The prepare arguments (see XrdSfsInterface.hh).
eInfo- The object where error or data response is to be returned.
client- Client's identify (may be null).
Returns
One of SFS_OK, SFS_DATA, SFS_ERROR, SFS_REDIRECT, SFS_STALL, or SFS_STARTED.
Note
Special action taken with certain return codes:
  • SFS_DATA The data is sent to the client as the "requestID".
  • SFS_OK The data pointed to by pargs.reqid is sent to the client as the "requestID".

Implements XrdOfsPrepare.

Definition at line 528 of file XrdOfsPrepGPI.cc.

531{
532 const char *reqName, *reqOpts, *tid = (client ? client->tident : "anon");
533 int rc;
534 bool ignore;
535
536// Establish the actual request
537//
538 if (pargs.opts & Prep_EVICT)
539 {reqName = "evict";
540 reqOpts = "";
541 ignore = (okReq & okEvict) == 0;
542 }
543 else if (pargs.opts & Prep_STAGE)
544 {reqName = "stage";
545 reqOpts = "Cnpw";
546 ignore = (okReq & okStage) == 0;
547 }
548 else {reqName = "prep";
549 reqOpts = "Cnpw";
550 ignore = (okReq & okPrep) == 0;
551 }
552
553// Check if this operation is supported
554//
555 if (ignore) return RetErr(eInfo, ENOTSUP, "process", reqName);
556
557// Get a request request object
558//
559 PrepRequest *rP = Assemble(rc, tid, reqName, pargs, reqOpts);
560
561// If we didn't get one or if there are no paths selected, complain
562//
563 if (!rP || rP->argMem.size() == 0)
564 return RetErr(eInfo, (rc ? rc : EINVAL), reqName, "files");
565
566// Either run or queue this request and return
567//
568 return Xeq(rP);
569}
#define Prep_EVICT
#define Prep_STAGE
int opts
Prep_xxx.
const char * tident
Trace identifier always preset.
static const int okEvict
static const int okStage
static const int okPrep
std::vector< std::string > argMem

References XrdOfsPrepGPIReal::PrepRequest::argMem, XrdOfsPrepGPIReal::okEvict, XrdOfsPrepGPIReal::okPrep, XrdOfsPrepGPIReal::okReq, XrdOfsPrepGPIReal::okStage, XrdSfsPrep::opts, Prep_EVICT, Prep_STAGE, and XrdSecEntity::tident.

◆ cancel()

int XrdOfsPrepGPIReal::PrepGPI::cancel ( XrdSfsPrep & pargs,
XrdOucErrInfo & eInfo,
const XrdSecEntity * client = 0 )
overridevirtual

Cancel a preveious prepare request.

Parameters
pargs- The prepare arguments (see XrdSfsInterface.hh). The pargs.reqid points to the "requestID" associated with the previously issued prepare request.
eInfo- The object where error or data response is to be returned.
client- Client's identify (may be null).
Returns
One of SFS_OK, SFS_ERROR, SFS_REDIRECT, SFS_STALL, or SFS_STARTED.

Implements XrdOfsPrepare.

Definition at line 578 of file XrdOfsPrepGPI.cc.

581{
582 const char *tid = (client ? client->tident : "anon");
583 int rc;
584
585// If the attached program does no know how to handle cancel, do the minimal
586// thing and remove the request from the waiting queue if it is there.
587//
588 if (!(okReq & okCancel))
589 {PrepRequest *rPP, *rP;
590 int bL;
591 char *bP = eInfo.getMsgBuff(bL);
592 if (reqFind(pargs.reqid, rPP, rP, true))
593 {bL = snprintf(bP, bL, "Request %s cancelled.", pargs.reqid);
594 } else {
595 bL = snprintf(bP, bL, "Request %s not cancellable.", pargs.reqid);
596 }
597 eInfo.setErrCode(bL);
598 return SFS_DATA;
599 }
600
601// Get a request request object
602//
603 PrepRequest *rP = Assemble(rc, tid, "cancel", pargs, "n");
604
605// If we didn't get one or if there are no paths selected, complain
606//
607 if (!rP) return RetErr(eInfo, (rc ? rc : EINVAL), "cancel", "files");
608
609// Either run or queue this request and return
610//
611 return Xeq(rP);
612}
#define SFS_DATA
char * reqid
Request ID.
char * getMsgBuff(int &mblen)
int setErrCode(int code)
static const int okCancel

References XrdOucErrInfo::getMsgBuff(), XrdOfsPrepGPIReal::okCancel, XrdOfsPrepGPIReal::okReq, XrdSfsPrep::reqid, XrdOucErrInfo::setErrCode(), SFS_DATA, and XrdSecEntity::tident.

+ Here is the call graph for this function:

◆ query()

int XrdOfsPrepGPIReal::PrepGPI::query ( XrdSfsPrep & pargs,
XrdOucErrInfo & eInfo,
const XrdSecEntity * client = 0 )
overridevirtual

Query a preveious prepare request.

Parameters
pargs- The prepare arguments (see XrdSfsInterface.hh). The pargs.reqid points to the "requestID" associated with the previously issued prepare request.
eInfo- The object where error or data response is to be returned.
client- Client's identify (may be null).
Returns
One of SFS_OK, SFS_ERROR, SFS_REDIRECT, or SFS_STALL.

Implements XrdOfsPrepare.

Definition at line 621 of file XrdOfsPrepGPI.cc.

624{
625 EPNAME("Query");
626 struct OucBuffer {XrdOucBuffer *pBuff;
627 OucBuffer() : pBuff(0) {}
628 ~OucBuffer() {if (pBuff) pBuff->Recycle();}
629 } OucBuff;
630 const char *tid = (client ? client->tident : "anon");
631 int rc, bL;
632 char *bP = eInfo.getMsgBuff(bL);
633
634// If the attached program does no know how to handle cancel, do the minimal
635// thing and remove the request from the waiting queue if it is there.
636//
637 if (!(okReq & okQuery))
638 {PrepRequest *rPP, *rP;
639 if (reqFind(pargs.reqid, rPP, rP))
640 {bL = snprintf(bP, bL, "Request %s queued.", pargs.reqid)+1;
641 } else {
642 bL = snprintf(bP, bL, "Request %s not queued.", pargs.reqid)+1;
643 }
644 eInfo.setErrCode(bL);
645 return SFS_DATA;
646 }
647
648// Allocate a buffer if need be
649//
650 if (bPool)
651 {OucBuff.pBuff = bPool->Alloc(maxResp);
652 if (OucBuff.pBuff)
653 {bP = OucBuff.pBuff->Buffer();
654 bL = maxResp;
655 }
656 }
657
658// Get a request request object
659//
660 PrepRequest *rP = Assemble(rc, tid, "query", pargs, "");
661
662// If we didn't get one or if there are no paths selected, complain
663//
664 if (!rP) return RetErr(eInfo, (rc ? rc : EINVAL), "query", "request");
665
666// Wait for our turn if need be. This is sloppy and spurious wakeups may
667// cause us to exceed the allowed limit.
668//
669 qryCond.Lock();
670 if (qryAllow) qryAllow--;
671 else {qryWait++;
672 DEBUG(tid, "Waiting to launch query "<<rP->reqID);
673 rc = qryCond.Wait(qryMaxWT);
674 qryWait--;
675 if (!rc) qryAllow--;
676 else {qryCond.UnLock();
677 return RetErr(eInfo, ETIMEDOUT, "query", "request");
678 }
679 }
680 qryCond.UnLock();
681
682// Run the query
683//
684 *bP = 0;
685 rc = qryRunner.Run(*rP, bP, bL);
686
687// Let the next query run
688//
689 qryCond.Lock();
690 qryAllow++;
691 if (qryWait) qryCond.Signal();
692 qryCond.UnLock();
693
694// See if this ended in an error
695//
696 if (rc <= 0) return RetErr(eInfo, ECANCELED, "query", "request");
697
698// Return response
699//
700 if (!OucBuff.pBuff) eInfo.setErrCode(rc);
701 else {OucBuff.pBuff->SetLen(rc);
702 eInfo.setErrInfo(rc, OucBuff.pBuff);
703 OucBuff.pBuff = 0;
704 }
705 return SFS_DATA;
706}
#define DEBUG(x)
#define EPNAME(x)
int Run(PrepRequest &req, char *bP=0, int bL=0)
XrdOucBuffer * Alloc(int sz)
void Recycle()
Recycle the buffer. The buffer may be reused in the future.
int setErrInfo(int code, const char *emsg)
static const int qryMaxWT
XrdOucBuffPool * bPool
static const int okQuery
XrdSysCondVar qryCond(0, "prepG query")

References XrdOucBuffPool::Alloc(), XrdOfsPrepGPIReal::bPool, DEBUG, EPNAME, XrdOucErrInfo::getMsgBuff(), XrdSysCondVar::Lock(), XrdOfsPrepGPIReal::maxResp, XrdOfsPrepGPIReal::okQuery, XrdOfsPrepGPIReal::okReq, XrdOfsPrepGPIReal::qryAllow, XrdOfsPrepGPIReal::qryCond, XrdOfsPrepGPIReal::qryMaxWT, XrdOfsPrepGPIReal::qryWait, XrdOucBuffer::Recycle(), XrdOfsPrepGPIReal::PrepRequest::reqID, XrdSfsPrep::reqid, XrdOfsPrepGPIReal::PrepGRun::Run(), XrdOucErrInfo::setErrCode(), XrdOucErrInfo::setErrInfo(), SFS_DATA, XrdSysCondVar::Signal(), XrdSecEntity::tident, XrdSysCondVar::UnLock(), and XrdSysCondVar::Wait().

+ Here is the call graph for this function:

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