XRootD
XrdCl::ThirdPartyCopyJob Class Reference

#include <XrdClThirdPartyCopyJob.hh>

+ Inheritance diagram for XrdCl::ThirdPartyCopyJob:
+ Collaboration diagram for XrdCl::ThirdPartyCopyJob:

Public Member Functions

 ThirdPartyCopyJob (uint16_t jobId, PropertyList *jobProperties, PropertyList *jobResults)
 Constructor. More...
 
virtual XRootDStatus Run (CopyProgressHandler *progress=0)
 
- Public Member Functions inherited from XrdCl::CopyJob
 CopyJob (uint16_t jobId, PropertyList *jobProperties, PropertyList *jobResults)
 Constructor. More...
 
virtual ~CopyJob ()
 Virtual destructor. More...
 
PropertyListGetProperties ()
 Get the job properties. More...
 
PropertyListGetResults ()
 Get the job results. More...
 
const URLGetSource () const
 Get source. More...
 
const URLGetTarget () const
 Get target. More...
 
void Init ()
 

Additional Inherited Members

- Protected Attributes inherited from XrdCl::CopyJob
uint16_t pJobId
 
PropertyListpProperties
 
PropertyListpResults
 
URL pSource
 
URL pTarget
 

Detailed Description

Definition at line 30 of file XrdClThirdPartyCopyJob.hh.

Constructor & Destructor Documentation

◆ ThirdPartyCopyJob()

XrdCl::ThirdPartyCopyJob::ThirdPartyCopyJob ( uint16_t  jobId,
PropertyList jobProperties,
PropertyList jobResults 
)

Constructor.

Definition at line 156 of file XrdClThirdPartyCopyJob.cc.

158  :
159  CopyJob( jobId, jobProperties, jobResults ),
160  dstFile( File::DisableVirtRedirect ),
161  sourceSize( 0 ),
162  initTimeout( 0 ),
163  force( false ),
164  coerce( false ),
165  delegate( false ),
166  nbStrm( 0 ),
167  tpcLite( false )
168  {
169  Log *log = DefaultEnv::GetLog();
170  log->Debug( UtilityMsg, "Creating a third party copy job, from %s to %s",
171  GetSource().GetObfuscatedURL().c_str(), GetTarget().GetObfuscatedURL().c_str() );
172  }
const URL & GetSource() const
Get source.
Definition: XrdClCopyJob.hh:94
const URL & GetTarget() const
Get target.
CopyJob(uint16_t jobId, PropertyList *jobProperties, PropertyList *jobResults)
Constructor.
Definition: XrdClCopyJob.hh:41
static Log * GetLog()
Get default log.
@ DisableVirtRedirect
Definition: XrdClFile.hh:52
const uint64_t UtilityMsg
XrdSysError Log
Definition: XrdConfig.cc:112

References XrdCl::Log::Debug(), XrdCl::DefaultEnv::GetLog(), XrdCl::CopyJob::GetSource(), XrdCl::CopyJob::GetTarget(), and XrdCl::UtilityMsg.

+ Here is the call graph for this function:

Member Function Documentation

◆ Run()

XRootDStatus XrdCl::ThirdPartyCopyJob::Run ( CopyProgressHandler progress = 0)
virtual

Run the copy job

Parameters
progressthe handler to be notified about the copy progress
Returns
status of the copy operation

Implements XrdCl::CopyJob.

Definition at line 177 of file XrdClThirdPartyCopyJob.cc.

