Hi, Greetings ! I am a new developer with Couchbase SDK and I was trying a basic .add method to add a document to Couchbase. I have setup my Couchbase server mostly as per the default instructions. Here’s the code block
try
{
client.add(“foo”, expireTime, “bar”, PersistTo.MASTER);
System.out.println(client.get(“foo”));
}
catch (Exception ex)
{
ex.printStackTrace();
}
The reason I am using PersistTo.MASTER is because I want to wait (I am guessing the right terminology is “observe”?) till the document gets persisted to the disk (so it’s readily available for query through views).
While I do this, I am getting an ArrayOutOfBoundException: -1. Here’s the stacktrace:
java.lang.ArrayIndexOutOfBoundsException: -1
at java.util.ArrayList.elementData(ArrayList.java:371)
at java.util.ArrayList.elementData(ArrayList.java:371)
at java.util.ArrayList.get(ArrayList.java:384 at java.util.ArrayList.get(ArrayList.java:384)
)
at com.couchbase.client.vbucket.config.DefaultConfig.getServer(DefaultConfig.java:81)
at com.couchbase.client.vbucket.config.DefaultConfig.getServer(DefaultConfig.java:81)
at com.couchbase.client.vbucket.VBucketNodeLocator.getServerByIndex(VBucketNodeLocator.java:112)
at com.couchbase.client.vbucket.VBucketNodeLocator.getServerByIndex(VBucketNodeLocator.java:112)
at com.couchbase.client.CouchbaseClient.observe(CouchbaseClient.java:1621)
at com.couchbase.client.CouchbaseClient.observe(CouchbaseClient.java:1621)
at com.couchbase.client.CouchbaseClient.observePoll(CouchbaseClient.java:1750)
at com.couchbase.client.CouchbaseClient.observePoll(CouchbaseClient.java:1750)
at com.couchbase.client.CouchbaseClient.add(CouchbaseClient.java:1312)
at com.couchbase.client.CouchbaseClient.add(CouchbaseClient.java:1312)
at com.couchbase.client.CouchbaseClient.add(CouchbaseClient.java:1344)
at com.couchbase.client.CouchbaseClient.add(CouchbaseClient.java:1344)
Is there something fundamentally wrong with my code or am I missing something?
The document does get added/created on the server (atleast I do get it back when I do a .get(“foo”)) but I am not sure if it ACTUALLY gets persisted to the disk because of that error and IF the document is actually persisted and ready to be queried though view.
All help appreciated. Please advise!
Thanks,
Shivang