Skip to content

Commit

Permalink
Add ability to configure durableDelete property for Batch Client Poli…
Browse files Browse the repository at this point in the history
…cies
  • Loading branch information
RomanCht committed Sep 4, 2024
1 parent a33829f commit 61cdf09
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ public ClientPolicy aerospikeClientPolicy(AerospikeProperties properties,
clientPolicy.writePolicyDefault = setupWritePolicy(properties);
clientPolicy.batchPolicyDefault = setupBatchPolicy(properties);
clientPolicy.queryPolicyDefault = setupQueryPolicy(properties);
clientPolicy.batchWritePolicyDefault = setupBatchWritePolicy(properties);
clientPolicy.batchDeletePolicyDefault = setupBatchDeletePolicy(properties);
clientPolicy.batchUDFPolicyDefault = setupBatchUDFPolicy(properties);
aerospikeEventLoops.ifPresent(loops -> clientPolicy.eventLoops = loops);

return clientPolicy;
Expand Down Expand Up @@ -142,6 +145,27 @@ private BatchPolicy setupBatchPolicy(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 QueryPolicy setupQueryPolicy(AerospikeProperties properties) {
AerospikeProperties.QueryPolicyDefault queryPolicyDefault = properties.getQuery();
QueryPolicy policy = new QueryPolicy();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,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();

/**
Expand Down Expand Up @@ -232,4 +238,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;
}
}

0 comments on commit 61cdf09

Please sign in to comment.