178  {
179  Log *log = DefaultEnv::GetLog();
180 
181  XRootDStatus st = CanDo();
182  if( !st.IsOK() ) return st;
183 
184  if( tpcLite )
185  {
186  //------------------------------------------------------------------------
187  // Run TPC-lite algorithm
188  //------------------------------------------------------------------------
189  XRootDStatus st = RunLite( progress );
190  if( !st.IsOK() ) return st;
191  }
192  else
193  {
194  //------------------------------------------------------------------------
195  // Run vanilla TPC algorithm
196  //------------------------------------------------------------------------
197  XRootDStatus st = RunTPC( progress );
198  if( !st.IsOK() ) return st;
199  }
200 
201  //--------------------------------------------------------------------------
202  // Verify the checksums if needed
203  //--------------------------------------------------------------------------
204  if( checkSumMode != "none" )
205  {
206  log->Debug( UtilityMsg, "Attempting checksum calculation." );
207  std::string sourceCheckSum;
208  std::string targetCheckSum;
209 
210  //------------------------------------------------------------------------
211  // Get the check sum at source
212  //------------------------------------------------------------------------
213  timeval oStart, oEnd;
214  XRootDStatus st;
215  if( checkSumMode == "end2end" || checkSumMode == "source" ||
216  !checkSumPreset.empty() )
217  {
218  gettimeofday( &oStart, 0 );
219  if( !checkSumPreset.empty() )
220  {
221  sourceCheckSum = checkSumType + ":";
222  sourceCheckSum += Utils::NormalizeChecksum( checkSumType,
223  checkSumPreset );
224  }
225  else
226  {
227  VirtualRedirector *redirector = 0;
228  std::string vrCheckSum;
229  if( GetSource().IsMetalink() &&
230  ( redirector = RedirectorRegistry::Instance().Get( GetSource() ) ) &&
231  !( vrCheckSum = redirector->GetCheckSum( checkSumType ) ).empty() )
232  sourceCheckSum = vrCheckSum;
233  else
234  st = Utils::GetRemoteCheckSum( sourceCheckSum, checkSumType, tpcSource );
235  }
236  gettimeofday( &oEnd, 0 );
237  if( !st.IsOK() )
238  return UpdateErrMsg( st, "source" );
239 
240  pResults->Set( "sourceCheckSum", sourceCheckSum );
241  }
242 
243  //------------------------------------------------------------------------
244  // Get the check sum at destination
245  //------------------------------------------------------------------------
246  timeval tStart, tEnd;
247 
248  if( checkSumMode == "end2end" || checkSumMode == "target" )
249  {
250  gettimeofday( &tStart, 0 );
251  st = Utils::GetRemoteCheckSum( targetCheckSum, checkSumType, realTarget );
252 
253  gettimeofday( &tEnd, 0 );
254  if( !st.IsOK() )
255  return UpdateErrMsg( st, "destination" );
256  pResults->Set( "targetCheckSum", targetCheckSum );
257  }
258 
259  //------------------------------------------------------------------------
260  // Make sure the checksums are both lower case
261  //------------------------------------------------------------------------
262  auto sanitize_cksum = []( char c )
263  {
264  std::locale loc;
265  if( std::isalpha( c ) ) return std::tolower( c, loc );
266  return c;
267  };
268 
269  std::transform( sourceCheckSum.begin(), sourceCheckSum.end(),
270  sourceCheckSum.begin(), sanitize_cksum );
271 
272  std::transform( targetCheckSum.begin(), targetCheckSum.end(),
273  targetCheckSum.begin(), sanitize_cksum );
274 
275  //------------------------------------------------------------------------
276  // Compare and inform monitoring
277  //------------------------------------------------------------------------
278  if( !sourceCheckSum.empty() && !targetCheckSum.empty() )
279  {
280  bool match = false;
281  if( sourceCheckSum == targetCheckSum )
282  match = true;
283 
284  Monitor *mon = DefaultEnv::GetMonitor();
285  if( mon )
286  {
287  Monitor::CheckSumInfo i;
288  i.transfer.origin = &GetSource();
289  i.transfer.target = &GetTarget();
290  i.cksum = sourceCheckSum;
291  i.oTime = Utils::GetElapsedMicroSecs( oStart, oEnd );
292  i.tTime = Utils::GetElapsedMicroSecs( tStart, tEnd );
293  i.isOK = match;
294  mon->Event( Monitor::EvCheckSum, &i );
295  }
296 
297  if( !match )
298  return XRootDStatus( stError, errCheckSumError, 0 );
299 
300  log->Info(UtilityMsg, "Checksum verification: succeeded." );
301  }
302  }
303 
304  return XRootDStatus();
305  }
PropertyList * pResults
static Monitor * GetMonitor()
Get the monitor object.
@ EvCheckSum
CheckSumInfo: File checksummed.
void Set(const std::string &name, const Item &value)
static RedirectorRegistry & Instance()
Returns reference to the single instance.
static std::string NormalizeChecksum(const std::string &name, const std::string &checksum)
Normalize checksum.
Definition: XrdClUtils.cc:648
static uint64_t GetElapsedMicroSecs(timeval start, timeval end)
Get the elapsed microseconds between two timevals.
Definition: XrdClUtils.cc:269
static XRootDStatus GetRemoteCheckSum(std::string &checkSum, const std::string &checkSumType, const URL &url)
Get a checksum from a remote xrootd server.
Definition: XrdClUtils.cc:279
const uint16_t stError
An error occurred that could potentially be retried.
Definition: XrdClStatus.hh:32
const uint16_t errCheckSumError
Definition: XrdClStatus.hh:101

References XrdCl::Monitor::CheckSumInfo::cksum, XrdCl::Log::Debug(), XrdCl::errCheckSumError, XrdCl::Monitor::EvCheckSum, XrdCl::Monitor::Event(), XrdCl::VirtualRedirector::GetCheckSum(), XrdCl::Utils::GetElapsedMicroSecs(), XrdCl::DefaultEnv::GetLog(), XrdCl::DefaultEnv::GetMonitor(), XrdCl::Utils::GetRemoteCheckSum(), XrdCl::CopyJob::GetSource(), XrdCl::CopyJob::GetTarget(), XrdCl::Log::Info(), XrdCl::RedirectorRegistry::Instance(), XrdCl::Monitor::CheckSumInfo::isOK, XrdCl::Status::IsOK(), XrdCl::Utils::NormalizeChecksum(), XrdCl::Monitor::TransferInfo::origin, XrdCl::Monitor::CheckSumInfo::oTime, XrdCl::CopyJob::pResults, XrdCl::PropertyList::Set(), XrdCl::stError, XrdCl::Monitor::TransferInfo::target, XrdCl::Monitor::CheckSumInfo::transfer, XrdCl::Monitor::CheckSumInfo::tTime, and XrdCl::UtilityMsg.

+ Here is the call graph for this function:

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