Skip to content

Commit

Permalink
Prepare 0.13.0
Browse files Browse the repository at this point in the history
  • Loading branch information
roimenashe committed Dec 21, 2023
1 parent c7b3603 commit d3eff8b
Show file tree
Hide file tree
Showing 10 changed files with 154 additions and 51 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ jobs:
steps:
# Checkout repo using https://github.com/marketplace/actions/checkout
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 17
Expand Down
7 changes: 6 additions & 1 deletion README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ image:https://github.com/aerospike-community/spring-data-aerospike-starters/work

|===
|`spring-data-aerospike-starters` |`spring-data-aerospike` |`aerospike-client` |`aerospike-reactor-client`
|0.13.x
|4.6.x
|7.2.x
|7.1.x

|0.12.x
|4.5.x
|7.1.x
Expand Down Expand Up @@ -76,7 +81,7 @@ Specify Aerospike server hosts and namespace:
[source,properties]
----
spring.aerospike.hosts=aerospike-1-server-ip:3000,aerospike-2-server-ip:3000
spring.data.aerospike.namespace=TEST
spring.data.aerospike.namespace=test
----

== Configuration options
Expand Down
12 changes: 6 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>3.1.2</version>
<version>3.2.0</version>
</parent>

<groupId>com.aerospike</groupId>
Expand All @@ -31,7 +31,7 @@
</modules>

<properties>
<revision>0.12.0</revision>
<revision>0.13.0</revision>
<java.version>17</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
Expand All @@ -40,11 +40,11 @@
<maven.gpg.plugin.version>1.6</maven.gpg.plugin.version>
<flatten.maven.plugin.version>1.5.0</flatten.maven.plugin.version>

<spring-data-aerospike.version>4.5.0</spring-data-aerospike.version>
<aerospike-reactor-client.version>7.0.0</aerospike-reactor-client.version>
<aerospike-client.version>7.1.0</aerospike-client.version>
<spring-data-aerospike.version>4.6.0</spring-data-aerospike.version>
<aerospike-reactor-client.version>7.1.0</aerospike-reactor-client.version>
<aerospike-client.version>7.2.0</aerospike-client.version>

<spring-cloud-starter.version>4.0.4</spring-cloud-starter.version>
<spring-cloud-starter.version>4.1.0</spring-cloud-starter.version>
</properties>

<licenses>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
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;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.domain.EntityScanner;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.data.aerospike.config.AerospikeDataSettings;
import org.springframework.data.aerospike.convert.AerospikeCustomConversions;
import org.springframework.data.aerospike.convert.AerospikeTypeAliasAccessor;
import org.springframework.data.aerospike.convert.MappingAerospikeConverter;
Expand All @@ -18,11 +21,13 @@
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;

import java.util.Collections;

