java driver : lisKeys() returned also deleted keys

Andy Gross andy at basho.com
Sat Nov 20 14:34:03 EST 2010


Hi Andrea,

Key deletion in Riak doesn't occur immediately in Riak - keys are first
marked with a tombstone marker and then reaped asynchronously.   If you
insert a sleep between the delete() and keys() calls (try a few seconds) -
does the test pass?

- Andy


On Sat, Nov 20, 2010 at 10:02 AM, Andrea Campolonghi <acampolonghi at gmail.com
> wrote:

> I am having this issues with the java driver :
> https://github.com/krestenkrab/riak-java-pb-client
>
> After deleting a key the listKeys method still return it.
> The following test case put and delete one simple key and fails when
> counting the listKeys item.
>
> Any Suggestion?
>
> public class RiakCacheTest extends TestCase {
>
>  private RiakClient rc;
>
> private String host = "172.16.194.134";
>
> private int port = 8087;
>
> private String bucket = "bucket";
>
>   @Override
>
> protected void setUp() throws Exception {
>
>  rc = new RiakClient(this.host,this.port);
>
>  rc.setClientID(this.getClass().toString());
>
> }
>
>   public void testRemove(){
>
>  String key = "key";
>
>  String value = "Andrea";
>
>   RiakObject obj = new RiakObject(this.bucket, key, value);
>
>   try{
>
>  this.rc.store(obj);
>
>  assertTrue(getValue(key).equals(value));
>
>  assertEquals(keys().size(),1);
>
>    this.rc.delete(this.bucket, key);
>
>  assertNull(getValue(key));
>
>  assertEquals(keys().size(),0);
>
>    }catch(IOException e){
>
>  e.printStackTrace();
>
>  }
>
>   }
>
>  private String getValue(String key){
>
>  String fetched = "";
>
>  try{
>
>  RiakObject[] ros = this.rc.fetch(this.bucket, key);
>
>  for(RiakObject ro : ros){
>
>   return ro.getValue().toStringUtf8();
>
>  }
>
>  }catch(IOException e){
>
>  e.printStackTrace();
>
>  }
>
>  return null;
>
> }
>
>
>  private List keys() {
>
>  ArrayList<String> result = new ArrayList<String>();
>
>  ByteString bucket = ByteString.copyFromUtf8(this.bucket);
>
>   try{
>
>   KeySource keys = this.rc.listKeys(bucket);
>
>   while(keys.hasNext()){
>
>   String key = keys.next().toStringUtf8();
>
>   result.add(key);
>
>   }
>
>  }catch(IOException e){
>
>  e.printStackTrace();
>
>  }
>
>  return result;
>
> }
>
>
> }
>
> --
> Andrea Campolonghi
>
> Cell : +39 347 2298435
> acampolonghi at gmail.com
> andrea at andreacfm.com
> http://www.andreacfm.com
>
> Railo Team
> andrea at getrailo.org
> http://getrailo.org
>
>
>
> _______________________________________________
> riak-users mailing list
> riak-users at lists.basho.com
> http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.basho.com/pipermail/riak-users_lists.basho.com/attachments/20101120/f5434b61/attachment.html>


More information about the riak-users mailing list