Skip to content

Commit

Permalink
[XrdCl] Move XrdClMessage.hh to private headers.
Browse files Browse the repository at this point in the history
  • Loading branch information
simonmichal committed Oct 2, 2019
1 parent f75c5bb commit 0f59cbc
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 90 deletions.
2 changes: 1 addition & 1 deletion src/XrdCl/CMakeLists.txt
Expand Up @@ -153,7 +153,6 @@ install(
XrdClEnv.hh
XrdClFile.hh
XrdClFileSystem.hh
XrdClMessage.hh
XrdClMonitor.hh
XrdClStatus.hh
XrdClURL.hh
Expand All @@ -167,6 +166,7 @@ install(

install(
FILES
XrdClMessage.hh
XrdClPostMaster.hh
XrdClPostMasterInterfaces.hh
XrdClTransportManager.hh
Expand Down
160 changes: 84 additions & 76 deletions src/XrdCl/XrdClFileSystem.cc
Expand Up @@ -871,7 +871,7 @@ namespace XrdCl
//------------------------------------------------------------------------
// Constructor and destructor
//------------------------------------------------------------------------
AssignLBHandler( FileSystem *fs, ResponseHandler *userHandler ):
AssignLBHandler( FileSystemImpl *fs, ResponseHandler *userHandler ):
pFS(fs), pUserHandler(userHandler) {}

virtual ~AssignLBHandler() {}
Expand All @@ -881,27 +881,10 @@ namespace XrdCl
//------------------------------------------------------------------------
virtual void HandleResponseWithHosts( XRootDStatus *status,
AnyObject *response,
HostList *hostList )
{
if( status->IsOK() )
{
HostList::reverse_iterator it;
for( it = hostList->rbegin(); it != hostList->rend(); ++it )
if( it->loadBalancer )
{
pFS->AssignLoadBalancer( it->url );
break;
}
}

bool finalrsp = !( status->IsOK() && status->code == suContinue );
pUserHandler->HandleResponseWithHosts( status, response, hostList );
if( finalrsp )
delete this;
}
HostList *hostList );

private:
FileSystem *pFS;
FileSystemImpl *pFS;
ResponseHandler *pUserHandler;
};

Expand All @@ -922,12 +905,77 @@ namespace XrdCl
delete pUrl;
}

//------------------------------------------------------------------------
// Send a message in a locked environment
//------------------------------------------------------------------------
Status Send( Message *msg,
ResponseHandler *handler,
MessageSendParams &params )
{
Log *log = DefaultEnv::GetLog();
XrdSysMutexHelper scopedLock( pMutex );

log->Dump( FileSystemMsg, "[0x%x@%s] Sending %s", this,
pUrl->GetHostId().c_str(), msg->GetDescription().c_str() );

if( !pLoadBalancerLookupDone && pFollowRedirects )
handler = new AssignLBHandler( this, handler ); // TODO

params.followRedirects = pFollowRedirects;

return MessageUtils::SendMessage( *pUrl, msg, handler, params, 0 );
}


//----------------------------------------------------------------------------
// Assign a load balancer if it has not already been assigned
//----------------------------------------------------------------------------
void AssignLoadBalancer( const URL &url )
{
Log *log = DefaultEnv::GetLog();
XrdSysMutexHelper scopedLock( pMutex );

if( pLoadBalancerLookupDone )
return;

log->Dump( FileSystemMsg, "[0x%x@%s] Assigning %s as load balancer", this,
pUrl->GetHostId().c_str(), url.GetHostId().c_str() );

delete pUrl;
pUrl = new URL( url );
pLoadBalancerLookupDone = true;
}

XrdSysMutex pMutex;
bool pLoadBalancerLookupDone;
bool pFollowRedirects;
URL *pUrl;
};

//------------------------------------------------------------------------
// Response callback
//------------------------------------------------------------------------
void AssignLBHandler::HandleResponseWithHosts( XRootDStatus *status,
AnyObject *response,
HostList *hostList )
{
if( status->IsOK() )
{
HostList::reverse_iterator it;
for( it = hostList->rbegin(); it != hostList->rend(); ++it )
if( it->loadBalancer )
{
pFS->AssignLoadBalancer( it->url );
break;
}
}

bool finalrsp = !( status->IsOK() && status->code == suContinue );
pUserHandler->HandleResponseWithHosts( status, response, hostList );
if( finalrsp )
delete this;
}

//----------------------------------------------------------------------------
// Constructor
//----------------------------------------------------------------------------
Expand Down Expand Up @@ -999,7 +1047,7 @@ namespace XrdCl

XRootDTransport::SetDescription( msg );

return Send( msg, handler, params );
return pImpl->Send( msg, handler, params );
}

//----------------------------------------------------------------------------
Expand Down Expand Up @@ -1077,7 +1125,7 @@ namespace XrdCl

XRootDTransport::SetDescription( msg );

return Send( msg, handler, params );
return pImpl->Send( msg, handler, params );
}

//----------------------------------------------------------------------------
Expand Down Expand Up @@ -1118,7 +1166,7 @@ namespace XrdCl
MessageUtils::ProcessSendParams( params );
XRootDTransport::SetDescription( msg );

return Send( msg, handler, params );
return pImpl->Send( msg, handler, params );
}

//----------------------------------------------------------------------------
Expand Down Expand Up @@ -1162,7 +1210,7 @@ namespace XrdCl
MessageUtils::ProcessSendParams( params );
XRootDTransport::SetDescription( msg );

return Send( msg, handler, params );
return pImpl->Send( msg, handler, params );
}

//----------------------------------------------------------------------------
Expand Down Expand Up @@ -1206,7 +1254,7 @@ namespace XrdCl
MessageUtils::ProcessSendParams( params );
XRootDTransport::SetDescription( msg );

return Send( msg, handler, params );
return pImpl->Send( msg, handler, params );
}

//----------------------------------------------------------------------------
Expand Down Expand Up @@ -1250,7 +1298,7 @@ namespace XrdCl
MessageUtils::ProcessSendParams( params );
XRootDTransport::SetDescription( msg );

return Send( msg, handler, params );
return pImpl->Send( msg, handler, params );
}

//----------------------------------------------------------------------------
Expand Down Expand Up @@ -1292,7 +1340,7 @@ namespace XrdCl
MessageUtils::ProcessSendParams( params );
XRootDTransport::SetDescription( msg );

return Send( msg, handler, params );
return pImpl->Send( msg, handler, params );
}

//----------------------------------------------------------------------------
Expand Down Expand Up @@ -1334,7 +1382,7 @@ namespace XrdCl
MessageUtils::ProcessSendParams( params );
XRootDTransport::SetDescription( msg );

return Send( msg, handler, params );
return pImpl->Send( msg, handler, params );
}

//----------------------------------------------------------------------------
Expand Down Expand Up @@ -1370,7 +1418,7 @@ namespace XrdCl
MessageUtils::ProcessSendParams( params );
XRootDTransport::SetDescription( msg );

return Send( msg, handler, params );
return pImpl->Send( msg, handler, params );
}

//----------------------------------------------------------------------------
Expand Down Expand Up @@ -1413,7 +1461,7 @@ namespace XrdCl
MessageUtils::ProcessSendParams( params );
XRootDTransport::SetDescription( msg );

return Send( msg, handler, params );
return pImpl->Send( msg, handler, params );
}

//----------------------------------------------------------------------------
Expand Down Expand Up @@ -1455,7 +1503,7 @@ namespace XrdCl
MessageUtils::ProcessSendParams( params );
XRootDTransport::SetDescription( msg );

return Send( msg, handler, params );
return pImpl->Send( msg, handler, params );
}

//----------------------------------------------------------------------------
Expand Down Expand Up @@ -1492,7 +1540,7 @@ namespace XrdCl
MessageUtils::ProcessSendParams( params );
XRootDTransport::SetDescription( msg );

