IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 19431


Ignore:
Timestamp:
Sep 8, 2008, 4:18:47 PM (18 years ago)
Author:
jhoblitt
Message:

start of inversion of soft volume semantics

Location:
trunk/Nebulous-Server
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Nebulous-Server/docs/setup.txt

    r13210 r19431  
    3232    chmod 0770 /data/ipp00?.?/nebulous
    3333    ls -lad /data/ipp00?.?/nebulous
     34
     35    mkdir /data/`hostname`.0/nebulous
     36    chown nobody:nebulous /data/`hostname`.0/nebulous
     37    chmod 0770 /data/`hostname`.0/nebulous
    3438
    3539=head2 Build and install the Nebulous Perl modules (see: README)
  • trunk/Nebulous-Server/lib/Nebulous/Keys.pm

    r18451 r19431  
    11# Copyright (c) 2004  Joshua Hoblitt
    22#
    3 # $Id: Keys.pm,v 1.2 2008-07-09 23:32:35 jhoblitt Exp $
     3# $Id: Keys.pm,v 1.3 2008-09-09 02:18:47 jhoblitt Exp $
    44
    55package Nebulous::Keys;
     
    88use warnings FATAL => qw( all );
    99
    10 our $VERSION = '0.01';
     10our $VERSION = '0.02';
    1111
    1212use base qw( Exporter Class::Accessor::Fast );
     
    9999    my $soft_volume;
    100100    # check to see if there is a tilde and remove it if found
    101     if (defined $volume and $volume =~ s/^~//) {
     101    unless (defined $volume and $volume =~ s/^~//) {
    102102        $soft_volume = 1;
    103103    }
  • trunk/Nebulous-Server/lib/Nebulous/Server.pm

    r19144 r19431  
    11# Copyright (c) 2004-2008  Joshua Hoblitt
    22#
    3 # $Id: Server.pm,v 1.83 2008-08-21 02:26:58 jhoblitt Exp $
     3# $Id: Server.pm,v 1.84 2008-09-09 02:18:47 jhoblitt Exp $
    44
    55package Nebulous::Server;
     
    150150        {
    151151            type        => SCALAR|UNDEF,
    152             callbacks   => {
    153                 # check that the volume requested is valid
    154                 'is valid volume name' => sub {
    155                     return 1 if not defined $_[0];
    156                     $self->_is_valid_volume_name($_[0])
    157                 },
    158             },
     152#            callbacks   => {
     153#                # check that the volume requested is valid
     154#                'is valid volume name' => sub {
     155#                    return 1 if not defined $_[0];
     156#                    $self->_is_valid_volume_name($_[0])
     157#                },
     158#            },
    159159            optional    => 1,
    160160        },
     
    167167    $log->debug( "entered - @_" );
    168168
     169    # vol_name overrides the key implied volume
    169170    $key = parse_neb_key($key, $vol_name);
    170     # vol_name overrides the key implied volume
    171     $vol_name = $key->volume;
    172 
    173     # the key isn't validiated on input for this method so we have to check it
    174     # again after parsing the key
    175     if (defined $vol_name and not $self->_is_valid_volume_name($vol_name)) {
     171
     172    if ($vol_name eq "99") {
     173        use Data::Dumper;
     174        print Dumper($key);
     175    }
     176
     177    # the key's volume can't be validiated on input for this method so we have
     178    # to check it after parsing the key
     179    if (defined $key->volume
     180        and not $key->soft_volume
     181        and not $self->_is_valid_volume_name($key->volume)
     182    ) {
    176183        $log->logdie("$vol_name is not a valid volume name");
    177184    }
    178185       
    179     if (defined $key->soft_volume) {
    180         $vol_name = undef;
    181     }
    182 
    183186    my ($vol_id, $vol_host, $vol_path, $vol_xattr)
    184         = $self->_get_storage_volume($vol_name);
     187        = $self->_get_storage_volume($key->volume, $key->soft_volume);
    185188
    186189    my $uri;
     
    330333        {
    331334            type        => SCALAR|UNDEF,
    332             callbacks   => {
    333                 # check that the volume name requested is valid
    334                 'is valid volume name' => sub {
    335                     return 1 if not defined $_[0];
    336                     $self->_is_valid_volume_name($_[0])
    337                 },
    338             },
     335#            callbacks   => {
     336#                # check that the volume name requested is valid
     337#                'is valid volume name' => sub {
     338#                    return 1 if not defined $_[0];
     339#                    $self->_is_valid_volume_name($_[0])
     340#                },
     341#            },
    339342            optional    => 1,
    340343        },
     
    11641167    use warnings;
    11651168
    1166     my $name = shift;
     1169    my ($name, $soft_volume) = @_;
    11671170
    11681171    my ($vol_id, $vol_host, $vol_path, $xattr);
     
    11781181            unless ($rows > 0) {
    11791182                $query->finish;
     1183
     1184                # if a volume name was specified, and is soft, and we failed to
     1185                # find it, fall back to any volume
     1186                if ($soft_volume) {
     1187                    return $self->_get_storage_volume;
     1188                }
    11801189                $log->logdie("storage volume: $name is not available");
    11811190            }
  • trunk/Nebulous-Server/t/03_server_create_object.t

    r18452 r19431  
    33# Copryight (C) 2004-2005  Joshua Hoblitt
    44#
    5 # $Id: 03_server_create_object.t,v 1.27 2008-07-10 00:20:02 jhoblitt Exp $
     5# $Id: 03_server_create_object.t,v 1.28 2008-09-09 02:18:47 jhoblitt Exp $
    66
    77use strict;
     
    353353
    354354eval {
    355     $neb->create_object("foo", 'node03');
     355    $neb->create_object("foo", '~node03');
    356356};
    357357like($@, qr/node03 is not available/, "request volume this is full");
     
    360360
    361361eval {
    362     $neb->create_object("neb://node03/foo");
     362    $neb->create_object("neb://~node03/foo");
    363363};
    364364like($@, qr/node03 is not available/, "request volume this is full");
     
    367367
    368368eval {
    369     $neb->create_object("foo", 'node04');
     369    $neb->create_object("foo", '~node04');
    370370};
    371371like($@, qr/node04 is not available/, "request volume with allocate = FALSE, available = FALSE");
     
    374374
    375375eval {
    376     $neb->create_object("neb://node04/foo");
     376    $neb->create_object("neb://~node04/foo");
    377377};
    378378like($@, qr/node04 is not available/, "request volume with allocate = FALSE, available = FALSE");
     
    381381
    382382eval {
    383     $neb->create_object("foo", 'node05');
     383    $neb->create_object("foo", '~node05');
    384384};
    385385like($@, qr/node05 is not available/, "request volume with allocate = FALSE , available = TRUE");
     
    388388
    389389eval {
    390     $neb->create_object("neb://node05/foo");
     390    $neb->create_object("neb://~node05/foo");
    391391};
    392392like($@, qr/node05 is not available/, "request volume with allocate = FALSE , available = TRUE");
     
    395395
    396396eval {
    397     $neb->create_object("foo", 'node06');
     397    $neb->create_object("foo", '~node06');
    398398};
    399399like($@, qr/node06 is not available/, "request volume with allocate = TRUE, available = FALSE");
     
    402402
    403403eval {
    404     $neb->create_object("neb://node06/foo");
     404    $neb->create_object("neb://~node06/foo");
    405405};
    406406like($@, qr/node06 is not available/, "request volume with allocate = TRUE, available = FALSE");
     
    408408Test::Nebulous->setup;
    409409
    410 eval {
    411     $neb->create_object("foo", 99);
    412 };
    413 like($@, qr/did not pass the \'is valid volume name\'/, "volume name doesn't exist");
     410{
     411    ok($neb->create_object("foo", 99));
     412}
     413
     414Test::Nebulous->setup;
     415
     416eval {
     417    $neb->create_object("foo", "~99");
     418};
     419like($@, qr/is not a valid volume name/, "volume name doesn't exist");
    414420
    415421Test::Nebulous->setup;
  • trunk/Nebulous-Server/t/04_server_replicate_object.t

    r18452 r19431  
    33# Copryight (C) 2004-2005  Joshua Hoblitt
    44#
    5 # $Id: 04_server_replicate_object.t,v 1.14 2008-07-10 00:20:02 jhoblitt Exp $
     5# $Id: 04_server_replicate_object.t,v 1.15 2008-09-09 02:18:47 jhoblitt Exp $
    66
    77use strict;
    88use warnings FATAL => qw( all );
    99
    10 use Test::More tests => 25;
     10use Test::More tests => 26;
    1111
    1212use lib qw( ./t ./lib );
     
    8282    # key, $volume
    8383    $neb->create_object("foo");
    84     my $uri1 = $neb->replicate_object("foo", "node01");
    85     my $uri2 = $neb->replicate_object("foo", "node02");
     84    my $uri1 = $neb->replicate_object("foo", "~node01");
     85    my $uri2 = $neb->replicate_object("foo", "~node02");
    8686
    8787    {
     
    155155Test::Nebulous->setup;
    156156
     157{
     158    $neb->create_object('foo');
     159    ok($neb->replicate_object('foo', 'bar'),'soft fake storage volume');
     160}
     161
     162Test::Nebulous->setup;
     163
    157164eval {
    158165    $neb->create_object('foo');
    159     $neb->replicate_object('foo', 'bar');
     166    $neb->replicate_object('foo', '~bar');
    160167};
    161 like($@, qr/is valid volume name/, 'storage volume does not exist');
     168like($@, qr/is not a valid volume name/, 'storage volume does not exist');
    162169
    163170Test::Nebulous->setup;
  • trunk/Nebulous-Server/t/75_parse_neb_key.t

    r18451 r19431  
    33# Copryight (C) 2004-2005  Joshua Hoblitt
    44#
    5 # $Id: 75_parse_neb_key.t,v 1.4 2008-07-09 23:32:35 jhoblitt Exp $
     5# $Id: 75_parse_neb_key.t,v 1.5 2008-09-09 02:18:47 jhoblitt Exp $
    66
    77use strict;
     
    7777    is($key->path, 'foo/bar/baz/quix', 'path');
    7878    is($key->volume, 'boing', 'volume name');
    79     is($key->soft_volume, undef, 'soft volume name');
     79    is($key->soft_volume, 1, 'soft volume name');
    8080}
    8181
     
    8585    is($key->path, 'foo/bar/baz/quix', 'path');
    8686    is($key->volume, 'boing', 'volume name');
    87     is($key->soft_volume, 1, 'soft volume name');
     87    is($key->soft_volume, undef, 'soft volume name');
    8888}
    8989
     
    9494    is($key->path, 'bar/baz/quix', 'path');
    9595    is($key->volume, 'foo', 'volume name');
    96     is($key->soft_volume, undef, 'soft volume name');
     96    is($key->soft_volume, 1, 'soft volume name');
    9797}
    9898
     
    102102    is($key->path, 'bar/baz/quix', 'path');
    103103    is($key->volume, 'foo', 'volume name');
    104     is($key->soft_volume, undef, 'soft volume name');
     104    is($key->soft_volume, 1, 'soft volume name');
    105105}
    106106
     
    110110    is($key->path, 'bar/baz/quix', 'path');
    111111    is($key->volume, 'foo', 'volume name');
    112     is($key->soft_volume, undef, 'soft volume name');
     112    is($key->soft_volume, 1, 'soft volume name');
    113113}
    114114
     
    118118    is($key->path, 'bar/baz/quix', 'path');
    119119    is($key->volume, 'foo', 'volume name');
    120     is($key->soft_volume, undef, 'soft volume name');
     120    is($key->soft_volume, 1, 'soft volume name');
    121121}
    122122
     
    126126    is($key->path, 'bar/baz/quix', 'path');
    127127    is($key->volume, 'foo', 'volume name');
    128     is($key->soft_volume, undef, 'soft volume name');
    129 }
    130 
    131 # URI w/ soft volume name
     128    is($key->soft_volume, 1, 'soft volume name');
     129}
     130
     131# URI w/ hard volume name
    132132{
    133133    my $key = parse_neb_key('neb://~foo/bar/baz/quix/');
     
    135135    is($key->path, 'bar/baz/quix', 'path');
    136136    is($key->volume, 'foo', 'volume name');
    137     is($key->soft_volume, 1, 'soft volume name');
     137    is($key->soft_volume, undef, 'soft volume name');
    138138}
    139139
     
    144144    is($key->path, 'bar/baz/quix', 'path');
    145145    is($key->volume, 'boing', 'volume name');
    146     is($key->soft_volume, undef, 'soft volume name');
     146    is($key->soft_volume, 1, 'soft volume name');
    147147}
    148148
     
    152152    is($key->path, 'bar/baz/quix', 'path');
    153153    is($key->volume, 'boing', 'volume name');
    154     is($key->soft_volume, 1, 'soft volume name');
     154    is($key->soft_volume, undef, 'soft volume name');
    155155}
    156156
     
    160160    is($key->path, 'bar/baz/quix', 'path');
    161161    is($key->volume, 'foo', 'volume name');
    162     is($key->soft_volume, undef, 'soft volume name');
     162    is($key->soft_volume, 1, 'soft volume name');
    163163}
    164164
     
    189189}
    190190
    191 # URI w/ soft volume name
     191# URI w/ hard volume name
    192192{
    193193    my $key = parse_neb_key('neb://~foo/bar/baz/quix/');
     
    195195    is($key->path, 'bar/baz/quix', 'path');
    196196    is($key->volume, 'foo', 'volume name');
    197     is($key->soft_volume, 1, 'soft volume name');
     197    is($key->soft_volume, undef, 'soft volume name');
    198198}
    199199
Note: See TracChangeset for help on using the changeset viewer.