IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 6, 2011, 11:00:22 AM (15 years ago)
Author:
eugene
Message:

merge changes from trunk

Location:
branches/eam_branches/ipp-20110710/Nebulous/bin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20110710/Nebulous/bin/neb-shift

    r28446 r32337  
    2929
    3030pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
    31 pod2usage( -msg => "Required options: --server <source key> <source volume>",
     31pod2usage( -msg => "Required options: --server --volume <source key> <source volume>",
    3232        -exitval => 2 )
    33         unless defined $server and defined $src and defined $abandon_vol;
     33        unless defined $server and defined $src and defined $abandon_vol and defined $volume;
    3434
    3535my $neb = Nebulous::Client->new(
     
    4545}
    4646
     47my $all_uris = $neb->find_instances($src);
     48
    4749my $status;
    48 if ($volume) {
    49     $status = $neb->replicate( $src, $volume);
     50$status = $neb->replicate( $src, $volume);
     51die "Replicate phase failed for $src ($abandon_vol) ($volume)" unless $status;
     52
     53$uris = $neb->find_instances($src, "~$volume");
     54unless (defined $uris) {
     55    die "Replicate phase failed for $src ($abandon_vol) ($volume)";
    5056}
    51 else {
    52     $status = $neb->replicate($src);
    53 }
    54 die "Replicate phase failed for $src ($abandon_vol) ($volume)" unless $status;
    5557
    5658$status = $neb->cull($src,$abandon_vol);
  • branches/eam_branches/ipp-20110710/Nebulous/bin/neb-stat

    r24644 r32337  
    1616use Pod::Usage qw( pod2usage );
    1717
    18 my ($server);
     18use Digest::MD5;
     19use URI;
     20
     21my ($validate,$server,$nouris);
    1922
    2023$server = $ENV{'NEB_SERVER'} unless $server;
     
    2225GetOptions(
    2326    'server|s=s'     => \$server,
     27    'validate|v'         => \$validate,
     28    'files'          => \$nouris,
    2429) || pod2usage( 2 );
    2530
     
    4449die "no instances found" unless $instances;   
    4550
     51my $user_copies;
     52eval {
     53    $user_copies = $neb->getxattr($key, "user.copies");
     54};
     55unless(defined($user_copies)) {
     56    $user_copies = 1;
     57}
     58
     59my @validation;
     60my %md5sum_uniq;
     61my $existing_copies = 0;
     62if (defined $validate) {
     63    my @existance;
     64    my @md5sums;
     65    my @files = map {URI->new($_)->file if $_} @$instances;
     66
     67    for (my $i = 0; $i <= $#files; $i++) {
     68        if (-e $files[$i]) {
     69            $existance[$i] = 1;
     70            $existing_copies++;
     71            my $fh;
     72            open($fh,$files[$i]);
     73            $md5sums[$i] = Digest::MD5->new->addfile($fh)->hexdigest;
     74            $md5sum_uniq{$md5sums[$i]} = 1;
     75            close($fh);
     76        }
     77        else {
     78            $existance[$i] = 0;
     79            $md5sums[$i] = 'NON-EXISTANT';
     80            $md5sum_uniq{$md5sums[$i]} = 1;
     81        }
     82        if (defined($nouris)) {
     83            $validation[$i] = sprintf("% 3d %32s %s",
     84                                      $existance[$i],
     85                                      $md5sums[$i],
     86                                      $files[$i]);
     87        }
     88        else {
     89            $validation[$i] = sprintf("% 3d %32s %s",
     90                                      $existance[$i],
     91                                      $md5sums[$i],
     92                                      ${ $instances }[$i]);
     93        }
     94    }
     95}
     96
    4697no warnings qw(uninitialized);
    47 print
    48     "object id:             ", @$stat[0], "\n",
    49     "key:                   ", @$stat[1], "\n",
    50     "read lock:             ", @$stat[2], "\n",
    51     "write lock:            ", @$stat[3], "\n",
    52     "epoch:                 ", @$stat[4], "\n",
    53     "mtime:                 ", @$stat[5], "\n",
    54     "available instances:   ", @$stat[6], "\n",
    55     "total instances:       ", @$stat[7], "\n",
    56     "instance location:\n", " " x 4,
    57     join("\n" . " " x 4, @$instances), "\n";
     98if (defined $validate) {
     99    print
     100        "object id:             ", @$stat[0], "\n",
     101        "key:                   ", @$stat[1], "\n",
     102        "read lock:             ", @$stat[2], "\n",
     103        "write lock:            ", @$stat[3], "\n",
     104        "epoch:                 ", @$stat[4], "\n",
     105        "mtime:                 ", @$stat[5], "\n",
     106        "md5sum count:          ", scalar(keys %md5sum_uniq), "\n",
     107        "requested instances:   ", $user_copies, "\n",
     108        "available instances:   ", @$stat[6], "\n",
     109        "existing instances:    ", $existing_copies, "\n",
     110        "total instances:       ", @$stat[7], "\n",
     111       
     112        "instance location:\n", " " x 4,
     113        join("\n" . " " x 4, @validation), "\n";
     114}
     115else {
     116    print
     117        "object id:             ", @$stat[0], "\n",
     118        "key:                   ", @$stat[1], "\n",
     119        "read lock:             ", @$stat[2], "\n",
     120        "write lock:            ", @$stat[3], "\n",
     121        "epoch:                 ", @$stat[4], "\n",
     122        "mtime:                 ", @$stat[5], "\n",
     123        "available instances:   ", @$stat[6], "\n",
     124        "requested instances:   ", $user_copies, "\n",
     125        "total instances:       ", @$stat[7], "\n",
     126       
     127        "instance location:\n", " " x 4,
     128        join("\n" . " " x 4, @$instances), "\n";
     129}
     130
    58131
    59132__END__
     
    67140=head1 SYNOPSIS
    68141
    69     neb-stat [--server <URL>] <key>
     142    neb-stat [--server <URL>] [--validate] <key>
    70143
    71144=head1 DESCRIPTION
     
    82155
    83156Optional if the appropriate environment variable is set.
     157
     158=item * --validate|-v
     159
     160Optional - prints out additional information including md5sum.
     161
     162=item * --files
     163
     164Optional - prints out disk files instead of uris during validate stage.
    84165
    85166=back
Note: See TracChangeset for help on using the changeset viewer.