Changeset 17756
- Timestamp:
- May 19, 2008, 5:46:11 PM (18 years ago)
- Location:
- trunk/Nebulous
- Files:
-
- 4 edited
-
Changes (modified) (1 diff)
-
lib/Nebulous/Client.pm (modified) (3 diffs)
-
t/56_client_find_instances.t (modified) (3 diffs)
-
t/57_client_find.t (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Nebulous/Changes
r17725 r17756 2 2 3 3 0.09 4 - change Nebulous::Client->find() to handle a volume param and to fall back 5 to searching on the ':any' volume if the first search fails 4 6 - change open_create() to attempt to open the instance file 10 times before 5 7 failing -
trunk/Nebulous/lib/Nebulous/Client.pm
r17737 r17756 1 1 # Copyright (c) 2004-2008 Joshua Hoblitt 2 2 # 3 # $Id: Client.pm,v 1.5 1 2008-05-19 20:52:37jhoblitt Exp $3 # $Id: Client.pm,v 1.52 2008-05-20 03:46:11 jhoblitt Exp $ 4 4 5 5 package Nebulous::Client; … … 671 671 my $self = shift; 672 672 673 my ( $key ) = validate_pos( @_,673 my ( $key, @params ) = validate_pos( @_, 674 674 { 675 675 type => SCALAR, … … 684 684 $log->debug( "entered - @_" ); 685 685 686 my $locations = $self->find_instances( $key, undef ); 686 my $locations = $self->find_instances( $key, @params ); 687 unless (defined $locations) { 688 unless ($self->err =~ /no instances on storage volume/) { 689 return; 690 } 691 692 # then fall back to looking for isntances on any volume 693 $locations = $self->find_instances( $key, ':any'); 694 unless (defined $locations) { 695 return; 696 } 697 } 687 698 688 699 my $path; -
trunk/Nebulous/t/56_client_find_instances.t
r5667 r17756 3 3 # Copryight (C) 2004-2005 Joshua Hoblitt 4 4 # 5 # $Id: 56_client_find_instances.t,v 1. 1 2005-12-03 02:52:31 jhoblitt Exp $5 # $Id: 56_client_find_instances.t,v 1.2 2008-05-20 03:46:11 jhoblitt Exp $ 6 6 7 7 use strict; … … 10 10 use Apache::Test qw( -withtestmore ); 11 11 12 plan tests => 19;12 plan tests => 29; 13 13 14 14 use lib qw( ./t ./lib ); … … 74 74 75 75 { 76 # key, volume == undef 77 my $neb = Nebulous::Client->new( 78 proxy => "http://$hostport/nebulous", 79 ); 80 $neb->create( "foo" ); 81 82 my $locations = $neb->find_instances( "foo", undef ); 83 84 is( scalar @$locations, 1, "found 1" ); 85 like( @$locations[0], qr/file:/, "URIs match" ); 86 ok( -e _get_file_path( @$locations[0] ), "URI matches file" ); 87 } 88 89 Test::Nebulous->setup; 90 91 { 92 # volume/key 93 my $neb = Nebulous::Client->new( 94 proxy => "http://$hostport/nebulous", 95 ); 96 $neb->create( "foo" ); 97 98 my $locations = $neb->find_instances( "neb://node01/foo"); 99 100 is( scalar @$locations, 1, "found 1" ); 101 like( @$locations[0], qr/file:/, "URIs match" ); 102 ok( -e _get_file_path( @$locations[0] ), "URI matches file" ); 103 } 104 105 Test::Nebulous->setup; 106 107 { 108 # volume/key, volume override 109 my $neb = Nebulous::Client->new( 110 proxy => "http://$hostport/nebulous", 111 ); 112 $neb->create( "foo", "node01" ); 113 114 my $locations = $neb->find_instances( "neb://node01/foo", "node02" ); 115 116 is($locations, undef, "no instances on specified volume" ); 117 } 118 119 Test::Nebulous->setup; 120 121 { 122 # volume/key, volume override 123 my $neb = Nebulous::Client->new( 124 proxy => "http://$hostport/nebulous", 125 ); 126 $neb->create( "foo", "node01" ); 127 128 my $locations = $neb->find_instances( "neb://node02/foo", ":any" ); 129 130 is( scalar @$locations, 1, "found 1" ); 131 like( @$locations[0], qr/file:/, "URIs match" ); 132 ok( -e _get_file_path( @$locations[0] ), "URI matches file" ); 133 } 134 135 Test::Nebulous->setup; 136 137 { 76 138 # key 77 139 my $neb = Nebulous::Client->new( -
trunk/Nebulous/t/57_client_find.t
r5667 r17756 3 3 # Copryight (C) 2004-2005 Joshua Hoblitt 4 4 # 5 # $Id: 57_client_find.t,v 1. 1 2005-12-03 02:52:31 jhoblitt Exp $5 # $Id: 57_client_find.t,v 1.2 2008-05-20 03:46:11 jhoblitt Exp $ 6 6 7 7 use strict; … … 10 10 use Apache::Test qw( -withtestmore ); 11 11 12 plan tests => 4;12 plan tests => 7; 13 13 14 14 use lib qw( ./t ./lib ); … … 37 37 38 38 { 39 # key, volume 40 my $neb = Nebulous::Client->new( 41 proxy => "http://$hostport/nebulous", 42 ); 43 my $uri = $neb->create( "foo", "node01" ); 44 45 my $path = $neb->find( "foo", "node01" ); 46 47 ok( -e $path, "file exists" ); 48 } 49 50 Test::Nebulous->setup; 51 52 { 53 # key, volume does not hold key but this works anyways ans find will fall 54 # back to looking for ":any" 55 my $neb = Nebulous::Client->new( 56 proxy => "http://$hostport/nebulous", 57 ); 58 my $uri = $neb->create( "foo", "node01" ); 59 60 my $path = $neb->find( "foo", "node02" ); 61 62 ok( -e $path, "file exists" ); 63 } 64 65 Test::Nebulous->setup; 66 67 { 68 # key, volume :any 69 my $neb = Nebulous::Client->new( 70 proxy => "http://$hostport/nebulous", 71 ); 72 my $uri = $neb->create( "foo", "node01" ); 73 74 my $path = $neb->find( "foo", ":any" ); 75 76 ok( -e $path, "file exists" ); 77 } 78 79 Test::Nebulous->setup; 80 81 { 39 82 my $neb = Nebulous::Client->new( 40 83 proxy => "http://$hostport/nebulous", … … 43 86 my $path = $neb->find( "foo" ); 44 87 45 ok( ! -e $path, "file doesn't exist" );88 is($path, undef, "file doesn't exist" ); 46 89 } 47 90 … … 55 98 $neb->find(); 56 99 }; 57 like( $@, qr/1 wasexpected/, "no params" );100 like( $@, qr/1 - 2 were expected/, "no params" ); 58 101 59 102 Test::Nebulous->setup; … … 64 107 ); 65 108 66 $neb->find( "foo", "bar" );109 $neb->find( "foo", "bar", "bong" ); 67 110 }; 68 like( $@, qr/1 wasexpected/, "too many params" );111 like( $@, qr/1 - 2 were expected/, "too many params" ); 69 112 70 113 Test::Nebulous->cleanup;
Note:
See TracChangeset
for help on using the changeset viewer.
