IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 24930 for trunk/Nebulous/lib


Ignore:
Timestamp:
Jul 28, 2009, 11:44:45 AM (17 years ago)
Author:
jhoblitt
Message:

add Nebulous::Client->there_can_be_only_one() method

Location:
trunk/Nebulous/lib/Nebulous
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Nebulous/lib/Nebulous/Client.pm

    r24927 r24930  
    360360
    361361    my $locations;
     362    my $removed = 0;
    362363    eval {
    363364        # first - strip off any inaccesible instances
    364         $self->prune($key);
     365        if (not defined $self->prune($key)) {
     366            # use the prune() method to also determine if $key is valid
     367            $removed = undef;
     368            return;
     369        }
    365370
    366371        # check to see if there is an instance on $vol_name that should be the
     
    375380                next if $victim eq $locations->[0];
    376381                $self->delete_instance($key, $victim);
     382                $removed++;
    377383            }
    378384        } else {
    379385            # nuke whatever
    380             my @stats = $self->stat($key);
    381             foreach (1 .. $stats[6]) {
     386            my $stats = $self->stat($key);
     387            # start at one so cull() is called one less time then the # of
     388            # instances
     389            for (my $i = 1; $i < $stats->[6]; $i++) {
    382390                $self->cull($key);
     391                $removed++;
    383392            }
    384393        }
     
    391400    $log->debug("leaving");
    392401
    393     return $locations->[0];
     402    return $removed;
    394403}
    395404
  • trunk/Nebulous/lib/Nebulous/Client.pod

    r24925 r24930  
    3535    my $mounts = $neb->mounts();
    3636    my $mode = $neb->chmod( $key, $mode );
    37     my $dead = $neb->prune( $key );
     37    my $n_dead = $neb->prune( $key );
     38    my $n_dead = $neb->there_can_be_only_one( $key, $vol );
    3839
    3940=head1 DESCRIPTION
     
    419420=back
    420421
    421 The number of inaccessible instances removed:
     422The number of instances removed.
     423
     424=item * there_can_be_only_one($key, $vol)
     425
     426Removes all but one instance of an object and automatically removes any
     427inaccessible instances.
     428
     429=over 4
     430
     431=item * key
     432
     433The storage object key (name).
     434
     435=item * vol
     436
     437If specified, the only remaining instance will be left on this volume (if an
     438instance already exists there).
     439
     440=back
     441
     442The number of avaiable instances removed.
    422443
    423444=item * mounts()
     
    479500=head1 COPYRIGHT
    480501
    481 Copyright (C) 2004-2008  Joshua Hoblitt.  All rights reserved.
     502Copyright (C) 2004-2009  Joshua Hoblitt.  All rights reserved.
    482503
    483504This program is free software; you can redistribute it and/or modify it under
Note: See TracChangeset for help on using the changeset viewer.