DATACOUCH-290 - Upgrade to java-client 2.4.4

Original pull request: #137.
This commit is contained in:
Subhashni Balakrishnan
2017-04-06 15:57:30 -07:00
parent b5cb03d5eb
commit 4983dfc7b2
10 changed files with 173 additions and 147 deletions

View File

@@ -21,8 +21,8 @@
<dist.key>DATACOUCH</dist.key>
<couchbase>2.2.8</couchbase>
<couchbase.osgi>2.2.8</couchbase.osgi>
<couchbase>2.4.4</couchbase>
<couchbase.osgi>2.4.4</couchbase.osgi>
<springdata.commons>1.12.9.BUILD-SNAPSHOT</springdata.commons>
<validation>1.0.0.GA</validation>
</properties>

View File

@@ -1,6 +1,7 @@
package org.springframework.data.couchbase.repository.index;
import com.couchbase.client.java.Bucket;
import com.couchbase.client.java.error.DesignDocumentDoesNotExistException;
import com.couchbase.client.java.query.Index;
import com.couchbase.client.java.query.N1qlQuery;
@@ -12,14 +13,19 @@ import org.springframework.test.context.support.DependencyInjectionTestExecution
* A test listener that will remove the indexes created in {@link IndexedRepositoryTests} before test case is run.
*
* @author Simon Baslé
* @author Subhashni Balakrishnan
*/
public class IndexedRepositoryTestListener extends DependencyInjectionTestExecutionListener {
@Override
public void beforeTestClass(final TestContext testContext) throws Exception {
Bucket client = (Bucket) testContext.getApplicationContext().getBean(BeanNames.COUCHBASE_BUCKET);
client.bucketManager().removeDesignDocument(IndexedRepositoryTests.VIEW_DOC);
client.bucketManager().removeDesignDocument("foo");
try {
client.bucketManager().removeDesignDocument(IndexedRepositoryTests.VIEW_DOC);
client.bucketManager().removeDesignDocument("foo");
} catch (DesignDocumentDoesNotExistException ex) {
//ignore
}
client.query(N1qlQuery.simple(Index.dropPrimaryIndex(client.name())));
client.query(N1qlQuery.simple(Index.dropIndex(client.name(), IndexedRepositoryTests.SECONDARY)));
}

View File

@@ -20,6 +20,7 @@ import static org.junit.Assert.*;
import java.util.Arrays;
import com.couchbase.client.java.error.DesignDocumentDoesNotExistException;
import com.couchbase.client.java.query.N1qlQuery;
import com.couchbase.client.java.query.N1qlQueryResult;
import com.couchbase.client.java.view.DesignDocument;
@@ -136,9 +137,15 @@ public class IndexedRepositoryTests {
public void shouldNotFindViewIndexWithIgnoringIndexManager() {
AnotherIndexedUserRepository repository = ignoringIndexFactory.getRepository(AnotherIndexedUserRepository.class);
DesignDocument designDoc = template.getCouchbaseBucket()
.bucketManager()
.getDesignDocument(VIEW_DOC);
DesignDocument designDoc = null;
try {
designDoc = template.getCouchbaseBucket()
.bucketManager()
.getDesignDocument(VIEW_DOC);
} catch (DesignDocumentDoesNotExistException ex) {
//ignore
}
if (designDoc != null) {
for (View view : designDoc.views()) {

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.
@@ -21,6 +21,7 @@ import com.couchbase.client.core.retry.FailFastRetryStrategy;
import com.couchbase.client.core.retry.RetryStrategy;
import com.couchbase.client.java.env.CouchbaseEnvironment;
import com.couchbase.client.java.env.DefaultCouchbaseEnvironment;
import com.couchbase.client.java.env.DefaultCouchbaseEnvironment.Builder;
import org.springframework.beans.factory.config.AbstractFactoryBean;
@@ -28,47 +29,15 @@ import org.springframework.beans.factory.config.AbstractFactoryBean;
* Factory Bean to help create a CouchbaseEnvironment (by offering setters for supported tuning methods).
*
* @author Simon Baslé
* @author Simon Bland
* @author Subhashni Balakrishnan
*/
/*package*/ class CouchbaseEnvironmentFactoryBean extends AbstractFactoryBean<CouchbaseEnvironment> {
private static final CouchbaseEnvironment DEFAULT_ENV = DefaultCouchbaseEnvironment.create();
public static final String RETRYSTRATEGY_FAILFAST = "FailFast";
public static final String RETRYSTRATEGY_BESTEFFORT = "BestEffort";
private long managementTimeout = DEFAULT_ENV.managementTimeout();
private long queryTimeout = DEFAULT_ENV.queryTimeout();
private long viewTimeout = DEFAULT_ENV.viewTimeout();
private long kvTimeout = DEFAULT_ENV.kvTimeout();
private long connectTimeout = DEFAULT_ENV.connectTimeout();
private long disconnectTimeout = DEFAULT_ENV.disconnectTimeout();
private boolean dnsSrvEnabled = DEFAULT_ENV.dnsSrvEnabled();
private boolean dcpEnabled = DEFAULT_ENV.dcpEnabled();
private boolean sslEnabled = DEFAULT_ENV.sslEnabled();
private String sslKeystoreFile = DEFAULT_ENV.sslKeystoreFile();
private String sslKeystorePassword = DEFAULT_ENV.sslKeystorePassword();
private boolean queryEnabled = DEFAULT_ENV.queryEnabled();
private int queryPort = DEFAULT_ENV.queryPort();
private boolean bootstrapHttpEnabled = DEFAULT_ENV.bootstrapHttpEnabled();
private boolean bootstrapCarrierEnabled = DEFAULT_ENV.bootstrapCarrierEnabled();
private int bootstrapHttpDirectPort = DEFAULT_ENV.bootstrapHttpDirectPort();
private int bootstrapHttpSslPort = DEFAULT_ENV.bootstrapHttpSslPort();
private int bootstrapCarrierDirectPort = DEFAULT_ENV.bootstrapCarrierDirectPort();
private int bootstrapCarrierSslPort = DEFAULT_ENV.bootstrapCarrierSslPort();
private int ioPoolSize = DEFAULT_ENV.ioPoolSize();
private int computationPoolSize = DEFAULT_ENV.computationPoolSize();
private int responseBufferSize = DEFAULT_ENV.responseBufferSize();
private int requestBufferSize = DEFAULT_ENV.requestBufferSize();
private int kvEndpoints = DEFAULT_ENV.kvEndpoints();
private int viewEndpoints = DEFAULT_ENV.viewEndpoints();
private int queryEndpoints = DEFAULT_ENV.queryEndpoints();
private RetryStrategy retryStrategy = DEFAULT_ENV.retryStrategy();
private long maxRequestLifetime = DEFAULT_ENV.maxRequestLifetime();
private long keepAliveInterval = DEFAULT_ENV.keepAliveInterval();
private long autoreleaseAfter = DEFAULT_ENV.autoreleaseAfter();
private boolean bufferPoolingEnabled = DEFAULT_ENV.bufferPoolingEnabled();
private boolean tcpNodelayEnabled = DEFAULT_ENV.tcpNodelayEnabled();
private boolean mutationTokensEnabled = DEFAULT_ENV.mutationTokensEnabled();
private final Builder couchbaseEnvBuilder = DefaultCouchbaseEnvironment.builder();
/*
These are tunings that are not practical to be exposed in a xml configuration
@@ -83,6 +52,17 @@ import org.springframework.beans.factory.config.AbstractFactoryBean;
eventBus
systemMetricsCollectorConfig
networkLatencyMetricsCollectorConfig
requestBufferWaitStrategy
sslKeystore
memcachedHashingStrategy
kvIoPool
queryIoPool
searchIoPool
viewIoPool
kvServiceConfig
queryServiceConfig
searchServiceConfig
viewServiceConfig
*/
@Override
@@ -92,41 +72,7 @@ import org.springframework.beans.factory.config.AbstractFactoryBean;
@Override
protected CouchbaseEnvironment createInstance() throws Exception {
return DefaultCouchbaseEnvironment.builder()
.managementTimeout(managementTimeout)
.queryTimeout(queryTimeout)
.viewTimeout(viewTimeout)
.kvTimeout(kvTimeout)
.connectTimeout(connectTimeout)
.disconnectTimeout(disconnectTimeout)
.dnsSrvEnabled(dnsSrvEnabled)
.dcpEnabled(dcpEnabled)
.sslEnabled(sslEnabled)
.sslKeystoreFile(sslKeystoreFile)
.sslKeystorePassword(sslKeystorePassword)
.queryEnabled(queryEnabled)
.queryPort(queryPort)
.bootstrapHttpEnabled(bootstrapHttpEnabled)
.bootstrapCarrierEnabled(bootstrapCarrierEnabled)
.bootstrapHttpDirectPort(bootstrapHttpDirectPort)
.bootstrapHttpSslPort(bootstrapHttpSslPort)
.bootstrapCarrierDirectPort(bootstrapCarrierDirectPort)
.bootstrapCarrierSslPort(bootstrapCarrierSslPort)
.ioPoolSize(ioPoolSize)
.computationPoolSize(computationPoolSize)
.responseBufferSize(responseBufferSize)
.requestBufferSize(requestBufferSize)
.kvEndpoints(kvEndpoints)
.viewEndpoints(viewEndpoints)
.queryEndpoints(queryEndpoints)
.retryStrategy(retryStrategy)
.maxRequestLifetime(maxRequestLifetime)
.keepAliveInterval(keepAliveInterval)
.autoreleaseAfter(autoreleaseAfter)
.bufferPoolingEnabled(bufferPoolingEnabled)
.tcpNodelayEnabled(tcpNodelayEnabled)
.mutationTokensEnabled(mutationTokensEnabled)
.build();
return couchbaseEnvBuilder.build();
}
/**
@@ -137,139 +83,135 @@ import org.springframework.beans.factory.config.AbstractFactoryBean;
*/
public void setRetryStrategy(String retryStrategy) {
if (RETRYSTRATEGY_FAILFAST.equals(retryStrategy)) {
this.retryStrategy = FailFastRetryStrategy.INSTANCE;
this.couchbaseEnvBuilder.retryStrategy(FailFastRetryStrategy.INSTANCE);
} else if (RETRYSTRATEGY_BESTEFFORT.equals(retryStrategy)) {
this.retryStrategy = BestEffortRetryStrategy.INSTANCE;
this.couchbaseEnvBuilder.retryStrategy(BestEffortRetryStrategy.INSTANCE);
}
}
//==== SETTERS for the factory bean ====
public void setManagementTimeout(long managementTimeout) {
this.managementTimeout = managementTimeout;
this.couchbaseEnvBuilder.managementTimeout(managementTimeout);
}
public void setQueryTimeout(long queryTimeout) {
this.queryTimeout = queryTimeout;
this.couchbaseEnvBuilder.queryTimeout(queryTimeout);
}
public void setViewTimeout(long viewTimeout) {
this.viewTimeout = viewTimeout;
this.couchbaseEnvBuilder.viewTimeout(viewTimeout);
}
public void setKvTimeout(long kvTimeout) {
this.kvTimeout = kvTimeout;
this.couchbaseEnvBuilder.kvTimeout(kvTimeout);
}
public void setConnectTimeout(long connectTimeout) {
this.connectTimeout = connectTimeout;
this.couchbaseEnvBuilder.connectTimeout(connectTimeout);
}
public void setDisconnectTimeout(long disconnectTimeout) {
this.disconnectTimeout = disconnectTimeout;
this.couchbaseEnvBuilder.disconnectTimeout(disconnectTimeout);
}
public void setDnsSrvEnabled(boolean dnsSrvEnabled) {
this.dnsSrvEnabled = dnsSrvEnabled;
this.couchbaseEnvBuilder.dnsSrvEnabled(dnsSrvEnabled);
}
public void setDcpEnabled(boolean dcpEnabled) {
this.dcpEnabled = dcpEnabled;
this.couchbaseEnvBuilder.dcpEnabled(dcpEnabled);
}
public void setSslEnabled(boolean sslEnabled) {
this.sslEnabled = sslEnabled;
this.couchbaseEnvBuilder.sslEnabled(sslEnabled);
}
public void setSslKeystoreFile(String sslKeystoreFile) {
this.sslKeystoreFile = sslKeystoreFile;
this.couchbaseEnvBuilder.sslKeystoreFile(sslKeystoreFile);
}
public void setSslKeystorePassword(String sslKeystorePassword) {
this.sslKeystorePassword = sslKeystorePassword;
}
public void setQueryEnabled(boolean queryEnabled) {
this.queryEnabled = queryEnabled;
}
public void setQueryPort(int queryPort) {
this.queryPort = queryPort;
this.couchbaseEnvBuilder.sslKeystorePassword(sslKeystorePassword);
}
public void setBootstrapHttpEnabled(boolean bootstrapHttpEnabled) {
this.bootstrapHttpEnabled = bootstrapHttpEnabled;
this.couchbaseEnvBuilder.bootstrapHttpEnabled(bootstrapHttpEnabled);
}
public void setBootstrapCarrierEnabled(boolean bootstrapCarrierEnabled) {
this.bootstrapCarrierEnabled = bootstrapCarrierEnabled;
this.couchbaseEnvBuilder.bootstrapCarrierEnabled(bootstrapCarrierEnabled);
}
public void setBootstrapHttpDirectPort(int bootstrapHttpDirectPort) {
this.bootstrapHttpDirectPort = bootstrapHttpDirectPort;
this.couchbaseEnvBuilder.bootstrapHttpDirectPort(bootstrapHttpDirectPort);
}
public void setBootstrapHttpSslPort(int bootstrapHttpSslPort) {
this.bootstrapHttpSslPort = bootstrapHttpSslPort;
this.couchbaseEnvBuilder.bootstrapHttpSslPort(bootstrapHttpSslPort);
}
public void setBootstrapCarrierDirectPort(int bootstrapCarrierDirectPort) {
this.bootstrapCarrierDirectPort = bootstrapCarrierDirectPort;
this.couchbaseEnvBuilder.bootstrapCarrierDirectPort(bootstrapCarrierDirectPort);
}
public void setBootstrapCarrierSslPort(int bootstrapCarrierSslPort) {
this.bootstrapCarrierSslPort = bootstrapCarrierSslPort;
this.couchbaseEnvBuilder.bootstrapCarrierSslPort(bootstrapCarrierSslPort);
}
public void setIoPoolSize(int ioPoolSize) {
this.ioPoolSize = ioPoolSize;
this.couchbaseEnvBuilder.ioPoolSize(ioPoolSize);
}
public void setComputationPoolSize(int computationPoolSize) {
this.computationPoolSize = computationPoolSize;
this.couchbaseEnvBuilder.computationPoolSize(computationPoolSize);
}
public void setResponseBufferSize(int responseBufferSize) {
this.responseBufferSize = responseBufferSize;
this.couchbaseEnvBuilder.responseBufferSize(responseBufferSize);
}
public void setRequestBufferSize(int requestBufferSize) {
this.requestBufferSize = requestBufferSize;
this.couchbaseEnvBuilder.requestBufferSize(requestBufferSize);
}
public void setKvEndpoints(int kvEndpoints) {
this.kvEndpoints = kvEndpoints;
this.couchbaseEnvBuilder.kvEndpoints(kvEndpoints);
}
public void setViewEndpoints(int viewEndpoints) {
this.viewEndpoints = viewEndpoints;
this.couchbaseEnvBuilder.viewEndpoints(viewEndpoints);
}
public void setQueryEndpoints(int queryEndpoints) {
this.queryEndpoints = queryEndpoints;
this.couchbaseEnvBuilder.queryEndpoints(queryEndpoints);
}
public void setMaxRequestLifetime(long maxRequestLifetime) {
this.maxRequestLifetime = maxRequestLifetime;
this.couchbaseEnvBuilder.maxRequestLifetime(maxRequestLifetime);
}
public void setKeepAliveInterval(long keepAliveInterval) {
this.keepAliveInterval = keepAliveInterval;
this.couchbaseEnvBuilder.keepAliveInterval(keepAliveInterval);
}
public void setAutoreleaseAfter(long autoreleaseAfter) {
this.autoreleaseAfter = autoreleaseAfter;
this.couchbaseEnvBuilder.autoreleaseAfter(autoreleaseAfter);
}
public void setBufferPoolingEnabled(boolean bufferPoolingEnabled) {
this.bufferPoolingEnabled = bufferPoolingEnabled;
this.couchbaseEnvBuilder.bufferPoolingEnabled(bufferPoolingEnabled);
}
public void setTcpNodelayEnabled(boolean tcpNodelayEnabled) {
this.tcpNodelayEnabled = tcpNodelayEnabled;
this.couchbaseEnvBuilder.tcpNodelayEnabled(tcpNodelayEnabled);
}
public void setMutationTokensEnabled(boolean mutationTokensEnabled) {
this.mutationTokensEnabled = mutationTokensEnabled;
this.couchbaseEnvBuilder.mutationTokensEnabled(mutationTokensEnabled);
}
}
public void setAnalyticsTimeout(long analyticsTimeout) {
this.couchbaseEnvBuilder.analyticsTimeout(analyticsTimeout);
}
}

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.*;
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 =====
@@ -83,18 +89,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 +318,74 @@ public class CouchbaseEnvironmentNoShutdownProxy implements CouchbaseEnvironment
public long searchTimeout() {
return delegate.searchTimeout();
}
}
@Override
public WaitStrategyFactory requestBufferWaitStrategy() {
return delegate.requestBufferWaitStrategy();
}
@Override
public EventLoopGroup kvIoPool() {
return delegate.kvIoPool();
}
@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();
}
@Override
public long analyticsTimeout() {
return delegate.analyticsTimeout();
}
@Override
public long configPollInterval() {
return delegate.configPollInterval();
}
@Override
public KeyValueServiceConfig kvServiceConfig() {
return delegate.kvServiceConfig();
}
@Override
public QueryServiceConfig queryServiceConfig() {
return delegate.queryServiceConfig();
}
@Override
public SearchServiceConfig searchServiceConfig() {
return delegate.searchServiceConfig();
}
@Override
public ViewServiceConfig viewServiceConfig() {
return delegate.viewServiceConfig();
}
}

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>
@@ -66,9 +64,11 @@ import org.springframework.util.StringUtils;
* <li>{@link DefaultCouchbaseEnvironment.Builder#bufferPoolingEnabled(boolean) bufferPoolingEnabled}</li>
* <li>{@link DefaultCouchbaseEnvironment.Builder#tcpNodelayEnabled(boolean) tcpNodelayEnabled}</li>
* <li>{@link DefaultCouchbaseEnvironment.Builder#mutationTokensEnabled(boolean) mutationTokensEnabled}</li>
* <li>{@link DefaultCouchbaseEnvironment.Builder#analyticsTimeout(long) analyticsTimeout}</li>
* </ul>
*
* @author Simon Baslé
* @author Subhashni Balakrishnan
*/
public class CouchbaseEnvironmentParser extends AbstractSingleBeanDefinitionParser {
@@ -117,8 +117,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");
@@ -138,6 +136,7 @@ public class CouchbaseEnvironmentParser extends AbstractSingleBeanDefinitionPars
setPropertyValue(envDefinitionBuilder, envElement, "bufferPoolingEnabled", "bufferPoolingEnabled");
setPropertyValue(envDefinitionBuilder, envElement, "tcpNodelayEnabled", "tcpNodelayEnabled");
setPropertyValue(envDefinitionBuilder, envElement, "mutationTokensEnabled", "mutationTokensEnabled");
setPropertyValue(envDefinitionBuilder, envElement, "analyticsTimeout", "analyticsTimeout");
//retry strategy is particular, in the xsd this is an enum (FailFast, BestEffort)
setPropertyValue(envDefinitionBuilder, envElement, "retryStrategy", "retryStrategy");

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.
@@ -23,6 +23,7 @@ import java.util.Collections;
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;
@@ -51,6 +52,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 {
@@ -241,7 +243,14 @@ 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)) {

View File

@@ -54,6 +54,7 @@
<xsd:attribute name="bufferPoolingEnabled" type="xsd:boolean"/>
<xsd:attribute name="tcpNodelayEnabled" type="xsd:boolean"/>
<xsd:attribute name="mutationTokensEnabled" type="xsd:boolean"/>
<xsd:attribute name="analyticsTimeout" type="xsd:long"/>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>

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.
@@ -79,8 +79,6 @@ public class CouchbaseEnvironmentParserTest {
assertThat(env.sslEnabled(), allOf(equalTo(true), not(defaultEnv.sslEnabled())));
assertThat(env.sslKeystoreFile(), is(equalTo("test")));
assertThat(env.sslKeystorePassword(), is(equalTo("test")));
assertThat(env.queryEnabled(), allOf(equalTo(true), not(defaultEnv.queryEnabled())));
assertThat(env.queryPort(), is(equalTo(7)));
assertThat(env.bootstrapHttpEnabled(), allOf(equalTo(false), not(defaultEnv.bootstrapHttpEnabled())));
assertThat(env.bootstrapCarrierEnabled(), allOf(equalTo(false), not(defaultEnv.bootstrapCarrierEnabled())));
assertThat(env.bootstrapHttpDirectPort(), is(equalTo(8)));
@@ -101,6 +99,7 @@ public class CouchbaseEnvironmentParserTest {
assertThat(env.bufferPoolingEnabled(), allOf(equalTo(false), not(defaultEnv.bufferPoolingEnabled())));
assertThat(env.tcpNodelayEnabled(), allOf(equalTo(false), not(defaultEnv.tcpNodelayEnabled())));
assertThat(env.mutationTokensEnabled(), allOf(equalTo(true), not(defaultEnv.mutationTokensEnabled())));
assertThat(env.analyticsTimeout(), is(equalTo(30L)));
}
@AfterClass

View File

@@ -23,8 +23,6 @@
sslEnabled="true"
sslKeystoreFile="test"
sslKeystorePassword="test"
queryEnabled="true"
queryPort="7"
bootstrapHttpEnabled="false"
bootstrapCarrierEnabled="false"
bootstrapHttpDirectPort="8"
@@ -45,6 +43,7 @@
bufferPoolingEnabled="false"
tcpNodelayEnabled="false"
mutationTokensEnabled="true"
analyticsTimeout="30"
/>
</beans>