From 6be772c26f1a39975d264181da653387638bb10b Mon Sep 17 00:00:00 2001 From: agrgr Date: Tue, 24 Sep 2024 12:30:47 +0300 Subject: [PATCH] move ServerVersionSupport to common configuration, update client beans return type, add CacheKeyProcessor bean, un-deprecate properties --- .../aerospike/AerospikeAutoConfiguration.java | 27 ++++--------------- .../aerospike/AerospikeProperties.java | 6 ----- .../AerospikeCommonDataConfiguration.java | 25 +++++++++++++++++ .../aerospike/AerospikeDataProperties.java | 3 --- 4 files changed, 30 insertions(+), 31 deletions(-) diff --git a/spring-boot-autoconfigure-data-aerospike/src/main/java/org/springframework/boot/autoconfigure/aerospike/AerospikeAutoConfiguration.java b/spring-boot-autoconfigure-data-aerospike/src/main/java/org/springframework/boot/autoconfigure/aerospike/AerospikeAutoConfiguration.java index a223431..637931f 100644 --- a/spring-boot-autoconfigure-data-aerospike/src/main/java/org/springframework/boot/autoconfigure/aerospike/AerospikeAutoConfiguration.java +++ b/spring-boot-autoconfigure-data-aerospike/src/main/java/org/springframework/boot/autoconfigure/aerospike/AerospikeAutoConfiguration.java @@ -23,15 +23,14 @@ import com.aerospike.client.async.NioEventLoops; import com.aerospike.client.policy.*; import com.aerospike.client.reactor.AerospikeReactorClient; +import com.aerospike.client.reactor.IAerospikeReactorClient; import org.springframework.boot.autoconfigure.AutoConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.boot.autoconfigure.data.aerospike.AerospikeDataProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; -import org.springframework.data.aerospike.server.version.ServerVersionSupport; import reactor.core.publisher.Flux; import java.util.Optional; @@ -50,28 +49,12 @@ public class AerospikeAutoConfiguration { @Bean(name = "aerospikeClient", destroyMethod = "close") @ConditionalOnMissingBean(IAerospikeClient.class) - public AerospikeClient aerospikeClient(AerospikeProperties properties, - ClientPolicy aerospikeClientPolicy) { + public IAerospikeClient aerospikeClient(AerospikeProperties properties, + ClientPolicy aerospikeClientPolicy) { Host[] hosts = Host.parseHosts(properties.getHosts(), properties.getDefaultPort()); return new AerospikeClient(aerospikeClientPolicy, hosts); } - @Bean(name = "aerospikeServerVersionSupport") - @ConditionalOnMissingBean(ServerVersionSupport.class) - public ServerVersionSupport serverVersionSupport(IAerospikeClient aerospikeClient, - AerospikeDataProperties properties) { - ServerVersionSupport serverVersionSupport = new ServerVersionSupport(aerospikeClient); - processServerVersionRefreshFrequency(properties.getServerVersionRefreshSeconds(), serverVersionSupport); - return serverVersionSupport; - } - - private void processServerVersionRefreshFrequency(int serverVersionRefreshSeconds, - ServerVersionSupport serverVersionSupport) { - if (serverVersionRefreshSeconds > 0) { - serverVersionSupport.scheduleServerVersionRefresh(serverVersionRefreshSeconds); - } - } - @Bean(name = "aerospikeClientPolicy") @ConditionalOnMissingBean public ClientPolicy aerospikeClientPolicy(AerospikeProperties properties, @@ -108,8 +91,8 @@ public static class AerospikeReactiveAutoConfiguration { @Bean(name = "aerospikeReactorClient", destroyMethod = "") @ConditionalOnMissingBean //disable destroy method, because we do not want AerospikeReactorClient to close AerospikeClient - public AerospikeReactorClient aerospikeReactorClient(IAerospikeClient aerospikeClient, - EventLoops eventLoops) { + public IAerospikeReactorClient aerospikeReactorClient(IAerospikeClient aerospikeClient, + EventLoops eventLoops) { return new AerospikeReactorClient(aerospikeClient, eventLoops); } diff --git a/spring-boot-autoconfigure-data-aerospike/src/main/java/org/springframework/boot/autoconfigure/aerospike/AerospikeProperties.java b/spring-boot-autoconfigure-data-aerospike/src/main/java/org/springframework/boot/autoconfigure/aerospike/AerospikeProperties.java index 6c6a6f7..620f4ab 100644 --- a/spring-boot-autoconfigure-data-aerospike/src/main/java/org/springframework/boot/autoconfigure/aerospike/AerospikeProperties.java +++ b/spring-boot-autoconfigure-data-aerospike/src/main/java/org/springframework/boot/autoconfigure/aerospike/AerospikeProperties.java @@ -38,10 +38,7 @@ public class AerospikeProperties { *

* See {@link com.aerospike.client.Host#parseHosts} documentation for more details. * - * @deprecated since 0.14.0, {@link AerospikeDataSettings} with the prefix "spring-data-aerospike.connection". - * will be used instead to read from application.properties */ - @Deprecated(since = "0.14.0", forRemoval = true) private String hosts; /** @@ -49,10 +46,7 @@ public class AerospikeProperties { *

* See {@link com.aerospike.client.Host#parseHosts} documentation for more details. * - * @deprecated since 0.14.0, {@link AerospikeDataSettings} with the prefix "spring-data-aerospike.connection". - * will be used instead to read from application.properties */ - @Deprecated(since = "0.14.0", forRemoval = true) private int defaultPort = 3000; /** diff --git a/spring-boot-autoconfigure-data-aerospike/src/main/java/org/springframework/boot/autoconfigure/data/aerospike/AerospikeCommonDataConfiguration.java b/spring-boot-autoconfigure-data-aerospike/src/main/java/org/springframework/boot/autoconfigure/data/aerospike/AerospikeCommonDataConfiguration.java index 63e2faa..05f96aa 100644 --- a/spring-boot-autoconfigure-data-aerospike/src/main/java/org/springframework/boot/autoconfigure/data/aerospike/AerospikeCommonDataConfiguration.java +++ b/spring-boot-autoconfigure-data-aerospike/src/main/java/org/springframework/boot/autoconfigure/data/aerospike/AerospikeCommonDataConfiguration.java @@ -1,5 +1,6 @@ package org.springframework.boot.autoconfigure.data.aerospike; +import com.aerospike.client.IAerospikeClient; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.BeanUtils; import org.springframework.boot.autoconfigure.AutoConfiguration; @@ -7,6 +8,8 @@ import org.springframework.boot.autoconfigure.domain.EntityScanner; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Bean; +import org.springframework.data.aerospike.cache.AerospikeCacheKeyProcessor; +import org.springframework.data.aerospike.cache.AerospikeCacheKeyProcessorImpl; import org.springframework.data.aerospike.config.AerospikeConnectionSettings; import org.springframework.data.aerospike.config.AerospikeDataSettings; import org.springframework.data.aerospike.config.AerospikeSettings; @@ -22,6 +25,7 @@ import org.springframework.data.aerospike.query.StatementBuilder; import org.springframework.data.aerospike.query.cache.IndexesCache; import org.springframework.data.aerospike.query.cache.IndexesCacheHolder; +import org.springframework.data.aerospike.server.version.ServerVersionSupport; import org.springframework.data.annotation.Persistent; import org.springframework.data.mapping.model.FieldNamingStrategy; @@ -31,6 +35,22 @@ @AutoConfiguration class AerospikeCommonDataConfiguration { + @Bean(name = "aerospikeServerVersionSupport") + @ConditionalOnMissingBean(ServerVersionSupport.class) + public ServerVersionSupport serverVersionSupport(IAerospikeClient aerospikeClient, + AerospikeDataProperties properties) { + ServerVersionSupport serverVersionSupport = new ServerVersionSupport(aerospikeClient); + processServerVersionRefreshFrequency(properties.getServerVersionRefreshSeconds(), serverVersionSupport); + return serverVersionSupport; + } + + private void processServerVersionRefreshFrequency(int serverVersionRefreshSeconds, + ServerVersionSupport serverVersionSupport) { + if (serverVersionRefreshSeconds > 0) { + serverVersionSupport.scheduleServerVersionRefresh(serverVersionRefreshSeconds); + } + } + @Bean(name = "aerospikeFilterExpressionsBuilder") @ConditionalOnMissingBean(name = "aerospikeFilterExpressionsBuilder") public FilterExpressionsBuilder aerospikeFilterExpressionsBuilder() { @@ -55,6 +75,11 @@ public IndexesCacheHolder aerospikeIndexCache() { return new IndexesCacheHolder(); } + @Bean(name = "aerospikeCacheKeyProcessor") + public AerospikeCacheKeyProcessor cacheKeyProcessor() { + return new AerospikeCacheKeyProcessorImpl(); + } + @Bean(name = "mappingAerospikeConverter") @ConditionalOnMissingBean(name = "mappingAerospikeConverter") public MappingAerospikeConverter mappingAerospikeConverter(AerospikeMappingContext aerospikeMappingContext, diff --git a/spring-boot-autoconfigure-data-aerospike/src/main/java/org/springframework/boot/autoconfigure/data/aerospike/AerospikeDataProperties.java b/spring-boot-autoconfigure-data-aerospike/src/main/java/org/springframework/boot/autoconfigure/data/aerospike/AerospikeDataProperties.java index 7a7d2bf..485cc65 100644 --- a/spring-boot-autoconfigure-data-aerospike/src/main/java/org/springframework/boot/autoconfigure/data/aerospike/AerospikeDataProperties.java +++ b/spring-boot-autoconfigure-data-aerospike/src/main/java/org/springframework/boot/autoconfigure/data/aerospike/AerospikeDataProperties.java @@ -23,13 +23,10 @@ /** * Configuration properties for Spring Data Aerospike. - * @deprecated since 0.14.0, {@link AerospikeDataSettings} with the prefix "spring-data-aerospike.data". - * will be used instead to read from application.properties. * * @author Igor Ermolenko * @author Anastasiia Smirnova */ -@Deprecated(since = "0.14.0", forRemoval = true) @ConfigurationProperties(prefix = "spring.data.aerospike") @Getter @Setter