From 9810382152443eae15113b641c2d003cebc4e91e Mon Sep 17 00:00:00 2001 From: Oliver Gierke Date: Wed, 19 Apr 2017 16:56:11 +0200 Subject: [PATCH] DATACOUCH-299 - Roll back to Java client 2.2.8. This reverts commit 4b78715ed58e97ac9affcdfe3012f3fbb49e53c1. Related ticket: DATACOUCH-290. --- pom.xml | 4 +- .../CouchbaseRepositoryViewTests.java | 6 +- .../repository/CustomUserRepository.java | 2 +- .../index/IndexedRepositoryTestListener.java | 10 +- .../index/IndexedRepositoryTests.java | 13 +-- .../CouchbaseEnvironmentFactoryBean.java | 28 ++---- .../CouchbaseEnvironmentNoShutdownProxy.java | 96 ++++--------------- .../config/CouchbaseEnvironmentParser.java | 9 +- .../repository/support/IndexManager.java | 13 +-- .../config/spring-couchbase-env-2.0.xsd | 1 - .../CouchbaseEnvironmentParserTest.java | 5 +- .../configurations/couchbaseEnv-bean.xml | 3 +- 12 files changed, 49 insertions(+), 141 deletions(-) diff --git a/pom.xml b/pom.xml index 30dd519a..47d3e58b 100644 --- a/pom.xml +++ b/pom.xml @@ -21,8 +21,8 @@ DATACOUCH - 2.4.4 - 2.4.4 + 2.2.8 + 2.2.8 1.13.3.BUILD-SNAPSHOT 1.0.0.GA diff --git a/src/integration/java/org/springframework/data/couchbase/repository/CouchbaseRepositoryViewTests.java b/src/integration/java/org/springframework/data/couchbase/repository/CouchbaseRepositoryViewTests.java index 01935302..b3f5c853 100644 --- a/src/integration/java/org/springframework/data/couchbase/repository/CouchbaseRepositoryViewTests.java +++ b/src/integration/java/org/springframework/data/couchbase/repository/CouchbaseRepositoryViewTests.java @@ -134,9 +134,9 @@ public class CouchbaseRepositoryViewTests { String highKey = "uname-11"; List keys = Arrays.asList(lowKey, middleKey, highKey); - User u1 = repository.findByUsernameIs(lowKey).get(0); - User u2 = repository.findByUsernameIs(middleKey).get(0); - User u3 = repository.findByUsernameIs(highKey).get(0); + User u1 = repository.findByUsernameIs(lowKey); + User u2 = repository.findByUsernameIs(middleKey); + User u3 = repository.findByUsernameIs(highKey); List in = repository.findAllByUsernameIn(keys); diff --git a/src/integration/java/org/springframework/data/couchbase/repository/CustomUserRepository.java b/src/integration/java/org/springframework/data/couchbase/repository/CustomUserRepository.java index 078ec18b..fe53a396 100644 --- a/src/integration/java/org/springframework/data/couchbase/repository/CustomUserRepository.java +++ b/src/integration/java/org/springframework/data/couchbase/repository/CustomUserRepository.java @@ -46,7 +46,7 @@ public interface CustomUserRepository extends CouchbaseRepository long countByUsernameGreaterThanEqualAndUsernameLessThan(String lowBound, String highBound); @View(viewName = "customFindByNameView") - List findByUsernameIs(String lowKey); + User findByUsernameIs(String lowKey); @View(viewName = "customFindByNameView") List findAllByUsernameIn(List keys); diff --git a/src/integration/java/org/springframework/data/couchbase/repository/index/IndexedRepositoryTestListener.java b/src/integration/java/org/springframework/data/couchbase/repository/index/IndexedRepositoryTestListener.java index 50489cbe..9fe208d9 100644 --- a/src/integration/java/org/springframework/data/couchbase/repository/index/IndexedRepositoryTestListener.java +++ b/src/integration/java/org/springframework/data/couchbase/repository/index/IndexedRepositoryTestListener.java @@ -1,7 +1,6 @@ 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; @@ -13,19 +12,14 @@ 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); - try { - client.bucketManager().removeDesignDocument(IndexedRepositoryTests.VIEW_DOC); - client.bucketManager().removeDesignDocument("foo"); - } catch (DesignDocumentDoesNotExistException ex) { - //ignore - } + client.bucketManager().removeDesignDocument(IndexedRepositoryTests.VIEW_DOC); + client.bucketManager().removeDesignDocument("foo"); client.query(N1qlQuery.simple(Index.dropPrimaryIndex(client.name()))); client.query(N1qlQuery.simple(Index.dropIndex(client.name(), IndexedRepositoryTests.SECONDARY))); } diff --git a/src/integration/java/org/springframework/data/couchbase/repository/index/IndexedRepositoryTests.java b/src/integration/java/org/springframework/data/couchbase/repository/index/IndexedRepositoryTests.java index 9dd3c66f..99fcc432 100644 --- a/src/integration/java/org/springframework/data/couchbase/repository/index/IndexedRepositoryTests.java +++ b/src/integration/java/org/springframework/data/couchbase/repository/index/IndexedRepositoryTests.java @@ -20,7 +20,6 @@ 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; @@ -137,15 +136,9 @@ public class IndexedRepositoryTests { public void shouldNotFindViewIndexWithIgnoringIndexManager() { AnotherIndexedUserRepository repository = ignoringIndexFactory.getRepository(AnotherIndexedUserRepository.class); - DesignDocument designDoc = null; - - try { - designDoc = template.getCouchbaseBucket() - .bucketManager() - .getDesignDocument(VIEW_DOC); - } catch (DesignDocumentDoesNotExistException ex) { - //ignore - } + DesignDocument designDoc = template.getCouchbaseBucket() + .bucketManager() + .getDesignDocument(VIEW_DOC); if (designDoc != null) { for (View view : designDoc.views()) { diff --git a/src/main/java/org/springframework/data/couchbase/config/CouchbaseEnvironmentFactoryBean.java b/src/main/java/org/springframework/data/couchbase/config/CouchbaseEnvironmentFactoryBean.java index 1c3d1e01..c1c9f5a6 100644 --- a/src/main/java/org/springframework/data/couchbase/config/CouchbaseEnvironmentFactoryBean.java +++ b/src/main/java/org/springframework/data/couchbase/config/CouchbaseEnvironmentFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors + * Copyright 2012-2016 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,7 +30,6 @@ import org.springframework.beans.factory.config.AbstractFactoryBean; * * @author Simon Baslé * @author Simon Bland - * @author Subhashni Balakrishnan */ /*package*/ class CouchbaseEnvironmentFactoryBean extends AbstractFactoryBean { @@ -52,17 +51,6 @@ import org.springframework.beans.factory.config.AbstractFactoryBean; eventBus systemMetricsCollectorConfig networkLatencyMetricsCollectorConfig - requestBufferWaitStrategy - sslKeystore - memcachedHashingStrategy - kvIoPool - queryIoPool - searchIoPool - viewIoPool - kvServiceConfig - queryServiceConfig - searchServiceConfig - viewServiceConfig */ @Override @@ -135,6 +123,14 @@ 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); } @@ -210,8 +206,4 @@ import org.springframework.beans.factory.config.AbstractFactoryBean; public void setMutationTokensEnabled(boolean mutationTokensEnabled) { this.couchbaseEnvBuilder.mutationTokensEnabled(mutationTokensEnabled); } - - public void setAnalyticsTimeout(long analyticsTimeout) { - this.couchbaseEnvBuilder.analyticsTimeout(analyticsTimeout); - } -} \ No newline at end of file +} diff --git a/src/main/java/org/springframework/data/couchbase/config/CouchbaseEnvironmentNoShutdownProxy.java b/src/main/java/org/springframework/data/couchbase/config/CouchbaseEnvironmentNoShutdownProxy.java index 3caa2c0f..c5a18482 100644 --- a/src/main/java/org/springframework/data/couchbase/config/CouchbaseEnvironmentNoShutdownProxy.java +++ b/src/main/java/org/springframework/data/couchbase/config/CouchbaseEnvironmentNoShutdownProxy.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors + * Copyright 2012-2016 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,14 +16,9 @@ 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; @@ -37,7 +32,6 @@ import rx.Scheduler; * * @author Simon Baslé * @author Jonathan Edwards - * @author Subhashni Balakrishnan */ public class CouchbaseEnvironmentNoShutdownProxy implements CouchbaseEnvironment { @@ -48,8 +42,8 @@ public class CouchbaseEnvironmentNoShutdownProxy implements CouchbaseEnvironment } @Override - public boolean shutdown() { - return false; + public Observable shutdown() { + return Observable.just(false); } //===== DELEGATION METHODS ===== @@ -89,6 +83,18 @@ 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(); @@ -318,74 +324,4 @@ 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(); - } -} \ No newline at end of file +} diff --git a/src/main/java/org/springframework/data/couchbase/config/CouchbaseEnvironmentParser.java b/src/main/java/org/springframework/data/couchbase/config/CouchbaseEnvironmentParser.java index 37b0f1a2..61caa967 100644 --- a/src/main/java/org/springframework/data/couchbase/config/CouchbaseEnvironmentParser.java +++ b/src/main/java/org/springframework/data/couchbase/config/CouchbaseEnvironmentParser.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors + * Copyright 2012-2015 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,6 +44,8 @@ import org.springframework.util.StringUtils; *
  • {@link DefaultCouchbaseEnvironment.Builder#sslEnabled(boolean) sslEnabled}
  • *
  • {@link DefaultCouchbaseEnvironment.Builder#sslKeystoreFile(String) sslKeystoreFile}
  • *
  • {@link DefaultCouchbaseEnvironment.Builder#sslKeystorePassword(String) sslKeystorePassword}
  • + *
  • {@link DefaultCouchbaseEnvironment.Builder#queryEnabled(boolean) queryEnabled}
  • + *
  • {@link DefaultCouchbaseEnvironment.Builder#queryPort(int) queryPort}
  • *
  • {@link DefaultCouchbaseEnvironment.Builder#bootstrapHttpEnabled(boolean) bootstrapHttpEnabled}
  • *
  • {@link DefaultCouchbaseEnvironment.Builder#bootstrapCarrierEnabled(boolean) bootstrapCarrierEnabled}
  • *
  • {@link DefaultCouchbaseEnvironment.Builder#bootstrapHttpDirectPort(int) bootstrapHttpDirectPort}
  • @@ -64,11 +66,9 @@ import org.springframework.util.StringUtils; *
  • {@link DefaultCouchbaseEnvironment.Builder#bufferPoolingEnabled(boolean) bufferPoolingEnabled}
  • *
  • {@link DefaultCouchbaseEnvironment.Builder#tcpNodelayEnabled(boolean) tcpNodelayEnabled}
  • *
  • {@link DefaultCouchbaseEnvironment.Builder#mutationTokensEnabled(boolean) mutationTokensEnabled}
  • - *
  • {@link DefaultCouchbaseEnvironment.Builder#analyticsTimeout(long) analyticsTimeout}
  • * * * @author Simon Baslé - * @author Subhashni Balakrishnan */ public class CouchbaseEnvironmentParser extends AbstractSingleBeanDefinitionParser { @@ -117,6 +117,8 @@ 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"); @@ -136,7 +138,6 @@ 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"); diff --git a/src/main/java/org/springframework/data/couchbase/repository/support/IndexManager.java b/src/main/java/org/springframework/data/couchbase/repository/support/IndexManager.java index 62f0fd17..5619817b 100644 --- a/src/main/java/org/springframework/data/couchbase/repository/support/IndexManager.java +++ b/src/main/java/org/springframework/data/couchbase/repository/support/IndexManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors + * Copyright 2012-2015 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,7 +23,6 @@ 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; @@ -52,7 +51,6 @@ 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 { @@ -243,14 +241,7 @@ public class IndexManager { } com.couchbase.client.java.view.View view = DefaultView.create(viewName, mapFunction, reduceFunction); - DesignDocument doc = null; - - try { - doc = manager.getDesignDocument(config.designDoc()); - } catch (DesignDocumentDoesNotExistException ex) { - //Ignore - } - + DesignDocument doc = manager.getDesignDocument(config.designDoc()); if (doc != null) { for (com.couchbase.client.java.view.View existingView : doc.views()) { if (existingView.name().equals(viewName)) { diff --git a/src/main/resources/org/springframework/data/couchbase/config/spring-couchbase-env-2.0.xsd b/src/main/resources/org/springframework/data/couchbase/config/spring-couchbase-env-2.0.xsd index 6973761f..0647c96b 100644 --- a/src/main/resources/org/springframework/data/couchbase/config/spring-couchbase-env-2.0.xsd +++ b/src/main/resources/org/springframework/data/couchbase/config/spring-couchbase-env-2.0.xsd @@ -54,7 +54,6 @@ - diff --git a/src/test/java/org/springframework/data/couchbase/config/CouchbaseEnvironmentParserTest.java b/src/test/java/org/springframework/data/couchbase/config/CouchbaseEnvironmentParserTest.java index 2ac0cfc2..b1b84863 100644 --- a/src/test/java/org/springframework/data/couchbase/config/CouchbaseEnvironmentParserTest.java +++ b/src/test/java/org/springframework/data/couchbase/config/CouchbaseEnvironmentParserTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors + * Copyright 2012-2015 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,6 +79,8 @@ 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))); @@ -99,7 +101,6 @@ 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 diff --git a/src/test/resources/configurations/couchbaseEnv-bean.xml b/src/test/resources/configurations/couchbaseEnv-bean.xml index 5040a2ce..d280a67c 100644 --- a/src/test/resources/configurations/couchbaseEnv-bean.xml +++ b/src/test/resources/configurations/couchbaseEnv-bean.xml @@ -23,6 +23,8 @@ sslEnabled="true" sslKeystoreFile="test" sslKeystorePassword="test" + queryEnabled="true" + queryPort="7" bootstrapHttpEnabled="false" bootstrapCarrierEnabled="false" bootstrapHttpDirectPort="8" @@ -43,7 +45,6 @@ bufferPoolingEnabled="false" tcpNodelayEnabled="false" mutationTokensEnabled="true" - analyticsTimeout="30" /> \ No newline at end of file