IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 20, 2008, 11:13:28 AM (18 years ago)
Author:
jhoblitt
Message:

server/client split

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Nebulous-Server/bin/neb-fsck

    r16264 r17072  
    33# Copyright (C) 2005-2008  Joshua Hoblitt
    44#
    5 # $Id: neb-fsck,v 1.1 2008-01-30 00:19:34 jhoblitt Exp $
     5# $Id: neb-fsck,v 1.2 2008-03-20 21:12:06 jhoblitt Exp $
    66
    77use strict;
     
    5959my $sql = Nebulous::Server::SQL->new();
    6060
     61print "Pass 1: Look for objects with inaccessable instances\n";
     62
    6163# so_id, ext_id, instances, available_instances, need_recovery, recoverable
    6264my $query = $dbh->prepare( $sql->find_objects_with_unavailable_instances );
     
    7072
    7173foreach my $obj (@rows) {
     74#    use Data::Dumper;
     75#    print Dumper($obj);
    7276    my $so_id = $obj->{so_id};
    7377    my $key = $obj->{ext_id};
    7478    my $has = $obj->{instances};
    75     my $available = $obj->{instances_available};
    76     my $need = $obj->{need_recovery};
     79    my $available = $obj->{available_instances} || 0;
     80    my $need_recovery = $obj->{need_recovery};
    7781    my $recoverable = $obj->{recoverable};
     82    # if the copies xattr is unset and the object has 2 or more instances, we
     83    # will assume a target of 2 copies
     84    my $copies = $obj->{copies} || 2;
    7885
    7986    # objects with only a single instance that are offline are unrecoverable so
    8087    # we don't need to handle that special case
    81     next unless $need;
     88    next unless $need_recovery;
    8289    unless ($recoverable) {
    8390        warn "so_id: $so_id key: \'$key\' ",
     
    8693    }
    8794
    88     $available ||= 0;
    89     next unless $available < 2;
    90 
    91     warn "so_id: $so_id key: \'$key\' ",
    92             " has only 1 instance avaiable -- replicating";
    93 
    94     $neb->replicate($obj->{ext_id})
    95         or warn "so_id: $so_id key: \'$key\' failed to replicate";
     95    my $need = $copies - $available;
     96    $need = 0 if $need < 0;
     97
     98    next unless $need;
     99
     100    for (; $need > 0; $need--) {
     101        warn "so_id: $so_id key: \'$key\' ",
     102            "has $available available instances, target $copies -- replicating";
     103        $neb->replicate($obj->{ext_id})
     104            or warn "so_id: $so_id key: \'$key\' replication failed";
     105
     106        $available++;
     107    }
    96108}
     109
     110print "Pass 2: Check volumes for files without an instance\n";
     111
     112# get a list of volumes and their paths
     113# get a list of all instances on a volume
     114# get a list of all files under the volumes path
     115# compare the two lists
    97116
    98117__END__
Note: See TracChangeset for help on using the changeset viewer.