ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitProd/Processing/bin/download.sh
Revision: 1.1
Committed: Sun Dec 5 01:01:20 2010 UTC (14 years, 5 months ago) by paus
Content type: application/x-sh
Branch: MAIN
CVS Tags: Mit_017
Log Message:
Next iteration with improved downloading tool.

File Contents

# User Rev Content
1 paus 1.1 #!/bin/bash
2     #---------------------------------------------------------------------------------------------------
3     # Go through a number of download requests
4     #---------------------------------------------------------------------------------------------------
5     H=`basename $0`
6     SAMPLE_LIST=$1
7     MIT_LOCATION="/pnfs/cmsaf.mit.edu/t2bat/cms/store/user/paus"
8     CERN_LOCATION="/castor/cern.ch/user/p/paus"
9    
10     # health checks
11     if [ ".$1" == "." ]
12     then
13     echo "";
14     echo "usage: $H <sampleList>";
15     echo ""
16     exit 1
17     fi
18    
19     # say what we do
20     echo ""
21     echo " ==== Download queue from $SAMPLE_LIST ===="
22     echo ""
23    
24     # check that queues are really empty
25     startTime=$(date +%s)
26     nowTime=$(date +%s); duration=$(($nowTime - $startTime))
27     jobs=`condor_q -global cmsprod | grep downloadFiles.sh | wc -l`
28     while [ "$jobs" != "0" ]
29     do
30     echo " waiting since $duration sec == condor queue has $jobs jobs left"; sleep 60; echo ""
31     jobs=`condor_q -global cmsprod | grep downloadFiles.sh | wc -l`
32     nowTime=$(date +%s); duration=$(($nowTime - $startTime))
33     done
34     echo " Queues are empty ($jobs) Let's get started."
35     echo ""
36    
37     # all right, ready to download
38     nSamples=`cat $SAMPLE_LIST | wc -l | cut -d ' ' -f1`
39     i=1
40     while [ $i -le $nSamples ]
41     do
42    
43     line=`head -$i $SAMPLE_LIST | tail -1`
44     if [ "`echo $line | grep ^#`" != "" ]
45     then
46     i=$(( $i+1 ))
47     continue
48     fi
49    
50     # define some quantities
51     book=`echo $line | tr -s ' ' | cut -d ' ' -f 2`
52     version=`basename $book`
53     dataset=`echo $line | tr -s ' ' | cut -d ' ' -f 3`
54    
55     #echo " downloadSample.sh $line"
56     mkdir -p /mnt/hadoop/cmsprod/$book/$dataset
57     downloadSample.sh $line
58    
59     nowTime=$(date +%s); duration=$(($nowTime - $startTime))
60     jobs=`condor_q -global cmsprod | grep downloadFiles.sh | wc -l`
61     while [ "$jobs" != "0" ]
62     do
63     echo " waiting since $duration sec == condor queue has $jobs jobs left"; sleep 60; echo ""
64     jobs=`condor_q -global cmsprod | grep downloadFiles.sh | wc -l`
65     nowTime=$(date +%s); duration=$(($nowTime - $startTime))
66     done
67     echo " Queues are empty ($jobs) --> cleaning up and making catalogs."
68     echo ""
69    
70     # remove zero length files
71     echo "removeZeroLengthFiles.sh /mnt/hadoop/cmsprod/$book/$dataset"
72     removeZeroLengthFiles.sh /mnt/hadoop/cmsprod/$book/$dataset
73    
74     # finally make the corresponding catalog
75     #echo "catalog.sh -ceg $version $dataset --retry /mnt/hadoop/cmsprod"
76     catalog.sh -ceg $version $dataset --retry /mnt/hadoop/cmsprod
77    
78     i=$(( $i+1 ))
79    
80     done
81    
82     exit 0