XRootD
XrdCl::Channel Class Reference

A communication channel between the client and the server. More...

#include <XrdClChannel.hh>

+ Collaboration diagram for XrdCl::Channel:

Public Member Functions

 Channel (const URL &url, Poller *poller, TransportHandler *transport, TaskManager *taskManager, JobManager *jobManager, const URL &prefurl=URL())
 
 ~Channel ()
 Destructor. More...
 
bool CanCollapse (const URL &url)
 
void DecFileInstCnt ()
 Decrement file object instance count bound to this channel. More...
 
Status ForceDisconnect ()
 Force disconnect of all streams. More...
 
Status ForceDisconnect (bool hush)
 Force disconnect of all streams. More...
 
Status ForceReconnect ()
 Force reconnect. More...
 
const URLGetURL () const
 Get the URL. More...
 
uint16_t NbConnectedStrm ()
 Get the number of connected data streams. More...
 
Status QueryTransport (uint16_t query, AnyObject &result)
 
void RegisterEventHandler (ChannelEventHandler *handler)
 Register channel event handler. More...
 
void RemoveEventHandler (ChannelEventHandler *handler)
 Remove a channel event handler. More...
 
XRootDStatus Send (Message *msg, MsgHandler *handler, bool stateful, time_t expires)
 
void SetOnDataConnectHandler (std::shared_ptr< Job > &onConnJob)
 Set the on-connect handler for data streams. More...
 
void Tick (time_t now)
 Handle a time event. More...
 

Detailed Description

A communication channel between the client and the server.

Definition at line 48 of file XrdClChannel.hh.

Constructor & Destructor Documentation

◆ Channel()

XrdCl::Channel::Channel ( const URL url,
Poller poller,
TransportHandler transport,
TaskManager taskManager,
JobManager jobManager,
const URL prefurl = URL() 
)

Constructor

Parameters
urladdress of the server to connect to
pollerpoller object to be used for non-blocking IO
transportprotocol specific transport handler
taskManagerasync task handler to be used by the channel
jobManagerworker thread handler to be used by the channel

Definition at line 84 of file XrdClChannel.cc.

89  :
90  pUrl( url.GetHostId() ),
91  pPoller( poller ),
92  pTransport( transport ),
93  pTaskManager( taskManager ),
94  pTickGenerator( 0 ),
95  pJobManager( jobManager )
96  {
97  Env *env = DefaultEnv::GetEnv();
98  Log *log = DefaultEnv::GetLog();
99 
100  int timeoutResolution = DefaultTimeoutResolution;
101  env->GetInt( "TimeoutResolution", timeoutResolution );
102 
103  pTransport->InitializeChannel( url, pChannelData );
104  log->Debug( PostMasterMsg, "Creating new channel to: %s",
105  url.GetChannelId().c_str() );
106 
107  pUrl.SetParams( url.GetParams() );
108  pUrl.SetProtocol( url.GetProtocol() );
109 
110  //--------------------------------------------------------------------------
111  // Create the stream
112  //--------------------------------------------------------------------------
113  pStream = new Stream( &pUrl, prefurl );
114  pStream->SetTransport( transport );
115  pStream->SetPoller( poller );
116  pStream->SetIncomingQueue( &pIncoming );
117  pStream->SetTaskManager( taskManager );
118  pStream->SetJobManager( jobManager );
119  pStream->SetChannelData( &pChannelData );
120  pStream->Initialize();
121 
122  //--------------------------------------------------------------------------
123  // Register the task generating timeout events
124  //--------------------------------------------------------------------------
125  pTickGenerator = new TickGeneratorTask( this, pUrl.GetChannelId() );
126  pTaskManager->RegisterTask( pTickGenerator, ::time(0)+timeoutResolution );
127  }
static Log * GetLog()
Get default log.
static Env * GetEnv()
Get default client environment.
bool GetInt(const std::string &key, int &value)
Definition: XrdClEnv.cc:89
Handle diagnostics.
Definition: XrdClLog.hh:101
void Debug(uint64_t topic, const char *format,...)
Print a debug message.
Definition: XrdClLog.cc:282
void SetTransport(TransportHandler *transport)
Set the transport.
Definition: XrdClStream.hh:91
void SetIncomingQueue(InQueue *incomingQueue)
Set the incoming queue.
Definition: XrdClStream.hh:107
void SetPoller(Poller *poller)
Set the poller.
Definition: XrdClStream.hh:99
void SetTaskManager(TaskManager *taskManager)
Set task manager.
Definition: XrdClStream.hh:123
void SetJobManager(JobManager *jobManager)
Set job manager.
Definition: XrdClStream.hh:131
void SetChannelData(AnyObject *channelData)
Set the channel data.
Definition: XrdClStream.hh:115
XRootDStatus Initialize()
Initializer.
Definition: XrdClStream.cc:171
void RegisterTask(Task *task, time_t time, bool own=true)
virtual void InitializeChannel(const URL &url, AnyObject &channelData)=0
Initialize channel.
std::string GetChannelId() const
Definition: XrdClURL.cc:505
std::string GetHostId() const
Get the host part of the URL (user:password@host:port)
Definition: XrdClURL.hh:99
const std::string & GetProtocol() const
Get the protocol.
Definition: XrdClURL.hh:118
void SetParams(const std::string &params)
Set params.
Definition: XrdClURL.cc:395
const ParamsMap & GetParams() const
Get the URL params.
Definition: XrdClURL.hh:244
void SetProtocol(const std::string &protocol)
Set protocol.
Definition: XrdClURL.hh:126
const uint64_t PostMasterMsg
const int DefaultTimeoutResolution

