IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 37287


Ignore:
Timestamp:
Aug 22, 2014, 9:13:32 AM (12 years ago)
Author:
eugene
Message:

rework transfer script for better symmetry and checking of local (LANL) files

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tags/ipp-pv3-20140717/ippScripts/scripts/sc_transfer_tool.pl

    r37286 r37287  
    1010use Sys::Hostname;
    1111
     12my $scp_cmd = "/usr/projects/cosmo/amd6100/bin/scp";
     13my $ssh_cmd = "/usr/projects/cosmo/amd6100/bin/ssh";
     14
    1215my $remote_root = '/lustre/scratch1/turquoise/watersc1/ps1/';
    13 $remote_root = '/scratch3/watersc1/';
     16   $remote_root = '/scratch3/watersc1/';
     17
    1418my $local_raw = "${remote_root}/raw/";
    1519my $local_tmp = "${remote_root}/tmp/";
     
    4650    'ippc32.ipp.ifa.hawaii.edu' => '', # -o NoneSwitch=yes -o NoneEnabled=yes'
    4751    );
    48 my $input_file;
     52
     53my $input_path;
     54my $local_file;
     55my $remote_file;
     56
    4957my $verbose = 0;
    5058my $fetch = 0;
     
    5462GetOptions(
    5563    'threads=s'   => \$threads,
    56     'input=s'     => \$input_file,
    57     'fetch=s'     => \$fetch,
     64    'input=s'     => \$input_path,
    5865    'offset=s'    => \$offset,
     66    'fetch'       => \$fetch,
    5967    'verbose'     => \$verbose,
    6068    'quickfetch'  => \$quickfetch,
     
    6270pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2) if @ARGV;
    6371pod2usage( -msg => "Required options: --input", -exitval => 3) unless
    64     defined($input_file);
     72    defined($input_path);
    6573
    6674my $hostname = hostname;
     
    7179unless(-d $local_raw) { system("mkdir -p $local_raw"); }
    7280
     81# we have two modes: fetch (-> LANL) and return (-> IPP)
     82
     83if ($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
    7391# 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 }
     92open (LOCAL,$local_file) || die "Couldn't find input file specified $local_file\n";
     93open (REMOTE,$remote_file) || die "Couldn't find input file specified $remote_file\n";
    8094
    8195# generate N output files (to be fed to the N rsync / tar threads)
    82 my $input_base = basename($input_file);
     96my $input_base = basename($local_file);
    8397my @filehandles;
    8498my $i;
     
    88102}
    89103
    90 open (STATFILE, ">${local_tmp}/${input_base}.stat");
     104my $stat_file = "$input_path.stat";
     105print "STATFILE: $stat_file\n";
     106open (STATFILE, ">$stat_file");
    91107
    92108$i = 0;
    93 while(<I>) {
    94     chomp;
     109while (my $Lname = <LOCAL>) {
     110    my $Rname = <REMOTE>;
     111
     112    chomp $Lname;
     113    chomp $Rname;
     114
    95115    $line++;
    96116    if ($line < $offset) { next; } # I think this is off-by-one in a safe direction
    97117
    98     if ($line % 250 == 0)  {
    99         print "line $line : $_\n";
    100     }
     118    if ($line % 250 == 0)  { print "line $line : $Lname\n"; }
    101119
    102120    $i = int(rand($#filehandles + 1));
    103 
    104     my $fline;
    105     if ($fetch) {
    106         $fline = <F>;
    107     }
    108121   
    109122    # if we are fetching, and 'quickfetch' is requested, skip file if it exists
     
    112125    if ($fetch) {
    113126        # 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;
    116129    } else {
    117130        # 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}
     139close(LOCAL);
     140close(REMOTE);
    127141close(STATFILE);
    128142
     
    139153        my $code = 0;
    140154        if ($fetch) {
    141             $code = fetch_task($host,"${input_base}.${i}", 0);
     155            $code = fetch_task($host,"${local_tmp}/${input_base}.${i}", 0);
    142156        } else {
    143157            $code = transfer_task($host,"${local_tmp}/${input_base}.${i}", 0);
     
    160174}
    161175
    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");
    165179# XXX check return status
    166180
     
    177191    my $error = shift;
    178192
    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=yes
    184     # $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";
    188193    my $option = $server_options{$destination_host};
     194
    189195    my $command = "rsync -Lt --omit-dir-times -e '$ssh_cmd ${option}' --files-from=${transfer_filelist} ${local_tmp} ${destination_host}:/";
    190196    print STDERR "$command\n";
     
    221227    my $error = shift;
    222228
    223     my $scp_cmd = "/usr/projects/cosmo/amd6100/bin/scp";
    224     my $ssh_cmd = "/usr/projects/cosmo/amd6100/bin/ssh";
    225229    my $option = $server_options{$destination_host};
    226230
    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}";
    241232    print STDERR "$command\n";
    242233
     
    247238        print "raw error_msg: $error_msg...\n";
    248239        ($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.");
    250241        print "*** stdout: *** \n";
    251242        foreach $line (@$stdout_buf) {
Note: See TracChangeset for help on using the changeset viewer.