DATACOUCH-260 - Update to 2.4.1 and fix tests

Adapted changes to 3.0 branch

Original pull request: #131.
This commit is contained in:
Subhashni Balakrishnan
2017-02-04 21:30:46 -08:00
parent 8733ea3cf5
commit 162d8124ab
17 changed files with 137 additions and 87 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors
* Copyright 2012-2017 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -30,6 +30,7 @@ import org.springframework.beans.factory.config.AbstractFactoryBean;
*
* @author Simon Baslé
* @author Simon Bland
* @author Subhashni Balakrishnan
*/
/*package*/ class CouchbaseEnvironmentFactoryBean extends AbstractFactoryBean<CouchbaseEnvironment> {
@@ -123,14 +124,6 @@ import org.springframework.beans.factory.config.AbstractFactoryBean;
this.couchbaseEnvBuilder.sslKeystorePassword(sslKeystorePassword);
}
public void setQueryEnabled(boolean queryEnabled) {
this.couchbaseEnvBuilder.queryEnabled(queryEnabled);
}
public void setQueryPort(int queryPort) {
this.couchbaseEnvBuilder.queryPort(queryPort);
}
public void setBootstrapHttpEnabled(boolean bootstrapHttpEnabled) {
this.couchbaseEnvBuilder.bootstrapHttpEnabled(bootstrapHttpEnabled);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors
* Copyright 2012-2017 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,9 +16,14 @@
package org.springframework.data.couchbase.config;
import java.security.KeyStore;
import java.util.concurrent.TimeUnit;
import com.couchbase.client.core.env.WaitStrategyFactory;
import com.couchbase.client.core.event.EventBus;
import com.couchbase.client.core.metrics.MetricsCollector;
import com.couchbase.client.core.metrics.NetworkLatencyMetricsCollector;
import com.couchbase.client.core.node.MemcachedHashingStrategy;
import com.couchbase.client.core.retry.RetryStrategy;
import com.couchbase.client.core.time.Delay;
import com.couchbase.client.deps.io.netty.channel.EventLoopGroup;
@@ -32,6 +37,7 @@ import rx.Scheduler;
*
* @author Simon Baslé
* @author Jonathan Edwards
* @author Subhashni Balakrishnan
*/
public class CouchbaseEnvironmentNoShutdownProxy implements CouchbaseEnvironment {
@@ -42,8 +48,8 @@ public class CouchbaseEnvironmentNoShutdownProxy implements CouchbaseEnvironment
}
@Override
public Observable<Boolean> shutdown() {
return Observable.just(false);
public boolean shutdown() {
return false;
}
//===== DELEGATION METHODS =====
@@ -58,6 +64,11 @@ public class CouchbaseEnvironmentNoShutdownProxy implements CouchbaseEnvironment
return delegate.ioPool();
}
@Override
public EventLoopGroup kvIoPool() {
return delegate.kvIoPool();
}
@Override
public Scheduler scheduler() {
return delegate.scheduler();
@@ -83,18 +94,6 @@ public class CouchbaseEnvironmentNoShutdownProxy implements CouchbaseEnvironment
return delegate.sslKeystorePassword();
}
@Override
@Deprecated
public boolean queryEnabled() {
return delegate.queryEnabled();
}
@Override
@Deprecated
public int queryPort() {
return delegate.queryPort();
}
@Override
public boolean bootstrapHttpEnabled() {
return delegate.bootstrapHttpEnabled();
@@ -324,4 +323,39 @@ public class CouchbaseEnvironmentNoShutdownProxy implements CouchbaseEnvironment
public long searchTimeout() {
return delegate.searchTimeout();
}
@Override
public WaitStrategyFactory requestBufferWaitStrategy() {
return delegate.requestBufferWaitStrategy();
}
@Override
public EventLoopGroup viewIoPool() {
return delegate.viewIoPool();
}
@Override
public EventLoopGroup searchIoPool() {
return delegate.searchIoPool();
}
@Override
public EventLoopGroup queryIoPool() {
return delegate.queryIoPool();
}
@Override
public KeyStore sslKeystore() {
return delegate.sslKeystore();
}
@Override
public boolean shutdown(long timeout, TimeUnit timeUnit) {
return delegate.shutdown(timeout, timeUnit);
}
@Override
public MemcachedHashingStrategy memcachedHashingStrategy() {
return delegate.memcachedHashingStrategy();
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2015 the original author or authors
* Copyright 2012-2017 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -44,8 +44,6 @@ import org.springframework.util.StringUtils;
* <li>{@link DefaultCouchbaseEnvironment.Builder#sslEnabled(boolean) sslEnabled}</li>
* <li>{@link DefaultCouchbaseEnvironment.Builder#sslKeystoreFile(String) sslKeystoreFile}</li>
* <li>{@link DefaultCouchbaseEnvironment.Builder#sslKeystorePassword(String) sslKeystorePassword}</li>
* <li>{@link DefaultCouchbaseEnvironment.Builder#queryEnabled(boolean) queryEnabled}</li>
* <li>{@link DefaultCouchbaseEnvironment.Builder#queryPort(int) queryPort}</li>
* <li>{@link DefaultCouchbaseEnvironment.Builder#bootstrapHttpEnabled(boolean) bootstrapHttpEnabled}</li>
* <li>{@link DefaultCouchbaseEnvironment.Builder#bootstrapCarrierEnabled(boolean) bootstrapCarrierEnabled}</li>
* <li>{@link DefaultCouchbaseEnvironment.Builder#bootstrapHttpDirectPort(int) bootstrapHttpDirectPort}</li>
@@ -69,6 +67,7 @@ import org.springframework.util.StringUtils;
* </ul>
*
* @author Simon Baslé
* @author Subhashni Balakrishnan
*/
public class CouchbaseEnvironmentParser extends AbstractSingleBeanDefinitionParser {
@@ -117,8 +116,6 @@ public class CouchbaseEnvironmentParser extends AbstractSingleBeanDefinitionPars
setPropertyValue(envDefinitionBuilder, envElement, "sslEnabled", "sslEnabled");
setPropertyValue(envDefinitionBuilder, envElement, "sslKeystoreFile", "sslKeystoreFile");
setPropertyValue(envDefinitionBuilder, envElement, "sslKeystorePassword", "sslKeystorePassword");
setPropertyValue(envDefinitionBuilder, envElement, "queryEnabled", "queryEnabled");
setPropertyValue(envDefinitionBuilder, envElement, "queryPort", "queryPort");
setPropertyValue(envDefinitionBuilder, envElement, "bootstrapHttpEnabled", "bootstrapHttpEnabled");
setPropertyValue(envDefinitionBuilder, envElement, "bootstrapCarrierEnabled", "bootstrapCarrierEnabled");
setPropertyValue(envDefinitionBuilder, envElement, "bootstrapHttpDirectPort", "bootstrapHttpDirectPort");

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2015 the original author or authors
* Copyright 2012-2017 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,6 +24,7 @@ import java.util.Collections;
import com.couchbase.client.java.Bucket;
import com.couchbase.client.java.bucket.BucketManager;
import com.couchbase.client.java.document.json.JsonObject;
import com.couchbase.client.java.error.DesignDocumentDoesNotExistException;
import com.couchbase.client.java.query.AsyncN1qlQueryResult;
import com.couchbase.client.java.query.Index;
import com.couchbase.client.java.query.Statement;
@@ -53,6 +54,7 @@ import org.springframework.data.repository.core.RepositoryInformation;
* Index creation will be attempted in parallel using the asynchronous APIs, but the overall process is still blocking.
*
* @author Simon Baslé
* @author Subhashni Balakrishnan
*/
public class IndexManager {
@@ -281,7 +283,12 @@ public class IndexManager {
}
com.couchbase.client.java.view.View view = DefaultView.create(viewName, mapFunction, reduceFunction);
DesignDocument doc = manager.getDesignDocument(config.designDoc());
DesignDocument doc = null;
try {
doc = manager.getDesignDocument(config.designDoc());
} catch(DesignDocumentDoesNotExistException ex) {
//ignore
}
if (doc != null) {
for (com.couchbase.client.java.view.View existingView : doc.views()) {
if (existingView.name().equals(viewName)) {