Changeset 32380
- Timestamp:
- Sep 9, 2011, 1:11:47 PM (15 years ago)
- Location:
- trunk/Nebulous-Server/bin
- Files:
-
- 1 added
- 1 edited
-
neb-admin (modified) (6 diffs)
-
neb-insedit (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Nebulous-Server/bin/neb-admin
r31943 r32380 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' => 53); 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 561 if (not defined $so_id_start) { $so_id_start = 0; } 562 if (not defined $so_id_range) { $so_id_range = 100000; } 563 my $so_id_end = $so_id_start + $so_id_range; 564 565 # XXX check if so_id_start is beyond MAX(so_id): if so, exit with exit status 10 566 { 567 my $query = $dbh->prepare("SELECT MAX(so_id) from storage_object"); 568 $query->execute; 569 my $answer = $query->fetchrow_arrayref; 570 my $max_so_id = $$answer[0]; 571 $query->finish; 572 573 if ($so_id_start > $max_so_id) { 574 print STDERR "at end of so_id range, reset please\n"; 575 exit 10; 576 } 577 } 578 579 # Determine a list of first instances 580 my $query = $dbh->prepare( 581 " 582 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 ( 583 select * FROM ( 584 select MAX(ins_id) AS MAXins_id, MIN(ins_id) AS MINins_id, so_id,ext_id,value AS user_copies FROM storage_object 585 JOIN storage_object_xattr USING(so_id) 586 RIGHT JOIN instance USING(so_id) 587 WHERE name = 'user.copies' 588 AND value >= 2 589 AND ext_id LIKE '%ota%fits' 590 AND so_id >= $so_id_start 591 AND so_id < $so_id_end 592 GROUP BY so_id 593 ) AS V 594 WHERE MAXins_id != MINins_id 595 ) AS S 596 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 597 LIMIT $limit 598 OFFSET $offset 599 "); 600 $query->execute(); 601 602 my @rows; 603 while (my $row = $query->fetchrow_hashref) { 604 push @rows, $row; 605 } 606 $query->finish; 607 608 print STDERR "No rows found\n" unless scalar @rows; 609 exit unless scalar @rows; 610 611 # compare number of responses to limit below 612 my $Npending = @rows; 613 614 print "targetPending MULTI\n\n"; 615 616 foreach my $obj (@rows) { 617 if (defined $verbose) { 618 require Data::Dumper; 619 print Data::Dumper::Dumper($obj); 620 } 621 622 my $so_id = $obj->{so_id}; 623 my $key = $obj->{ext_id}; 624 625 my $ins_id = $obj->{ins_id}; 626 my $uri = $obj->{uri}; 627 my $class_id = $obj->{class_id}; 628 629 my $source_vol_id = $obj->{vol_id}; 630 my $source_name = $obj->{vol_name}; 631 my $source_host = $obj->{vol_host}; 632 633 634 my $destination_vol_id = $destination{VOL}{$class_id}; 635 my $destination_name = $destination{NAME}{$class_id}; 636 my $destination_host = $destination{HOST}{$class_id}; 637 my $destination_uri = $uri; 638 $destination_uri =~ s/$source_name/$destination_name/; 639 640 my %md = ( 641 so_id => $so_id, 642 key => $key, 643 ins_id => $ins_id, 644 uri => $uri, 645 class_id => $class_id, 646 647 source_vol_id => $source_vol_id, 648 source_name => $source_name, 649 source_host => $source_host, 650 651 destination_vol_id => $destination_vol_id, 652 destination_name => $destination_name, 653 destination_host => $destination_host, 654 destination_uri => $destination_uri, 655 ); 656 if ($source_vol_id != $destination_vol_id) { 657 print_metadata("targetPending", \%md); 658 print "\n"; 659 } 660 } 661 662 # use a different exit status if we hit the limit (likely more files pending) 663 print STDERR "Which exit: $Npending $limit\n"; 664 # This is a better way to do this. This should be even better-er. 665 if ($Npending < $limit) { 666 exit 0; 667 } 668 else { 669 exit 1; 670 } 671 } 672 526 673 sub removal 527 674 {
Note:
See TracChangeset
for help on using the changeset viewer.
