Closed obazoud closed 5 years ago
Did you try the suggestions listed in the original issue? You need to disable the "Carrier Configuration" - which will prevent the client from trying to connect to port 11210.
Yeah... i try it but still get the same error. Did you manage to get it working with java client 2.1.3?? @mnunberg
No, I haven't tested it. Can you show me how you're instantiating the client. @daschl @avsej
@mnunberg what code are you looking for exactly?
@daschl I'm looking for @saferrer 's code. Just put your names here as essentially a CC. The Java client should also try to connect to port 8091 if it can't connect to 11210 as well, perhaps?
that's what it does HTTP bootstrap is the fallback for Carrier unless explicitly disabled on the environment. This is needed also for 2.2 and older compat.
Hi @mnunberg, @daschl! Thank you both guys for the help! this is my code!
Test class
BucketConfiguration bucketConfiguration = new BucketConfiguration();
bucketConfiguration.numNodes = 10;
bucketConfiguration.numReplicas = 3;
bucketConfiguration.name = "default";
bucketConfiguration.type = Bucket.BucketType.COUCHBASE;
bucketConfiguration.password = "";
ArrayList<BucketConfiguration> configList = new ArrayList<>();
configList.add(bucketConfiguration);
couchbaseMock = new CouchbaseMock(8091, configList);
couchbaseMock.start();
couchbaseMock.waitForStartup();
Creating the cluster
cluster = CouchbaseCluster.create(DefaultCouchbaseEnvironment.builder().bootstrapCarrierEnabled(false).build(), nodeAddresses);
The exception:
10:24:28.444 [cb-io-1-1] WARN c.c.client.core.endpoint.Endpoint - [null][KeyValueEndpoint]: Could not connect to endpoint, retrying with delay 32 MILLISECONDS:
java.net.ConnectException: Connection refused: /127.0.0.1:11210
Couchbasemock version: 1.1.0
Java Couchbase client: 2.1.3
Thanks for the help!
Also struggling:
couchbaseMock = new CouchbaseMock("localhost", 8091, 10, 1024);
couchbaseMock.start();
couchbaseMock.waitForStartup();
cluster = CouchbaseCluster.create(DefaultCouchbaseEnvironment.builder().bootstrapCarrierEnabled(false).build(), Arrays.asList("127.0.0.1"));
Bucket bucket = cluster.openBucket("default");
Gives the following error:
com.couchbase.client.core.config.ConfigurationException: Could not open bucket.
at com.couchbase.client.core.config.DefaultConfigurationProvider$5.call(DefaultConfigurationProvider.java:274)
at com.couchbase.client.core.config.DefaultConfigurationProvider$5.call(DefaultConfigurationProvider.java:271)
at rx.internal.operators.OperatorOnErrorResumeNextViaFunction$1.onError(OperatorOnErrorResumeNextViaFunction.java:77)
at rx.internal.operators.OperatorDoOnEach$1.onError(OperatorDoOnEach.java:70)
at rx.internal.operators.OperatorMap$1.onError(OperatorMap.java:49)
at rx.internal.operators.OperatorDoOnEach$1.onError(OperatorDoOnEach.java:70)
at rx.internal.operators.OperatorTake$1.onError(OperatorTake.java:57)
at rx.internal.operators.OperatorMerge$MergeSubscriber.drainAndComplete(OperatorMerge.java:473)
at rx.internal.operators.OperatorMerge$MergeSubscriber.innerError(OperatorMerge.java:426)
at rx.internal.operators.OperatorMerge$MergeSubscriber.access$800(OperatorMerge.java:93)
at rx.internal.operators.OperatorMerge$InnerSubscriber.onError(OperatorMerge.java:552)
at rx.internal.operators.OperatorMap$1.onError(OperatorMap.java:49)
at rx.internal.operators.OperatorMap$1.onNext(OperatorMap.java:58)
at rx.internal.operators.OperatorMerge$InnerSubscriber.emit(OperatorMerge.java:635)
at rx.internal.operators.OperatorMerge$InnerSubscriber.onNext(OperatorMerge.java:545)
at rx.internal.operators.OperatorMap$1.onNext(OperatorMap.java:55)
Digging further, the error cause is:
Instantiation of [simple type, class com.couchbase.client.core.config.DefaultCouchbaseBucketConfig] value failed:
Partition size is not equal after conversion, this is a bug.
So the partition size problem seems to be that the cluster map sent back by the mock is not what the new sdk is expecting. But, if you set the mock to only have 1 not and no replicas its works fine and connects.
@mtalbot
But, if you set the mock to only have 1 not and no replicas its works fine and connects.
How did you do this?
When your doing the bucket configuration in code set numReplicas = 0 and numNodes = 1 and it works
Can you post a working code snippet? Doesn't work for me with that change (TimeoutException). Trying to run a test as follows. Couchbase mock 1.2.0, Couchbase java-client:2.2.2
BucketConfiguration bucketConfiguration = new BucketConfiguration();
bucketConfiguration.numNodes = 1;
bucketConfiguration.numReplicas = 0;
bucketConfiguration.name = "default";
bucketConfiguration.type = org.couchbase.mock.Bucket.BucketType.COUCHBASE;
bucketConfiguration.password = "";
ArrayList<BucketConfiguration> configList = new ArrayList<>();
configList.add(bucketConfiguration);
CouchbaseMock couchbaseMock = new CouchbaseMock(8091, configList);
couchbaseMock.start();
couchbaseMock.waitForStartup();
CouchbaseCluster cluster = CouchbaseCluster.create(DefaultCouchbaseEnvironment.builder().bootstrapCarrierEnabled(false).build(), Arrays.asList("127.0.0.1"));
Bucket bucket = cluster.openBucket("default");
So the issues seem to be that the sdk doesn't disable carrier bootstraping and doesn't fail over.
public CouchbaseCluster mockedCouchbase(CouchbaseMock mock) throws MalformedURLException { Bucket mockbucket = mock.getBuckets().get(bucket); MemcachedServer server = mockbucket.getServers()[0]; CouchbaseEnvironment environment = DefaultCouchbaseEnvironment. builder(). bootstrapCarrierEnabled(false). bootstrapHttpEnabled(true). bootstrapHttpDirectPort(mock.getHttpPort()). sslEnabled(false). bootstrapCarrierDirectPort(server.getPort()). build();
return CouchbaseCluster.create(environment, mock.getHttpHost());
}
Is there any news about this?? @mnunberg
I am also trying to start a mock couchbase server before running test but it seems to be a problem when connecting with my client (i am using java-client v2.1.3)
is there something i am doing wrong?? This is my code:
Thanks!