XRootD
Loading...
Searching...
No Matches
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.
 
bool CanCollapse (const URL &url)
 
void DecFileInstCnt ()
 Decrement file object instance count bound to this channel.
 
Status ForceDisconnect ()
 Force disconnect of all streams.
 
Status ForceDisconnect (bool hush)
 Force disconnect of all streams.
 
Status ForceReconnect ()
 Force reconnect.
 
const URLGetURL () const
 Get the URL.
 
uint16_t NbConnectedStrm ()
 Get the number of connected data streams.
 
Status QueryTransport (uint16_t query, AnyObject &result)
 
void RegisterEventHandler (ChannelEventHandler *handler)
 Register channel event handler.
 
void RemoveEventHandler (ChannelEventHandler *handler)
 Remove a channel event handler.
 
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.
 
void Tick (time_t now)
 Handle a time event.
 

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.
void SetTransport(TransportHandler *transport)
Set the transport.
void SetIncomingQueue(InQueue *incomingQueue)
Set the incoming queue.
void SetPoller(Poller *poller)
Set the poller.
void SetTaskManager(TaskManager *taskManager)
Set task manager.
void SetJobManager(JobManager *jobManager)
Set job manager.
void SetChannelData(AnyObject *channelData)
Set the channel data.
XRootDStatus Initialize()
Initializer.
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
void SetParams(const std::string &params)
Set params.
Definition XrdClURL.cc:395
void SetProtocol(const std::string &protocol)
Set protocol.
Definition XrdClURL.hh:126
const uint64_t PostMasterMsg
const int DefaultTimeoutResolution
XrdSysError Log
Definition XrdConfig.cc:112

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.

References ForceDisconnect().

Referenced by ForceDisconnect().

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

◆ 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.
const uint16_t stError
An error occurred that could potentially be retried.
const uint16_t errOperationInterrupted

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.

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.

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.

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)

References XrdCl::Stream::Tick().

Referenced by XrdCl::TickGeneratorTask::Run().

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

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