@@ -325,36 +325,52 @@ def download_xrootd(sourceFile, destination, debug, payload):
325325 xrd_exit = timed_transfer (filename = sourceFile , debug = debug , cache = cache , destination = destination )
326326
327327 payload ['xrdexit1' ]= xrd_exit
328+ tries = 1
329+ payload ['cache1' ] = cache
328330
329331 if xrd_exit == '0' : #worked first try
330332 logging .debug ("Transfer success using %s" , nearest_cache )
331- payload [ 'tries' ] = 1
333+ status = "First Cache Success"
332334 payload ['cache' ] = cache
333335
334- else : #pull from origin
335- logging .info ("XrdCP from cache failed on %s, pulling from main redirector" , nearest_cache )
336+ if xrd_exit != '0' : # pull from second nearest cache
337+ cache = nearest_cache_list [1 ]
338+ logging .info ("XrdCP from cache failed on %s, pulling from second nearest cache %s" , nearest_cache , cache )
339+ xrd_exit = timed_transfer (filename = sourceFile , debug = debug , cache = cache , destination = destination )
340+ payload ['xrdexit2' ]= xrd_exit
341+ payload ['cache2' ] = cache
342+
343+ if xrd_exit == '0' :
344+ logging .info ("Second Cache Success" )
345+ status = 'Second Cache Success'
346+ payload ['cache' ] = cache
347+ tries = 2
348+
349+ if xrd_exit != '0' : # pull from the origin
350+ logging .info ("XrdCP from cache failed on %s, pulling from main redirector" , cache )
336351 cache = main_redirector
337352 xrd_exit = timed_transfer (filename = sourceFile , cache = cache , debug = debug , destination = destination )
353+ payload ['xrdexit3' ]= xrd_exit
354+ payload ['cache3' ] = cache
338355
339356 if xrd_exit == '0' :
340357 logging .info ("Trunk Success" )
341358 status = 'Trunk Sucess'
342- tries = 2
359+ payload ['cache' ] = cache
360+ tries = 3
343361 else :
344- logging .info ("stashcp failed after 2 xrootd attempts" )
362+ logging .info ("stashcp failed after 3 xrootd attempts" )
345363 status = 'Timeout'
346- tries = 2
364+ tries = 3
347365
348- payload ['status' ]= status
349- payload ['xrdexit2' ]= xrd_exit
350- payload ['tries' ]= tries
351- payload ['cache' ] = cache
366+ payload ['status' ]= status
367+
368+ payload ['tries' ]= tries
352369
353- if xrd_exit == '0' :
354- return True
355- else :
356- return False
357- return True
370+ if xrd_exit == '0' :
371+ return True
372+ else :
373+ return False
358374
359375def check_for_xrootd ():
360376 """
0 commit comments