return Send( msg, handler, params );
return pImpl->Send( msg, handler, params );
}

//----------------------------------------------------------------------------
Expand Down Expand Up @@ -1557,7 +1605,7 @@ namespace XrdCl
MessageUtils::ProcessSendParams( params );
XRootDTransport::SetDescription( msg );

return Send( msg, handler, params );
return pImpl->Send( msg, handler, params );
}

//----------------------------------------------------------------------------
Expand Down Expand Up @@ -1726,7 +1774,7 @@ namespace XrdCl
MessageUtils::ProcessSendParams( params );
XRootDTransport::SetDescription( msg );

return Send( msg, handler, params );
return pImpl->Send( msg, handler, params );
}

//----------------------------------------------------------------------------
Expand Down Expand Up @@ -1781,7 +1829,7 @@ namespace XrdCl
MessageUtils::ProcessSendParams( params );
XRootDTransport::SetDescription( msg );

return Send( msg, handler, params );
return pImpl->Send( msg, handler, params );
}

//------------------------------------------------------------------------
Expand Down Expand Up @@ -1957,46 +2005,6 @@ namespace XrdCl
return false;
}

//----------------------------------------------------------------------------
// Assign a load balancer if it has not already been assigned
//----------------------------------------------------------------------------
void FileSystem::AssignLoadBalancer( const URL &url )
{
Log *log = DefaultEnv::GetLog();
XrdSysMutexHelper scopedLock( pImpl->pMutex );

if( pImpl->pLoadBalancerLookupDone )
return;

log->Dump( FileSystemMsg, "[0x%x@%s] Assigning %s as load balancer", this,
pImpl->pUrl->GetHostId().c_str(), url.GetHostId().c_str() );

delete pImpl->pUrl;
pImpl->pUrl = new URL( url );
pImpl->pLoadBalancerLookupDone = true;
}

//----------------------------------------------------------------------------
// Send a message in a locked environment
//----------------------------------------------------------------------------
Status FileSystem::Send( Message *msg,
ResponseHandler *handler,
MessageSendParams &params )
{
Log *log = DefaultEnv::GetLog();
XrdSysMutexHelper scopedLock( pImpl->pMutex );

log->Dump( FileSystemMsg, "[0x%x@%s] Sending %s", this,
pImpl->pUrl->GetHostId().c_str(), msg->GetDescription().c_str() );

if( !pImpl->pLoadBalancerLookupDone && pImpl->pFollowRedirects )
handler = new AssignLBHandler( this, handler );

params.followRedirects = pImpl->pFollowRedirects;

return MessageUtils::SendMessage( *pImpl->pUrl, msg, handler, params, 0 );
}

//------------------------------------------------------------------------
// Generic implementation of xattr operation
//------------------------------------------------------------------------
Expand Down Expand Up @@ -2025,7 +2033,7 @@ namespace XrdCl

XRootDTransport::SetDescription( msg );

return Send( msg, handler, params );
return pImpl->Send( msg, handler, params );
}

//------------------------------------------------------------------------
Expand Down
13 changes: 0 additions & 13 deletions src/XrdCl/XrdClFileSystem.hh
Expand Up @@ -38,7 +38,6 @@
namespace XrdCl
{
class PostMaster;
class Message;
class FileSystemPlugIn;
struct MessageSendParams;

Expand Down Expand Up @@ -849,18 +848,6 @@ namespace XrdCl
FileSystem(const FileSystem &other);
FileSystem &operator = (const FileSystem &other);

//------------------------------------------------------------------------
// Send a message in a locked environment
//------------------------------------------------------------------------
Status Send( Message *msg,
ResponseHandler *handler,
MessageSendParams &params );

//------------------------------------------------------------------------
// Assign a load balancer if it has not already been assigned
//------------------------------------------------------------------------
void AssignLoadBalancer( const URL &url );

//------------------------------------------------------------------------
// Lock the internal lock
//------------------------------------------------------------------------
Expand Down

0 comments on commit 0f59cbc

Please sign in to comment.