Index: /trunk/Nebulous/Changes
===================================================================
--- /trunk/Nebulous/Changes	(revision 17755)
+++ /trunk/Nebulous/Changes	(revision 17756)
@@ -2,4 +2,6 @@
 
 0.09
+    - change Nebulous::Client->find() to handle a volume param and to fall back
+      to searching on the ':any' volume if the first search fails
     - change open_create() to attempt to open the instance file 10 times before
       failing
Index: /trunk/Nebulous/lib/Nebulous/Client.pm
===================================================================
--- /trunk/Nebulous/lib/Nebulous/Client.pm	(revision 17755)
+++ /trunk/Nebulous/lib/Nebulous/Client.pm	(revision 17756)
@@ -1,5 +1,5 @@
 # Copyright (c) 2004-2008  Joshua Hoblitt
 #
-# $Id: Client.pm,v 1.51 2008-05-19 20:52:37 jhoblitt Exp $
+# $Id: Client.pm,v 1.52 2008-05-20 03:46:11 jhoblitt Exp $
 
 package Nebulous::Client;
@@ -671,5 +671,5 @@
     my $self = shift;
 
-    my ( $key ) = validate_pos( @_,
+    my ( $key, @params ) = validate_pos( @_,
         {
             type        => SCALAR,
@@ -684,5 +684,16 @@
     $log->debug( "entered - @_" );
 
-    my $locations = $self->find_instances( $key, undef );
+    my $locations = $self->find_instances( $key, @params );
+    unless (defined $locations) {
+        unless ($self->err =~ /no instances on storage volume/) {
+            return;
+        }
+
+        # then fall back to looking for isntances on any volume
+        $locations = $self->find_instances( $key, ':any');
+        unless (defined $locations) {
+            return;
+        }
+    }
 
     my $path;
Index: /trunk/Nebulous/t/56_client_find_instances.t
===================================================================
--- /trunk/Nebulous/t/56_client_find_instances.t	(revision 17755)
+++ /trunk/Nebulous/t/56_client_find_instances.t	(revision 17756)
@@ -3,5 +3,5 @@
 # Copryight (C) 2004-2005  Joshua Hoblitt
 #
-# $Id: 56_client_find_instances.t,v 1.1 2005-12-03 02:52:31 jhoblitt Exp $
+# $Id: 56_client_find_instances.t,v 1.2 2008-05-20 03:46:11 jhoblitt Exp $
 
 use strict;
@@ -10,5 +10,5 @@
 use Apache::Test qw( -withtestmore );
 
-plan tests => 19;
+plan tests => 29;
 
 use lib qw( ./t ./lib );
@@ -74,4 +74,66 @@
 
 {
+    # key, volume == undef
+    my $neb = Nebulous::Client->new(
+        proxy => "http://$hostport/nebulous",
+    );
+    $neb->create( "foo" );
+
+    my $locations = $neb->find_instances( "foo", undef );
+
+    is( scalar @$locations, 1, "found 1" );
+    like( @$locations[0], qr/file:/, "URIs match" );
+    ok( -e _get_file_path( @$locations[0] ), "URI matches file" );
+}
+
+Test::Nebulous->setup;
+
+{
+    # volume/key
+    my $neb = Nebulous::Client->new(
+        proxy => "http://$hostport/nebulous",
+    );
+    $neb->create( "foo" );
+
+    my $locations = $neb->find_instances( "neb://node01/foo");
+
+    is( scalar @$locations, 1, "found 1" );
+    like( @$locations[0], qr/file:/, "URIs match" );
+    ok( -e _get_file_path( @$locations[0] ), "URI matches file" );
+}
+
+Test::Nebulous->setup;
+
+{
+    # volume/key, volume override
+    my $neb = Nebulous::Client->new(
+        proxy => "http://$hostport/nebulous",
+    );
+    $neb->create( "foo", "node01" );
+
+    my $locations = $neb->find_instances( "neb://node01/foo", "node02" );
+
+    is($locations, undef, "no instances on specified volume" );
+}
+
+Test::Nebulous->setup;
+
+{
+    # volume/key, volume override
+    my $neb = Nebulous::Client->new(
+        proxy => "http://$hostport/nebulous",
+    );
+    $neb->create( "foo", "node01" );
+
+    my $locations = $neb->find_instances( "neb://node02/foo", ":any" );
+
+    is( scalar @$locations, 1, "found 1" );
+    like( @$locations[0], qr/file:/, "URIs match" );
+    ok( -e _get_file_path( @$locations[0] ), "URI matches file" );
+}
+
+Test::Nebulous->setup;
+
+{
     # key
     my $neb = Nebulous::Client->new(
Index: /trunk/Nebulous/t/57_client_find.t
===================================================================
--- /trunk/Nebulous/t/57_client_find.t	(revision 17755)
+++ /trunk/Nebulous/t/57_client_find.t	(revision 17756)
@@ -3,5 +3,5 @@
 # Copryight (C) 2004-2005  Joshua Hoblitt
 #
-# $Id: 57_client_find.t,v 1.1 2005-12-03 02:52:31 jhoblitt Exp $
+# $Id: 57_client_find.t,v 1.2 2008-05-20 03:46:11 jhoblitt Exp $
 
 use strict;
@@ -10,5 +10,5 @@
 use Apache::Test qw( -withtestmore );
 
-plan tests => 4;
+plan tests => 7;
 
 use lib qw( ./t ./lib );
@@ -37,4 +37,47 @@
 
 {
+    # key, volume
+    my $neb = Nebulous::Client->new(
+        proxy => "http://$hostport/nebulous",
+    );
+    my $uri = $neb->create( "foo", "node01" );
+
+    my $path = $neb->find( "foo", "node01" );
+
+    ok( -e $path, "file exists" );
+}
+
+Test::Nebulous->setup;
+
+{
+    # key, volume does not hold key but this works anyways ans find will fall
+    # back to looking for ":any"
+    my $neb = Nebulous::Client->new(
+        proxy => "http://$hostport/nebulous",
+    );
+    my $uri = $neb->create( "foo", "node01" );
+
+    my $path = $neb->find( "foo", "node02" );
+
+    ok( -e $path, "file exists" );
+}
+
+Test::Nebulous->setup;
+
+{
+    # key, volume :any
+    my $neb = Nebulous::Client->new(
+        proxy => "http://$hostport/nebulous",
+    );
+    my $uri = $neb->create( "foo", "node01" );
+
+    my $path = $neb->find( "foo", ":any" );
+
+    ok( -e $path, "file exists" );
+}
+
+Test::Nebulous->setup;
+
+{
     my $neb = Nebulous::Client->new(
         proxy => "http://$hostport/nebulous",
@@ -43,5 +86,5 @@
     my $path = $neb->find( "foo" );
 
-    ok( ! -e $path, "file doesn't exist" );
+    is($path, undef, "file doesn't exist" );
 }
 
@@ -55,5 +98,5 @@
     $neb->find();
 };
-like( $@, qr/1 was expected/, "no params" );
+like( $@, qr/1 - 2 were expected/, "no params" );
 
 Test::Nebulous->setup;
@@ -64,7 +107,7 @@
     );
 
-    $neb->find( "foo", "bar" );
+    $neb->find( "foo", "bar", "bong" );
 };
-like( $@, qr/1 was expected/, "too many params" );
+like( $@, qr/1 - 2 were expected/, "too many params" );
 
 Test::Nebulous->cleanup;
