[JCBC-223] Cannot use Persist.ONE/MASTER on a single node installation Created: 29/Jan/13  Updated: 31/Jan/13  Resolved: 30/Jan/13

Status: Resolved
Project: Couchbase Java Client
Component/s: Core
Affects Version/s: 1.1.0, 1.1.1
Fix Version/s: 1.1.2
Security Level: Public

Type: Bug Priority: Major
Reporter: Tug Grall (Inactive) Assignee: Michael Nitschinger
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment: Couchbase 2.0.0 Single node installation

Issue Links:
Duplicate
is duplicated by JCBC-181 Misleading exception when replica ser... Resolved

 Description   
Using the default bucket I am trying to use the simple "Durability" option using the following code:

----
            {
                System.out.println("Set a Key-Value and Get the Key-Value");
                OperationFuture op = cb.set("mytest", 0, "my value", PersistTo.MASTER);
                System.out.println("cb.get(\"mytest\")" + " => " + cb.get("mytest") + "\"");
                System.out.println("");
            }
----

This raises the following exception:
java.lang.ArrayIndexOutOfBoundsException: -1
at java.util.ArrayList.get(ArrayList.java:324)
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.CouchbaseClient.observe(CouchbaseClient.java:1601)
at com.couchbase.client.CouchbaseClient.observePoll(CouchbaseClient.java:1730)
at com.couchbase.client.CouchbaseClient.set(CouchbaseClient.java:1179)
at com.couchbase.client.CouchbaseClient.set(CouchbaseClient.java:1211)
at com.couchbase.devday.Ex02Storage.main(Ex02Storage.java:36)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)


I am using the code available at :
https://github.com/couchbaselabs/DeveloperDay
https://github.com/couchbaselabs/DeveloperDay/blob/master/Java/basic-operations/src/main/java/com/couchbase/devday/Ex08Observe.java
(this example does not contain the PersistTo.ONE or MASTER since it does not work on a single node.
but as you can see this is a very basic sample code

 Comments   
Comment by Michael Nitschinger [ 29/Jan/13 ]
Note that this only happens on a one-node bucket when replica is enabled.

Looks like this then:

{"hashAlgorithm":"CRC","numReplicas":1,"serverList":["127.0.0.1:11210"],"vBucketMap":[[0,-1],[0,-1],[0,-1],[0,-1],[0,-1],[0,-1],[0,-1],[0,-1],[0,-1],[0,-1],[0,-1],[0,-1],[0,-1],[0,-1],[0,-1],[0,-1],[0,-1],[0,-1],[0,-1],[0,-1],[0,-1],[0,-1],[0,-1],[0,-1],[0,-1],[0,-1],[0,-1],[0,-1],[0,-1],[0,-1],[0,-1],[0,-1],[0,-1],[0,-1],[0,-1],[0,-1],[0,-1],[0,-1],[0,-1],[0,-1],[0,-1],[0,-1],[0,-1],[0,-1],[0,-1],[0,-1],[0,-1],[0,-1],[0,-1],[0,-1],[0,-1],[0,-1],[0,-1],[0,-1],[0,-1],[0,-1],[0,-1],[0,-1],[0,-1],[0,-1],[0,-1],[0,-1],[0,-1],[0,-1]]},"

and when no replica is defined there is no -1 replica of course.
Comment by Michael Nitschinger [ 29/Jan/13 ]
http://review.couchbase.org/#/c/24261
Comment by Michael Nitschinger [ 30/Jan/13 ]
fixed.
Generated at Wed Oct 01 21:15:06 CDT 2014 using JIRA 5.2.4#845-sha1:c9f4cc41abe72fb236945343a1f485c2c844dac9.