- Timestamp:
- Nov 8, 2011, 2:44:12 PM (15 years ago)
- Location:
- branches/eam_branches/ipp-20110906
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
Nebulous-Server/bin/neb-admin (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20110906
- Property svn:mergeinfo changed
-
branches/eam_branches/ipp-20110906/Nebulous-Server/bin/neb-admin
r31943 r32630 29 29 $pending, 30 30 $balance, 31 $retarget, 31 32 $balance_N_sources, 32 33 $balance_M_destinations, … … 49 50 'pendingreplicate|r' => \$pending, 50 51 'pendingbalance|b' => \$balance, 52 'pendingtarget|t' => \$retarget, 51 53 'balancesources|N=s' => \$balance_N_sources, 52 54 'balancedestinations|M=s' => \$balance_M_destinations, … … 64 66 pod2usage( -msg => "--limit is meaningless without --pendingreplicate", 65 67 -exitval => 2 ) 66 if defined $limit and not (defined $pending or defined $balance );68 if defined $limit and not (defined $pending or defined $balance or defined $retarget); 67 69 pod2usage( -msg => "no operation specified", -exitval => 2 ) 68 unless defined $pending or defined $balance ;70 unless defined $pending or defined $balance or defined $retarget; 69 71 pod2usage( -msg => "--pendingbalance needs --balancesources and --balancedestinations options", 70 72 -exitval => 2) … … 81 83 elsif (defined $balance) { 82 84 $pidfile = '/var/tmp/neb-admin.balance'; 85 } 86 elsif (defined $retarget) { 87 $pidfile = '/var/tmp/neb-admin.retarget'; 83 88 } 84 89 else { … … 107 112 } elsif ($balance) { 108 113 balance(); 114 } elsif ($retarget) { 115 retarget(); 109 116 } else { 110 117 die "THIS SHOULD NOT HAPPEN"; … … 524 531 } 525 532 533 sub retarget 534 { 535 my %destination; 536 %{ $destination{VOL} } = ('ota01' => 7, 'ota02' => 8, 'ota03' => 3, 'ota04' => 3, 'ota05' => 4, 'ota06' => 4, 537 'ota10' => 50, 'ota11' => 50, 'ota12' => 6, 'ota13' => 6, 'ota14' => 7, 'ota15' => 8, 'ota16' => 15, 'ota17' => 15, 538 'ota20' => 16, 'ota21' => 18, 'ota22' => 18, 'ota23' => 17, 'ota24' => 9, 'ota25' => 9, 'ota26' => 10, 'ota27' => 11, 539 'ota30' => 12, 'ota31' => 52, 'ota32' => 14, 'ota33' => 14, 'ota34' => 19, 'ota35' => 16, 'ota36' => 20, 'ota37' => 12, 540 'ota40' => 32, 'ota41' => 11, 'ota42' => 10, 'ota43' => 17, 'ota44' => 49, 'ota45' => 23, 'ota46' => 24, 'ota47' => 25, 541 'ota50' => 26, 'ota51' => 27, 'ota52' => 28, 'ota53' => 29, 'ota54' => 30, 'ota55' => 31, 'ota56' => 51, 'ota57' => 33, 542 'ota60' => 34, 'ota61' => 35, 'ota62' => 36, 'ota63' => 37, 'ota64' => 38, 'ota65' => 39, 'ota66' => 41, 'ota67' => 42, 543 'ota71' => 43, 'ota72' => 44, 'ota73' => 45, 'ota74' => 46, 'ota75' => 47, 'ota76' => 48); 544 %{ $destination{HOST} } = ('ota01' => 'ipp010','ota02' => 'ipp011','ota03' => 'ipp006','ota04' => 'ipp006','ota05' => 'ipp007','ota06' => 'ipp007', 545 'ota10' => 'ipp008','ota11' => 'ipp008','ota12' => 'ipp009','ota13' => 'ipp009','ota14' => 'ipp010','ota15' => 'ipp011','ota16' => 'ipp012','ota17' => 'ipp012', 546 'ota20' => 'ipp013','ota21' => 'ipp014','ota22' => 'ipp014','ota23' => 'ipp015','ota24' => 'ipp016','ota25' => 'ipp016','ota26' => 'ipp017','ota27' => 'ipp018', 547 'ota30' => 'ipp019','ota31' => 'ipp020','ota32' => 'ipp021','ota33' => 'ipp021','ota34' => 'ipp023','ota35' => 'ipp013','ota36' => 'ipp024','ota37' => 'ipp019', 548 'ota40' => 'ipp025','ota41' => 'ipp018','ota42' => 'ipp017','ota43' => 'ipp015','ota44' => 'ipp027','ota45' => 'ipp028','ota46' => 'ipp029','ota47' => 'ipp030', 549 'ota50' => 'ipp031','ota51' => 'ipp032','ota52' => 'ipp033','ota53' => 'ipp034','ota54' => 'ipp035','ota55' => 'ipp036','ota56' => 'ipp037','ota57' => 'ipp038', 550 'ota60' => 'ipp039','ota61' => 'ipp040','ota62' => 'ipp041','ota63' => 'ipp042','ota64' => 'ipp043','ota65' => 'ipp044','ota66' => 'ipp046','ota67' => 'ipp047', 551 'ota71' => 'ipp048','ota72' => 'ipp049','ota73' => 'ipp050','ota74' => 'ipp051','ota75' => 'ipp052','ota76' => 'ipp053'); 552 %{ $destination{NAME} } = ('ota01' => 'ipp010.0','ota02' => 'ipp011.0','ota03' => 'ipp006.0','ota04' => 'ipp006.0','ota05' => 'ipp007.0','ota06' => 'ipp007.0', 553 'ota10' => 'ipp008.0','ota11' => 'ipp008.0','ota12' => 'ipp009.0','ota13' => 'ipp009.0','ota14' => 'ipp010.0','ota15' => 'ipp011.0','ota16' => 'ipp012.0','ota17' => 'ipp012.0', 554 'ota20' => 'ipp013.0','ota21' => 'ipp014.0','ota22' => 'ipp014.0','ota23' => 'ipp015.0','ota24' => 'ipp016.0','ota25' => 'ipp016.0','ota26' => 'ipp017.0','ota27' => 'ipp018.0', 555 'ota30' => 'ipp019.0','ota31' => 'ipp020.0','ota32' => 'ipp021.0','ota33' => 'ipp021.0','ota34' => 'ipp023.0','ota35' => 'ipp013.0','ota36' => 'ipp024.0','ota37' => 'ipp019.0', 556 'ota40' => 'ipp025.0','ota41' => 'ipp018.0','ota42' => 'ipp017.0','ota43' => 'ipp015.0','ota44' => 'ipp027.0','ota45' => 'ipp028.0','ota46' => 'ipp029.0','ota47' => 'ipp030.0', 557 'ota50' => 'ipp031.0','ota51' => 'ipp032.0','ota52' => 'ipp033.0','ota53' => 'ipp034.0','ota54' => 'ipp035.0','ota55' => 'ipp036.0','ota56' => 'ipp037.0','ota57' => 'ipp038.0', 558 'ota60' => 'ipp039.0','ota61' => 'ipp040.0','ota62' => 'ipp041.0','ota63' => 'ipp042.0','ota64' => 'ipp043.0','ota65' => 'ipp044.0','ota66' => 'ipp046.0','ota67' => 'ipp047.0', 559 'ota71' => 'ipp048.0','ota72' => 'ipp049.0','ota73' => 'ipp050.0','ota74' => 'ipp051.0','ota75' => 'ipp052.0','ota76' => 'ipp053.0'); 560 my %blocked_volume = ('ipp027' => 1, 561 'ipp037' => 1, 562 'ipp043' => 1, 563 'ipp044' => 1, 564 'ipp053' => 1, 565 'ipp023' => 1,'ipp024' => 1,'ipp025' => 1,'ipp026' => 1,'ipp028' => 1,'ipp029' => 1,'ipp030' => 1,'ipp031' => 1,'ipp032' => 1,'ipp033' => 1, 566 'ipp034' => 1,'ipp035' => 1,'ipp036' => 1,'ipp038' => 1,'ipp039' => 1,'ipp040' => 1,'ipp041' => 1,'ipp042' => 1,'ipp045' => 1,'ipp046' => 1, 567 'ipp047' => 1,'ipp048' => 1,'ipp049' => 1,'ipp050' => 1,'ipp051' => 1,'ipp052' => 1); 568 if (not defined $so_id_start) { $so_id_start = 0; } 569 if (not defined $so_id_range) { $so_id_range = 100000; } 570 my $so_id_end = $so_id_start + $so_id_range; 571 572 # XXX check if so_id_start is beyond MAX(so_id): if so, exit with exit status 10 573 { 574 my $query = $dbh->prepare("SELECT MAX(so_id) from storage_object"); 575 $query->execute; 576 my $answer = $query->fetchrow_arrayref; 577 my $max_so_id = $$answer[0]; 578 $query->finish; 579 580 if ($so_id_start > $max_so_id) { 581 print STDERR "at end of so_id range, reset please\n"; 582 exit 10; 583 } 584 } 585 586 # Determine a list of first instances 587 my $query = $dbh->prepare( 588 " 589 SELECT S.so_id,ext_id,ins_id,uri,substr(uri,-10,5) AS class_id,vol_id,name AS vol_name,host AS vol_host FROM ( 590 select * FROM ( 591 select MAX(ins_id) AS MAXins_id, MIN(ins_id) AS MINins_id, so_id,ext_id,value AS user_copies FROM storage_object 592 JOIN storage_object_xattr USING(so_id) 593 RIGHT JOIN instance USING(so_id) 594 WHERE name = 'user.copies' 595 AND value >= 2 596 AND ext_id LIKE '%ota%fits' 597 AND so_id >= $so_id_start 598 AND so_id < $so_id_end 599 GROUP BY so_id 600 ) AS V 601 WHERE MAXins_id != MINins_id 602 ) AS S 603 JOIN instance ON (S.MINins_id = instance.ins_id AND S.so_id = instance.so_id) JOIN volume USING(vol_id) WHERE volume.available = 1 604 LIMIT $limit 605 OFFSET $offset 606 "); 607 $query->execute(); 608 609 my @rows; 610 while (my $row = $query->fetchrow_hashref) { 611 push @rows, $row; 612 } 613 $query->finish; 614 615 print STDERR "No rows found\n" unless scalar @rows; 616 exit unless scalar @rows; 617 618 # compare number of responses to limit below 619 my $Npending = @rows; 620 621 print "targetPending MULTI\n\n"; 622 623 foreach my $obj (@rows) { 624 if (defined $verbose) { 625 require Data::Dumper; 626 print Data::Dumper::Dumper($obj); 627 } 628 629 my $so_id = $obj->{so_id}; 630 my $key = $obj->{ext_id}; 631 632 my $ins_id = $obj->{ins_id}; 633 my $uri = $obj->{uri}; 634 my $class_id = $obj->{class_id}; 635 636 my $source_vol_id = $obj->{vol_id}; 637 my $source_name = $obj->{vol_name}; 638 my $source_host = $obj->{vol_host}; 639 640 641 my $destination_vol_id = $destination{VOL}{$class_id}; 642 my $destination_name = $destination{NAME}{$class_id}; 643 my $destination_host = $destination{HOST}{$class_id}; 644 my $destination_uri = $uri; 645 unless ((defined($destination_uri))&& 646 (defined($source_name))&& 647 (defined($destination_name))) { 648 next; 649 } 650 if (defined($blocked_volume{$destination_host})) { 651 next; 652 } 653 $destination_uri =~ s/$source_name/$destination_name/; 654 655 my %md = ( 656 so_id => $so_id, 657 key => $key, 658 ins_id => $ins_id, 659 uri => $uri, 660 class_id => $class_id, 661 662 source_vol_id => $source_vol_id, 663 source_name => $source_name, 664 source_host => $source_host, 665 666 destination_vol_id => $destination_vol_id, 667 destination_name => $destination_name, 668 destination_host => $destination_host, 669 destination_uri => $destination_uri, 670 ); 671 if ($source_vol_id != $destination_vol_id) { 672 print_metadata("targetPending", \%md); 673 print "\n"; 674 } 675 } 676 677 # use a different exit status if we hit the limit (likely more files pending) 678 print STDERR "Which exit: $Npending $limit\n"; 679 # This is a better way to do this. This should be even better-er. 680 if ($Npending < $limit) { 681 exit 0; 682 } 683 else { 684 exit 1; 685 } 686 } 687 526 688 sub removal 527 689 {
Note:
See TracChangeset
for help on using the changeset viewer.
