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

#include <XrdClThirdPartyCopyJob.hh>

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

Public Member Functions

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

Additional Inherited Members

Protected Attributes inherited from XrdCl::CopyJob
uint32_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 ( uint32_t jobId,
PropertyList * jobProperties,
PropertyList * jobResults )

Constructor.

Definition at line 161 of file XrdClThirdPartyCopyJob.cc.

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

References XrdCl::CopyJob::CopyJob(), 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 182 of file XrdClThirdPartyCopyJob.cc.

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

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::Status::IsOK(), XrdCl::Monitor::CheckSumInfo::isOK, XrdCl::Utils::NormalizeChecksum(), XrdCl::Monitor::TransferInfo::origin, XrdCl::Monitor::CheckSumInfo::oTime, XrdCl::CopyJob::pResults, 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: