I am trying to execute a simple fetching of data as a string from Riak.
We are trying to execute a sample code and we are getting the error. It's a Java code written for fetching data from Riak
I made sure riak is running by Sudo Riak Start
Error as follows:
Exception in thread "main" com.basho.riak.client.RiakRetryFailedException: java.io.EOFException
at com.basho.riak.client.cap.DefaultRetrier.attempt(DefaultRetrier.java:79)
at com.basho.riak.client.cap.DefaultRetrier.attempt(DefaultRetrier.java:81)
at com.basho.riak.client.cap.DefaultRetrier.attempt(DefaultRetrier.java:81)
at com.basho.riak.client.cap.DefaultRetrier.attempt(DefaultRetrier.java:81)
at com.basho.riak.client.cap.DefaultRetrier.attempt(DefaultRetrier.java:53)
at com.basho.riak.client.bucket.FetchBucket.execute(FetchBucket.java:72)
at riak.App.main(App.java:15)
Caused by: java.io.EOFException
at java.io.DataInputStream.readInt(DataInputStream.java:392)
at com.basho.riak.pbc.RiakConnection.receive(RiakConnection.java:110)
at com.basho.riak.pbc.RiakClient.getBucketProperties(RiakClient.java:697)
at com.basho.riak.client.raw.pbc.PBClientAdapter.fetchBucket(PBClientAdapter.java:249)
at com.basho.riak.client.bucket.FetchBucket$1.call(FetchBucket.java:74)
at com.basho.riak.client.bucket.FetchBucket$1.call(FetchBucket.java:1)
at com.basho.riak.client.cap.DefaultRetrier.attempt(DefaultRetrier.java:72)
... 6 more
Sample code:
package riak;
import com.basho.riak.client.IRiakClient;
import com.basho.riak.client.IRiakObject;
import com.basho.riak.client.RiakException;
import com.basho.riak.client.RiakFactory;
import com.basho.riak.client.bucket.Bucket;
public class App
{
public static void main(String[] args) throws RiakException
{
//IRiakClient riakClient = RiakFactory.httpClient();
IRiakClient client = RiakFactory.pbcClient("127.0.0.1", 8098);
Bucket myBucket = client.fetchBucket("TestBucket").execute();
IRiakObject myObject = myBucket.fetch("TestKey").execute();
// note that getValueAsString() will return null here if there's no value in Riak
System.out.println(myObject.getValueAsString());
client.shutdown();
}
}
Thank you so much for all your help.
I have found the problem!
My port # was 8087 instead of 8098
We need to configure that in /etc/riak/app.conf (Under API settings)
I have reconfigured that and It fixed it.
Thank you!