1

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();
    }
}
Dark Knight
  • 503
  • 2
  • 12
  • 25
  • 1
    The peer has closed the connection. – user207421 Dec 03 '13 at 07:18
  • what do you mean? We are using localhost and I can see that our riak server is up and running! Can you please explain? (Sorry I'm kinda new to riak) – Dark Knight Dec 03 '13 at 07:19
  • 1
    What I mean is that the peer application, presumably the Riak server, has closed the connection which your code is reading from, which causes it to throw EOFException. Seems perfectly clear to me. – user207421 Dec 03 '13 at 07:28

3 Answers3

1

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!

Dark Knight
  • 503
  • 2
  • 12
  • 25
0

Signals that an end of file or end of stream has been reached unexpectedly during input. This exception is mainly used by data input streams to signal end of stream. Note that many other input operations return a special value on end of stream rather than throwing an exception.

and you can see that as below http://docs.oracle.com/javase/7/docs/api/java/io/EOFException.html

0

The port is 8087 because you're using pbcclient. That's correct. In case of using the httpclient, the default port is 8098. That's what you were confused. And so was I, hehe.