Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FMWK-264 Bump dependencies and prepare v0.13.0 #219

Merged
merged 6 commits into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Import GPG Key
uses: crazy-max/ghaction-import-gpg@v5
uses: crazy-max/ghaction-import-gpg@v6
with:
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}
- name: Set up Maven Central Repository
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 17
Expand Down
5 changes: 5 additions & 0 deletions 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
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
Expand Up @@ -21,19 +21,17 @@
import com.aerospike.client.IAerospikeClient;
import com.aerospike.client.async.EventLoops;
import com.aerospike.client.async.NioEventLoops;
import com.aerospike.client.policy.BatchPolicy;
import com.aerospike.client.policy.ClientPolicy;
import com.aerospike.client.policy.Policy;
import com.aerospike.client.policy.QueryPolicy;
import com.aerospike.client.policy.WritePolicy;
import com.aerospike.client.policy.*;
import com.aerospike.client.reactor.AerospikeReactorClient;
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;
Expand All @@ -58,6 +56,22 @@ public AerospikeClient aerospikeClient(AerospikeProperties properties,
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,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package org.springframework.boot.autoconfigure.data.aerospike;

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 @@ -23,6 +25,7 @@

import java.util.Collections;

@Slf4j
@AutoConfiguration
class AerospikeCommonDataConfiguration {

Expand Down Expand Up @@ -54,8 +57,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 All @@ -75,7 +80,8 @@ public AerospikeCustomConversions aerospikeCustomConversions() {
@ConditionalOnMissingBean(name = "aerospikeMappingContext")
public AerospikeMappingContext aerospikeMappingContext(ApplicationContext applicationContext,
AerospikeCustomConversions aerospikeCustomConversions,
AerospikeDataProperties aerospikeDataProperties) throws Exception {
AerospikeDataProperties aerospikeDataProperties)
throws Exception {
AerospikeMappingContext context = new AerospikeMappingContext();
context.setInitialEntitySet(new EntityScanner(applicationContext).scan(Document.class, Persistent.class));
context.setSimpleTypeHolder(aerospikeCustomConversions.getSimpleTypeHolder());
Expand All @@ -91,4 +97,17 @@ public AerospikeMappingContext aerospikeMappingContext(ApplicationContext applic
public AerospikeExceptionTranslator aerospikeExceptionTranslator() {
return new DefaultAerospikeExceptionTranslator();
}

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,14 @@ public AerospikeTemplate aerospikeTemplate(IAerospikeClient aerospikeClient,
MappingAerospikeConverter mappingAerospikeConverter,
AerospikeMappingContext aerospikeMappingContext,
AerospikeExceptionTranslator aerospikeExceptionTranslator,
QueryEngine queryEngine, IndexRefresher indexRefresher) {
QueryEngine queryEngine, IndexRefresher indexRefresher,
ServerVersionSupport serverVersionSupport) {
return new AerospikeTemplate(aerospikeClient,
aerospikeDataProperties.getNamespace(),
mappingAerospikeConverter,
aerospikeMappingContext,
aerospikeExceptionTranslator, queryEngine, indexRefresher);
aerospikeExceptionTranslator, queryEngine, indexRefresher,
serverVersionSupport);
}

@Bean(name = "aerospikeQueryEngine")
Expand All @@ -66,26 +72,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 @@ -16,6 +16,8 @@

package org.springframework.boot.autoconfigure.data.aerospike;

import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;

/**
Expand All @@ -25,6 +27,8 @@
* @author Anastasiia Smirnova
*/
@ConfigurationProperties(prefix = "spring.data.aerospike")
@Getter
@Setter
public class AerospikeDataProperties {

/**
Expand Down Expand Up @@ -55,43 +59,34 @@ public class AerospikeDataProperties {
*/
private boolean createIndexesOnStartup = true;

public String getNamespace() {
return namespace;
}

public void setNamespace(String namespace) {
this.namespace = namespace;
}

public String getTypeKey() {
return typeKey;
}

public void setTypeKey(String typeKey) {
this.typeKey = typeKey;
}

public boolean isScansEnabled() {
return scansEnabled;
}
/**
* Send user defined key in addition to hash digest on both reads and writes
*/
private boolean sendKey = true;

public void setScansEnabled(boolean scansEnabled) {
this.scansEnabled = scansEnabled;
}
/**
* Automatically refresh indexes cache every <N> seconds
*/
private int indexCacheRefreshSeconds = 3600;

public Class<?> getFieldNamingStrategy() {
return fieldNamingStrategy;
}
/**
* Automatically refresh cached server version every <N> seconds
*/
private int serverVersionRefreshSeconds = 0;

public void setFieldNamingStrategy(Class<?> fieldNamingStrategy) {
this.fieldNamingStrategy = fieldNamingStrategy;
}
/**
* Limit amount of results returned by server. Non-positive value means no limit.
*/
private long queryMaxRecords = 10_000L;

public boolean isCreateIndexesOnStartup() {
return createIndexesOnStartup;
}
/**
* Maximum batch size for batch write operations
*/
private int batchWriteSize = 100;

public void setCreateIndexesOnStartup(boolean createIndexesOnStartup) {
this.createIndexesOnStartup = createIndexesOnStartup;
}
/**
* Define how @Id fields (primary keys) and Map keys are stored: false - always as String,
* true - preserve original type if supported
*/
private boolean keepOriginalKeyTypes = false;
}
Loading
Loading