IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 36686


Ignore:
Timestamp:
Apr 22, 2014, 12:51:33 PM (12 years ago)
Author:
watersc1
Message:

Updated rawcheck.pl that fixes easy-to-fix errors.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tags/ipp-20130712/ippScripts/scripts/rawcheck.pl

    • Property svn:mergeinfo set to (toggle deleted branches)
      /trunk/ippScripts/scripts/rawcheck.plmergedeligible
      /branches/czw_branch/20101203/ippScripts/scripts/rawcheck.pl29907-30631
      /branches/czw_branch/20120906/ippScripts/scripts/rawcheck.pl34410-34786
      /branches/eam_branches/ipp-20101103/ippScripts/scripts/rawcheck.pl29657-29920
      /branches/eam_branches/ipp-20101205/ippScripts/scripts/rawcheck.pl29959-30585
      /branches/eam_branches/ipp-20110213/ippScripts/scripts/rawcheck.pl30628-31149
      /branches/eam_branches/ipp-20110404/ippScripts/scripts/rawcheck.pl31166-31444
      /branches/eam_branches/ipp-20110505/ippScripts/scripts/rawcheck.pl31458-31658
      /branches/eam_branches/ipp-20110710/ippScripts/scripts/rawcheck.pl31852-32345
      /branches/eam_branches/ipp-20110906/ippScripts/scripts/rawcheck.pl32363-32631
      /branches/eam_branches/ipp-20111110/ippScripts/scripts/rawcheck.pl32645-32694
      /branches/eam_branches/ipp-20120405/ippScripts/scripts/rawcheck.pl33724-33957
      /branches/eam_branches/ipp-20120601/ippScripts/scripts/rawcheck.pl33977-34079
      /branches/eam_branches/ipp-20120627/ippScripts/scripts/rawcheck.pl34099-34256
      /branches/eam_branches/ipp-20120805/ippScripts/scripts/rawcheck.pl34292-34401
      /branches/eam_branches/ipp-20120905/ippScripts/scripts/rawcheck.pl34407-34747
      /branches/eam_branches/ipp-20121130/ippScripts/scripts/rawcheck.pl34755-34841
      /branches/eam_branches/ipp-20121219/ippScripts/scripts/rawcheck.pl34857-35096
      /branches/eam_branches/ipp-20130207/ippScripts/scripts/rawcheck.pl35125-35236
      /branches/eam_branches/ipp-20130307/ippScripts/scripts/rawcheck.pl35267-35414
      /branches/eam_branches/ipp-20130419/ippScripts/scripts/rawcheck.pl35420-35554
      /branches/eam_branches/ipp-20130509/ippScripts/scripts/rawcheck.pl35565-35753
      /branches/haf_add201112/ippScripts/scripts/rawcheck.pl32980-33029
    r36379 r36686  
    134134            $existing_copies++;
    135135            $md5sums[$i] = local_md5sum($files[$i]);
    136 #           my $fh;
    137 #           open($fh,$files[$i]);
    138 #           $md5sums[$i] = Digest::MD5->new->addfile($fh)->hexdigest;
    139 #           close($fh);
    140136            $md5sum_uniq{$md5sums[$i]} = 1;
    141137
     
    183179        print
    184180            "object id:             ", @$stat[0], "\n",
    185             "key:                   ", @$stat[1], "\n",
    186             "read lock:             ", @$stat[2], "\n";
    187 #           "write lock:            ", @$stat[3], "\n";
     181            "key:                   ", @$stat[1], "\n";
    188182        print
    189             "epoch:                 ", @$stat[4], "\n",
    190             "mtime:                 ", @$stat[5], "\n";
     183            "epoch:                 ", @$stat[4], "\n";
    191184        print
    192185            "md5sum count:          ", scalar(keys %md5sum_uniq), "\n";
     
    220213        }
    221214        close(DD);
    222         $quality[0] = 1;
    223         print "cp $good_file $files[0]\n";
    224         system("cp $good_file $files[0]");
    225 # Begin my best validation thought
     215        if ($good_file eq '') {
     216            die "No valid instance of key: $key";
     217        }
     218        else {
     219            $quality[0] = 1;
     220            print "cp $good_file $files[0]\n";
     221            system("cp $good_file $files[0]");
     222        }
     223        # Begin my best validation thought
    226224        {
    227225            my $tmpmd5 = local_md5sum($files[0]);
    228 #           my $fh;
    229 #           open($fh,$files[0]);
    230 #           my $tmpmd5 = Digest::MD5->new->addfile($fh)->hexdigest;
    231 #           close($fh);
    232226            if ($tmpmd5 ne $md5sum) {
    233227                die "Post-replication md5sum does not match! $tmpmd5 != $md5sum";
    234228            }
    235229        }
    236 # End my best validation thought.
     230        # End my best validation thought.
    237231
    238232        $Ngood = 1;  # We now hand off this single valid instance object to be handled by the Ngood=1 case.
     233    }
     234   
     235    if ($quality[0] == 0) { # The first instance is bad.
     236        # But since we're here, and not up there, there must be at least one good copy.  Find it.
     237        for (my $i = 0; $i <= $#md5sums; $i++) {
     238            if ($md5sums[$i] eq $md5sum) { # Found it.
     239                print "cp $files[$i] $files[0]\n";
     240                system("cp $files[$i] $files[0]");
     241                # Begin my best validation thought
     242                {
     243                    my $tmpmd5 = local_md5sum($files[0]);
     244                    if ($tmpmd5 ne $md5sum) {
     245                        die "Post-replication md5sum does not match! $tmpmd5 != $md5sum";
     246                    }
     247                }
     248                # End my best validation thought.
     249                last; # We're done here now.
     250            }
     251        }       
    239252    }
    240253
     
    256269                if ($@) { die $@; }
    257270               
    258 # Begin my best validation thought
     271                # Begin my best validation thought
    259272                system("sync") == 0 or die "Couldn't sync?";
    260273                my $uris = $neb->find_instances($key,$rep_vol);
    261274                @$uris = map {URI->new($_)->file if $_} @$uris;
    262275                my $tmpmd5 = local_md5sum(${ $uris }[0]);
    263 #               my $fh;
    264 #               open($fh,${ $uris }[0]);
    265 #               my $tmpmd5 = Digest::MD5->new->addfile($fh)->hexdigest;
    266 #               close($fh);
    267276                if ($tmpmd5 ne $md5sum) {
    268277                    die "Post-replication md5sum does not match! $tmpmd5 != $md5sum";
    269278                }
    270 # End my best validation thought.
     279                # End my best validation thought.
    271280            }       
    272281        }
     
    280289                if ($@) { die $@; }
    281290
    282 # Begin my best validation thought
     291                # Begin my best validation thought
    283292                system("sync") == 0 or die "Couldn't sync?";
    284293                my $uris = $neb->find_instances($key,$rep_vol);
    285294                @$uris = map {URI->new($_)->file if $_} @$uris;
    286 
    287 #               print $uris . " " . ${ $uris }[0] . " \n";
    288295                my $tmpmd5 = local_md5sum(${ $uris }[0]);
    289 #               my $fh;
    290 #               open($fh,${ $uris }[0]);
    291 #               my $tmpmd5 = Digest::MD5->new->addfile($fh)->hexdigest;
    292 #               close($fh);
    293296                if ($tmpmd5 ne $md5sum) {
    294297                    die "Post-replication md5sum does not match! $tmpmd5 != $md5sum";
    295298                }
    296 # End my best validation thought.
     299                # End my best validation thought.
    297300
    298301            }       
     
    309312#           print "$existance[$i] $quality[$i] $md5sums[$i] $md5sum $diskhosts[$i] $diskvols[$i]\n";
    310313            if ($quality[$i] != 1) {
     314                if ($existance[$i] == 0) { # This disk file doesn't exist.
     315                    system("touch $files[$i]");
     316                }
    311317                my $cull_vol = $diskhosts[$i] . "." . $diskvols[$i];
    312318                print "neb-cull --volume $cull_vol $key\n";
     
    314320                    # The tilde here is to force hard volumes.  Don't touch it.
    315321                    $neb->cull($key,"~${cull_vol}",2) or die "failed to cull a superfluous instance";
    316                     if ($@) { die $@; }
     322                    if ($@) { die "$@"; }
    317323                }
    318324            }
Note: See TracChangeset for help on using the changeset viewer.