IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 32953


Ignore:
Timestamp:
Dec 13, 2011, 3:41:45 PM (15 years ago)
Author:
watersc1
Message:

Add option to neb-host to specify a single volume on a host. Update to neb-admin to prevent multiple instances landing on the same volume.

Location:
tags/ipp-20111110/Nebulous-Server/bin
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • tags/ipp-20111110/Nebulous-Server/bin

  • tags/ipp-20111110/Nebulous-Server/bin/neb-admin

    r32861 r32953  
    601601
    602602    # Determine a list of first instances
     603#     my $query = $dbh->prepare(
     604#       "
     605# 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 (
     606#   select * FROM (
     607#   select MAX(ins_id) AS MAXins_id, MIN(ins_id) AS MINins_id, so_id,ext_id,value AS user_copies FROM storage_object
     608#     JOIN storage_object_xattr USING(so_id)
     609#     RIGHT JOIN instance USING(so_id)
     610#      WHERE name = 'user.copies'
     611#      AND value >= 2
     612#      AND ext_id LIKE '%ota%fits'
     613#      AND so_id >= $so_id_start
     614#      AND so_id <  $so_id_end
     615#      GROUP BY so_id
     616#   ) AS V
     617#   WHERE MAXins_id != MINins_id
     618#   ) AS S
     619#   JOIN instance ON (S.MINins_id = instance.ins_id AND S.so_id = instance.so_id)
     620#   JOIN volume USING(vol_id) WHERE volume.available = 1
     621#   LIMIT $limit
     622#   OFFSET $offset
     623# ");
    603624    my $query = $dbh->prepare(
    604625        "
    605 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 (
    606   select * FROM (
    607   select MAX(ins_id) AS MAXins_id, MIN(ins_id) AS MINins_id, so_id,ext_id,value AS user_copies FROM storage_object
    608     JOIN storage_object_xattr USING(so_id)
    609     RIGHT JOIN instance USING(so_id)
    610      WHERE name = 'user.copies'
    611      AND value >= 2
    612      AND ext_id LIKE '%ota%fits'
    613      AND so_id >= $so_id_start
    614      AND so_id <  $so_id_end
    615      GROUP BY so_id
    616   ) AS V
    617   WHERE MAXins_id != MINins_id
    618   ) AS S
    619   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
    620   LIMIT $limit
    621   OFFSET $offset
     626SELECT 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,
     627       instance.vol_id AS  second_vol_id,volume.name AS second_name,volume.host AS second_host FROM (
     628  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 (
     629    select * FROM (
     630      select MAX(ins_id) AS MAXins_id, MIN(ins_id) AS MINins_id, so_id,ext_id,value AS user_copies FROM storage_object
     631        JOIN storage_object_xattr USING(so_id)
     632        RIGHT JOIN instance USING(so_id)
     633         WHERE name = 'user.copies'
     634         AND value >= 2
     635         AND ext_id LIKE '%ota%fits'
     636         AND so_id >= $so_id_start
     637         AND so_id <  $so_id_end
     638         GROUP BY so_id
     639      ) AS V
     640      WHERE MAXins_id != MINins_id
     641    ) AS S
     642    JOIN instance ON (S.MINins_id = instance.ins_id AND S.so_id = instance.so_id)
     643    JOIN volume USING(vol_id) WHERE volume.available = 1
     644  ) AS Z
     645JOIN instance ON (MAXins_id = instance.ins_id AND Z.so_id = instance.so_id)
     646JOIN volume ON(instance.vol_id = volume.vol_id) WHERE volume.available = 1
     647LIMIT $limit
     648OFFSET $offset
    622649");
     650
    623651    $query->execute();
    624652
     
    654682        my $source_host   = $obj->{vol_host};
    655683
     684        my $second_vol_id   = $obj->{second_vol_id};
     685        my $second_vol_name = $obj->{second_name};
     686        my $second_vol_host = $obj->{second_host};
    656687
    657688        my $destination_vol_id = $destination{VOL}{$class_id};
     
    664695            next;
    665696        }
    666         if (defined($blocked_volume{$destination_host})) {
    667             next;
    668         }
     697       
    669698        $destination_uri =~ s/$source_name/$destination_name/;
    670699       
     
    684713            destination_host   => $destination_host,
    685714            destination_uri    => $destination_uri,
     715            second_host        => $second_vol_host,
     716            second_vol_id      => $second_vol_id,
     717            blocked_host_bool  => defined($blocked_volume{$destination_host})
    686718        );
     719
     720        if ((defined($blocked_volume{$destination_host}))||
     721            ($source_vol_id == $destination_vol_id)||
     722            ($second_vol_id == $destination_vol_id)||
     723            ($source_name   eq $destination_name)||
     724            ($second_vol_name eq $destination_name)) {
     725#           print_metadata("targetFailed", \%md);
     726            next;
     727        }
     728
    687729        if ($source_vol_id != $destination_vol_id) {
    688730            print_metadata("targetPending", \%md);
  • tags/ipp-20111110/Nebulous-Server/bin/neb-host

    r28526 r32953  
    1818my ($host, $state, $note,
    1919    $db, $dbhost, $dbpass, $dbuser,
    20     $allocate, $available, $debug);
     20    $allocate, $available, $debug,$volume);
    2121
    2222# $db     = $ENV{'NEB_DB'} unless $db;
     
    5656    'dbuser=s'       => \$dbuser,
    5757    'dbpass=s'       => \$dbpass,
    58 
     58    'volume'         => \$volume,
    5959   
    6060    ) || pod2usage( 2 );
     
    9898   
    9999    my %constraint;
    100     $constraint{'v.host'} = $host;
     100    if (defined($volume)) {
     101        $constraint{'v.name'} = $host;
     102    }
     103    else {
     104        $constraint{'v.host'} = $host;
     105    }
    101106    my %set;
    102107    $set{'v.allocate'} = $allocate if defined $allocate;
Note: See TracChangeset for help on using the changeset viewer.