Changeset 37287
- Timestamp:
- Aug 22, 2014, 9:13:32 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tags/ipp-pv3-20140717/ippScripts/scripts/sc_transfer_tool.pl
r37286 r37287 10 10 use Sys::Hostname; 11 11 12 my $scp_cmd = "/usr/projects/cosmo/amd6100/bin/scp"; 13 my $ssh_cmd = "/usr/projects/cosmo/amd6100/bin/ssh"; 14 12 15 my $remote_root = '/lustre/scratch1/turquoise/watersc1/ps1/'; 13 $remote_root = '/scratch3/watersc1/'; 16 $remote_root = '/scratch3/watersc1/'; 17 14 18 my $local_raw = "${remote_root}/raw/"; 15 19 my $local_tmp = "${remote_root}/tmp/"; … … 46 50 'ippc32.ipp.ifa.hawaii.edu' => '', # -o NoneSwitch=yes -o NoneEnabled=yes' 47 51 ); 48 my $input_file; 52 53 my $input_path; 54 my $local_file; 55 my $remote_file; 56 49 57 my $verbose = 0; 50 58 my $fetch = 0; … … 54 62 GetOptions( 55 63 'threads=s' => \$threads, 56 'input=s' => \$input_file, 57 'fetch=s' => \$fetch, 64 'input=s' => \$input_path, 58 65 'offset=s' => \$offset, 66 'fetch' => \$fetch, 59 67 'verbose' => \$verbose, 60 68 'quickfetch' => \$quickfetch, … … 62 70 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2) if @ARGV; 63 71 pod2usage( -msg => "Required options: --input", -exitval => 3) unless 64 defined($input_ file);72 defined($input_path); 65 73 66 74 my $hostname = hostname; … … 71 79 unless(-d $local_raw) { system("mkdir -p $local_raw"); } 72 80 81 # we have two modes: fetch (-> LANL) and return (-> IPP) 82 83 if ($fetch) { 84 $local_file = "$input_path.check"; 85 $remote_file = "$input_path.transfer"; 86 } else { 87 $local_file = "$input_path.generate"; 88 $remote_file = "$input_path.return"; 89 } 90 73 91 # open the input file list 74 open(I,$input_file) || die "Couldn't find input file specified\n"; 75 76 # open the fetch file list, if provided 77 if ($fetch) { 78 open(F,$fetch) || die "Couldn't find fetch file specified\n"; 79 } 92 open (LOCAL,$local_file) || die "Couldn't find input file specified $local_file\n"; 93 open (REMOTE,$remote_file) || die "Couldn't find input file specified $remote_file\n"; 80 94 81 95 # generate N output files (to be fed to the N rsync / tar threads) 82 my $input_base = basename($ input_file);96 my $input_base = basename($local_file); 83 97 my @filehandles; 84 98 my $i; … … 88 102 } 89 103 90 open (STATFILE, ">${local_tmp}/${input_base}.stat"); 104 my $stat_file = "$input_path.stat"; 105 print "STATFILE: $stat_file\n"; 106 open (STATFILE, ">$stat_file"); 91 107 92 108 $i = 0; 93 while(<I>) { 94 chomp; 109 while (my $Lname = <LOCAL>) { 110 my $Rname = <REMOTE>; 111 112 chomp $Lname; 113 chomp $Rname; 114 95 115 $line++; 96 116 if ($line < $offset) { next; } # I think this is off-by-one in a safe direction 97 117 98 if ($line % 250 == 0) { 99 print "line $line : $_\n"; 100 } 118 if ($line % 250 == 0) { print "line $line : $Lname\n"; } 101 119 102 120 $i = int(rand($#filehandles + 1)); 103 104 my $fline;105 if ($fetch) {106 $fline = <F>;107 }108 121 109 122 # if we are fetching, and 'quickfetch' is requested, skip file if it exists … … 112 125 if ($fetch) { 113 126 # We are fetching, and do not already have this file. 114 if ($quickfetch && (-e $ _)) { next; }115 print { $filehandles[$i] } $ fline;127 if ($quickfetch && (-e $Lname)) { next; } 128 print { $filehandles[$i] } $Rname; 116 129 } else { 117 130 # We are pushing, but only send back files we actually have 118 if (-e "$_") { 119 print { $filehandles[$i] } "$_" . "\n"; 120 print STATFILE, "$_ PASS\n"; 121 } else { 122 print STATFILE, "$_ FAIL\n"; 123 } 124 } 125 } 126 close(I); 131 if (-e $Lname) { 132 print { $filehandles[$i] } "$Rname\n"; 133 print STATFILE "$Rname PASS\n"; 134 } else { 135 print STATFILE "$Rname FAIL\n"; 136 } 137 } 138 } 139 close(LOCAL); 140 close(REMOTE); 127 141 close(STATFILE); 128 142 … … 139 153 my $code = 0; 140 154 if ($fetch) { 141 $code = fetch_task($host,"${ input_base}.${i}", 0);155 $code = fetch_task($host,"${local_tmp}/${input_base}.${i}", 0); 142 156 } else { 143 157 $code = transfer_task($host,"${local_tmp}/${input_base}.${i}", 0); … … 160 174 } 161 175 162 my $scp_command = "$scp_cmd $option ${local_tmp}/${input_base}.stat $hosts[0]:/tmp/";163 print "$scp_command\n";164 system("$scp_command");176 # my $scp_command = "$scp_cmd $option ${local_tmp}/${input_base}.stat $hosts[0]:/tmp/"; 177 # print "$scp_command\n"; 178 # system("$scp_command"); 165 179 # XXX check return status 166 180 … … 177 191 my $error = shift; 178 192 179 # the transform bit is there because it looks like the ' gets dropped, so the * is interpreted, and why is our tar so out of date?180 # my $command = "tar cf - --ignore-failed-read --dereference"181 # $command = "$command --files-from=${transfer_filelist}"182 # $command = "$command | /usr/projects/cosmo/amd6100/bin/ssh"183 # $command = "$command -o NoneSwitch=yes -o NoneEnabled=yes184 # $command = "$command $destination_host tar xf - -C /data/"185 # $command = "$command --transform '" . 's,^.\*/data/,,' . "' --dereference";186 187 my $ssh_cmd = "/usr/projects/cosmo/amd6100/bin/ssh";188 193 my $option = $server_options{$destination_host}; 194 189 195 my $command = "rsync -Lt --omit-dir-times -e '$ssh_cmd ${option}' --files-from=${transfer_filelist} ${local_tmp} ${destination_host}:/"; 190 196 print STDERR "$command\n"; … … 221 227 my $error = shift; 222 228 223 my $scp_cmd = "/usr/projects/cosmo/amd6100/bin/scp";224 my $ssh_cmd = "/usr/projects/cosmo/amd6100/bin/ssh";225 229 my $option = $server_options{$destination_host}; 226 230 227 # get the list of files to be transferred 228 # print "$scp_cmd $option ${local_tmp}/${transfer_filelist} ${destination_host}:/tmp/\n"; 229 # system("$scp_cmd $option ${local_tmp}/${transfer_filelist} ${destination_host}:/tmp/"); 230 # my $cmd1 = "rsync -e '$ssh_cmd $option' -auv ${local_tmp}/${transfer_filelist} ${destination_host}:/tmp/"; 231 # print "$cmd1\n"; 232 # system ("$cmd1"); 233 234 # do the transfer 235 236 # XXX EAM : fix this (use rsync not tar) 237 # my $command = "rsync -e '$ssh_cmd ${option}' --files-from=/tmp/${transfer_filelist} ${destination_host}:/ ${local_raw}"; 238 my $command = "rsync -e '$ssh_cmd ${option}' --files-from=${local_tmp}/${transfer_filelist} ${destination_host}:/ ${local_raw}"; 239 240 # my $command = "$ssh_cmd $option $destination_host tar cf - --ignore-failed-read --dereference --files-from=/tmp/${transfer_filelist} | tar xf - -C ${local_raw} --skip-old-files --warning=existing-file --dereference "; 231 my $command = "rsync -e '$ssh_cmd ${option}' --files-from=${transfer_filelist} ${destination_host}:/ ${local_raw}"; 241 232 print STDERR "$command\n"; 242 233 … … 247 238 print "raw error_msg: $error_msg...\n"; 248 239 ($error_code) = $error_msg =~ m/exited with value (\d+)/; 249 warn("Transfer of files in $ local_tmp/$transfer_filelist from $destination_host failed with error ($error_code) $error_msg.");240 warn("Transfer of files in $transfer_filelist from $destination_host failed with error ($error_code) $error_msg."); 250 241 print "*** stdout: *** \n"; 251 242 foreach $line (@$stdout_buf) {
Note:
See TracChangeset
for help on using the changeset viewer.
