Changeset 41005 for branches/eam_branches/ipp-20191011
- Timestamp:
- Oct 31, 2019, 10:29:48 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20191011/Nebulous/lib/Nebulous/Client.pm
r40991 r41005 209 209 }, 210 210 ); 211 211 212 212 $log->debug( "entered - @_" ); 213 213 … … 310 310 my $stats = $self->stat($key); 311 311 my $instances = $stats->[6]; 312 312 313 if ((not defined $instances) or ($instances == 0)) { 313 314 $self->set_err("can not cull - no instances"); … … 315 316 return; 316 317 } 317 if ($instances < $min_copies) {318 if ($instances <= $min_copies) { 318 319 $self->set_err("can not cull - not enough instances"); 319 320 $log->debug("leaving"); … … 403 404 eval { 404 405 # first - strip off any inaccesible instances 406 # these are not counted in the 'removed' number 405 407 if (not defined $self->prune($key)) { 406 408 # use the prune() method to also determine if $key is valid 407 409 die "invalid key: $key"; 408 410 } 409 410 # check to see if there is an instance on $vol_name that should be the 411 # sole survivor 411 412 # check to see if there is an instance on $vol_name that 413 # should be the sole survivor. This is a bit dangerous : what 414 # if the only instance is on an invalid volume? what if an 415 # invalid volume is specified? 416 412 417 if (defined $vol_name) { 413 418 $locations = $self->find_instances($key, $vol_name); 419 if (not defined $locations) { 420 die "no instances on requested node"; 421 } 422 if (scalar @$locations == 0) { 423 die "no instances on requested node"; 424 } 414 425 } 415 426 … … 418 429 419 430 if (defined $locations) { 420 # XXX this is an example of passing 'find_invalid' to find_instances 421 my $instances = $self->find_instances($key, undef, 'find them all'); 422 if (not defined $instances) { 431 # first delete the valid instances (except the one we own) 432 my $instances_valid = $self->find_instances($key, undef, 0); # find all valid instances 433 if (not defined $instances_valid) { 434 # there should have been at least one valid instance? 423 435 die "no instances"; 424 436 } 425 if (scalar @$instances == 1) { 426 # only one instance nothing to do 427 return 0; 428 } 429 if (scalar @$instances == 0) { 437 if (scalar @$instances_valid == 0) { 438 # there should have been at least one valid instance? 430 439 die "no instances"; 431 440 } 432 foreach my $victim (@$instances) { 433 next if $victim eq $locations->[0]; 434 $self->delete_instance($key, $victim); 435 $removed++; 436 } 441 442 # we have more than one instance, delete the others 443 if (scalar @$instances_valid > 1) { 444 foreach my $victim (@$instances_valid) { 445 next if $victim eq $locations->[0]; 446 $self->delete_instance($key, $victim); 447 $removed ++; 448 } 449 } 450 # the prune above should have deleted any invalid instances, so we only 451 # need to worry about the valid instances; 437 452 } else { 438 453 # nuke whatever … … 918 933 unless(defined($params[0])) { 919 934 $params[0] = hostname() . ".0"; 920 #print STDERR "Setting host to $params[0]\n";935 # print STDERR "Setting host to $params[0]\n"; 921 936 } 922 937 … … 1187 1202 1188 1203 $log->debug( "entered - @_" ); 1189 1190 1204 1191 1205 my $locations; … … 1380 1394 } 1381 1395 1396 if ($response->faultstring =~ /is valid object key/) { 1397 $log->logdie("parameter #1 to delete_instance did not pass the 'is valid object key' callback"); 1398 } 1399 1382 1400 $log->logdie("unhandled fault - ", $self->err); 1383 1401 } … … 1542 1560 } 1543 1561 1562 sub set_log_level 1563 { 1564 my $self = shift; 1565 1566 my $log_level = shift; 1567 1568 $log->level($log_level); 1569 1570 return $self; 1571 } 1572 1544 1573 1545 1574 1;
Note:
See TracChangeset
for help on using the changeset viewer.
