XRootD
Loading...
Searching...
No Matches
XrdHttpTpc::PMarkManager Class Reference

#include <XrdHttpTpcPMarkManager.hh>

+ Collaboration diagram for XrdHttpTpc::PMarkManager:

Classes

class  SocketInfo
 

Public Member Functions

 PMarkManager (XrdHttpExtReq &req, const TPC::TpcType type)
 
virtual ~PMarkManager ()=default
 
void beginPMarks ()
 
bool connect (int fd, const struct sockaddr *sockP, size_t sockPLen, uint32_t timeout_sec, std::stringstream &err)
 
void endPmark (int fd)
 
bool isEnabled () const
 
void startTransfer ()
 

Detailed Description

Definition at line 52 of file XrdHttpTpcPMarkManager.hh.

Constructor & Destructor Documentation

◆ PMarkManager()

XrdHttpTpc::PMarkManager::PMarkManager ( XrdHttpExtReq & req,
const TPC::TpcType type )

Definition at line 35 of file XrdHttpTpcPMarkManager.cc.

35: mPmark(req.pmark), mReq(req), mTransferWillStart(false), mTpcType(tpcType) {}
XrdNetPMark * pmark

◆ ~PMarkManager()

virtual XrdHttpTpc::PMarkManager::~PMarkManager ( )
virtualdefault

Member Function Documentation

◆ beginPMarks()

void XrdHttpTpc::PMarkManager::beginPMarks ( )

Creates the different packet marking handles allowing to mark the transfer packets

Call this after the curl_multi_perform() has been called.

Definition at line 66 of file XrdHttpTpcPMarkManager.cc.

66 {
67 if(mSocketInfos.empty()) {
68 return;
69 }
70
71 if(mPmarkHandles.empty()) {
72 // Create the first pmark handle
73 std::stringstream ss;
74 ss << "scitag.flow=" << mReq.mSciTag
75 // One has to consider that this server is the client side of a normal HTTP PUT/GET. But unlike normal HTTP PUT and GET requests where clients
76 // do not emit a firefly, this server WILL emit a firefly.
77 //
78 // For PULL: it is expected that I send a GET request to the remote server
79 // however, it is myself who will emit the firefly, then I should consider that the GET is actually a PUT
80 // that I do on behalf of the remote server... Hence why if the tpc transfer type is Pull, the pmark.appname
81 // will be equal to http-put
82 //
83 // For PUSH: it is expected that I send a PUT request to the remote server.
84 // however, it is myself who will emit the firefly, then I should consider that the PUT is actually a GET
85 // that I do on behalf of the remote server... Hence why if the tpc transfer is Push, the pmark.appname will be equal to http-get.
86 << "&" << "pmark.appname=" << ((mTpcType == TPC::TpcType::Pull) ? "http-put" : "http-get");
87 SocketInfo & sockInfo = mSocketInfos.front();
88 auto pmark = mPmark->Begin(sockInfo.client, mReq.resource.c_str(), ss.str().c_str(), "http-tpc");
89 if(!pmark) {
90 return;
91 }
92 mPmarkHandles.emplace(sockInfo.client.addrInfo->SockFD(),std::unique_ptr<XrdNetPMark::Handle>(pmark));
93 mSocketInfos.pop();
94 }
95
96 auto pmarkHandleItor = mPmarkHandles.begin();
97 while(!mSocketInfos.empty()) {
98 SocketInfo & sockInfo = mSocketInfos.front();
99 auto pmark = mPmark->Begin(*sockInfo.client.addrInfo, *(pmarkHandleItor->second), nullptr);
100 if (!pmark) {
101 // The packet marking handle could not be created from the first handle, let's retry next time
102 break;
103 }
104
105 int fd = sockInfo.client.addrInfo->SockFD();
106 mPmarkHandles.emplace(fd, std::unique_ptr<XrdNetPMark::Handle>(pmark));
107 mSocketInfos.pop();
108 }
109}
std::string resource
virtual Handle * Begin(XrdSecEntity &Client, const char *path=0, const char *cgi=0, const char *app=0)=0

References XrdSecEntity::addrInfo, XrdNetPMark::Begin(), XrdHttpTpc::PMarkManager::SocketInfo::client, XrdHttpExtReq::mSciTag, TPC::Pull, XrdHttpExtReq::resource, and XrdNetAddrInfo::SockFD().

+ Here is the call graph for this function:

◆ connect()

bool XrdHttpTpc::PMarkManager::connect ( int fd,
const struct sockaddr * sockP,
size_t sockPLen,
uint32_t timeout_sec,
std::stringstream & err )

Will connect the socket attached to the file descriptor within a certain timeout and add the file descriptor to the. packet marking manager so packet marking can be done achieved later on If pmark is not enabled, this function will just return true without trying to connect (libcurl will perform the connection). False will be returned in case the connection could not have been done.

Parameters
fdthe fd associated to the socket
sockPthe connection information
sockPLenthe length of the connection information
timeout_secthe timeout after which the connection is considered failed
errthe error stream allowing to understand from where the issue comes from
Returns
true if the connection could be established or if pmark is disabled, false otherwise

Definition at line 44 of file XrdHttpTpcPMarkManager.cc.

44 {
45 if(isEnabled()) {
46 // We only connect if the packet marking is enabled
47 bool couldConnect = XrdNetUtils::ConnectWithTimeout(fd,sockP,sockPLen,timeout_sec,err);
48 if(couldConnect) {
49 addFd(fd,sockP);
50 } else {
51 return false;
52 }
53 }
54 // If pmark is not enabled, we leave libcurl doing the connection
55 return true;
56}
static bool ConnectWithTimeout(int sockfd, const struct sockaddr *clientAddr, size_t clientAddrLen, uint32_t timeout_sec, std::stringstream &errMsg)

References XrdNetUtils::ConnectWithTimeout(), and isEnabled().

+ Here is the call graph for this function:

◆ endPmark()

void XrdHttpTpc::PMarkManager::endPmark ( int fd)

This function deletes the PMark handle associated to the fd passed in parameter Use this before closing the associated socket! Otherwise the information contained in the firefly (e.g sent bytes or received bytes) will have values equal to 0.

Parameters
fdthe fd of the socket to be closed

Definition at line 111 of file XrdHttpTpcPMarkManager.cc.

111 {
112 // We need to delete the PMark handle associated to the fd passed in parameter
113 // we just look for it and reset the unique_ptr to nullptr to trigger the PMark handle deletion
114 mPmarkHandles.erase(fd);
115}

◆ isEnabled()

bool XrdHttpTpc::PMarkManager::isEnabled ( ) const
Returns
true if packet marking can happen i.e the packet marking is enabled in the configuration and a scitag was provided by the user.

Definition at line 58 of file XrdHttpTpcPMarkManager.cc.

58 {
59 return mPmark && (mReq.mSciTag >= 0);
60}

References XrdHttpExtReq::mSciTag.

Referenced by connect().

+ Here is the caller graph for this function:

◆ startTransfer()

void XrdHttpTpc::PMarkManager::startTransfer ( )

Calling this function will indicate that the connections that will happen will be related to the data transfer. The addFd(...) function will then register any socket that is created after this function will be called.

Definition at line 62 of file XrdHttpTpcPMarkManager.cc.

62 {
63 mTransferWillStart = true;
64}

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