- Timestamp:
- Mar 5, 2012, 5:19:48 PM (14 years ago)
- Location:
- branches/meh_branches/ppstack_test
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
Nebulous-Server/bin/neb-admin (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/meh_branches/ppstack_test
- Property svn:mergeinfo changed
-
branches/meh_branches/ppstack_test/Nebulous-Server/bin/neb-admin
r31943 r33415 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"; … … 306 313 SELECT S.*,vol_id FROM ( 307 314 -- Select objects that are in our so_id range, with two copies (and two requested copies) 308 SELECT MAX(ins_id) AS MAXins_id,MIN(ins_id) AS MINins_id,so_id,ext_id ,value AS user_copiesFROM315 SELECT MAX(ins_id) AS MAXins_id,MIN(ins_id) AS MINins_id,so_id,ext_id FROM 309 316 storage_object JOIN storage_object_xattr USING(so_id) RIGHT JOIN instance USING(so_id) 310 317 WHERE name = 'user.copies' AND value >= 2 … … 462 469 my $so_id = $obj->{so_id}; 463 470 my $key = $obj->{ext_id}; 464 my $copies = $obj->{user_copies};471 # my $copies = $obj->{user_copies}; 465 472 466 473 my $source_vol_id = $obj->{vol_id}; … … 480 487 my %md = ( 481 488 key => $key, 482 copies => $copies,489 # copies => $copies, 483 490 so_id => $so_id, 484 491 source_vol_id => $source_vol_id, … … 524 531 } 525 532 533 sub retarget 534 { 535 my %destination; 536 my %vol_id_list = ('ipp004.0' => 1,'ipp005.0' => 2, 'ipp006.0' => 3, 'ipp007.0' => 4,'ipp008.0' => 50,'ipp009.0' => 6,'ipp010.0' => 7, 537 'ipp011.0' => 8,'ipp012.0' => 15,'ipp013.0' => 16, 'ipp014.0' => 18,'ipp015.0' => 17,'ipp016.0' => 9,'ipp017.0' => 10,'ipp018.0' => 11,'ipp019.0' => 12, 538 'ipp020.0' => 52,'ipp021.0' => 14,'ipp023.0' => 19,'ipp024.0' => 20,'ipp025.0' => 32,'ipp026.0' => 21, 'ipp027.0' => 49, 539 'ipp028.0' => 23,'ipp029.0' => 24,'ipp030.0' => 25,'ipp031.0' => 26,'ipp032.0' => 27,'ipp033.0' => 28,'ipp034.0' => 29, 540 'ipp035.0' => 30,'ipp036.0' => 31,'ipp037.0' => 51,'ipp038.0' => 33,'ipp039.0' => 34,'ipp040.0' => 35,'ipp041.0' => 36, 541 'ipp042.0' => 37,'ipp043.0' => 38,'ipp044.0' => 39,'ipp045.0' => 40,'ipp046.0' => 41,'ipp047.0' => 42,'ipp048.0' => 43, 542 'ipp049.0' => 44,'ipp050.0' => 45,'ipp051.0' => 46,'ipp052.0' => 47,'ipp053.0' => 48,'ipp054.0' => 62,'ipp055.0' => 63, 543 'ipp056.0' => 64,'ipp057.0' => 65,'ipp058.0' => 66,'ipp059.0' => 67,'ipp060.0' => 68,'ipp061.0' => 69,'ipp062.0' => 70, 544 'ipp063.0' => 71,'ipp064.0' => 72,'ipp065.0' => 73,'ipp066.0' => 74); 545 %{ $destination{VOL} } = ('ota01' => 7, 'ota02' => 8, 'ota03' => 3, 'ota04' => 3, 'ota05' => 4, 'ota06' => 4, 546 'ota10' => 50, 'ota11' => 50, 'ota12' => 6, 'ota13' => 6, 'ota14' => 7, 'ota15' => 8, 'ota16' => 15, 'ota17' => 15, 547 'ota20' => 16, 'ota21' => 18, 'ota22' => 18, 'ota23' => 17, 'ota24' => 9, 'ota25' => 9, 'ota26' => 10, 'ota27' => 11, 548 'ota30' => 12, 'ota31' => 52, 'ota32' => 14, 'ota33' => 14, 'ota34' => 19, 'ota35' => 16, 'ota36' => 20, 'ota37' => 12, 549 'ota40' => 32, 'ota41' => 11, 'ota42' => 10, 'ota43' => 17, 'ota44' => 49, 'ota45' => 23, 'ota46' => 24, 'ota47' => 25, 550 'ota50' => 26, 'ota51' => 27, 'ota52' => 28, 'ota53' => 29, 'ota54' => 30, 'ota55' => 31, 'ota56' => 51, 'ota57' => 33, 551 'ota60' => 34, 'ota61' => 35, 'ota62' => 36, 'ota63' => 37, 'ota64' => 38, 'ota65' => 39, 'ota66' => 41, 'ota67' => 42, 552 'ota71' => 43, 'ota72' => 44, 'ota73' => 45, 'ota74' => 46, 'ota75' => 47, 'ota76' => 48); 553 %{ $destination{HOST} } = ('ota01' => 'ipp010','ota02' => 'ipp011','ota03' => 'ipp006','ota04' => 'ipp054','ota05' => 'ipp007','ota06' => 'ipp055', 554 'ota10' => 'ipp008','ota11' => 'ipp056','ota12' => 'ipp009','ota13' => 'ipp057','ota14' => 'ipp058','ota15' => 'ipp059','ota16' => 'ipp012','ota17' => 'ipp060', 555 'ota20' => 'ipp013','ota21' => 'ipp014','ota22' => 'ipp061','ota23' => 'ipp015','ota24' => 'ipp016','ota25' => 'ipp062','ota26' => 'ipp064','ota27' => 'ipp065', 556 'ota30' => 'ipp066','ota31' => 'ipp020','ota32' => 'ipp063','ota33' => 'ipp021','ota34' => 'ipp023','ota35' => 'ipp013','ota36' => 'ipp024','ota37' => 'ipp019', 557 'ota40' => 'ipp025','ota41' => 'ipp018','ota42' => 'ipp017','ota43' => 'ipp015','ota44' => 'ipp027','ota45' => 'ipp028','ota46' => 'ipp029','ota47' => 'ipp030', 558 'ota50' => 'ipp031','ota51' => 'ipp032','ota52' => 'ipp033','ota53' => 'ipp034','ota54' => 'ipp035','ota55' => 'ipp036','ota56' => 'ipp037','ota57' => 'ipp038', 559 'ota60' => 'ipp039','ota61' => 'ipp040','ota62' => 'ipp041','ota63' => 'ipp042','ota64' => 'ipp043','ota65' => 'ipp044','ota66' => 'ipp046','ota67' => 'ipp047', 560 'ota71' => 'ipp048','ota72' => 'ipp049','ota73' => 'ipp050','ota74' => 'ipp051','ota75' => 'ipp052','ota76' => 'ipp053'); 561 %{ $destination{NAME} } = ('ota01' => 'ipp010.0','ota02' => 'ipp011.0','ota03' => 'ipp006.0','ota04' => 'ipp054.0','ota05' => 'ipp007.0','ota06' => 'ipp055.0', 562 'ota10' => 'ipp008.0','ota11' => 'ipp056.0','ota12' => 'ipp009.0','ota13' => 'ipp057.0','ota14' => 'ipp058.0','ota15' => 'ipp059.0','ota16' => 'ipp012.0','ota17' => 'ipp060.0', 563 'ota20' => 'ipp013.0','ota21' => 'ipp014.0','ota22' => 'ipp061.0','ota23' => 'ipp015.0','ota24' => 'ipp016.0','ota25' => 'ipp062.0','ota26' => 'ipp064.0','ota27' => 'ipp065.0', 564 'ota30' => 'ipp066.0','ota31' => 'ipp020.0','ota32' => 'ipp063.0','ota33' => 'ipp021.0','ota34' => 'ipp023.0','ota35' => 'ipp013.0','ota36' => 'ipp024.0','ota37' => 'ipp019.0', 565 'ota40' => 'ipp025.0','ota41' => 'ipp018.0','ota42' => 'ipp017.0','ota43' => 'ipp015.0','ota44' => 'ipp027.0','ota45' => 'ipp028.0','ota46' => 'ipp029.0','ota47' => 'ipp030.0', 566 'ota50' => 'ipp031.0','ota51' => 'ipp032.0','ota52' => 'ipp033.0','ota53' => 'ipp034.0','ota54' => 'ipp035.0','ota55' => 'ipp036.0','ota56' => 'ipp037.0','ota57' => 'ipp038.0', 567 'ota60' => 'ipp039.0','ota61' => 'ipp040.0','ota62' => 'ipp041.0','ota63' => 'ipp042.0','ota64' => 'ipp043.0','ota65' => 'ipp044.0','ota66' => 'ipp046.0','ota67' => 'ipp047.0', 568 'ota71' => 'ipp048.0','ota72' => 'ipp049.0','ota73' => 'ipp050.0','ota74' => 'ipp051.0','ota75' => 'ipp052.0','ota76' => 'ipp053.0'); 569 foreach my $k (keys %{ $destination{NAME} }) { 570 $destination{VOL}{$k} = $vol_id_list{$destination{NAME}{$k}}; 571 } 572 my %blocked_volume = ('ipp027' => 1, 573 'ipp037' => 1, 574 'ipp043' => 1, 575 'ipp044' => 1, 576 'ipp053' => 1, 577 'ipp023' => 1,'ipp024' => 1,'ipp025' => 1,'ipp026' => 1,'ipp028' => 1,'ipp029' => 1,'ipp030' => 1,'ipp031' => 1,'ipp032' => 1,'ipp033' => 1, 578 'ipp034' => 1,'ipp035' => 1,'ipp036' => 1,'ipp038' => 1,'ipp039' => 1,'ipp040' => 1,'ipp041' => 1,'ipp042' => 1,'ipp045' => 1,'ipp046' => 1, 579 'ipp047' => 1,'ipp048' => 1,'ipp049' => 1,'ipp050' => 1,'ipp051' => 1,'ipp052' => 1, 580 # These hosts are blocked due to concern about their RAID arrays. 581 # 'ipp054' => 1,'ipp055' => 1,'ipp056' => 1,'ipp057' => 1,'ipp058' => 1,'ipp059' => 1, 582 # 'ipp060' => 1,'ipp061' => 1,'ipp062' => 1,'ipp063' => 1,'ipp064' => 1,'ipp065' => 1, 'ipp066' => 1 583 'ipp064' => 1, 'ipp066' => 1 584 ); 585 if (not defined $so_id_start) { $so_id_start = 0; } 586 if (not defined $so_id_range) { $so_id_range = 100000; } 587 my $so_id_end = $so_id_start + $so_id_range; 588 589 # XXX check if so_id_start is beyond MAX(so_id): if so, exit with exit status 10 590 { 591 my $query = $dbh->prepare("SELECT MAX(so_id) from storage_object"); 592 $query->execute; 593 my $answer = $query->fetchrow_arrayref; 594 my $max_so_id = $$answer[0]; 595 $query->finish; 596 597 if ($so_id_start > $max_so_id) { 598 print STDERR "at end of so_id range, reset please\n"; 599 exit 10; 600 } 601 } 602 603 # Determine a list of first instances 604 # my $query = $dbh->prepare( 605 # " 606 # 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 ( 607 # select * FROM ( 608 # select MAX(ins_id) AS MAXins_id, MIN(ins_id) AS MINins_id, so_id,ext_id,value AS user_copies FROM storage_object 609 # JOIN storage_object_xattr USING(so_id) 610 # RIGHT JOIN instance USING(so_id) 611 # WHERE name = 'user.copies' 612 # AND value >= 2 613 # AND ext_id LIKE '%ota%fits' 614 # AND so_id >= $so_id_start 615 # AND so_id < $so_id_end 616 # GROUP BY so_id 617 # ) AS V 618 # WHERE MAXins_id != MINins_id 619 # ) AS S 620 # JOIN instance ON (S.MINins_id = instance.ins_id AND S.so_id = instance.so_id) 621 # JOIN volume USING(vol_id) WHERE volume.available = 1 622 # LIMIT $limit 623 # OFFSET $offset 624 # "); 625 my $query = $dbh->prepare( 626 " 627 SELECT Z.so_id,ext_id,Z.ins_id,Z.uri,substr(Z.uri,-10,5) AS class_id,Z.vol_id,vol_name,vol_host, 628 instance.vol_id AS second_vol_id,volume.name AS second_name,volume.host AS second_host FROM ( 629 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,MAXins_id FROM ( 630 select * FROM ( 631 select MAX(ins_id) AS MAXins_id, MIN(ins_id) AS MINins_id, so_id,ext_id FROM storage_object 632 JOIN storage_object_xattr USING(so_id) 633 RIGHT JOIN instance USING(so_id) 634 WHERE name = 'user.copies' 635 AND value >= 2 636 AND ext_id LIKE '%ota%fits' 637 AND so_id >= $so_id_start 638 AND so_id < $so_id_end 639 GROUP BY so_id 640 ) AS V 641 WHERE MAXins_id != MINins_id 642 ) AS S 643 JOIN instance ON (S.MINins_id = instance.ins_id AND S.so_id = instance.so_id) 644 JOIN volume USING(vol_id) WHERE volume.available = 1 645 ) AS Z 646 JOIN instance ON (MAXins_id = instance.ins_id AND Z.so_id = instance.so_id) 647 JOIN volume ON(instance.vol_id = volume.vol_id) WHERE volume.available = 1 648 LIMIT $limit 649 OFFSET $offset 650 "); 651 652 $query->execute(); 653 654 my @rows; 655 while (my $row = $query->fetchrow_hashref) { 656 push @rows, $row; 657 } 658 $query->finish; 659 660 print STDERR "No rows found\n" unless scalar @rows; 661 exit unless scalar @rows; 662 663 # compare number of responses to limit below 664 my $Npending = @rows; 665 666 print "targetPending MULTI\n\n"; 667 668 foreach my $obj (@rows) { 669 if (defined $verbose) { 670 require Data::Dumper; 671 print Data::Dumper::Dumper($obj); 672 } 673 674 my $so_id = $obj->{so_id}; 675 my $key = $obj->{ext_id}; 676 677 my $ins_id = $obj->{ins_id}; 678 my $uri = $obj->{uri}; 679 my $class_id = $obj->{class_id}; 680 681 my $source_vol_id = $obj->{vol_id}; 682 my $source_name = $obj->{vol_name}; 683 my $source_host = $obj->{vol_host}; 684 685 my $second_vol_id = $obj->{second_vol_id}; 686 my $second_vol_name = $obj->{second_name}; 687 my $second_vol_host = $obj->{second_host}; 688 689 my $destination_vol_id = $destination{VOL}{$class_id}; 690 my $destination_name = $destination{NAME}{$class_id}; 691 my $destination_host = $destination{HOST}{$class_id}; 692 my $destination_uri = $uri; 693 unless ((defined($destination_uri))&& 694 (defined($source_name))&& 695 (defined($destination_name))) { 696 next; 697 } 698 699 $destination_uri =~ s/$source_name/$destination_name/; 700 701 my %md = ( 702 so_id => $so_id, 703 key => $key, 704 ins_id => $ins_id, 705 uri => $uri, 706 class_id => $class_id, 707 708 source_vol_id => $source_vol_id, 709 source_name => $source_name, 710 source_host => $source_host, 711 712 destination_vol_id => $destination_vol_id, 713 destination_name => $destination_name, 714 destination_host => $destination_host, 715 destination_uri => $destination_uri, 716 second_host => $second_vol_host, 717 second_vol_id => $second_vol_id 718 # blocked_host_bool => defined($blocked_volume{$destination_host}) 719 ); 720 721 if ((defined($blocked_volume{$destination_host}))|| 722 ($source_vol_id == $destination_vol_id)|| 723 ($second_vol_id == $destination_vol_id)|| 724 ($source_name eq $destination_name)|| 725 ($second_vol_name eq $destination_name)) { 726 # print_metadata("targetFailed", \%md); 727 next; 728 } 729 730 if ($source_vol_id != $destination_vol_id) { 731 print_metadata("targetPending", \%md); 732 print "\n"; 733 } 734 } 735 736 # use a different exit status if we hit the limit (likely more files pending) 737 print STDERR "Which exit: $Npending $limit\n"; 738 # This is a better way to do this. This should be even better-er. 739 if ($Npending < $limit) { 740 exit 0; 741 } 742 else { 743 exit 1; 744 } 745 } 746 526 747 sub removal 527 748 {
Note:
See TracChangeset
for help on using the changeset viewer.
