From 3236306e53a34c0eb55be1e0af1a9ef5b9e65dc4 Mon Sep 17 00:00:00 2001 From: Yulin Qin Date: Tue, 27 Mar 2018 21:00:00 +0800 Subject: [PATCH 1/2] Replace Couchbase's deprecated methods See gh-12655 --- .../couchbase/CouchbaseAutoConfiguration.java | 14 ++- .../couchbase/CouchbaseProperties.java | 88 +++++++++++++++++++ .../CouchbaseAutoConfigurationTests.java | 48 +++++++++- 3 files changed, 143 insertions(+), 7 deletions(-) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/couchbase/CouchbaseAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/couchbase/CouchbaseAutoConfiguration.java index 15b68cf7e79..637b3878e9f 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/couchbase/CouchbaseAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/couchbase/CouchbaseAutoConfiguration.java @@ -16,6 +16,9 @@ package org.springframework.boot.autoconfigure.couchbase; +import com.couchbase.client.core.env.KeyValueServiceConfig; +import com.couchbase.client.core.env.QueryServiceConfig; +import com.couchbase.client.core.env.ViewServiceConfig; import com.couchbase.client.java.Bucket; import com.couchbase.client.java.Cluster; import com.couchbase.client.java.CouchbaseBucket; @@ -40,6 +43,7 @@ import org.springframework.context.annotation.Primary; * * @author Eddú Meléndez * @author Stephane Nicoll + * @author Yulin Qin * @since 1.4.0 */ @Configuration @@ -102,14 +106,18 @@ public class CouchbaseAutoConfiguration { if (timeouts.getConnect() != null) { builder = builder.connectTimeout(timeouts.getConnect().toMillis()); } - builder = builder.kvEndpoints(endpoints.getKeyValue()); + builder = builder.keyValueServiceConfig(KeyValueServiceConfig.create(endpoints.getKeyValue())); if (timeouts.getKeyValue() != null) { builder = builder.kvTimeout(timeouts.getKeyValue().toMillis()); } - builder = builder.queryEndpoints(endpoints.getQuery()); + int minQuery = endpoints.getQuery() != 1 ? endpoints.getQuery() : endpoints.getQueryservice().getMinEndpoints(); + int maxQuery = endpoints.getQuery() != 1 ? endpoints.getQuery() : endpoints.getQueryservice().getMaxEndpoints(); + builder = builder.queryServiceConfig(QueryServiceConfig.create(minQuery, maxQuery)); if (timeouts.getQuery() != null) { + int minView = endpoints.getView() != 1 ? endpoints.getView() : endpoints.getViewservice().getMinEndpoints(); + int maxView = endpoints.getView() != 1 ? endpoints.getView() : endpoints.getViewservice().getMaxEndpoints(); builder = builder.queryTimeout(timeouts.getQuery().toMillis()) - .viewEndpoints(endpoints.getView()); + .viewServiceConfig(ViewServiceConfig.create(minView, maxView)); } if (timeouts.getSocketConnect() != null) { builder = builder.socketConnectTimeout( diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/couchbase/CouchbaseProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/couchbase/CouchbaseProperties.java index 31599aa382a..f79b86de0c1 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/couchbase/CouchbaseProperties.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/couchbase/CouchbaseProperties.java @@ -20,6 +20,7 @@ import java.time.Duration; import java.util.List; import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.DeprecatedConfigurationProperty; import org.springframework.util.StringUtils; /** @@ -27,6 +28,7 @@ import org.springframework.util.StringUtils; * * @author Eddú Meléndez * @author Stephane Nicoll + * @author Yulin Qin * @since 1.4.0 */ @ConfigurationProperties(prefix = "spring.couchbase") @@ -126,6 +128,16 @@ public class CouchbaseProperties { */ private int view = 1; + /** + * Dynamic query service configuration. + */ + private Queryservice queryservice = new Queryservice(); + + /** + * Dynamic view service configuration. + */ + private Viewservice viewservice = new Viewservice(); + public int getKeyValue() { return this.keyValue; } @@ -134,24 +146,100 @@ public class CouchbaseProperties { this.keyValue = keyValue; } + @Deprecated + @DeprecatedConfigurationProperty(replacement = "spring.couchbase.env.endpoints.queryservice") public int getQuery() { return this.query; } + @Deprecated public void setQuery(int query) { this.query = query; } + @Deprecated + @DeprecatedConfigurationProperty(replacement = "spring.couchbase.env.endpoints.viewservice") public int getView() { return this.view; } + @Deprecated public void setView(int view) { this.view = view; } + public Queryservice getQueryservice() { + return this.queryservice; + } + + public void setQueryservice(Queryservice queryservice) { + this.queryservice = queryservice; + } + + public Viewservice getViewservice() { + return this.viewservice; + } + + public void setViewservice(Viewservice viewservice) { + this.viewservice = viewservice; + } + + public static class Queryservice { + /** + * Minimum Number of sockets per node against the query (N1QL) service. + */ + private int minEndpoints = 1; + /** + * Maximum Number of sockets per node against the query (N1QL) service. + */ + private int maxEndpoints = 1; + + public int getMinEndpoints() { + return this.minEndpoints; + } + + public void setMinEndpoints(int minEndpoints) { + this.minEndpoints = minEndpoints; + } + + public int getMaxEndpoints() { + return this.maxEndpoints; + } + + public void setMaxEndpoints(int maxEndpoints) { + this.maxEndpoints = maxEndpoints; + } + } + + public static class Viewservice { + /** + * Minimum Number of sockets per node against the view service. + */ + private int minEndpoints = 1; + /** + * Maximum Number of sockets per node against the view service. + */ + private int maxEndpoints = 1; + + public int getMinEndpoints() { + return this.minEndpoints; + } + + public void setMinEndpoints(int minEndpoints) { + this.minEndpoints = minEndpoints; + } + + public int getMaxEndpoints() { + return this.maxEndpoints; + } + + public void setMaxEndpoints(int maxEndpoints) { + this.maxEndpoints = maxEndpoints; + } + } } + public static class Ssl { /** diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/couchbase/CouchbaseAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/couchbase/CouchbaseAutoConfigurationTests.java index eb30f3ff8a7..14cd62ba2bd 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/couchbase/CouchbaseAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/couchbase/CouchbaseAutoConfigurationTests.java @@ -43,6 +43,7 @@ import static org.mockito.Mockito.mock; * * @author Eddú Meléndez * @author Stephane Nicoll + * @author Yulin Qin */ public class CouchbaseAutoConfigurationTests { @@ -84,16 +85,55 @@ public class CouchbaseAutoConfigurationTests { } @Test - public void customizeEnvEndpoints() { + public void customizeEnvEndpointsIfBothStaticAndDynamicAreSetThenStaticEndpointsTakePriorityForBackwardsCompatibility() { testCouchbaseEnv((env) -> { - assertThat(env.kvEndpoints()).isEqualTo(4); - assertThat(env.queryEndpoints()).isEqualTo(5); - assertThat(env.viewEndpoints()).isEqualTo(6); + assertThat(env.kvServiceConfig().minEndpoints()).isEqualTo(4); + assertThat(env.kvServiceConfig().maxEndpoints()).isEqualTo(4); + assertThat(env.queryServiceConfig().minEndpoints()).isEqualTo(5); + assertThat(env.queryServiceConfig().maxEndpoints()).isEqualTo(5); + assertThat(env.viewServiceConfig().minEndpoints()).isEqualTo(6); + assertThat(env.viewServiceConfig().maxEndpoints()).isEqualTo(6); }, "spring.couchbase.env.endpoints.keyValue=4", + "spring.couchbase.env.endpoints.queryservice.min-endpoints=2", + "spring.couchbase.env.endpoints.queryservice.max-endpoints=3", "spring.couchbase.env.endpoints.query=5", + "spring.couchbase.env.endpoints.viewservice.min-endpoints=2", + "spring.couchbase.env.endpoints.viewservice.max-endpoints=3", "spring.couchbase.env.endpoints.view=6"); } + + @Test + public void customizeEnvEndpointsWhenQueryAndViewStillWork() { + testCouchbaseEnv((env) -> { + assertThat(env.kvServiceConfig().minEndpoints()).isEqualTo(3); + assertThat(env.kvServiceConfig().maxEndpoints()).isEqualTo(3); + assertThat(env.queryServiceConfig().minEndpoints()).isEqualTo(2); + assertThat(env.queryServiceConfig().maxEndpoints()).isEqualTo(2); + assertThat(env.viewServiceConfig().minEndpoints()).isEqualTo(3); + assertThat(env.viewServiceConfig().maxEndpoints()).isEqualTo(3); + }, "spring.couchbase.env.endpoints.keyValue=3", + "spring.couchbase.env.endpoints.query=2", + "spring.couchbase.env.endpoints.view=3"); + } + + + @Test + public void customizeEnvEndpointsIfOnlyDynamicEndpointsAreSet() { + testCouchbaseEnv((env) -> { + assertThat(env.kvServiceConfig().minEndpoints()).isEqualTo(4); + assertThat(env.kvServiceConfig().maxEndpoints()).isEqualTo(4); + assertThat(env.queryServiceConfig().minEndpoints()).isEqualTo(2); + assertThat(env.queryServiceConfig().maxEndpoints()).isEqualTo(3); + assertThat(env.viewServiceConfig().minEndpoints()).isEqualTo(2); + assertThat(env.viewServiceConfig().maxEndpoints()).isEqualTo(3); + }, "spring.couchbase.env.endpoints.keyValue=4", + "spring.couchbase.env.endpoints.queryservice.min-endpoints=2", + "spring.couchbase.env.endpoints.queryservice.max-endpoints=3", + "spring.couchbase.env.endpoints.viewservice.min-endpoints=2", + "spring.couchbase.env.endpoints.viewservice.max-endpoints=3"); + } + @Test public void customizeEnvTimeouts() { testCouchbaseEnv((env) -> { From 6692301d51d22e1a427180c8fc7754d6ea8e6df8 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Mon, 9 Apr 2018 16:04:05 +0200 Subject: [PATCH 2/2] Polish "Replace Couchbase's deprecated methods" Closes gh-12655 --- .../couchbase/CouchbaseAutoConfiguration.java | 41 ++++++++-- .../couchbase/CouchbaseProperties.java | 82 ++++++------------- .../CouchbaseAutoConfigurationTests.java | 81 +++++++++--------- .../appendix-application-properties.adoc | 6 +- 4 files changed, 106 insertions(+), 104 deletions(-) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/couchbase/CouchbaseAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/couchbase/CouchbaseAutoConfiguration.java index 637b3878e9f..65a2fb8b8bd 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/couchbase/CouchbaseAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/couchbase/CouchbaseAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 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. @@ -106,18 +106,21 @@ public class CouchbaseAutoConfiguration { if (timeouts.getConnect() != null) { builder = builder.connectTimeout(timeouts.getConnect().toMillis()); } - builder = builder.keyValueServiceConfig(KeyValueServiceConfig.create(endpoints.getKeyValue())); + builder = builder.keyValueServiceConfig(KeyValueServiceConfig.create( + endpoints.getKeyValue())); if (timeouts.getKeyValue() != null) { builder = builder.kvTimeout(timeouts.getKeyValue().toMillis()); } - int minQuery = endpoints.getQuery() != 1 ? endpoints.getQuery() : endpoints.getQueryservice().getMinEndpoints(); - int maxQuery = endpoints.getQuery() != 1 ? endpoints.getQuery() : endpoints.getQueryservice().getMaxEndpoints(); - builder = builder.queryServiceConfig(QueryServiceConfig.create(minQuery, maxQuery)); + CouchbaseServiceConfig queryConfig = determineCouchbaseServiceConfig( + endpoints.getQueryservice(), endpoints.getQuery()); + builder = builder.queryServiceConfig(QueryServiceConfig.create( + queryConfig.minEndpoints, queryConfig.maxEndpoints)); if (timeouts.getQuery() != null) { - int minView = endpoints.getView() != 1 ? endpoints.getView() : endpoints.getViewservice().getMinEndpoints(); - int maxView = endpoints.getView() != 1 ? endpoints.getView() : endpoints.getViewservice().getMaxEndpoints(); + CouchbaseServiceConfig viewConfig = determineCouchbaseServiceConfig( + endpoints.getViewservice(), endpoints.getView()); builder = builder.queryTimeout(timeouts.getQuery().toMillis()) - .viewServiceConfig(ViewServiceConfig.create(minView, maxView)); + .viewServiceConfig(ViewServiceConfig.create( + viewConfig.minEndpoints, viewConfig.maxEndpoints)); } if (timeouts.getSocketConnect() != null) { builder = builder.socketConnectTimeout( @@ -139,6 +142,28 @@ public class CouchbaseAutoConfiguration { return builder; } + private CouchbaseServiceConfig determineCouchbaseServiceConfig( + CouchbaseProperties.Endpoints.CouchbaseService couchbaseService, + Integer fallback) { + if (couchbaseService.getMinEndpoints() != 1 + || couchbaseService.getMaxEndpoints() != 1) { + return new CouchbaseServiceConfig(couchbaseService.getMinEndpoints(), + couchbaseService.getMaxEndpoints()); + } + int endpoints = (fallback != null ? fallback : 1); + return new CouchbaseServiceConfig(endpoints, endpoints); + } + + private static class CouchbaseServiceConfig { + private int minEndpoints; + private int maxEndpoints; + + CouchbaseServiceConfig(int minEndpoints, int maxEndpoints) { + this.minEndpoints = minEndpoints; + this.maxEndpoints = maxEndpoints; + } + } + } /** diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/couchbase/CouchbaseProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/couchbase/CouchbaseProperties.java index f79b86de0c1..f3ddc31beeb 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/couchbase/CouchbaseProperties.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/couchbase/CouchbaseProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 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. @@ -119,105 +119,73 @@ public class CouchbaseProperties { private int keyValue = 1; /** - * Number of sockets per node against the query (N1QL) service. + * Query (N1QL) service configuration. */ - private int query = 1; + private final CouchbaseService queryservice = new CouchbaseService(); /** - * Number of sockets per node against the view service. + * View service configuration. */ - private int view = 1; + private final CouchbaseService viewservice = new CouchbaseService(); /** - * Dynamic query service configuration. + * Number of sockets per node against the query (N1QL) service. */ - private Queryservice queryservice = new Queryservice(); + private Integer query; /** - * Dynamic view service configuration. + * Number of sockets per node against the view service. */ - private Viewservice viewservice = new Viewservice(); + private Integer view; public int getKeyValue() { return this.keyValue; } + @Deprecated public void setKeyValue(int keyValue) { this.keyValue = keyValue; } @Deprecated - @DeprecatedConfigurationProperty(replacement = "spring.couchbase.env.endpoints.queryservice") - public int getQuery() { + @DeprecatedConfigurationProperty(replacement = "spring.couchbase.env.endpoints.queryservice.max-endpoints") + public Integer getQuery() { return this.query; } @Deprecated - public void setQuery(int query) { + public void setQuery(Integer query) { this.query = query; } + public CouchbaseService getQueryservice() { + return this.queryservice; + } + @Deprecated - @DeprecatedConfigurationProperty(replacement = "spring.couchbase.env.endpoints.viewservice") - public int getView() { + @DeprecatedConfigurationProperty(replacement = "spring.couchbase.env.endpoints.viewservice.max-endpoints") + public Integer getView() { return this.view; } @Deprecated - public void setView(int view) { + public void setView(Integer view) { this.view = view; } - public Queryservice getQueryservice() { - return this.queryservice; - } - - public void setQueryservice(Queryservice queryservice) { - this.queryservice = queryservice; - } - - public Viewservice getViewservice() { + public CouchbaseService getViewservice() { return this.viewservice; } - public void setViewservice(Viewservice viewservice) { - this.viewservice = viewservice; - } + public static class CouchbaseService { - public static class Queryservice { /** - * Minimum Number of sockets per node against the query (N1QL) service. + * Minimum number of sockets per node. */ private int minEndpoints = 1; - /** - * Maximum Number of sockets per node against the query (N1QL) service. - */ - private int maxEndpoints = 1; - public int getMinEndpoints() { - return this.minEndpoints; - } - - public void setMinEndpoints(int minEndpoints) { - this.minEndpoints = minEndpoints; - } - - public int getMaxEndpoints() { - return this.maxEndpoints; - } - - public void setMaxEndpoints(int maxEndpoints) { - this.maxEndpoints = maxEndpoints; - } - } - - public static class Viewservice { /** - * Minimum Number of sockets per node against the view service. - */ - private int minEndpoints = 1; - /** - * Maximum Number of sockets per node against the view service. + * Maximum number of sockets per node. */ private int maxEndpoints = 1; @@ -236,7 +204,9 @@ public class CouchbaseProperties { public void setMaxEndpoints(int maxEndpoints) { this.maxEndpoints = maxEndpoints; } + } + } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/couchbase/CouchbaseAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/couchbase/CouchbaseAutoConfigurationTests.java index 14cd62ba2bd..44b16593393 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/couchbase/CouchbaseAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/couchbase/CouchbaseAutoConfigurationTests.java @@ -43,7 +43,6 @@ import static org.mockito.Mockito.mock; * * @author Eddú Meléndez * @author Stephane Nicoll - * @author Yulin Qin */ public class CouchbaseAutoConfigurationTests { @@ -85,53 +84,59 @@ public class CouchbaseAutoConfigurationTests { } @Test - public void customizeEnvEndpointsIfBothStaticAndDynamicAreSetThenStaticEndpointsTakePriorityForBackwardsCompatibility() { + public void customizeEnvEndpoints() { testCouchbaseEnv((env) -> { - assertThat(env.kvServiceConfig().minEndpoints()).isEqualTo(4); - assertThat(env.kvServiceConfig().maxEndpoints()).isEqualTo(4); - assertThat(env.queryServiceConfig().minEndpoints()).isEqualTo(5); - assertThat(env.queryServiceConfig().maxEndpoints()).isEqualTo(5); - assertThat(env.viewServiceConfig().minEndpoints()).isEqualTo(6); - assertThat(env.viewServiceConfig().maxEndpoints()).isEqualTo(6); - }, "spring.couchbase.env.endpoints.keyValue=4", - "spring.couchbase.env.endpoints.queryservice.min-endpoints=2", - "spring.couchbase.env.endpoints.queryservice.max-endpoints=3", - "spring.couchbase.env.endpoints.query=5", - "spring.couchbase.env.endpoints.viewservice.min-endpoints=2", - "spring.couchbase.env.endpoints.viewservice.max-endpoints=3", - "spring.couchbase.env.endpoints.view=6"); + assertThat(env.kvServiceConfig().minEndpoints()).isEqualTo(2); + assertThat(env.kvServiceConfig().maxEndpoints()).isEqualTo(2); + assertThat(env.queryServiceConfig().minEndpoints()).isEqualTo(3); + assertThat(env.queryServiceConfig().maxEndpoints()).isEqualTo(5); + assertThat(env.viewServiceConfig().minEndpoints()).isEqualTo(4); + assertThat(env.viewServiceConfig().maxEndpoints()).isEqualTo(6); + }, "spring.couchbase.env.endpoints.key-value=2", + "spring.couchbase.env.endpoints.queryservice.min-endpoints=3", + "spring.couchbase.env.endpoints.queryservice.max-endpoints=5", + "spring.couchbase.env.endpoints.viewservice.min-endpoints=4", + "spring.couchbase.env.endpoints.viewservice.max-endpoints=6"); } - @Test - public void customizeEnvEndpointsWhenQueryAndViewStillWork() { + @Deprecated + public void customizeEnvEndpointsWithDeprecatedProperties() { testCouchbaseEnv((env) -> { - assertThat(env.kvServiceConfig().minEndpoints()).isEqualTo(3); - assertThat(env.kvServiceConfig().maxEndpoints()).isEqualTo(3); - assertThat(env.queryServiceConfig().minEndpoints()).isEqualTo(2); - assertThat(env.queryServiceConfig().maxEndpoints()).isEqualTo(2); - assertThat(env.viewServiceConfig().minEndpoints()).isEqualTo(3); - assertThat(env.viewServiceConfig().maxEndpoints()).isEqualTo(3); - }, "spring.couchbase.env.endpoints.keyValue=3", - "spring.couchbase.env.endpoints.query=2", - "spring.couchbase.env.endpoints.view=3"); + assertThat(env.queryServiceConfig().minEndpoints()).isEqualTo(3); + assertThat(env.queryServiceConfig().maxEndpoints()).isEqualTo(3); + assertThat(env.viewServiceConfig().minEndpoints()).isEqualTo(4); + assertThat(env.viewServiceConfig().maxEndpoints()).isEqualTo(4); + }, "spring.couchbase.env.endpoints.query=3", + "spring.couchbase.env.endpoints.view=4"); } + @Test + public void customizeEnvEndpointsUsesNewInfrastructure() { + testCouchbaseEnv((env) -> { + assertThat(env.queryServiceConfig().minEndpoints()).isEqualTo(3); + assertThat(env.queryServiceConfig().maxEndpoints()).isEqualTo(5); + assertThat(env.viewServiceConfig().minEndpoints()).isEqualTo(4); + assertThat(env.viewServiceConfig().maxEndpoints()).isEqualTo(6); + }, "spring.couchbase.env.endpoints.query=33", + "spring.couchbase.env.endpoints.queryservice.min-endpoints=3", + "spring.couchbase.env.endpoints.queryservice.max-endpoints=5", + "spring.couchbase.env.endpoints.view=44", + "spring.couchbase.env.endpoints.viewservice.min-endpoints=4", + "spring.couchbase.env.endpoints.viewservice.max-endpoints=6"); + } @Test - public void customizeEnvEndpointsIfOnlyDynamicEndpointsAreSet() { + public void customizeEnvEndpointsUsesNewInfrastructureWithOnlyMax() { testCouchbaseEnv((env) -> { - assertThat(env.kvServiceConfig().minEndpoints()).isEqualTo(4); - assertThat(env.kvServiceConfig().maxEndpoints()).isEqualTo(4); - assertThat(env.queryServiceConfig().minEndpoints()).isEqualTo(2); - assertThat(env.queryServiceConfig().maxEndpoints()).isEqualTo(3); - assertThat(env.viewServiceConfig().minEndpoints()).isEqualTo(2); - assertThat(env.viewServiceConfig().maxEndpoints()).isEqualTo(3); - }, "spring.couchbase.env.endpoints.keyValue=4", - "spring.couchbase.env.endpoints.queryservice.min-endpoints=2", - "spring.couchbase.env.endpoints.queryservice.max-endpoints=3", - "spring.couchbase.env.endpoints.viewservice.min-endpoints=2", - "spring.couchbase.env.endpoints.viewservice.max-endpoints=3"); + assertThat(env.queryServiceConfig().minEndpoints()).isEqualTo(1); + assertThat(env.queryServiceConfig().maxEndpoints()).isEqualTo(5); + assertThat(env.viewServiceConfig().minEndpoints()).isEqualTo(1); + assertThat(env.viewServiceConfig().maxEndpoints()).isEqualTo(6); + }, "spring.couchbase.env.endpoints.query=33", + "spring.couchbase.env.endpoints.queryservice.max-endpoints=5", + "spring.couchbase.env.endpoints.view=44", + "spring.couchbase.env.endpoints.viewservice.max-endpoints=6"); } @Test diff --git a/spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc b/spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc index 3551095503f..77998bfcc21 100644 --- a/spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc +++ b/spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc @@ -573,8 +573,10 @@ content into your application. Rather, pick only the properties that you need. spring.couchbase.bucket.name=default # Name of the bucket to connect to. spring.couchbase.bucket.password= # Password of the bucket. spring.couchbase.env.endpoints.key-value=1 # Number of sockets per node against the key/value service. - spring.couchbase.env.endpoints.query=1 # Number of sockets per node against the query (N1QL) service. - spring.couchbase.env.endpoints.view=1 # Number of sockets per node against the view service. + spring.couchbase.env.endpoints.queryservice.min-endpoints=1 # Minimum number of sockets per node. + spring.couchbase.env.endpoints.queryservice.max-endpoints=1 # Maximum number of sockets per node. + spring.couchbase.env.endpoints.viewservice.min-endpoints=1 # Minimum number of sockets per node. + spring.couchbase.env.endpoints.viewservice.max-endpoints=1 # Maximum number of sockets per node. spring.couchbase.env.ssl.enabled= # Whether to enable SSL support. Enabled automatically if a "keyStore" is provided unless specified otherwise. spring.couchbase.env.ssl.key-store= # Path to the JVM key store that holds the certificates. spring.couchbase.env.ssl.key-store-password= # Password used to access the key store.