IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 24639


Ignore:
Timestamp:
Jul 1, 2009, 6:40:27 PM (17 years ago)
Author:
jhoblitt
Message:

change Nebulous::Server->stat_object() to return both the total number of instance and just those that are available

Location:
trunk/Nebulous-Server
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Nebulous-Server/Changes

    r24637 r24639  
    3333    - add the ability to delete a storage object when it has instances that are
    3434      offline
     35    - change Nebulous::Server->stat_object() to return both the total number of
     36      instance and just those that are available
    3537     
    36380.16
  • trunk/Nebulous-Server/lib/Nebulous/Server.pod

    r24278 r24639  
    183183    mtime
    184184    number of instances
     185    number of available instances
    185186
    186187=item * mounts( $key );
  • trunk/Nebulous-Server/lib/Nebulous/Server/SQL.pm

    r24638 r24639  
    8383    stat_object          => qq{
    8484        SELECT
    85             storage_object.so_id,
    86             storage_object.ext_id,
    87             read_lock,
    88             write_lock,
    89             storage_object_attr.epoch,
    90             storage_object_attr.mtime,
    91             COUNT(instance.so_id) as instances
    92         FROM storage_object
    93         JOIN storage_object_attr
     85            so.so_id,
     86            so.ext_id,
     87            attr.read_lock,
     88            attr.write_lock,
     89            attr.epoch,
     90            attr.mtime,
     91            COUNT(instance.so_id) as instances,
     92            SUM(available) as available
     93        FROM storage_object as so
     94        JOIN storage_object_attr as attr
    9495            USING (so_id)
    9596        JOIN instance
    9697            USING (so_id)
    97         WHERE ext_id = ?
    98         GROUP BY storage_object.so_id
     98        LEFT JOIN mountedvol
     99            USING(vol_id)
     100        WHERE ext_id = ?
     101        GROUP BY so.so_id
    99102    },
    100103    # Note: this sets an update lock
  • trunk/Nebulous-Server/t/10_server_stat_object.t

    r24356 r24639  
    88use warnings FATAL => qw( all );
    99
    10 use Test::More tests => 12;
     10use Test::More tests => 13;
    1111
    1212use lib qw( ./t ./lib );
     
    2727    my $info = $neb->stat_object("foo");
    2828
    29     is(scalar @$info, 7, "number of columns");
     29    is(scalar @$info, 8, "number of columns");
    3030}
    3131
     
    3737    my $info = $neb->stat_object("foo");
    3838
    39     is(scalar @$info, 7,                       "number of columns");
     39    is(scalar @$info, 8,                       "number of columns");
    4040    is(@$info[0], 1,                           "so_id");
    4141    is(@$info[1], "foo",                       "ext_id");
     
    4545    like(@$info[5], qr/....-..-.. ..:..:../,   "mtime");
    4646    is(@$info[6], 1,                           "instances");
     47    is(@$info[7], 1,                           "available instances");
    4748}
    4849
Note: See TracChangeset for help on using the changeset viewer.