0

I have a single node riak installed locally from deb. I have no other settings done other than the one that comes with installation.

 // Write objects
Location myKey = new Location(new Namespace("cars", "dodge"), "viper");
BinaryValue text = BinaryValue.create("vroom");
RiakObject obj = new RiakObject()
        .setContentType("text/plain")
        .setValue(text);
StoreValue store = new StoreValue.Builder(myKey, obj).build();
client.execute(store);

// read objects
FetchValue fetch = new FetchValue.Builder(myKey).build();
FetchValue.Response response = client.execute(fetch);
RiakObject obj = response.getValue(RiakObject.class);
System.out.println(obj.getValue());

this code already exists in basho docs. The only change I did was removing

withOption(StoreOption.W, new Quorum(3)) and withOption(FetchOption.R, new Quorum(3))

because the new client for basho does not take it.

I see that for the first time from a standalone program I am able to write and read but when I read for the second time I don't see the value. Am I missing some configuration ?

Raghuveer
  • 2,859
  • 7
  • 34
  • 66
  • First, you seem to mix up 'viperKey' with 'myKey' in the sample code. Second, make sure you don't use the default replication factor (which is n_val = 3) on your single node. Also, try 'notfound_ok=false'. – vempo Nov 10 '16 at 07:52
  • Corrected the typo, so should I set "n_val = 1" ? – Raghuveer Nov 10 '16 at 11:46
  • 1
    Check properties of the 'cars/dodge' bucket. By default Riak creates three replicas of a key, which of course does not makes sense in a single-node setup. Moreover, this creates unnecessary load on the node. I'm not sure how it works, but it looks like you may hit a replica that hasn't been copied yet if the "fetch" comes quickly after the "store", so that Riak returns "not found" (in case of "notfound_ok = true"). Also, in a single-node setup, it could be a good idea to reduce the ring size - say 'ring_size = 8'. – vempo Nov 10 '16 at 11:57
  • Were you able to solve the problem? – vempo Nov 14 '16 at 18:41
  • I tried inserting a single string and it worked. I havent tried inserting varieties of schemas though. – Raghuveer Nov 14 '16 at 18:44

0 Answers0