Changeset 25121 for trunk/Nebulous/lib
- Timestamp:
- Aug 18, 2009, 5:02:45 PM (17 years ago)
- File:
-
- 1 edited
-
trunk/Nebulous/lib/Nebulous/Client.pm (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Nebulous/lib/Nebulous/Client.pm
r24996 r25121 275 275 my $self = shift; 276 276 277 my ($key, $vol_name ) = validate_pos(@_,277 my ($key, $vol_name, $min_copies) = validate_pos(@_, 278 278 { 279 279 type => SCALAR, … … 284 284 optional => 1, 285 285 }, 286 ); 287 288 $log->debug( "entered - @_" ); 289 290 my $locations; 286 { 287 # min copies 288 type => SCALAR, 289 optional => 1, 290 }, 291 ); 292 293 $min_copies ||= 1; 294 295 $log->debug( "entered - @_" ); 296 297 my $stats = $self->stat($key); 298 my $instances = $stats->[6]; 299 if ((not defined $instances) or ($instances == 0)) { 300 $self->set_err("can not cull - no instances"); 301 $log->debug("leaving"); 302 return; 303 } 304 if ($instances < $min_copies) { 305 $self->set_err("can not cull - not enough instances"); 306 $log->debug("leaving"); 307 308 return; 309 } 310 291 311 # if vol_name is specified we need to stat the file to find out how many 292 312 # instances there are on all volumes. Otherwise we wouldn't know if it's 293 313 # safe to remove the last instance on the specified volume. 294 314 # XXX We need some way to determine which is the best instance to remove 315 my $locations; 295 316 if (defined $vol_name) { 296 my @stats = $self->stat($key);297 my $instances = $stats[6];298 if (defined $instances and $instances < 2) {299 $self->set_err("can not cull - not enough instances");300 $log->debug("leaving");301 302 return;303 }304 305 317 $locations = $self->find_instances($key, $vol_name); 306 unless (defined $locations) {307 $self->set_err( "no instances" );308 $log->debug( "leaving" );309 310 return;311 }312 318 } else { 313 319 $locations = $self->find_instances($key); 314 unless ($locations) { 315 $self->set_err( "no instances" ); 316 $log->debug("leaving"); 317 318 return; 319 } 320 321 if (scalar @{ $locations } < 2) { 322 $self->set_err("can not cull - not enough instances"); 323 $log->debug("leaving"); 324 325 return; 326 } 320 } 321 322 unless (defined $locations) { 323 $self->set_err( "no instances" ); 324 $log->debug( "leaving" ); 325 326 return; 327 327 } 328 328 … … 393 393 } 394 394 for (my $i = 1; $i < $stats->[6]; $i++) { 395 $self->cull($key );395 $self->cull($key, "any", 1); 396 396 $removed++; 397 397 }
Note:
See TracChangeset
for help on using the changeset viewer.