@Slf4j
@AutoConfiguration
class AerospikeCommonDataConfiguration {

Expand Down Expand Up @@ -54,8 +59,10 @@ public IndexesCacheHolder aerospikeIndexCache() {
@ConditionalOnMissingBean(name = "mappingAerospikeConverter")
public MappingAerospikeConverter mappingAerospikeConverter(AerospikeMappingContext aerospikeMappingContext,
AerospikeTypeAliasAccessor aerospikeTypeAliasAccessor,
AerospikeCustomConversions aerospikeCustomConversions) {
return new MappingAerospikeConverter(aerospikeMappingContext, aerospikeCustomConversions, aerospikeTypeAliasAccessor);
AerospikeCustomConversions aerospikeCustomConversions,
AerospikeDataProperties aerospikeDataProperties) {
return new MappingAerospikeConverter(aerospikeMappingContext, aerospikeCustomConversions,
aerospikeTypeAliasAccessor, aerospikeDataSettings(aerospikeDataProperties));
}

@Bean(name = "aerospikeTypeAliasAccessor")
Expand Down Expand Up @@ -91,4 +98,37 @@ public AerospikeMappingContext aerospikeMappingContext(ApplicationContext applic
public AerospikeExceptionTranslator aerospikeExceptionTranslator() {
return new DefaultAerospikeExceptionTranslator();
}

@Bean(name = "aerospikeServerVersionSupport")
public ServerVersionSupport serverVersionSupport(IAerospikeClient aerospikeClient,
AerospikeDataProperties aerospikeDataProperties) {
ServerVersionSupport serverVersionSupport = new ServerVersionSupport(aerospikeClient);
int serverVersionRefreshFrequency =
aerospikeDataSettings(aerospikeDataProperties).getServerVersionRefreshSeconds();
processServerVersionRefreshFrequency(serverVersionRefreshFrequency, serverVersionSupport);
return serverVersionSupport;
}

private void processServerVersionRefreshFrequency(int serverVersionRefreshSeconds,
ServerVersionSupport serverVersionSupport) {
if (serverVersionRefreshSeconds <= 0) {
log.info("Periodic server version refreshing is not scheduled, interval ({}) is <= 0",
serverVersionRefreshSeconds);
} else {
serverVersionSupport.scheduleServerVersionRefresh(serverVersionRefreshSeconds);
}
}

private AerospikeDataSettings aerospikeDataSettings(AerospikeDataProperties aerospikeDataProperties) {
AerospikeDataSettings.AerospikeDataSettingsBuilder builder = AerospikeDataSettings.builder();
configureDataSettings(builder, aerospikeDataProperties);
return builder.build();
}

private void configureDataSettings(AerospikeDataSettings.AerospikeDataSettingsBuilder builder,
AerospikeDataProperties aerospikeDataProperties) {
builder.scansEnabled(aerospikeDataProperties.isScansEnabled());
builder.sendKey(aerospikeDataProperties.isSendKey());
builder.createIndexesOnStartup(aerospikeDataProperties.isCreateIndexesOnStartup());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@
package org.springframework.boot.autoconfigure.data.aerospike;

import com.aerospike.client.IAerospikeClient;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Lazy;
import org.springframework.data.aerospike.config.AerospikeDataSettings;
import org.springframework.data.aerospike.convert.MappingAerospikeConverter;
import org.springframework.data.aerospike.core.AerospikeExceptionTranslator;
import org.springframework.data.aerospike.core.AerospikeTemplate;
Expand All @@ -35,13 +37,15 @@
import org.springframework.data.aerospike.query.cache.IndexRefresher;
import org.springframework.data.aerospike.query.cache.IndexesCacheUpdater;
import org.springframework.data.aerospike.query.cache.InternalIndexOperations;
import org.springframework.data.aerospike.server.version.ServerVersionSupport;

/**
* Configure Spring Data's Aerospike support.
*
* @author Igor Ermolenko
* @author Anastasiia Smirnova
*/
@Slf4j
@AutoConfiguration
class AerospikeDataConfiguration {

Expand All @@ -52,12 +56,10 @@ public AerospikeTemplate aerospikeTemplate(IAerospikeClient aerospikeClient,
MappingAerospikeConverter mappingAerospikeConverter,
AerospikeMappingContext aerospikeMappingContext,
AerospikeExceptionTranslator aerospikeExceptionTranslator,
QueryEngine queryEngine, IndexRefresher indexRefresher) {
return new AerospikeTemplate(aerospikeClient,
aerospikeDataProperties.getNamespace(),
mappingAerospikeConverter,
aerospikeMappingContext,
aerospikeExceptionTranslator, queryEngine, indexRefresher);
QueryEngine queryEngine, IndexRefresher indexRefresher,
ServerVersionSupport serverVersionSupport) {
return new AerospikeTemplate(aerospikeClient, aerospikeDataProperties.getNamespace(), mappingAerospikeConverter,
aerospikeMappingContext, aerospikeExceptionTranslator, queryEngine, indexRefresher, serverVersionSupport);
}

@Bean(name = "aerospikeQueryEngine")
Expand All @@ -66,26 +68,55 @@ public QueryEngine aerospikeQueryEngine(IAerospikeClient aerospikeClient,
AerospikeDataProperties aerospikeDataProperties,
FilterExpressionsBuilder filterExpressionsBuilder,
StatementBuilder statementBuilder) {
QueryEngine queryEngine = new QueryEngine(aerospikeClient, statementBuilder, filterExpressionsBuilder, aerospikeClient.getQueryPolicyDefault());
QueryEngine queryEngine = new QueryEngine(aerospikeClient, statementBuilder, filterExpressionsBuilder);
queryEngine.setScansEnabled(aerospikeDataProperties.isScansEnabled());
queryEngine.setQueryMaxRecords(aerospikeDataProperties.getQueryMaxRecords());
return queryEngine;
}

@Bean(name = "aerospikeIndexRefresher")
@ConditionalOnMissingBean(name = "aerospikeIndexRefresher")
public IndexRefresher aerospikeIndexRefresher(IAerospikeClient aerospikeClient, IndexesCacheUpdater indexesCacheUpdater) {
IndexRefresher refresher = new IndexRefresher(aerospikeClient, aerospikeClient.getInfoPolicyDefault(), new InternalIndexOperations(new IndexInfoParser()), indexesCacheUpdater);
public IndexRefresher indexRefresher(IAerospikeClient aerospikeClient, IndexesCacheUpdater indexesCacheUpdater,
ServerVersionSupport serverVersionSupport,
AerospikeDataProperties aerospikeDataProperties) {
IndexRefresher refresher = new IndexRefresher(aerospikeClient, aerospikeClient.getInfoPolicyDefault(),
new InternalIndexOperations(new IndexInfoParser()), indexesCacheUpdater, serverVersionSupport);
refresher.refreshIndexes();
int refreshFrequency = aerospikeDataSettings(aerospikeDataProperties).getIndexCacheRefreshSeconds();
processCacheRefreshFrequency(refreshFrequency, refresher);
return refresher;
}

private void processCacheRefreshFrequency(int indexCacheRefreshSeconds, IndexRefresher indexRefresher) {
if (indexCacheRefreshSeconds <= 0) {
log.info("Periodic index cache refreshing is not scheduled, interval ({}) is <= 0",
indexCacheRefreshSeconds);
} else {
indexRefresher.scheduleRefreshIndexes(indexCacheRefreshSeconds);
}
}

@Bean
@ConditionalOnMissingBean(name = "aerospikePersistenceEntityIndexCreator")
public AerospikePersistenceEntityIndexCreator aerospikePersistenceEntityIndexCreator(
AerospikeDataProperties aerospikeDataProperties,
@Lazy AerospikeTemplate template,
@Lazy ObjectProvider<AerospikeTemplate> template,
ObjectProvider<AerospikeMappingContext> aerospikeMappingContext,
AerospikeIndexResolver aerospikeIndexResolver) {
return new AerospikePersistenceEntityIndexCreator(aerospikeMappingContext, aerospikeDataProperties.isCreateIndexesOnStartup(), aerospikeIndexResolver, template);
return new AerospikePersistenceEntityIndexCreator(aerospikeMappingContext,
aerospikeDataProperties.isCreateIndexesOnStartup(), aerospikeIndexResolver, template);
}

private AerospikeDataSettings aerospikeDataSettings(AerospikeDataProperties aerospikeDataProperties) {
AerospikeDataSettings.AerospikeDataSettingsBuilder builder = AerospikeDataSettings.builder();
configureDataSettings(builder, aerospikeDataProperties);
return builder.build();
}

private void configureDataSettings(AerospikeDataSettings.AerospikeDataSettingsBuilder builder,
AerospikeDataProperties aerospikeDataProperties) {
builder.scansEnabled(aerospikeDataProperties.isScansEnabled());
builder.sendKey(aerospikeDataProperties.isSendKey());
builder.createIndexesOnStartup(aerospikeDataProperties.isCreateIndexesOnStartup());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ public class AerospikeDataProperties {
*/
private boolean scansEnabled = false;

/**
* Limit amount of results returned by server. Non-positive value means no limit.
*/
private long queryMaxRecords = 10_000L;

/**
* Specifies fully qualified name of the FieldNamingStrategy for the entities.
*/
Expand All @@ -55,6 +60,11 @@ public class AerospikeDataProperties {
*/
private boolean createIndexesOnStartup = true;

/**
* Send user defined key in addition to hash digest on both reads and writes
*/
private boolean sendKey = true;

public String getNamespace() {
return namespace;
}
Expand All @@ -79,6 +89,14 @@ public void setScansEnabled(boolean scansEnabled) {
this.scansEnabled = scansEnabled;
}

public long getQueryMaxRecords() {
return queryMaxRecords;
}

public void setQueryMaxRecords(long queryMaxRecords) {
this.queryMaxRecords = queryMaxRecords;
}

public Class<?> getFieldNamingStrategy() {
return fieldNamingStrategy;
}
Expand All @@ -94,4 +112,12 @@ public boolean isCreateIndexesOnStartup() {
public void setCreateIndexesOnStartup(boolean createIndexesOnStartup) {
this.createIndexesOnStartup = createIndexesOnStartup;
}

public boolean isSendKey() {
return sendKey;
}

public void setSendKey(boolean sendKey) {
this.sendKey = sendKey;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.springframework.data.aerospike.query.cache.IndexesCacheUpdater;
import org.springframework.data.aerospike.query.cache.InternalIndexOperations;
import org.springframework.data.aerospike.query.cache.ReactorIndexRefresher;
import org.springframework.data.aerospike.server.version.ServerVersionSupport;

/**
* Configure Spring Data's Reactive Aerospike support.
Expand All @@ -52,9 +53,12 @@ public ReactiveAerospikeTemplate reactiveAerospikeTemplate(MappingAerospikeConve
AerospikeMappingContext aerospikeMappingContext,
AerospikeExceptionTranslator aerospikeExceptionTranslator,
AerospikeReactorClient aerospikeReactorClient,
ReactorQueryEngine reactorQueryEngine, ReactorIndexRefresher reactorIndexRefresher) {
return new ReactiveAerospikeTemplate(aerospikeReactorClient, aerospikeDataProperties.getNamespace(), mappingAerospikeConverter, aerospikeMappingContext,
aerospikeExceptionTranslator, reactorQueryEngine, reactorIndexRefresher);
ReactorQueryEngine reactorQueryEngine,
ReactorIndexRefresher reactorIndexRefresher,
ServerVersionSupport serverVersionSupport) {
return new ReactiveAerospikeTemplate(aerospikeReactorClient, aerospikeDataProperties.getNamespace(),
mappingAerospikeConverter, aerospikeMappingContext,
aerospikeExceptionTranslator, reactorQueryEngine, reactorIndexRefresher, serverVersionSupport);
}

@Bean(name = "reactiveAerospikeQueryEngine")
Expand All @@ -63,17 +67,20 @@ public ReactorQueryEngine reactiveAerospikeQueryEngine(AerospikeReactorClient ae
AerospikeDataProperties aerospikeDataProperties,
FilterExpressionsBuilder filterExpressionsBuilder,
StatementBuilder statementBuilder) {
ReactorQueryEngine queryEngine = new ReactorQueryEngine(aerospikeReactorClient, statementBuilder, filterExpressionsBuilder, aerospikeReactorClient.getQueryPolicyDefault());
ReactorQueryEngine queryEngine = new ReactorQueryEngine(aerospikeReactorClient, statementBuilder,
filterExpressionsBuilder);
queryEngine.setScansEnabled(aerospikeDataProperties.isScansEnabled());
queryEngine.setQueryMaxRecords(aerospikeDataProperties.getQueryMaxRecords());
return queryEngine;
}

@Bean(name = "reactiveAerospikeIndexRefresher")
@ConditionalOnMissingBean(name = "reactiveAerospikeIndexRefresher")
public ReactorIndexRefresher reactiveAerospikeIndexRefresher(AerospikeReactorClient aerospikeReactorClient,
IndexesCacheUpdater indexesCacheUpdater) {
IndexesCacheUpdater indexesCacheUpdater,
ServerVersionSupport serverVersionSupport) {
ReactorIndexRefresher refresher = new ReactorIndexRefresher(aerospikeReactorClient, aerospikeReactorClient.getInfoPolicyDefault(),
new InternalIndexOperations(new IndexInfoParser()), indexesCacheUpdater);
new InternalIndexOperations(new IndexInfoParser()), indexesCacheUpdater, serverVersionSupport);
refresher.refreshIndexes().block();
return refresher;
}
Expand All @@ -82,10 +89,11 @@ public ReactorIndexRefresher reactiveAerospikeIndexRefresher(AerospikeReactorCli
@ConditionalOnMissingBean(name = "reactiveAerospikePersistenceEntityIndexCreator")
public ReactiveAerospikePersistenceEntityIndexCreator reactiveAerospikePersistenceEntityIndexCreator(
AerospikeDataProperties aerospikeDataProperties,
@Lazy ReactiveAerospikeTemplate template,
@Lazy ObjectProvider<ReactiveAerospikeTemplate> template,
ObjectProvider<AerospikeMappingContext> aerospikeMappingContext,
AerospikeIndexResolver aerospikeIndexResolver) {
return new ReactiveAerospikePersistenceEntityIndexCreator(aerospikeMappingContext, aerospikeDataProperties.isCreateIndexesOnStartup(),
return new ReactiveAerospikePersistenceEntityIndexCreator(aerospikeMappingContext,
aerospikeDataProperties.isCreateIndexesOnStartup(),
aerospikeIndexResolver,
template);
}
Expand Down
Loading

0 comments on commit d3eff8b

Please sign in to comment.