Changeset 37271
- Timestamp:
- Aug 20, 2014, 12:03:58 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tags/ipp-pv3-20140717/ippScripts/scripts/sc_transfer_tool.pl
r37126 r37271 14 14 my $local_raw = "${remote_root}/raw/"; 15 15 my $local_tmp = "${remote_root}/tmp/"; 16 my $threads = 10; 17 my @hosts = ('ippc20.ipp.ifa.hawaii.edu','ippc24.ipp.ifa.hawaii.edu','ippc28.ipp.ifa.hawaii.edu', 18 'ippc21.ipp.ifa.hawaii.edu','ippc25.ipp.ifa.hawaii.edu','ippc29.ipp.ifa.hawaii.edu', 19 'ippc22.ipp.ifa.hawaii.edu','ippc26.ipp.ifa.hawaii.edu', 20 'ippc23.ipp.ifa.hawaii.edu','ippc27.ipp.ifa.hawaii.edu' ); 16 my $threads = 11; 17 my @hosts = ( 18 'ippc20.ipp.ifa.hawaii.edu', 19 'ippc21.ipp.ifa.hawaii.edu', 20 'ippc22.ipp.ifa.hawaii.edu', 21 'ippc23.ipp.ifa.hawaii.edu', 22 'ippc24.ipp.ifa.hawaii.edu', 23 'ippc25.ipp.ifa.hawaii.edu', 24 'ippc26.ipp.ifa.hawaii.edu', 25 'ippc27.ipp.ifa.hawaii.edu', 26 'ippc28.ipp.ifa.hawaii.edu', 27 #'ippc29.ipp.ifa.hawaii.edu', (mark's hi-mem test machine) 28 #'ippc30.ipp.ifa.hawaii.edu', (postage stamp server) 29 'ippc31.ipp.ifa.hawaii.edu', 30 'ippc32.ipp.ifa.hawaii.edu' 31 ); 21 32 @hosts = (@hosts, @hosts, @hosts, @hosts, @hosts); 33 my %server_options = ( 34 'ippc20.ipp.ifa.hawaii.edu' => '', 35 'ippc21.ipp.ifa.hawaii.edu' => '', 36 'ippc22.ipp.ifa.hawaii.edu' => '', 37 'ippc23.ipp.ifa.hawaii.edu' => '', 38 'ippc24.ipp.ifa.hawaii.edu' => '', 39 'ippc25.ipp.ifa.hawaii.edu' => '', 40 'ippc26.ipp.ifa.hawaii.edu' => '', # -o NoneSwitch=yes -o NoneEnabled=yes', 41 'ippc27.ipp.ifa.hawaii.edu' => '', # -o NoneSwitch=yes -o NoneEnabled=yes', 42 'ippc28.ipp.ifa.hawaii.edu' => '', # -o NoneSwitch=yes -o NoneEnabled=yes', 43 'ippc29.ipp.ifa.hawaii.edu' => '', # -o NoneSwitch=yes -o NoneEnabled=yes', 44 'ippc30.ipp.ifa.hawaii.edu' => '', # -o NoneSwitch=yes -o NoneEnabled=yes', 45 'ippc31.ipp.ifa.hawaii.edu' => '', # -o NoneSwitch=yes -o NoneEnabled=yes', 46 'ippc32.ipp.ifa.hawaii.edu' => '', # -o NoneSwitch=yes -o NoneEnabled=yes' 47 ); 22 48 my $input_file; 23 49 my $verbose = 0; 24 50 my $fetch = 0; 25 51 my $offset = 0; 52 my $quickfetch = 0; 26 53 27 54 GetOptions( … … 31 58 'offset=s' => \$offset, 32 59 'verbose' => \$verbose, 60 'quickfetch' => \$quickfetch, 33 61 ) or pod2usage( 2 ); 34 62 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2) if @ARGV; … … 43 71 unless(-d $local_raw) { system("mkdir -p $local_raw"); } 44 72 73 # open the input file list 45 74 open(I,$input_file) || die "Couldn't find input file specified\n"; 75 76 # open the fetch file list, if provided 46 77 if ($fetch) { 47 78 open(F,$fetch) || die "Couldn't find fetch file specified\n"; 48 79 } 80 81 # generate N output files (to be fed to the N rsync / tar threads) 49 82 my $input_base = basename($input_file); 50 83 my @filehandles; … … 54 87 open($filehandles[$i], ">${local_tmp}/${input_base}.${i}"); 55 88 } 89 56 90 $i = 0; 57 91 while(<I>) { … … 60 94 if ($line < $offset) { next; } # I think this is off-by-one in a safe direction 61 95 96 if ($line % 250 == 0) { 97 print "line $line : $_\n"; 98 } 99 62 100 $i = int(rand($#filehandles + 1)); 63 101 … … 66 104 $fline = <F>; 67 105 } 68 if (($fetch)&&(!(-e $_))) { # We are fetching, and do not already have this file. 106 107 # if we are fetching, and 'quickfetch' is requested, skip file if it exists 108 # NOTE: this does not check that the transfer was complete or the file is current 109 110 if ($fetch) { 111 # We are fetching, and do not already have this file. 112 if ($quickfetch && (-e $_)) { next; } 69 113 print { $filehandles[$i] } $fline; 70 114 } … … 72 116 # The rsync call expects to find files of a given name in the directory specified. 73 117 # print { $filehandles[$i] } "${local_tmp}/$_" . "\n"; 118 # if (-e "${local_tmp}/$_") { 74 119 print { $filehandles[$i] } "$_" . "\n"; 120 # } 121 # else { 122 # print "missing $_\n"; 123 # } 75 124 } 76 125 } … … 90 139 if ($fetch) { 91 140 $code = fetch_task($host,"${input_base}.${i}", 0); 92 } 93 else { 141 } else { 94 142 $code = transfer_task($host,"${local_tmp}/${input_base}.${i}", 0); 95 143 } 144 print STDERR "$host $input_base $i $code\n"; 96 145 exit($code); 97 146 } 98 147 } 148 my $global_status = 0; 99 149 for ($i = 0; $i < $threads; $i++) { 100 150 waitpid($pids[$i],0); 151 my $this_status = $?; 152 print "exit status $hosts[$i] : $this_status\n"; 153 if ($this_status) { $global_status = ($this_status >> 8); } 101 154 } 102 155 … … 105 158 } 106 159 160 print "global status: $global_status\n"; 161 exit ($global_status); 107 162 108 163 # distribute bundles to nodes … … 116 171 117 172 # 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? 118 # my $command = "tar cf - --ignore-failed-read --dereference --files-from=${transfer_filelist} | /usr/projects/cosmo/amd6100/bin/ssh -o NoneSwitch=yes -o NoneEnabled=yes $destination_host tar xf - -C /data/ --transform '" . 's,^.\*/data/,,' . "' --dereference"; 119 my $command = "rsync -Lpt -e '/usr/projects/cosmo/amd6100/bin/ssh -o NoneSwitch=yes -o NoneEnabled=yes' --files-from=${transfer_filelist} ${local_tmp} ${destination_host}:/"; 173 # my $command = "tar cf - --ignore-failed-read --dereference" 174 # $command = "$command --files-from=${transfer_filelist}" 175 # $command = "$command | /usr/projects/cosmo/amd6100/bin/ssh" 176 # $command = "$command -o NoneSwitch=yes -o NoneEnabled=yes 177 # $command = "$command $destination_host tar xf - -C /data/" 178 # $command = "$command --transform '" . 's,^.\*/data/,,' . "' --dereference"; 179 180 my $ssh_cmd = "/usr/projects/cosmo/amd6100/bin/ssh"; 181 my $option = $server_options{$destination_host}; 182 my $command = "rsync -Lt --omit-dir-times -e '$ssh_cmd ${option}' --files-from=${transfer_filelist} ${local_tmp} ${destination_host}:/"; 120 183 print STDERR "$command\n"; 121 184 122 185 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 123 186 run(command => $command, verbose => $verbose); 187 188 my $return_value = 0; 124 189 unless ($success) { 125 print STDERR "ERROR: $error_code\n"; 126 # my $std = join "\n", @{ $stdout_buf }; 127 # print "STDOUT: $std\n"; 128 # $std = join "\n", @{ $stderr_buf }; 129 # print "STDERR: $std\n"; 130 131 # foreach my $line (@{ $stderr_buf }) { # This is a hack. A messy ugly hack. 132 # if ($line =~ /No such file or directory/) { 133 # my $file = (split /\s+/, $line)[1]; 134 # $file =~ s/:$//; 135 # if ($file !~ /nebulous/) { next; } 136 # print STDERR "Touching $file so tar can continue.\n"; 137 # system("touch $file"); 138 # } 139 # } 140 141 warn("Transfer of $transfer_filelist to $destination_host failed with error $error_code."); 142 $error++; 143 if ($error < 4) { 144 $error_code = transfer_task($destination_host,$transfer_filelist,$error); 145 } 146 else { 147 die("Failed too many times $error $destination_host $transfer_filelist"); 148 } 149 } 150 return($error_code); 190 if ($error_code =~ /value 23/) { 191 print STDERR "Some files failed to transfer. Partial run?\n"; 192 $error = 23; 193 $return_value = 23; 194 } else { 195 print STDERR "ERROR: $error_code\n"; 196 warn("Transfer of $transfer_filelist to $destination_host failed with error $error_code."); 197 sleep(5); 198 $error++; 199 if ($error < 4) { 200 $error_code = transfer_task($destination_host,$transfer_filelist,$error); 201 } 202 else { 203 die("Failed too many times $error $destination_host $transfer_filelist"); 204 } 205 $return_value = 1; 206 } 207 } 208 return($return_value); 151 209 } 152 210 … … 156 214 my $error = shift; 157 215 158 system("/usr/projects/cosmo/amd6100/bin/scp -o NoneSwitch=yes -o NoneEnabled=yes ${local_tmp}/${transfer_filelist} ${destination_host}:/tmp/"); 159 my $command = "/usr/projects/cosmo/amd6100/bin/ssh -o NoneSwitch=yes -o NoneEnabled=yes $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 "; 216 my $scp_cmd = "/usr/projects/cosmo/amd6100/bin/scp"; 217 my $ssh_cmd = "/usr/projects/cosmo/amd6100/bin/ssh"; 218 my $option = $server_options{$destination_host}; 219 220 # get the list of files to be transferred 221 # print "$scp_cmd $option ${local_tmp}/${transfer_filelist} ${destination_host}:/tmp/\n"; 222 # system("$scp_cmd $option ${local_tmp}/${transfer_filelist} ${destination_host}:/tmp/"); 223 # my $cmd1 = "rsync -e '$ssh_cmd $option' -auv ${local_tmp}/${transfer_filelist} ${destination_host}:/tmp/"; 224 # print "$cmd1\n"; 225 # system ("$cmd1"); 226 227 # do the transfer 228 229 # XXX EAM : fix this (use rsync not tar) 230 # my $command = "rsync -e '$ssh_cmd ${option}' --files-from=/tmp/${transfer_filelist} ${destination_host}:/ ${local_raw}"; 231 my $command = "rsync -e '$ssh_cmd ${option}' --files-from=${local_tmp}/${transfer_filelist} ${destination_host}:/ ${local_raw}"; 232 233 # 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 "; 160 234 print STDERR "$command\n"; 161 235 162 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 236 my $error_code = 0; 237 my ( $success, $error_msg, $full_buf, $stdout_buf, $stderr_buf ) = 163 238 run(command => $command, verbose => $verbose); 164 239 unless ($success) { 165 $error_code = (($error_code >> 8) or 4); 166 warn("Transfer of $transfer_filelist to $destination_host failed with error $error_code."); 167 $error++; 168 if ($error < 4) { 169 $error_code = fetch_task($destination_host,$transfer_filelist,$error); 170 } 171 else { 172 die("Failed too many times $error $destination_host $transfer_filelist"); 240 print "raw error_msg: $error_msg...\n"; 241 ($error_code) = $error_msg =~ m/exited with value (\d+)/; 242 warn("Transfer of files in $local_tmp/$transfer_filelist from $destination_host failed with error ($error_code) $error_msg."); 243 print "*** stdout: *** \n"; 244 foreach $line (@$stdout_buf) { 245 print STDERR "stdout: $line\n"; 246 } 247 print "*** stderr: *** \n"; 248 foreach $line (@$stderr_buf) { 249 print STDERR "stderr: $line\n"; 250 } 251 if ($error_code == 23) { 252 print STDERR "Some files failed to transfer\n"; 253 } else { 254 $error++; 255 if ($error < 4) { 256 $error_code = fetch_task($destination_host,$transfer_filelist,$error); 257 } else { 258 print STDERR "Failed too many times $error $destination_host $transfer_filelist\n"; 259 } 173 260 } 174 261 }
Note:
See TracChangeset
for help on using the changeset viewer.