References XrdCl::Log::Debug(), XrdCl::DefaultTimeoutResolution, XrdCl::URL::GetChannelId(), XrdCl::DefaultEnv::GetEnv(), XrdCl::Env::GetInt(), XrdCl::DefaultEnv::GetLog(), XrdCl::URL::GetParams(), XrdCl::URL::GetProtocol(), XrdCl::Stream::Initialize(), XrdCl::TransportHandler::InitializeChannel(), XrdCl::PostMasterMsg, XrdCl::TaskManager::RegisterTask(), XrdCl::Stream::SetChannelData(), XrdCl::Stream::SetIncomingQueue(), XrdCl::Stream::SetJobManager(), XrdCl::URL::SetParams(), XrdCl::Stream::SetPoller(), XrdCl::URL::SetProtocol(), XrdCl::Stream::SetTaskManager(), and XrdCl::Stream::SetTransport().

+ Here is the call graph for this function:

◆ ~Channel()

XrdCl::Channel::~Channel ( )

Destructor.

Definition at line 132 of file XrdClChannel.cc.

133  {
134  pTickGenerator->Invalidate();
135  delete pStream;
136  pTransport->FinalizeChannel( pChannelData );
137  }
virtual void FinalizeChannel(AnyObject &channelData)=0
Finalize channel.

References XrdCl::TransportHandler::FinalizeChannel(), and XrdCl::TickGeneratorTask::Invalidate().

+ Here is the call graph for this function:

Member Function Documentation

◆ CanCollapse()

bool XrdCl::Channel::CanCollapse ( const URL url)
Returns
: true if this channel can be collapsed using this URL, false otherwise

Definition at line 208 of file XrdClChannel.cc.

209  {
210  return pStream->CanCollapse( url );
211  }
bool CanCollapse(const URL &url)

References XrdCl::Stream::CanCollapse().

Referenced by XrdCl::PostMaster::CollapseRedirect().

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

◆ DecFileInstCnt()

void XrdCl::Channel::DecFileInstCnt ( )

Decrement file object instance count bound to this channel.

Definition at line 216 of file XrdClChannel.cc.

217  {
218  pTransport->DecFileInstCnt( pChannelData );
219  }
virtual void DecFileInstCnt(AnyObject &channelData)=0
Decrement file object instance count bound to this channel.

References XrdCl::TransportHandler::DecFileInstCnt().

Referenced by XrdCl::PostMaster::DecFileInstCnt().

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

◆ ForceDisconnect() [1/2]

Status XrdCl::Channel::ForceDisconnect ( )

Force disconnect of all streams.

Definition at line 162 of file XrdClChannel.cc.

163  {
164  return ForceDisconnect(false);
165  }
Status ForceDisconnect()
Force disconnect of all streams.

◆ ForceDisconnect() [2/2]

Status XrdCl::Channel::ForceDisconnect ( bool  hush)

Force disconnect of all streams.

Definition at line 170 of file XrdClChannel.cc.

171  {
172  //--------------------------------------------------------------------------
173  // Disconnect and recreate the streams
174  //--------------------------------------------------------------------------
175  pStream->ForceError( Status( stError, errOperationInterrupted ), hush );
176 
177  return Status();
178  }
void ForceError(XRootDStatus status, bool hush=false)
Force error.
Definition: XrdClStream.cc:913
const uint16_t stError
An error occurred that could potentially be retried.
Definition: XrdClStatus.hh:32
const uint16_t errOperationInterrupted
Definition: XrdClStatus.hh:91
Procedure execution status.
Definition: XrdClStatus.hh:115

References XrdCl::errOperationInterrupted, XrdCl::Stream::ForceError(), and XrdCl::stError.

+ Here is the call graph for this function:

◆ ForceReconnect()

Status XrdCl::Channel::ForceReconnect ( )

Force reconnect.

