IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 19493


Ignore:
Timestamp:
Sep 11, 2008, 12:35:52 PM (18 years ago)
Author:
jhoblitt
Message:

invert soft volume semantics

Location:
trunk/Nebulous-Server
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Nebulous-Server/Changes

    r19144 r19493  
    11Revision history for Nebulous
     2
     30.15
     4    - invert soft volume semantics
    25
    360.14 Wed Aug 20 16:25:43 HST 2008
  • trunk/Nebulous-Server/lib/Nebulous/Server.pm

    r19473 r19493  
    11# Copyright (c) 2004-2008  Joshua Hoblitt
    22#
    3 # $Id: Server.pm,v 1.85 2008-09-10 23:55:54 bills Exp $
     3# $Id: Server.pm,v 1.86 2008-09-11 22:35:52 jhoblitt Exp $
    44
    55package Nebulous::Server;
     
    169169    # vol_name overrides the key implied volume
    170170    $key = parse_neb_key($key, $vol_name);
    171 
    172     if ($vol_name eq "99") {
    173         use Data::Dumper;
    174         print Dumper($key);
    175     }
     171    $vol_name = $key->volume;
    176172
    177173    # the key's volume can't be validiated on input for this method so we have
    178174    # 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     ) {
    183         $log->logdie("$vol_name is not a valid volume name");
     175    if (defined $vol_name
     176        and not $self->_is_valid_volume_name($key->volume)) {
     177        if ($key->soft_volume) {
     178            $log->warn( "$vol_name is not a known volume name" );
     179            $vol_name = undef;
     180        } else {
     181            die "$vol_name is not a valid volume name"
     182        }
    184183    }
    185184       
    186185    my ($vol_id, $vol_host, $vol_path, $vol_xattr)
    187         = $self->_get_storage_volume($key->volume, $key->soft_volume);
     186        = $self->_get_storage_volume($vol_name, $key->soft_volume);
    188187
    189188    my $uri;
     
    252251    };
    253252    if ($@) {
     253#        and not $key->soft_volume
    254254        $db->rollback;
    255255        $log->debug("rollback");
     
    358358    $log->debug("entered - @_");
    359359
     360    # vol_name overrides the key implied volume
    360361    $key = parse_neb_key($key, $vol_name);
    361     # vol_name overrides the key implied volume
    362362    $vol_name = $key->volume;
    363363
    364     if (defined $key->soft_volume) {
    365         $vol_name = undef;
    366     }
    367 
    368     if (defined $vol_name and !$self->_is_valid_volume_name($vol_name)) {
    369         die "$vol_name is not a valid volume name"
     364    if (defined $vol_name
     365        and not $self->_is_valid_volume_name($key->volume)) {
     366        if ($key->soft_volume) {
     367            $log->warn( "$vol_name is not a known volume name" );
     368            $vol_name = undef;
     369        } else {
     370            die "$vol_name is not a valid volume name"
     371        }
    370372    }
    371373       
     
    430432    if ($@) {
    431433        $db->rollback;
     434        # handle soft volumes
     435        if (defined $vol_name and defined $key->soft_volume) {
     436            $log->debug("retrying with 'any' volume");
     437            return $self->replicate_object($key->path, 'any');
     438        }
    432439        $log->debug("rollback");
    433440        $log->logdie("error: $@");
     
    928935        {
    929936            type        => SCALAR|UNDEF,
    930             callbacks   => {
    931                 # check that the volume name requested is valid
    932                 'is valid volume name' => sub {
    933                     return 1 if not defined $_[0];
    934                     $self->_is_valid_volume_name($_[0])
    935                 },
    936             },
     937#            callbacks   => {
     938#                # check that the volume name requested is valid
     939#                'is valid volume name' => sub {
     940#                    return 1 if not defined $_[0];
     941#                    $self->_is_valid_volume_name($_[0])
     942#                },
     943#            },
    937944            optional    => 1,
    938945        },
     
    945952    $log->debug("entered - @_");
    946953
     954    # vol_name overrides the key implied volume
    947955    $key = parse_neb_key($key, $vol_name);
    948     # vol_name overrides the key implied volume
    949956    $vol_name = $key->volume;
    950957
    951     # handle soft volumes
    952     if (defined $key->soft_volume) {
    953         $vol_name = undef;
     958    # the key's volume can't be validiated on input for this method so we have
     959    # to check it after parsing the key
     960    if (defined $vol_name
     961        and not $self->_is_valid_volume_name($key->volume)) {
     962        if ($key->soft_volume) {
     963            $log->warn( "$vol_name is not a known volume name" );
     964            $vol_name = undef;
     965        } else {
     966            die "$vol_name is not a valid volume name"
     967        }
    954968    }
    955969
     
    980994        }
    981995    };
    982     $log->logdie("database error: $@") if $@;
     996    if ($@) {
     997        $db->rollback;
     998        # handle soft volumes
     999        if (defined $vol_name and defined $key->soft_volume) {
     1000            $log->debug("retrying with 'any' volume");
     1001            return $self->find_instances($key->path, 'any');
     1002        }
     1003        $log->logdie("database error: $@");
     1004    }
    9831005
    9841006    # XXX remove this?
     
    11711193    my ($vol_id, $vol_host, $vol_path, $xattr);
    11721194    eval {
    1173         # TODO cache this?
    11741195        my $query;
    11751196        my $rows;
  • trunk/Nebulous-Server/lib/Test/Nebulous.pm

    r19491 r19493  
    11# Copyright (C) 2004  Joshua Hoblitt
    22#
    3 # $Id: Nebulous.pm,v 1.3 2008-09-11 21:18:35 bills Exp $
     3# $Id: Nebulous.pm,v 1.4 2008-09-11 22:35:52 jhoblitt Exp $
    44
    55package Test::Nebulous;
     
    3232my $dir5 = "";
    3333my $dir6 = "";
     34my $dir7 = "";
    3435
    3536sub setup {
     
    4546    $dir5 = tempdir( CLEANUP => 0 );
    4647    $dir6 = tempdir( CLEANUP => 0 );
     48    $dir7 = tempdir( CLEANUP => 0 );
    4749
    4850    foreach my $statement (@{ $sql->get_db_schema }) {
     
    7072
    7173    # node06: allocate = TRUE, available = FALSE
    72     $dbh->do(qq{ INSERT INTO volume (vol_id, name, host, path, allocate, available) VALUES (6, 'node06', 'node06', ?, TRUE, FALSE) }, undef, $dir4);
     74    $dbh->do(qq{ INSERT INTO volume (vol_id, name, host, path, allocate, available) VALUES (6, 'node06', 'node06', ?, TRUE, FALSE) }, undef, $dir6);
    7375    $dbh->do(qq{ INSERT INTO mount VALUES (?, 10e10, 10e7) }, undef, $dir6);
     76
     77    # node07: full
     78    $dbh->do(qq{ INSERT INTO volume (vol_id, name, host, path, allocate, available) VALUES (7, 'node07', 'node07', ?, TRUE, TRUE) }, undef, $dir7);
     79    $dbh->do(qq{ INSERT INTO mount VALUES (?, 10e10, 10e10) }, undef, $dir7);
    7480
    7581    $dbh->do(qq{ call getmountedvol() });
     
    8894    rmtree([$dir5], 0, 1) if -e $dir5;
    8995    rmtree([$dir6], 0, 1) if -e $dir6;
     96    rmtree([$dir7], 0, 1) if -e $dir7;
    9097}
    9198
  • trunk/Nebulous-Server/t/03_server_create_object.t

    r19470 r19493  
    33# Copryight (C) 2004-2005  Joshua Hoblitt
    44#
    5 # $Id: 03_server_create_object.t,v 1.29 2008-09-10 23:53:23 bills Exp $
     5# $Id: 03_server_create_object.t,v 1.30 2008-09-11 22:35:52 jhoblitt Exp $
    66
    77use strict;
     
    353353
    354354eval {
    355     $neb->create_object("foo", '~node03');
    356 };
    357 like($@, qr/node03 is not available/, "request volume this is full");
    358 
    359 Test::Nebulous->setup;
    360 
    361 eval {
    362     $neb->create_object("neb://~node03/foo");
    363 };
    364 like($@, qr/node03 is not available/, "request volume this is full");
     355    $neb->create_object("foo", '~node07');
     356};
     357like($@, qr/node07 is not available/, "request volume this is full");
     358
     359Test::Nebulous->setup;
     360
     361eval {
     362    $neb->create_object("neb://~node07/foo");
     363};
     364like($@, qr/node07 is not available/, "request volume this is full");
    365365
    366366Test::Nebulous->setup;
  • trunk/Nebulous-Server/t/04_server_replicate_object.t

    r19431 r19493  
    33# Copryight (C) 2004-2005  Joshua Hoblitt
    44#
    5 # $Id: 04_server_replicate_object.t,v 1.15 2008-09-09 02:18:47 jhoblitt Exp $
     5# $Id: 04_server_replicate_object.t,v 1.16 2008-09-11 22:35:52 jhoblitt Exp $
    66
    77use strict;
     
    155155Test::Nebulous->setup;
    156156
    157 {
     157eval {
    158158    $neb->create_object('foo');
    159159    ok($neb->replicate_object('foo', 'bar'),'soft fake storage volume');
    160 }
     160};
    161161
    162162Test::Nebulous->setup;
  • trunk/Nebulous-Server/t/07_server_find_instances.t

    r19471 r19493  
    33# Copryight (C) 2004-2005  Joshua Hoblitt
    44#
    5 # $Id: 07_server_find_instances.t,v 1.15 2008-09-10 23:54:22 bills Exp $
     5# $Id: 07_server_find_instances.t,v 1.16 2008-09-11 22:35:52 jhoblitt Exp $
    66
    77use strict;
     
    121121eval {
    122122    $neb->create_object('foo');
    123     $neb->find_instances('foo', 'bar');
     123    $neb->find_instances('foo', '~bar');
    124124};
    125 like($@, qr/is valid volume name/, "storage volume does not exist");
     125like($@, qr/is not a valid volume name/, "storage volume does not exist");
    126126
    127127Test::Nebulous->setup;
  • trunk/Nebulous-Server/t/15_mounts.t

    r18389 r19493  
    33# Copryight (C) 2008  Joshua Hoblitt
    44#
    5 # $Id: 15_mounts.t,v 1.2 2008-07-01 00:28:07 jhoblitt Exp $
     5# $Id: 15_mounts.t,v 1.3 2008-09-11 22:35:52 jhoblitt Exp $
    66
    77use strict;
     
    2828    my $mounts = $neb->mounts();
    2929
    30     is(scalar @$mounts, 6, "number of rows");
     30    is(scalar @$mounts, 7, "number of rows");
    3131
    3232    my %row;
Note: See TracChangeset for help on using the changeset viewer.