XRootD
Loading...
Searching...
No Matches
XrdCl::Channel Class Reference

#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.
void Finalize ()
Status ForceDisconnect ()
 Force disconnect of all streams.
Status ForceDisconnect (bool hush)
 Force disconnect of all streams.
Status ForceDisconnect (std::shared_ptr< Channel > self, const uint64_t sess)
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 SetSelf (std::shared_ptr< Channel > &self)
 Gives us access to the shared pointer that the postmaster holds for us.
void Tick (time_t now)
 Handle a time event.

Detailed Description

A communication channel between the client and the server

Notes on ownership. The Channel is owned via shared_ptr usually held by at least PostMaster. Channels replaced during a RedirectCollapse may no longer be held by PostMaster. Channel has a weak_ptr to its shared_ptr (pSelf). Channel owns a Stream, which also holds a weak_ptr for its owning Channel. The Stream owns a number of AsyncSocketHandler (one for each substream). After Connect() the SocketHandler will hold a shared_ptr for Channel until the SocketHandler is Closed. Thus lifetime of Channel ends when PostMaster gives up holding the Channel and all AsyncSocketHandler Close connections. PostMaster also maintains a set of non-owning Channel* for live Channel objects, for PostMaster::Finalize() to use to issue Finalize() on any live Channels.

Definition at line 61 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 = std::make_unique<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.
const uint64_t PostMasterMsg
const int DefaultTimeoutResolution
XrdSysError Log
Definition XrdConfig.cc:113

References XrdCl::Log::Debug(), XrdCl::DefaultTimeoutResolution, XrdCl::URL::GetChannelId(), XrdCl::DefaultEnv::GetEnv(), XrdCl::Env::GetInt(), XrdCl::DefaultEnv::GetLog(), XrdCl::URL::GetParams(), XrdCl::URL::GetProtocol(), and XrdCl::PostMasterMsg.

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 pStream.reset();
136 pTransport->FinalizeChannel( pChannelData );
137 }

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 230 of file XrdClChannel.cc.

231 {
232 return pStream->CanCollapse( url );
233 }

◆ DecFileInstCnt()

void XrdCl::Channel::DecFileInstCnt ( )

Decrement file object instance count bound to this channel.

Definition at line 238 of file XrdClChannel.cc.

239 {
240 pTransport->DecFileInstCnt( pChannelData );
241 }

◆ Finalize()

void XrdCl::Channel::Finalize ( )

Used by the PostMaster to indicate the Channel should release all resources. It should be assumed that the jobmanager has already been stopped & finalized and the poller and taskmanager have been stopped.

Definition at line 162 of file XrdClChannel.cc.

163 {
164 pStream->Finalize();
165 }

◆ ForceDisconnect() [1/3]

Status XrdCl::Channel::ForceDisconnect ( )

Force disconnect of all streams.

Definition at line 170 of file XrdClChannel.cc.

171 {
172 return ForceDisconnect(false);
173 }
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/3]

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

Force disconnect of all streams.

Definition at line 178 of file XrdClChannel.cc.

179 {
180 //--------------------------------------------------------------------------
181 // Disconnect the stream and all substreams
182 //--------------------------------------------------------------------------
183 pStream->ForceError( Status( stError, errOperationInterrupted ), hush, 0);
184
185 return Status();
186 }
const uint16_t stError
An error occurred that could potentially be retried.
const uint16_t errOperationInterrupted

References XrdCl::errOperationInterrupted, and XrdCl::stError.

◆ ForceDisconnect() [3/3]

Status XrdCl::Channel::ForceDisconnect ( std::shared_ptr< Channel > self,
const uint64_t sess )

Force disconnect of all streams. This was triggered internally, e.g. by one of our Streams.

Definition at line 191 of file XrdClChannel.cc.

193 {
194 //--------------------------------------------------------------------------
195 // Disconnect the stream and all substreams
196 //--------------------------------------------------------------------------
197 pStream->ForceError( Status( stError, errOperationInterrupted ), false, sess );
198
199 return Status();
200 }

References XrdCl::errOperationInterrupted, and XrdCl::stError.

◆ ForceReconnect()

Status XrdCl::Channel::ForceReconnect ( )

Force reconnect.

Definition at line 205 of file XrdClChannel.cc.

206 {
207 pStream->ForceConnect();
208 return Status();
209 }

◆ GetURL()

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

Get the URL.

Definition at line 88 of file XrdClChannel.hh.

89 {
90 return pUrl;
91 }

◆ NbConnectedStrm()

uint16_t XrdCl::Channel::NbConnectedStrm ( )

Get the number of connected data streams.

Definition at line 214 of file XrdClChannel.cc.

215 {
216 return XRootDTransport::NbConnectedStrm( pChannelData );
217 }
static uint16_t NbConnectedStrm(AnyObject &channelData)
Number of currently connected data streams.

References XrdCl::XRootDTransport::NbConnectedStrm().

Here is the call 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 246 of file XrdClChannel.cc.

247 {
248 if( query < 2000 )
249 return pTransport->Query( query, result, pChannelData );
250 return pStream->Query( query, result );
251 }

◆ RegisterEventHandler()

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

Register channel event handler.

Definition at line 256 of file XrdClChannel.cc.

257 {
258 pStream->RegisterEventHandler( handler );
259 }

◆ RemoveEventHandler()

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

Remove a channel event handler.

Definition at line 264 of file XrdClChannel.cc.

265 {
266 pStream->RemoveEventHandler( handler );
267 }

◆ 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 }

◆ SetOnDataConnectHandler()

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

Set the on-connect handler for data streams.

Definition at line 222 of file XrdClChannel.cc.

223 {
224 pStream->SetOnDataConnectHandler( onConnJob );
225 }

◆ SetSelf()

void XrdCl::Channel::SetSelf ( std::shared_ptr< Channel > & self)

Gives us access to the shared pointer that the postmaster holds for us.

Definition at line 269 of file XrdClChannel.cc.

270 {
271 pSelf = self;
272 if( pStream ) pStream->SetChannel( pSelf );
273 }

◆ 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 }

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