Definition at line 183 of file XrdClChannel.cc.

184  {
185  pStream->ForceConnect();
186  return Status();
187  }
void ForceConnect()
Force connection.
Definition: XrdClStream.cc:347

References XrdCl::Stream::ForceConnect().

+ Here is the call graph for this function:

◆ GetURL()

const URL& XrdCl::Channel::GetURL ( ) const
inline

Get the URL.

Definition at line 75 of file XrdClChannel.hh.

76  {
77  return pUrl;
78  }

◆ NbConnectedStrm()

uint16_t XrdCl::Channel::NbConnectedStrm ( )

Get the number of connected data streams.

Definition at line 192 of file XrdClChannel.cc.

193  {
194  return XRootDTransport::NbConnectedStrm( pChannelData );
195  }
static uint16_t NbConnectedStrm(AnyObject &channelData)
Number of currently connected data streams.

References XrdCl::XRootDTransport::NbConnectedStrm().

Referenced by XrdCl::PostMaster::NbConnectedStrm().

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

◆ QueryTransport()

Status XrdCl::Channel::QueryTransport ( uint16_t  query,
AnyObject result 
)

Query the transport handler

Parameters
querythe query as defined in the TransportQuery struct or others that may be recognized by the protocol transport
resultthe result of the query
Returns
status of the query

Definition at line 224 of file XrdClChannel.cc.

225  {
226  if( query < 2000 )
227  return pTransport->Query( query, result, pChannelData );
228  return pStream->Query( query, result );
229  }
Status Query(uint16_t query, AnyObject &result)
Query the stream.
virtual Status Query(uint16_t query, AnyObject &result, AnyObject &channelData)=0
Query the channel.

References XrdCl::Stream::Query(), and XrdCl::TransportHandler::Query().

Referenced by XrdCl::PostMaster::QueryTransport().

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

◆ RegisterEventHandler()

void XrdCl::Channel::RegisterEventHandler ( ChannelEventHandler handler)

Register channel event handler.

Definition at line 234 of file XrdClChannel.cc.

235  {
236  pStream->RegisterEventHandler( handler );
237  }
void RegisterEventHandler(ChannelEventHandler *handler)
Register channel event handler.

References XrdCl::Stream::RegisterEventHandler().

Referenced by XrdCl::PostMaster::RegisterEventHandler().

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

◆ RemoveEventHandler()

void XrdCl::Channel::RemoveEventHandler ( ChannelEventHandler handler)

Remove a channel event handler.

Definition at line 242 of file XrdClChannel.cc.

243  {
244  pStream->RemoveEventHandler( handler );
245  }
void RemoveEventHandler(ChannelEventHandler *handler)
Remove a channel event handler.

References XrdCl::Stream::RemoveEventHandler().

Referenced by XrdCl::PostMaster::RemoveEventHandler().

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

◆ Send()

XRootDStatus XrdCl::Channel::Send ( Message msg,
MsgHandler handler,
bool  stateful,
time_t  expires 
)

Send the message asynchronously - the message is inserted into the send queue and a listener is called when the message is successfully pushed through the wire or when the timeout elapses

Parameters
msgmessage to be sent
handlerhandler to be notified about the status
statefulphysical stream disconnection causes an error
expiresunix timestamp after which a failure is reported to the listener
Returns
success if the message was successfully inserted into the send queues, failure otherwise

Definition at line 142 of file XrdClChannel.cc.

147  {
148  return pStream->Send( msg, handler, stateful, expires );
149  }
XRootDStatus Send(Message *msg, MsgHandler *handler, bool stateful, time_t expires)
Queue the message for sending.
Definition: XrdClStream.cc:297

References XrdCl::Stream::Send().

Referenced by XrdCl::PostMaster::Send().

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

◆ SetOnDataConnectHandler()

void XrdCl::Channel::SetOnDataConnectHandler ( std::shared_ptr< Job > &  onConnJob)

Set the on-connect handler for data streams.

Definition at line 200 of file XrdClChannel.cc.

201  {
202  pStream->SetOnDataConnectHandler( onConnJob );
203  }
void SetOnDataConnectHandler(std::shared_ptr< Job > &onConnJob)
Set the on-connect handler for data streams.
Definition: XrdClStream.hh:263

References XrdCl::Stream::SetOnDataConnectHandler().

Referenced by XrdCl::PostMaster::SetOnDataConnectHandler().

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

◆ Tick()

void XrdCl::Channel::Tick ( time_t  now)

Handle a time event.

Definition at line 154 of file XrdClChannel.cc.

155  {
156  pStream->Tick( now );
157  }
void Tick(time_t now)
Definition: XrdClStream.cc:377

References XrdCl::Stream::Tick().

+ Here is the call graph for this function:

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