IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 26292 for trunk/Nebulous


Ignore:
Timestamp:
Nov 30, 2009, 1:54:49 PM (17 years ago)
Author:
watersc1
Message:

Nebulous: Implemented a number of bug fixes and modifications to

ensure no loss of data.

  • Each volume can now be associated into a cabinet, defining their physical arrangement.
  • File creation: new files without a specified volume are created on a random volume from a subset of the N least full.
  • Replication: file replication uses the same volume selection method, with the constraints that a copy not be automatically placed on the same volume as another, and that the first copy not be housed within the same volume.
  • Cull: instead of removing the first available instance, first attempt to remove an instance on the same volume as another, then attempt to remove an instance in the same cabinet as another, and then remove the first only if those fail.
  • Corrected bug that prevented the deletion of an object if it had more than one unavailable instance.
  • Fixed nebdiskd to synchronize between volume->mountedvol tables and to properly remove volumes that were no longer accessible.
File:
1 edited

Legend:

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

    r25121 r26292  
    315315    my $locations;
    316316    if (defined $vol_name) {
    317         $locations = $self->find_instances($key, $vol_name);
     317        $locations = $self->find_instances_for_cull($key, $vol_name);
    318318    } else {
    319         $locations = $self->find_instances($key);
     319        $locations = $self->find_instances_for_cull($key);
    320320    }
    321321
     
    326326        return;
    327327    }
    328 
    329     my $uri = $self->delete_instance($key, @$locations[0]);
     328   
     329    # Calculate which is the best instance to remove. First, see if we have two copies
     330    # on one volume, if so, delete the first of those copies.
     331    my $delete_index = -1;
     332
     333    for (my $i = 0 ; $i <= $#{ $locations }; $i++) {
     334        for (my $j = $i + 1; $j <= $#{ $locations }; $j++) {
     335            if (@$locations[$i]->{vol_id} eq @$locations[$j]->{vol_id}) {
     336                $delete_index = $i;
     337            }
     338        }
     339    }
     340    # If we don't have two copies on one volume, see if we have two copies on a single
     341    # cabinet. If so, delete the first of those copies.
     342    if ($delete_index == -1) {
     343        for (my $i = 0 ; $i <= $#{ $locations }; $i++) {
     344            for (my $j = $i + 1; $j <= $#{ $locations }; $j++) {
     345                if (@$locations[$i]->{cab_id} eq @$locations[$j]->{cab_id}) {
     346                    $delete_index = $i;
     347                }
     348            }
     349        }
     350    }
     351    # Fail-safe. We didn't have any duplicates (the instances are "well-mixed"), so
     352    # delete the first.
     353    if ($delete_index == -1) {
     354        $delete_index = 0;
     355    }   
     356    my $uri = $self->delete_instance($key, @$locations[$delete_index]->{uri});
    330357
    331358    eval {
    332         _nuke_file(_get_file_path(@$locations[0]));
     359        _nuke_file(_get_file_path(@$locations[$delete_index]->{uri}));
    333360    };
    334361    if ($@) {
     
    758785}
    759786
     787sub find_instances_for_cull
     788{
     789    my $self = shift;
     790
     791    my ( $key, @params ) = validate_pos( @_,
     792        {
     793            type        => SCALAR,
     794        },
     795        {
     796            #volume
     797            type        => SCALAR|UNDEF,
     798            optional    => 1,
     799        },
     800    );
     801
     802    $log->debug( "entered - @_" );
     803
     804    my $response = $self->{ 'server' }->find_instances_for_cull( $key, @params );
     805    if ( $response->fault ) {
     806        $self->set_err($response->faultstring);
     807        # check to see if this failure is because $key doesn't exist
     808        if ($response->faultstring =~ /is valid object key/) {
     809            $log->debug( "leaving" );
     810            return;
     811        }
     812        # key is valid but no instances are on the specified volume
     813        if ($response->faultstring =~ /no instances on storage volume/) {
     814            $log->debug( "leaving" );
     815            return;
     816        }
     817
     818        $log->logdie("unhandled fault - ", $self->err);
     819    }
     820
     821    my $uris = $response->result;
     822
     823    $log->debug( "server found: @$uris" );
     824
     825    $log->debug( "leaving" );
     826
     827    return $uris;
     828}
     829
    760830
    761831sub find
Note: See TracChangeset for help on using the changeset viewer.