1
votes

I have tried a snippet from Basho's docs which is given as below :

public class TasteOfRiak {              
public static void main(String[] args) throws UnknownHostException, ExecutionException, InterruptedException 
  {          
     RiakClient client = RiakClient.newClient(port, "IP");      
     Location location = new Location(new Namespace("Bucket"), "bucketType");   
     FetchValue fv = new FetchValue.Builder(location).build();  
     FetchValue.Response response = client.execute(fv);                     
     String value = response.getValue(String.class);    
     System.out.println(value);              
     client.shutdown();         
  }
}

But, this throws exception :

[main] ERROR com.basho.riak.client.core.RiakNode - Connection attempt failed: java.net.ConnectException: Connection timed out: no further information: Exception in thread "main" [pool-1-thread-2] INFO com.basho.riak.client.core.DefaultNodeManager - NodeManager moved node to unhealthy list; 3.34.211.202:8098 java.util.concurrent.ExecutionException: com.basho.riak.client.core.NoNodesAvailableException at com.basho.riak.client.core.FutureOperation.get(FutureOperation.java:260) at com.basho.riak.client.api.commands.CoreFutureAdapter.get(CoreFutureAdapter.java:52) at com.basho.riak.client.api.RiakCommand.execute(RiakCommand.java:89) at com.basho.riak.client.api.RiakClient.execute(RiakClient.java:293) at TasteOfRiak.main(TasteOfRiak.java:20) Caused by: com.basho.riak.client.core.NoNodesAvailableException at com.basho.riak.client.core.DefaultNodeManager.executeOnNode(DefaultNodeManager.java:95) at com.basho.riak.client.core.RiakCluster.execute(RiakCluster.java:197) at com.basho.riak.client.core.RiakCluster.retryOperation(RiakCluster.java:328) at com.basho.riak.client.core.RiakCluster.access$800(RiakCluster.java:44) at com.basho.riak.client.core.RiakCluster$RetryTask.run(RiakCluster.java:340) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) at java.util.concurrent.FutureTask.run(FutureTask.java:262) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:178) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:744)

2
tried from the given link to fetch record, gives error : [pool-1-thread-1] ERROR com.basho.riak.client.core.RiakNode - Connection attempt failed: 127.0.0.1:10017; java.net.ConnectException: Connection refused: no further information: /127.0.0.1:10017 com.basho.riak.client.core.NoNodesAvailableException - Mayank Sinha
Connection refused means that there is nothing listening at that IP and port. - Joe
Mayank, Joe is correct. Can you please confirm that you have a node of Riak running at that address (127.0.0.1)? You can check from the command line doing "riak ping". You can also check from a web browser on that local machine using 127.0.0.1:8098/stats. - Craig
@Craig Yes, Riak is running at 127.0.0.1, ping returns pong and stats output: Forbidden mochiweb+webmachine web server - Andriy Boyko

2 Answers

1
votes

Check the the riak node is running (as Craig said), and you could see the node name in etc/vm.args.

Make sure erlang node cookie correct. Erlang VM will check the cookie from other VM is match, if not, it would refuse the ping or connection request. Local cookie place in ~/.erlang.cookie, suggest to try setting VM cookie as your local cookie before connect.

Another way:

$ bin/riak console
%% set cookie
erlang:set_cookie(your_riak_node_name, your_cookie)
0
votes

The riak java client doesn't support HTTP. Make sure you are connecting using protocol buffer port. Default is 8087

Also make sure your Riak server is listening on the ip address you specify. You can edit the listeners in etc/riak/riak.conf