Skip to content

Commit 77196ce

Browse files
authored
Merge pull request #57 from djw8605/multi_origin
Use redirector to enable multi origins
2 parents aae9ffa + 363e743 commit 77196ce

File tree

4 files changed

+42
-28
lines changed

4 files changed

+42
-28
lines changed

.travis.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,16 @@ env:
33
matrix:
44
- OS_TYPE=centos OS_VERSION=6
55
- OS_TYPE=centos OS_VERSION=7
6-
- OS_TYPE=centos OS_VERSION=6 XRD_CACHE="root://stash.osgconnect.net"
76
- OS_TYPE=centos OS_VERSION=6 XRD_CACHE="root://xrd-cache-1.t2.ucsd.edu"
87
- OS_TYPE=centos OS_VERSION=6 XRD_CACHE="root://mwt2-stashcache.campuscluster.illinois.edu"
98
- OS_TYPE=centos OS_VERSION=6 XRD_CACHE="root://hcc-stash.unl.edu"
109
- OS_TYPE=centos OS_VERSION=6 XRD_CACHE="root://osgxroot.usatlas.bnl.gov"
11-
- OS_TYPE=centos OS_VERSION=6 XRD_CACHE="its-condor-xrootd1.syr.edu"
12-
- OS_TYPE=centos OS_VERSION=7 XRD_CACHE="root://stash.osgconnect.net"
10+
- OS_TYPE=centos OS_VERSION=6 XRD_CACHE="root://its-condor-xrootd1.syr.edu"
1311
- OS_TYPE=centos OS_VERSION=7 XRD_CACHE="root://xrd-cache-1.t2.ucsd.edu"
1412
- OS_TYPE=centos OS_VERSION=7 XRD_CACHE="root://mwt2-stashcache.campuscluster.illinois.edu"
1513
- OS_TYPE=centos OS_VERSION=7 XRD_CACHE="root://hcc-stash.unl.edu"
1614
- OS_TYPE=centos OS_VERSION=7 XRD_CACHE="root://osgxroot.usatlas.bnl.gov"
17-
- OS_TYPE=centos OS_VERSION=7 XRD_CACHE="its-condor-xrootd1.syr.edu"
15+
- OS_TYPE=centos OS_VERSION=7 XRD_CACHE="root://its-condor-xrootd1.syr.edu"
1816

1917

2018
services:

bin/caches.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
[
2-
{"name":"root://student02.ci-connect.net", "status":0, "longitude":-87.603, "latitude":41.78},
3-
{"name":"root://stash.osgconnect.net", "status":1, "longitude":-87.603, "latitude":41.78},
4-
{"name":"root://cm3.bu.edu", "status":0, "longitude":-72.6167, "latitude":42.2042},
52
{"name":"root://xrd-cache-1.t2.ucsd.edu", "status":1, "longitude":-117.2359, "latitude":32.8807},
63
{"name":"root://mwt2-stashcache.campuscluster.illinois.edu", "status":1, "longitude":-88.23, "latitude":40.107487},
74
{"name":"root://hcc-stash.unl.edu", "status":1, "longitude":-96.702991, "latitude":40.812957},
8-
{"name":"root://osgxroot.usatlas.bnl.gov", "status":1, "longitude":-72.9333, "latitude":40.8167}
5+
{"name":"root://osgxroot.usatlas.bnl.gov", "status":1, "longitude":-72.9333, "latitude":40.8167},
6+
{"name":"root://its-condor-xrootd1.syr.edu", "status":1, "longitude":-72.9333, "latitude":40.8167}
97
]

bin/stashcp

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,26 +15,16 @@ import shutil
1515
import logging
1616
from urlparse import urlparse
1717

18-
18+
main_redirector = "root://redirector.osgstorage.org"
19+
stash_origin = "root://stash.osgconnect.net"
1920

2021
TIMEOUT = 300
2122
DIFF = TIMEOUT * 10
2223

2324

2425
def doStashCpSingle(sourceFile, destination, cache, debug=False):
2526

26-
logging.debug("Checking size of file.")
27-
(xrdfs_stdout, xrdfs_stderr) = subprocess.Popen(["xrdfs", "root://stash.osgconnect.net", "stat", sourceFile], stdout=subprocess.PIPE).communicate()
28-
xrdcp_version = subprocess.Popen(['echo $(xrdcp -V 2>&1)'], stdout=subprocess.PIPE, shell=True).communicate()[0][:-1]
29-
try:
30-
fileSize = int(re.findall(r"Size: \d+", xrdfs_stdout)[0].split(": ")[1])
31-
except Exception as e:
32-
sys.stderr.write("Unable to find size of file\n")
33-
print str(xrdfs_stdout)
34-
sys.stderr.write(str(xrdfs_stderr))
35-
sys.stderr.write("\n")
36-
return 1
37-
logging.debug("Size of the file %s is %s", sourceFile, str(fileSize))
27+
3828
#cache=get_best_stashcache()
3929
logging.debug("Using Cache %s", cache)
4030

@@ -44,8 +34,7 @@ def doStashCpSingle(sourceFile, destination, cache, debug=False):
4434
filename = destination + '/' + sourceFile.split('/')[-1]
4535

