IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 30, 2007, 4:52:04 PM (19 years ago)
Author:
jhoblitt
Message:

remove $class_id & $comment params from Nebulous::Server->create() and Nebulous::Client->create*() and all supporting functions and tests

Location:
trunk/Nebulous-Server
Files:
2 deleted
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Nebulous-Server/Changes

    r13087 r13092  
    22
    330.05
     4    - remove $class_id & $comment params from Nebulous::Server->create() and
     5      Nebulous::Client->create*() and all supporting functions and tests
    46    - add Nebulous::Server->{setxattr_object, listxattr_object,
    57      getxattr_object, removexattr_object}()
  • trunk/Nebulous-Server/MANIFEST

    r13087 r13092  
    8585t/07_server_find_instances.t
    8686t/08_server_delete_instance.t
    87 t/09_server_is_valid_class_id.t
    8887t/09_server_stat_object.t
    8988t/10_server_is_valid_volume_name.t
    90 t/11_server_is_valid_class_id.t
    9189t/12_server_find_objects.t
    9290t/13_server_rename_object.t
  • trunk/Nebulous-Server/lib/Nebulous/Server.pm

    r13087 r13092  
    11# Copyright (c) 2004  Joshua Hoblitt
    22#
    3 # $Id: Server.pm,v 1.27 2007-05-01 02:00:07 jhoblitt Exp $
     3# $Id: Server.pm,v 1.28 2007-05-01 02:52:04 jhoblitt Exp $
    44
    55package Nebulous::Server;
     
    123123    my $self = shift;
    124124
    125     my ( $key, $class, $volume, $comment ) = validate_pos( @_,
    126         {
    127             type        => SCALAR,
    128         },
    129         {
    130             type        => SCALAR,
    131             callbacks   => {
    132                 'is + integer' => sub { $_[0] =~ /^\d+$/ },
    133                 # check that the class requested is valid
    134                 'is valid class id' => sub { $self->_is_valid_class_id( $_[0] ) },
    135             },
    136             default     => 0,
     125    my ($key, $volume) = validate_pos(@_,
     126        {
     127            type        => SCALAR,
    137128        },
    138129        {
     
    144135            optional    => 1,
    145136        },
    146         {
    147             type        => SCALAR,
    148             callbacks   => {
    149                 # check that the comment isn't too long
    150                 'comment length' => sub { length $_[0] < 256 },
    151             },
    152             optional    => 1,
    153         },
    154137    );
    155138
     
    185168            # create storage_object_attr
    186169            my $query = $db->prepare_cached( $sql->new_object_attr );
    187             $query->execute( $object_id, $class, $comment );
     170            $query->execute( $object_id );
    188171        }
    189172
     
    10701053}
    10711054
    1072 sub _is_valid_class_id {
    1073     my ($self, $class_id) = @_;
    1074 
    1075     my $log = $self->log;
    1076     my $sql = $self->sql;
    1077     my $db  = $self->db;
    1078 
    1079     my $class;
    1080     eval {
    1081         my $query = $db->prepare_cached( $sql->get_class_by_id );
    1082         $query->execute( $class_id );
    1083         ( $class ) = $query->fetchrow_array;
    1084 
    1085         $query->finish;
    1086     };
    1087     if ( $@ ) {
    1088         $db->rollback;
    1089         $log->logdie( "database error: $@" );
    1090     }
    1091 
    1092     return ( defined $class ) ? 1 : undef;
    1093 }
    1094 
    10951055sub _is_valid_volume_name  {
    10961056    my ($self, $vol_name) = @_;
  • trunk/Nebulous-Server/lib/Nebulous/Server/SQL.pm

    r13087 r13092  
    11# Copyright (c) 2004  Joshua Hoblitt
    22#
    3 # $Id: SQL.pm,v 1.29 2007-05-01 02:00:07 jhoblitt Exp $
     3# $Id: SQL.pm,v 1.30 2007-05-01 02:52:04 jhoblitt Exp $
    44
    55package Nebulous::Server::SQL;
     
    2929    new_object_attr  => qq{
    3030        INSERT INTO storage_object_attr
    31         (so_id, class_id, comment, read_lock, write_lock)
    32         VALUES (?, ?, ?, 0, NULL)
     31        (so_id, read_lock, write_lock)
     32        VALUES (?, 0, NULL)
    3333    },
    3434    delete_object       => qq{
     
    4848    get_object          => qq{
    4949        SELECT storage_object.so_id,
    50             ext_id, class_id, comment, read_lock, write_lock, epoch, mtime
     50            ext_id, read_lock, write_lock, epoch, mtime
    5151        FROM storage_object
    5252        LEFT JOIN storage_object_attr
     
    176176        INSERT INTO volume (name, path)
    177177        VALUES (?, ?)
    178     },
    179     get_class_by_id => qq{
    180         SELECT class_id, priority, comment
    181         FROM class
    182         WHERE class_id = ?
    183178    },
    184179    get_volume_by_name => qq{
     
    257252CREATE TABLE storage_object_attr (
    258253    so_id BIGINT NOT NULL AUTO_INCREMENT,
    259     class_id TINYINT NOT NULL,
    260     comment VARCHAR(255),
    261254    read_lock TINYINT DEFAULT 0 NOT NULL,
    262255    write_lock ENUM( 'write' ),
    263256    epoch TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    264257    mtime TIMESTAMP,
    265     PRIMARY KEY(so_id),
    266     KEY(class_id)
     258    PRIMARY KEY(so_id)
    267259) ENGINE=innodb;
    268260
     
    318310    PRIMARY KEY(mountpoint)
    319311) ENGINE=innodb;
    320 
    321 ###
    322 
    323 CREATE TABLE class (
    324     class_id TINYINT NOT NULL,
    325     priority TINYINT,
    326     comment VARCHAR(255),
    327     PRIMARY KEY(class_id)
    328 ) ENGINE=innodb;
    329 
    330 ###
    331 
    332 INSERT INTO class VALUES(0,0, 'default class ID');
    333312
    334313###
  • trunk/Nebulous-Server/t/03_server_create_object.t

    r12960 r13092  
    33# Copryight (C) 2004-2005  Joshua Hoblitt
    44#
    5 # $Id: 03_server_create_object.t,v 1.12 2007-04-23 20:42:29 jhoblitt Exp $
     5# $Id: 03_server_create_object.t,v 1.13 2007-05-01 02:52:04 jhoblitt Exp $
    66
    77use strict;
    88use warnings FATAL => qw( all );
    99
    10 use Test::More tests => 14;
     10use Test::More tests => 8;
    1111
    1212use lib qw( ./t ./lib );
     
    3838
    3939{
    40     # key, class
    41     my $uri = $neb->create_object("foo", 0);
    42 
    43     my ($scheme, $auth, $path, $query, $frag) = uri_split($uri);
    44     ok(-e $path, "file exists");
    45     uri_scheme_ok($uri, 'file');
    46 }
    47 
    48 Test::Nebulous->setup;
    49 
    50 {
    51     # key, class, volume
    52     my $uri = $neb->create_object("foo", 0, "node01");
    53 
    54     my ($scheme, $auth, $path, $query, $frag) = uri_split($uri);
    55     ok(-e $path, "file exists");
    56     uri_scheme_ok($uri, 'file');
    57 }
    58 
    59 Test::Nebulous->setup;
    60 
    61 {
    62     # key, class, volume, comment
    63     my $uri = $neb->create_object("foo", 0, "node01", "this is foo");
     40    # key, volume
     41    my $uri = $neb->create_object("foo", "node01");
    6442
    6543    my ($scheme, $auth, $path, $query, $frag) = uri_split($uri);
     
    7856Test::Nebulous->setup;
    7957
    80 {
    81     my $uri = $neb->create_object("foo", 1);
    82 
    83     my ($scheme, $auth, $path, $query, $frag) = uri_split($uri);
    84     ok(-e $path, "class exists");
    85 }
    86 
    87 Test::Nebulous->setup;
    88 
    8958eval {
    9059    $neb->create_object("foo", 99);
    9160};
    92 like($@, qr/did not pass the \'is valid class id\'/, "class doesn't exist");
    93 
    94 Test::Nebulous->setup;
    95 
    96 eval {
    97     $neb->create_object(1, 0, 'node01', 'x' x 256);
    98 };
    99 like($@, qr/comment length/, "comment is too long");
     61like($@, qr/did not pass the \'is valid volume name\'/, "volume name doesn't exist");
    10062
    10163Test::Nebulous->setup;
     
    10466    $neb->create_object();
    10567};
    106 like($@, qr/2 - 4 were expected/, "no params");
     68like($@, qr/1 - 2 were expected/, "no params");
    10769
    10870Test::Nebulous->setup;
    10971
    11072eval {
    111     $neb->create_object( 1, 0, 'node01', 1, 1 );
     73    $neb->create_object(1, "node01", 3);
    11274};
    113 like($@, qr/2 - 4 were expected/, "too many params");
     75like($@, qr/1 - 2 were expected/, "too many params");
    11476
    11577Test::Nebulous->cleanup;
  • trunk/Nebulous-Server/t/09_server_stat_object.t

    r12646 r13092  
    33# Copryight (C) 2004-2005  Joshua Hoblitt
    44#
    5 # $Id: 09_server_stat_object.t,v 1.9 2007-03-28 22:01:37 jhoblitt Exp $
     5# $Id: 09_server_stat_object.t,v 1.10 2007-05-01 02:52:04 jhoblitt Exp $
    66
    77use strict;
    88use warnings FATAL => qw( all );
    99
    10 use Test::More tests => 13;
     10use Test::More tests => 11;
    1111
    1212use lib qw( ./t ./lib );
     
    2929    my $info = $neb->stat_object("foo");
    3030
    31     is(scalar @$info, 8, "number of columns");
     31    is(scalar @$info, 6, "number of columns");
    3232}
    3333
     
    3535
    3636{
    37     my $uri = $neb->create_object("foo", 0, "node01", "foobar");
     37    my $uri = $neb->create_object("foo", "node01");
    3838
    3939    my $info = $neb->stat_object("foo");
    4040
    41     is(scalar @$info, 8,                       "number of columns");
     41    is(scalar @$info, 6,                       "number of columns");
    4242    is(@$info[0], 1,                           "so_id");
    4343    is(@$info[1], "foo",                       "ext_id");
    44     is(@$info[2], 0,                           "class_id");
    45     is(@$info[3], "foobar",                    "comment");
    46     is(@$info[4], 0,                           "read lock");
    47     is(@$info[5], undef,                       "write lock");
    48     like(@$info[6], qr/....-..-.. ..:..:../,   "epoch");
    49     like(@$info[6], qr/....-..-.. ..:..:../,   "mtime");
     44    is(@$info[2], 0,                           "read lock");
     45    is(@$info[3], undef,                       "write lock");
     46    like(@$info[4], qr/....-..-.. ..:..:../,   "epoch");
     47    like(@$info[5], qr/....-..-.. ..:..:../,   "mtime");
    5048}
    5149
Note: See TracChangeset for help on using the changeset viewer.