diff --git a/pom.xml b/pom.xml index da2b655..cdd9797 100644 --- a/pom.xml +++ b/pom.xml @@ -31,7 +31,7 @@ - 0.8.1 + 0.8.2 1.8 ${java.version} ${java.version} 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 dbe1bb9..d9bfde9 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 @@ -24,11 +24,14 @@ 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.ClientPolicy; import com.aerospike.client.policy.QueryPolicy; import com.aerospike.client.policy.WritePolicy; +import com.aerospike.client.policy.BatchPolicy; +import com.aerospike.client.policy.BatchDeletePolicy; +import com.aerospike.client.policy.BatchUDFPolicy; +import com.aerospike.client.policy.BatchWritePolicy; import com.aerospike.client.reactor.AerospikeReactorClient; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; @@ -78,8 +81,11 @@ public ClientPolicy aerospikeClientPolicy(AerospikeProperties properties, clientPolicy.readPolicyDefault = setupReadPolicy(properties); clientPolicy.writePolicyDefault = setupWritePolicy(properties); - clientPolicy.batchPolicyDefault = setupBatchPolicy(properties); clientPolicy.queryPolicyDefault = setupQueryPolicy(properties); + clientPolicy.batchPolicyDefault = setupBatchPolicy(properties); + clientPolicy.batchWritePolicyDefault = setupBatchWritePolicy(properties); + clientPolicy.batchDeletePolicyDefault = setupBatchDeletePolicy(properties); + clientPolicy.batchUDFPolicyDefault = setupBatchUDFPolicy(properties); aerospikeEventLoops.ifPresent(loops -> clientPolicy.eventLoops = loops); return clientPolicy; @@ -141,6 +147,27 @@ private QueryPolicy setupQueryPolicy(AerospikeProperties properties) { return policy; } + private BatchWritePolicy setupBatchWritePolicy(AerospikeProperties properties) { + AerospikeProperties.BatchWritePolicyDefault batchWritePolicyDefault = properties.getBatchWrite(); + BatchWritePolicy policy = new BatchWritePolicy(); + whenPresent(batchWritePolicyDefault.durableDelete, p -> policy.durableDelete = p); + return policy; + } + + private BatchDeletePolicy setupBatchDeletePolicy(AerospikeProperties properties) { + AerospikeProperties.BatchDeletePolicyDefault batchDeletePolicyDefault = properties.getBatchDelete(); + BatchDeletePolicy policy = new BatchDeletePolicy(); + whenPresent(batchDeletePolicyDefault.durableDelete, p -> policy.durableDelete = p); + return policy; + } + + private BatchUDFPolicy setupBatchUDFPolicy(AerospikeProperties properties) { + AerospikeProperties.BatchUDFPolicyDefault batchUDFPolicyDefault = properties.getBatchUdf(); + BatchUDFPolicy policy = new BatchUDFPolicy(); + whenPresent(batchUDFPolicyDefault.durableDelete, p -> policy.durableDelete = p); + return policy; + } + private void setGeneralPolicyProperties(Policy policy, AerospikeProperties.PolicyDefault policyDefault) { whenPresent(policyDefault.socketTimeout, p -> policy.socketTimeout = (int) p.toMillis()); whenPresent(policyDefault.totalTimeout, p -> policy.totalTimeout = (int) p.toMillis()); 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 4e1e2c9..d6fffdd 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 @@ -112,6 +112,12 @@ public class AerospikeProperties { private BatchPolicyDefault batch = new BatchPolicyDefault(); + private BatchWritePolicyDefault batchWrite = new BatchWritePolicyDefault(); + + private BatchDeletePolicyDefault batchDelete = new BatchDeletePolicyDefault(); + + private BatchUDFPolicyDefault batchUdf = new BatchUDFPolicyDefault(); + private QueryPolicyDefault query = new QueryPolicyDefault(); /** @@ -221,4 +227,40 @@ public static class BatchPolicyDefault extends PolicyDefault { */ public Boolean sendSetName; } + + /** + * For more details on each option see corresponding field documentation in {@link com.aerospike.client.policy.BatchWritePolicy}. + */ + @Data + public static class BatchWritePolicyDefault extends PolicyDefault { + + /** + * If the transaction results in a record deletion, leave a tombstone for the record. + */ + public Boolean durableDelete; + } + + /** + * For more details on each option see corresponding field documentation in {@link com.aerospike.client.policy.BatchDeletePolicy}. + */ + @Data + public static class BatchDeletePolicyDefault extends PolicyDefault { + + /** + * If the transaction results in a record deletion, leave a tombstone for the record. + */ + public Boolean durableDelete; + } + + /** + * For more details on each option see corresponding field documentation in {@link com.aerospike.client.policy.BatchUDFPolicy}. + */ + @Data + public static class BatchUDFPolicyDefault extends PolicyDefault { + + /** + * If the transaction results in a record deletion, leave a tombstone for the record. + */ + public Boolean durableDelete; + } }