4636
payload = {}
47-
payload['xrdcp_version'] = xrdcp_version
48-
payload['filesize'] = fileSize
37+
4938
payload['filename'] = sourceFile
5039
payload['sitename'] = sitename
5140
payload.update(parse_job_ad())
@@ -66,12 +55,14 @@ def doStashCpSingle(sourceFile, destination, cache, debug=False):
6655
logging.debug("Succesfully copied file from CVMFS!")
6756
end1 = int(time.time()*1000)
6857
dlSz=os.stat(destination).st_size
58+
filesize = os.stat(cvmfs_file).st_size
6959
dltime=end1-start1
7060
destSpace=1
7161
status = 'Success'
7262
payload['timestamp']=end1
7363
payload['host']="CVMFS"
7464
payload['download_size']=dlSz
65+
payload['filesize'] = filesize
7566
payload['download_time']=dltime
7667
payload['destination_space']=destSpace
7768
payload['status']=status
@@ -89,6 +80,23 @@ def doStashCpSingle(sourceFile, destination, cache, debug=False):
8980
else:
9081
logging.debug("CVMFS File does not exist")
9182

83+
# Now check the size of the file with xrootd
84+
logging.debug("Checking size of file.")
85+
(xrdfs_stdout, xrdfs_stderr) = subprocess.Popen(["xrdfs", main_redirector, "stat", sourceFile], stdout=subprocess.PIPE).communicate()
86+
xrdcp_version = subprocess.Popen(['echo $(xrdcp -V 2>&1)'], stdout=subprocess.PIPE, shell=True).communicate()[0][:-1]
87+
try:
88+
fileSize = int(re.findall(r"Size: \d+", xrdfs_stdout)[0].split(": ")[1])
89+
except Exception as e:
90+
sys.stderr.write("Unable to find size of file\n")
91+
print str(xrdfs_stdout)
92+
sys.stderr.write(str(xrdfs_stderr))
93+
sys.stderr.write("\n")
94+
return 1
95+
logging.debug("Size of the file %s is %s", sourceFile, str(fileSize))
96+
97+
payload['xrdcp_version'] = xrdcp_version
98+
payload['filesize'] = fileSize
99+
92100
end1=int(time.time()*1000)
93101
payload['end1']=end1
94102
payload['start1']=start1
@@ -123,8 +131,8 @@ def doStashCpSingle(sourceFile, destination, cache, debug=False):
123131
es_send(payload)
124132

125133
else: #pull from origin
126-
logging.warning("XrdCP from cache failed on %s, pulling from origin", cache)
127-
cache="root://stash.osgconnect.net"
134+
logging.warning("XrdCP from cache failed on %s, pulling from main redirector", cache)
135+
cache=main_redirector
128136
start3 = int(time.time()*1000)
129137
xrd_exit=timed_transfer(filename=sourceFile, debug=debug, cache=cache, destination=destination)
130138
end3=int(time.time()*1000)
@@ -179,9 +187,9 @@ def parse_job_ad():
179187
return temp_list
180188

181189
def dostashcpdirectory(sourceDir, destination, cache, debug=False):
182-
sourceItems = subprocess.Popen(["xrdfs", "root://stash.osgconnect.net", "ls", sourceDir], stdout=subprocess.PIPE).communicate()[0].split()
190+
sourceItems = subprocess.Popen(["xrdfs", stash_origin, "ls", sourceDir], stdout=subprocess.PIPE).communicate()[0].split()
183191
for remote_file in sourceItems:
184-
command2 = 'xrdfs root://stash.osgconnect.net stat '+ remote_file + ' | grep "IsDir" | wc -l'
192+
command2 = 'xrdfs ' + stash_origin + ' stat '+ remote_file + ' | grep "IsDir" | wc -l'
185193
isdir=subprocess.Popen([command2],stdout=subprocess.PIPE,shell=True).communicate()[0].split()[0]
186194
if isdir!='0':
187195
result = dostashcpdirectory(remote_file, destination, cache, debug)

bin/stashcp2/tests/test_inside_docker.sh

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ cp /StashCache/bin/stashcp2/tests/job.ad ./.job.ad
4242

4343
# Test against a file that is known to not exist
4444
set +e
45-
/StashCache/bin/stashcp --cache=$XRD_CACHE /blah/does/not/exist
45+
/StashCache/bin/stashcp --cache=$XRD_CACHE /blah/does/not/exist ./
4646
if [ $? -eq 0 ]; then
4747
echo "Failed to exit with non-zero exit status when it should have"
4848
exit 1
@@ -79,5 +79,15 @@ fi
7979
/StashCache/bin/stashcp --cache=$XRD_CACHE -d -r /user/dweitzel/public/blast/queries ./
8080
ls -lah
8181

82+
rm -rf queries
83+
84+
/StashCache/bin/stashcp --cache=$XRD_CACHE -d /xenon/rucio/x1t_SR001_170419_1605_mv/73/90/XENON1T-0-000008000-000008999-000001000.zip ./
85+
86+
result=`md5sum XENON1T-0-000008000-000008999-000001000.zip | awk '{print $1;}'`
87+
if [ "$result" != "dd00dd6a6b1e0de4a3b8ecf1a34b24b3" ]; then
88+
exit 1
89+
fi
90+
91+
8292

8393

0 commit comments

Comments
 (0)