]>
Commit | Line | Data |
---|---|---|
e3e96f08 | 1 | # |
2 | # sh script to download the data from alien to the local storage | |
3 | # | |
4 | # Arguments: | |
5 | # $1 fileList | |
6 | # $2 timeOut in seconds | |
7 | # $3 nprocess | |
8 | # $4 prefix | |
9 | # | |
10 | # Algorithm: | |
11 | # 1. Check the input parameters | |
12 | # 2. Group randomly the files into the group - generates nprocess download scripts | |
13 | # 3. Start $nprocess to download the files - with forced timeout | |
14 | # Example usage: | |
15 | # 1. Create file list | |
16 | # alien_find /alice/data/2010/LHC10h/000138795/pass0_2 root_ar | grep root > file.list | |
17 | # 2. run script with timeout 60 and n processes 10 and the sarting diectory -current directory | |
2bfe5463 | 18 | # $ALICE_ROOT/PWGPP/CalibMacros/MergeCalibration/alienDownloadTimeOut.sh file.list 60 30 `pwd` |
e3e96f08 | 19 | # |
20 | ||
21 | fileList=$1 | |
22 | timeOut=$2 | |
23 | nprocess=$3 | |
24 | prefix=$4 | |
25 | # | |
26 | # 1. Check the input variables | |
27 | # | |
28 | if ! [ -e $fileList ]; then | |
29 | echo Input file does not exist | |
30 | exit; | |
31 | fi; | |
32 | ||
33 | if [ ${#timeOut} -lt 1 ]; then | |
34 | echo Time out not specified | |
35 | exit; | |
36 | fi; | |
37 | ||
38 | if [ ${#nprocess} -lt 1 ]; then | |
39 | echo N processes not specified | |
40 | exit; | |
41 | fi; | |
42 | ||
43 | # | |
44 | # 2. Group randomly the files into the group - generates nprocess download scripts | |
45 | # | |
46 | nfiles=`wc $fileList | gawk '{print $1;}'` | |
47 | echo NFiles" "$nfiles" "$fileList" "TimeOut:$timeOut | |
48 | counterProcess=0; | |
49 | mkdirhier tmpDownload | |
50 | rm -rf tmpDownload/*.sh | |
51 | # | |
52 | # generate download scripts | |
53 | # | |
54 | for afile in `sort -r $fileList`; do | |
55 | dname=$prefix/`dirname $afile` | |
56 | fname=`basename $afile` | |
57 | if ! [ -e $dname/$fname ] ; then | |
58 | mkdirhier $dname | |
59 | echo "echo Date `date` >> job$counterProcess.log>> job$counterProcess.log " >> tmpDownload/download$counterProcess.sh | |
60 | echo "echo alien_cp alien:////$afile $dname 2>> job$counterProcess.log>> job$counterProcess.log " >> tmpDownload/download$counterProcess.sh | |
61 | echo "timeout $timeOut alien_cp -t $timeOut -i alien.txt -m alien:////$afile $dname 2>> job$counterProcess.log>> job$counterProcess.log " >> tmpDownload/download$counterProcess.sh | |
62 | echo "cat alien.txt >> job$counterProcess.log " >> tmpDownload/download$counterProcess.sh | |
63 | let counterProcess=$counterProcess+1 | |
64 | if [ $counterProcess -gt $nprocess ]; then | |
65 | let counterProcess=0; | |
66 | fi; | |
67 | fi; | |
68 | done; | |
69 | ||
70 | echo NFiles" "$nfiles" "$fileList" "TimeOut:$timeOut | |
71 | ||
72 | # | |
73 | # 3. Start $nprocess to download the files - with forced timeout | |
74 | # | |
75 | for job in `ls tmpDownload/download*.sh`; do | |
76 | chmod u+x $job; | |
77 | echo $job | |
78 | command $job & | |
79 | done; > download.log |