IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 32342


Ignore:
Timestamp:
Sep 6, 2011, 11:03:43 AM (15 years ago)
Author:
eugene
Message:

merge changes from trunk

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20110710/Nebulous-Server/bin/neb-admin

    r31829 r32342  
    299299        "
    300300SELECT * FROM (
    301  -- U Randomize the list of all possible source/destination matches,then group by so_id to select one at random
    302  SELECT T.*,volume.cab_id AS source_cab_id,volume.name AS source_name,volume.host AS source_host,
    303         destination.vol_id AS destination_vol_id,destination.cab_id AS destination_cab_id,
    304         destination.name AS destination_name,destination.host AS destination_host FROM (
    305   -- V Ensure that the copy we found on the source volume is the second copy instance
    306   SELECT K.vol_id AS here,K.ins_id,K.so_id,ext_id,value AS user_copies,MAXins_id,instance.vol_id AS there FROM (
    307    -- W Determine what the second copy instance is
    308    SELECT V.*,MAX(instance.ins_id) AS MAXins_id FROM (
    309     -- X Determine which hosts have instances of an object
    310     SELECT vol_id,ins_id,so_id,ext_id,value FROM
    311     storage_object JOIN storage_object_xattr USING(so_id) JOIN instance USING(so_id)
    312     WHERE vol_id IN (
    313      -- Y Extra select for debugging purposes
    314      SELECT vol_id FROM (
    315       -- Z Ran hosts by R (need to be a source) and return top N
    316       SELECT mountedvol.vol_id,mountedvol.name,mountedvol.available,mountedvol.allocate,total,used,
    317              (used / total) AS D,total * ((used / total) - $average ) AS R,  -- average
    318              (used / total) - $average AS delta,
    319              cab_id FROM
    320       mountedvol JOIN volume USING(vol_id)
    321       WHERE mountedvol.available = 1
    322       ORDER BY delta DESC LIMIT $balance_N_sources                                            -- N
    323       ) AS ranked_sources
    324       -- Z End
    325      )
    326      -- Y End
    327     AND name = 'user.copies' AND value >= 2
    328   AND ext_id LIKE '%ota%fits'       -- This line is the emergency speedup option
    329     AND so_id >= $so_id_start                                  -- so_id_start
    330     AND so_id <  $so_id_end                                    -- so_id_end
    331    ) AS V -- volumes that host a copy
    332    -- X End
    333   LEFT OUTER JOIN instance USING(so_id) GROUP BY so_id
    334   ) AS K -- copies that are the second copy
    335   -- W End
    336  JOIN instance ON MAXins_id = instance.ins_id GROUP BY so_id
    337  ) AS T -- matched copies that I know the second copy is on my source volume
    338  -- V End
    339  JOIN volume on T.here = volume.vol_id RIGHT JOIN (
    340   -- Y2 Chose a random destination from the list
    341   SELECT vol_id,cab_id,name,host FROM (
    342    -- Z2 Reverse rank hosts by R and return top M
    343    SELECT mountedvol.vol_id,mountedvol.name,mountedvol.host,mountedvol.available,mountedvol.allocate,total,used,
    344           (used / total) AS D,total * ((used / total) - $average ) AS R,  -- average
    345           (used / total) - $average AS delta,
    346           cab_id FROM
    347    mountedvol JOIN volume USING(vol_id)
    348    WHERE mountedvol.available = 1 AND mountedvol.allocate = 1
    349    ORDER BY delta ASC LIMIT $balance_M_destinations                                               -- M
    350   ) AS ranked_destinations
    351   -- Z2 End
    352  ORDER BY RAND()
    353  ) AS destination
    354  -- Y2 End
    355  ON destination.cab_id != volume.cab_id
    356  WHERE here = there
    357  ORDER BY RAND()
     301#  -- U Randomize the list of all possible source/destination matches,then group by so_id to select one at random
     302  SELECT T.*,volume.cab_id AS source_cab_id, volume.name AS source_name, volume.host AS source_host,
     303         destination.vol_id AS destination_vol_id,destination.cab_id AS destination_cab_id,
     304         destination.name AS destination_name,destination.host AS destination_host FROM (
     305    -- V Select the volume that matches the instance with the largest ins_id
     306    SELECT S.*,vol_id FROM (
     307      -- 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_copies FROM
     309       storage_object JOIN storage_object_xattr USING(so_id) RIGHT JOIN instance USING(so_id)
     310       WHERE name = 'user.copies' AND value >= 2
     311       AND ext_id LIKE '%ota%fits'                  -- This line is the emergency speedup option
     312       AND so_id >= $so_id_start                    -- so_id_start
     313       AND so_id <  $so_id_end                      -- so_id_end
     314       GROUP BY so_id
     315      ) AS S
     316      JOIN instance ON (S.MAXins_id = instance.ins_id)
     317      WHERE vol_id IN (
     318       -- Y Extra select for debugging purposes
     319       SELECT vol_id FROM (
     320        -- Z Ran hosts by R (need to be a source) and return top N
     321        SELECT mountedvol.vol_id,mountedvol.name,mountedvol.available,mountedvol.allocate,total,used,
     322               (used / total) AS D,total * ((used / total) - $average ) AS R,  -- average
     323               (used / total) - $average AS delta,
     324               cab_id FROM
     325        mountedvol JOIN volume USING(vol_id)
     326        WHERE mountedvol.available = 1
     327        AND mountedvol.xattr = 0
     328        ORDER BY delta DESC LIMIT $balance_N_sources                                            -- N
     329        ) AS ranked_sources
     330        -- Z End
     331       )
     332       -- Y End
     333       AND MAXins_id != MINins_id
     334     ) AS T
     335     -- V End
     336     JOIN volume on T.vol_id = volume.vol_id RIGHT JOIN (
     337       -- Y2 Chose a random destination from the list
     338       SELECT vol_id,cab_id,name,host FROM (
     339         -- Z2 Reverse rank hosts by R and return top M
     340         SELECT mountedvol.vol_id,mountedvol.name,mountedvol.host,mountedvol.available,mountedvol.allocate,total,used,
     341                (used / total) AS D,total * ((used / total) - $average ) AS R,  -- average
     342                (used / total) - $average AS delta,
     343                cab_id FROM
     344         mountedvol JOIN volume USING(vol_id)
     345         WHERE mountedvol.available = 1 AND mountedvol.allocate = 1
     346         AND mountedvol.xattr = 1
     347         ORDER BY delta ASC LIMIT $balance_M_destinations                                               -- M
     348       ) AS ranked_destinations
     349       -- Z2 End
     350     ORDER BY RAND()
     351     ) AS destination
     352     -- Y2 End
     353   ON destination.cab_id != volume.cab_id
     354   ORDER BY RAND()
    358355) AS results
     356WHERE so_id IS NOT NULL
    359357-- U End
    360358GROUP BY so_id
    361     LIMIT $limit                                               -- limit
    362     OFFSET $offset                                             -- offset
    363 
    364 "    );
     359  LIMIT $limit                                               -- limit
     360  OFFSET $offset                                             -- offset
     361
     362");
     363
     364#     my $query = $dbh->prepare(
     365#       "
     366# SELECT * FROM (
     367#  -- U Randomize the list of all possible source/destination matches,then group by so_id to select one at random
     368#  SELECT T.*,volume.cab_id AS source_cab_id,volume.name AS source_name,volume.host AS source_host,
     369#         destination.vol_id AS destination_vol_id,destination.cab_id AS destination_cab_id,
     370#         destination.name AS destination_name,destination.host AS destination_host FROM (
     371#   -- V Ensure that the copy we found on the source volume is the second copy instance
     372#   SELECT K.vol_id AS here,K.ins_id,K.so_id,ext_id,value AS user_copies,MAXins_id,instance.vol_id AS there FROM (
     373#    -- W Determine what the second copy instance is
     374#    SELECT V.*,MAX(instance.ins_id) AS MAXins_id FROM (
     375#     -- X Determine which hosts have instances of an object
     376#     SELECT vol_id,ins_id,so_id,ext_id,value FROM
     377#     storage_object JOIN storage_object_xattr USING(so_id) JOIN instance USING(so_id)
     378#     WHERE vol_id IN (
     379#      -- Y Extra select for debugging purposes
     380#      SELECT vol_id FROM (
     381#       -- Z Ran hosts by R (need to be a source) and return top N
     382#       SELECT mountedvol.vol_id,mountedvol.name,mountedvol.available,mountedvol.allocate,total,used,
     383#              (used / total) AS D,total * ((used / total) - $average ) AS R,  -- average
     384#              (used / total) - $average AS delta,
     385#              cab_id FROM
     386#       mountedvol JOIN volume USING(vol_id)
     387#       WHERE mountedvol.available = 1
     388#       ORDER BY delta DESC LIMIT $balance_N_sources                                            -- N
     389#       ) AS ranked_sources
     390#       -- Z End
     391#      )
     392#      -- Y End
     393#     AND name = 'user.copies' AND value >= 2
     394#   AND ext_id LIKE '%ota%fits'       -- This line is the emergency speedup option
     395#     AND so_id >= $so_id_start                                  -- so_id_start
     396#     AND so_id <  $so_id_end                                    -- so_id_end
     397#    ) AS V -- volumes that host a copy
     398#    -- X End
     399#   LEFT OUTER JOIN instance USING(so_id) GROUP BY so_id
     400#   ) AS K -- copies that are the second copy
     401#   -- W End
     402#  JOIN instance ON MAXins_id = instance.ins_id GROUP BY so_id
     403#  ) AS T -- matched copies that I know the second copy is on my source volume
     404#  -- V End
     405#  JOIN volume on T.here = volume.vol_id RIGHT JOIN (
     406#   -- Y2 Chose a random destination from the list
     407#   SELECT vol_id,cab_id,name,host FROM (
     408#    -- Z2 Reverse rank hosts by R and return top M
     409#    SELECT mountedvol.vol_id,mountedvol.name,mountedvol.host,mountedvol.available,mountedvol.allocate,total,used,
     410#           (used / total) AS D,total * ((used / total) - $average ) AS R,  -- average
     411#           (used / total) - $average AS delta,
     412#           cab_id FROM
     413#    mountedvol JOIN volume USING(vol_id)
     414#    WHERE mountedvol.available = 1 AND mountedvol.allocate = 1
     415#    ORDER BY delta ASC LIMIT $balance_M_destinations                                               -- M
     416#   ) AS ranked_destinations
     417#   -- Z2 End
     418#  ORDER BY RAND()
     419#  ) AS destination
     420#  -- Y2 End
     421#  ON destination.cab_id != volume.cab_id
     422#  WHERE here = there
     423#  ORDER BY RAND()
     424# ) AS results
     425# -- U End
     426# GROUP BY so_id
     427#     LIMIT $limit                                               -- limit
     428#     OFFSET $offset                                             -- offset
     429
     430# "    );
    365431
    366432    $query->execute();
     
    389455       
    390456
    391         my $here = $obj->{here};
    392         my $there = $obj->{there};
    393         my $ins_id = $obj->{ins_id};
     457#       my $here = $obj->{here};
     458#       my $there = $obj->{there};
     459#       my $ins_id = $obj->{ins_id};
    394460        my $max_ins_id = $obj->{MAXins_id};
    395461       
     
    398464        my $copies = $obj->{user_copies};
    399465
    400         my $source_vol_id = $obj->{here};
     466        my $source_vol_id = $obj->{vol_id};
    401467        my $source_cab_id = $obj->{source_cab_id};
    402468        my $source_name   = $obj->{source_name};
     
    408474        my $destination_host   = $obj->{destination_host};
    409475       
    410         unless ($here == $there) { $Npending-- ; next; }
    411         unless ($ins_id == $max_ins_id) { $Npending-- ; next; }
     476#       unless ($here == $there) { $Npending-- ; next; }
     477#       unless ($ins_id == $max_ins_id) { $Npending-- ; next; }
    412478        unless ($source_cab_id != $destination_cab_id) { $Npending-- ;  next; }
    413479       
Note: See TracChangeset for help on using the changeset viewer.