0

I am using Java Couchbase client version 1.4.6

We have couple of nodes for HA.

Problem is that if one nodes go down the client doesnt try next ones and just keep trying the first one it succedded to connect(before it went down)

Any idea how I can set the client to jump over to the next couchbase node in cluster?

This is how I configure it:

private CouchbaseClient client;


private ArrayList<URI> nodes = new ArrayList<>();
    private String uri;
    private String bucket;
    private String password;

    @Override
    public void init() {
        uri = "host.1,host.2,host.3"
        bucket = "default"
        password = "password"
        try {
            addUrlList();
            client = new CouchbaseClient(nodes, bucket, password);
        } catch (Exception e) {
            logger.error("Error connecting to Couchbase: " + e.getMessage(), e);
        }
    }

    private void addUrlList() {
        List<String> urlList= Arrays.asList(uri.split(","));
        for(String url:urlList)
        {
            uri = "http://" + url + ":8091/pools";
            nodes.add(URI.create(uri));
        }
    }

and thats the exception:

2015-03-12T09:27:54.200+0000 STDIO [ERROR] INFO
2015-03-12T09:27:54.200+0000 STDIO [ERROR] com.couchbase.client.CouchbaseConnection
2015-03-12T09:27:54.200+0000 STDIO [ERROR] :
2015-03-12T09:27:54.200+0000 STDIO [ERROR] Reconnecting {QA sa=host.1/ip.address:11210, #Rops=0, #Wops=0, #iq=0, topRop=null, topWop=null, toWrite=0, interested=0}

2015-03-12T09:27:57.198+0000 STDIO [ERROR] 2015-03-12 09:27:57.198
2015-03-12T09:27:57.199+0000 STDIO [ERROR] INFO
2015-03-12T09:27:57.199+0000 STDIO [ERROR] com.couchbase.client.CouchbaseConnection
2015-03-12T09:27:57.199+0000 STDIO [ERROR] :
2015-03-12T09:27:57.199+0000 STDIO [ERROR] Reconnecting due to exception on {QA sa=host.1/ip.address:11210:11210, #Rops=0, #Wops=0, #iq=0, topRop=null, topWop=null, toWrite=0, interested=0}
2015-03-12T09:27:57.199+0000 STDIO [ERROR] java.net.NoRouteToHostException: No route to host
2015-03-12T09:27:57.200+0000 STDIO [ERROR] at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
2015-03-12T09:27:57.200+0000 STDIO [ERROR] at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:739)
2015-03-12T09:27:57.200+0000 STDIO [ERROR] at net.spy.memcached.MemcachedConnection.handleIO(MemcachedConnection.java:677)
2015-03-12T09:27:57.200+0000 STDIO [ERROR] at net.spy.memcached.MemcachedConnection.handleIO(MemcachedConnection.java:436)
2015-03-12T09:27:57.200+0000 STDIO [ERROR] at com.couchbase.client.CouchbaseConnection.run(CouchbaseConnection.java:325)
2015-03-12T09:27:57.201+0000 STDIO [ERROR] 2015-03-12 09:27:57.201
2015-03-12T09:27:57.201+0000 STDIO [ERROR] WARN
2015-03-12T09:27:57.201+0000 STDIO [ERROR] com.couchbase.client.CouchbaseConnection
2015-03-12T09:27:57.201+0000 STDIO [ERROR] :
2015-03-12T09:27:57.201+0000 STDIO [ERROR] Closing, and reopening {QA sa=host.1/ip.address:11210:11210, #Rops=0, #Wops=0, #iq=0, topRop=null, topWop=null, toWrite=0, interested=0}, attempt 1380.
rayman
  • 20,786
  • 45
  • 148
  • 246
  • Have you tried by submitting this to their issue tracker? (https://issues.couchbase.com). They are usually really keen to help and understand what it is happening. Just in case, have you tried the Couchbase Client 2.0? – facundofarias Mar 12 '15 at 09:46
  • what do you mean 2.0? the last one via maven repo is: 1.4.8 – rayman Mar 12 '15 at 10:00
  • I mean using this one: https://github.com/couchbase/couchbase-java-client/tree/release20 – facundofarias Mar 12 '15 at 10:10
  • 1
    the 2.0 generation (currently latest is 2.1.1) is a rewrite of the SDK, hence the artifact name change from "couchbase-client" to "java-client"... it is quite a different API though, and spring-data-couchbase has not yet been ported to it – Simon Baslé Mar 12 '15 at 10:58

0 Answers0