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-641 Clean up documentation #819

Merged
merged 4 commits into from
Jan 9, 2025
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
1 change: 1 addition & 0 deletions src/main/asciidoc/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ include::reference/template.adoc[]
include::reference/secondary-indexes.adoc[]
include::reference/indexed-annotation.adoc[]
include::reference/caching.adoc[]
include::reference/transactions.adoc[]
include::reference/configuration.adoc[]

:leveloffset: -1
Expand Down
4 changes: 2 additions & 2 deletions src/main/asciidoc/reference/configuration.adoc
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[[configuration]]
= Configuration

Configuration parameters can be set in a standard `application.properties` file using `spring.data.aerospike*` prefix
or by overriding configuration from `AbstractAerospikeDataConfiguration` class.
Configuration parameters can be set in a standard `application.properties` file using `spring.aerospike*`
and `spring.data.aerospike*` prefixes or by overriding configuration from `AbstractAerospikeDataConfiguration` class.

[[configuration.application-properties]]
== Application.properties
Expand Down
6 changes: 2 additions & 4 deletions src/main/asciidoc/reference/transactions.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,9 @@ public class MyService {

== Aerospike Operations Support

Behind the curtains Aerospike transaction manager uses MRTs (multi-record transactions)
which is an Aerospike feature allowing to group together multiple Aerospike operation requests
into a single transaction.
Behind the curtains Aerospike transaction manager uses an Aerospike feature allowing to group together multiple Aerospike operation requests into a single transaction.

NOTE: Not all of the Aerospike operations can participate in transactions.
NOTE: Not all the Aerospike operations can participate in transactions.

Here is a list of Aerospike operations that participate in transactions:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1989,11 +1989,12 @@ protected Filter cdtContains(IndexCollectionType collectionType, Map<QualifierKe
qualifierMap.put(CTX_ARRAY, resolveCtxList(ctxList));
}
return switch (valType) {
// TODO: Add Bytes and Double Support (will fail on old mode - no results)
case INTEGER -> Filter.contains(getBinName(qualifierMap), collectionType, val.toLong(),
getCtxArr(qualifierMap));
case STRING -> Filter.contains(getBinName(qualifierMap), collectionType, val.toString(),
getCtxArr(qualifierMap));
case BLOB -> Filter.contains(getBinName(qualifierMap), collectionType, (byte[]) val.getObject(),
getCtxArr(qualifierMap));
default -> null;
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.aerospike.config.AerospikeDataSettings;
import org.springframework.data.aerospike.query.qualifier.Qualifier;
import org.springframework.data.aerospike.repository.query.Query;
Expand All @@ -53,10 +51,9 @@
@Slf4j
public class QueryEngine {

private static final Logger logger = LoggerFactory.getLogger(QueryEngine.class);
public static final String SCANS_DISABLED_MESSAGE =
"Query without a filter will initiate a scan. Since scans are potentially dangerous operations, they are " +
"disabled by default in spring-data-aerospike. " +
"Query without a secondary index filter will initiate a scan. Since scans are potentially dangerous operations," +
" they are disabled by default in spring-data-aerospike. " +
"If you still need to use them, enable them via `scans-enabled` property.";
public static final List<Integer> SEC_INDEX_ERROR_RESULT_CODES = List.of(
INDEX_NOTFOUND, INDEX_OOM, INDEX_NOTREADABLE, INDEX_GENERIC, INDEX_NAME_MAXLEN, INDEX_MAXCOUNT);
Expand Down Expand Up @@ -128,7 +125,8 @@ public KeyRecordIterator select(String namespace, String set, String[] binNames,
return new KeyRecordIterator(namespace, rs);
} catch (AerospikeException e) {
if (statement.getFilter() != null && SEC_INDEX_ERROR_RESULT_CODES.contains(e.getResultCode())) {
log.warn("Got secondary index related exception (resultCode: {}), retrying with filter expression only",
log.warn("Got secondary index related exception (resultCode: {}), " +
"retrying with filter expression only (scan operation)",
e.getResultCode());
return retryWithFilterExpression(namespace, qualifier, statement);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ public Flux<KeyRecord> select(String namespace, String set, String[] binNames, @
&& SEC_INDEX_ERROR_RESULT_CODES.contains(ae.getResultCode()))
{
log.warn(
"Got secondary index related exception (resultCode: {}), retrying with filter expression only",
"Got secondary index related exception (resultCode: {}), " +
"retrying with filter expression only (scan operation)",
ae.getResultCode());
return retryWithFilterExpression(qualifier, statement);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public boolean isServerVersionGtOrEq7() {
/**
* @return true if Server version is 8.0 or greater
*/
public boolean isMRTSupported() {
public boolean isTxnSupported() {
return ModuleDescriptor.Version.parse(getServerVersion())
.compareTo(SERVER_VERSION_8_0_0_0) >= 0;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class EqualsTests extends PersonRepositoryQueryTests {

@Test
void deleteBySimplePropertyEquals_String() {
assertThat(repository.findByFirstName("Leroi")).isNotEmpty();
assertThat(repository.findByFirstName("Leroi")).isNotEmpty().hasSize(2);
repository.deleteByFirstName("Leroi");
assertThat(repository.findByFirstName("Leroi")).isEmpty();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1573,6 +1573,11 @@ List<P> findByFriendStringMapNotContaining(AerospikeQueryCriterion criterion,

long countByFirstName(String name);

/**
* Delete all entities with the given first name
*
* @param name First name to match
*/
void deleteByFirstName(String name);

List<P> readByFirstName(String name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public class ReactiveAerospikeTemplateTransactionTests extends BaseReactiveInteg

@BeforeAll
public void beforeAll() {
TestUtils.checkAssumption(serverVersionSupport.isMRTSupported(),
TestUtils.checkAssumption(serverVersionSupport.isTxnSupported(),
"Skipping transactions tests because Aerospike Server 8.0.0+ is required", log);
}

Expand All @@ -89,7 +89,7 @@ public void afterAll() {

@Test
public void verifyOneWriteInTransaction() {
// Multi-record transactions are supported starting with Server version 8.0+
// Transactions are supported starting with Server version 8.0+
SampleClasses.DocumentWithIntegerId document = new SampleClasses.DocumentWithIntegerId(500, "test1");

// only for testing purposes as performing one write in a transaction lacks sense
Expand All @@ -109,7 +109,7 @@ public void verifyOneWriteInTransaction() {

@Test
public void verifyMultipleWritesInTransaction() {
// Multi-record transactions are supported starting with Server version 8.0+
// Transactions are supported starting with Server version 8.0+
SampleClasses.DocumentWithIntegerId document1 = new SampleClasses.DocumentWithIntegerId(501, "test1");
SampleClasses.DocumentWithIntegerId document2 = new SampleClasses.DocumentWithIntegerId(501, "test2");

Expand All @@ -129,7 +129,7 @@ public void verifyMultipleWritesInTransaction() {

@Test
public void verifyMultipleWritesInTransactionWithTimeout() {
// Multi-record transactions are supported starting with Server version 8.0+
// Transactions are supported starting with Server version 8.0+
SampleClasses.DocumentWithIntegerId document1 = new SampleClasses.DocumentWithIntegerId(520, "test1");
SampleClasses.DocumentWithIntegerId document2 = new SampleClasses.DocumentWithIntegerId(520, "test2");

Expand All @@ -151,7 +151,7 @@ public void verifyMultipleWritesInTransactionWithTimeout() {

@Test
public void verifyMultipleWritesInTransactionWithTimeoutExpired() {
// Multi-record transactions are supported starting with Server version 8.0+
// Transactions are supported starting with Server version 8.0+
SampleClasses.DocumentWithIntegerId document1 = new SampleClasses.DocumentWithIntegerId(521, "test1");
SampleClasses.DocumentWithIntegerId document2 = new SampleClasses.DocumentWithIntegerId(521, "test2");

Expand All @@ -164,15 +164,15 @@ public void verifyMultipleWritesInTransactionWithTimeoutExpired() {
.as(StepVerifier::create)
.verifyErrorMatches(throwable -> {
if (throwable instanceof RecoverableDataAccessException) {
return throwable.getMessage().contains("MRT expired");
return throwable.getMessage().contains("Transaction expired");
}
return false;
});
}

@Test
public void verifyMultipleWritesInTransactionWithDefaultTimeoutExpired() {
// Multi-record transactions are supported starting with Server version 8.0+
// Transactions are supported starting with Server version 8.0+
SampleClasses.DocumentWithIntegerId document1 = new SampleClasses.DocumentWithIntegerId(522, "test1");
SampleClasses.DocumentWithIntegerId document2 = new SampleClasses.DocumentWithIntegerId(522, "test2");

Expand All @@ -185,15 +185,15 @@ public void verifyMultipleWritesInTransactionWithDefaultTimeoutExpired() {
.as(StepVerifier::create)
.verifyErrorMatches(throwable -> {
if (throwable instanceof RecoverableDataAccessException) {
return throwable.getMessage().contains("MRT expired");
return throwable.getMessage().contains("Transaction expired");
}
return false;
});
}

@Test
public void oneWriteInTransaction_manual_transactional() {
// Multi-record transactions are supported starting with Server version 8.0+
// Transactions are supported starting with Server version 8.0+
SampleClasses.DocumentWithIntegerId document = new SampleClasses.DocumentWithIntegerId(502, "test1");

transactionalOperator.transactional(reactiveTemplate.insert(document)).then()
Expand All @@ -209,7 +209,7 @@ public void oneWriteInTransaction_manual_transactional() {

@Test
public void oneWriteInTransaction_manual_execute() {
// Multi-record transactions are supported starting with Server version 8.0+
// Transactions are supported starting with Server version 8.0+
SampleClasses.DocumentWithIntegerId document = new SampleClasses.DocumentWithIntegerId(503, "test1");

// Manually manage the transaction by using transactionalOperator.execute()
Expand All @@ -231,7 +231,7 @@ public void oneWriteInTransaction_manual_execute() {

@Test
public void multipleWritesInTransaction_manual_execute() {
// Multi-record transactions are supported starting with Server version 8.0+
// Transactions are supported starting with Server version 8.0+
SampleClasses.DocumentWithIntegerId document1 = new SampleClasses.DocumentWithIntegerId(504, "test1");
SampleClasses.DocumentWithIntegerId document2 = new SampleClasses.DocumentWithIntegerId(505, "test2");

Expand All @@ -254,7 +254,7 @@ public void multipleWritesInTransaction_manual_execute() {

@Test
public void verifyRepeatingCommit() {
// Multi-record transactions are supported starting with Server version 8.0+
// Transactions are supported starting with Server version 8.0+
SampleClasses.DocumentWithIntegerId document1 = new SampleClasses.DocumentWithIntegerId(506, "test1");

// Manually manage the transaction by using transactionalOperator.execute()
Expand All @@ -280,7 +280,7 @@ public void verifyRepeatingCommit() {

@Test
public void verifyTransactionRollback() {
// Multi-record transactions are supported starting with Server version 8.0+
// Transactions are supported starting with Server version 8.0+
SampleClasses.DocumentWithIntegerId document = new SampleClasses.DocumentWithIntegerId(507, "test1");

reactiveTemplate.insert(document).then(reactiveTemplate.insert(document))
Expand All @@ -298,7 +298,7 @@ public void verifyTransactionRollback() {

@Test
public void oneWriteInTransaction_multipleThreads() {
// Multi-record transactions are supported starting with Server version 8.0+
// Transactions are supported starting with Server version 8.0+
AtomicInteger counter = new AtomicInteger();
int threadsNumber = 5;
AsyncUtils.executeConcurrently(threadsNumber, () -> {
Expand All @@ -320,7 +320,7 @@ public void oneWriteInTransaction_multipleThreads() {

@Test
public void rollbackTransaction_multipleThreads() {
// Multi-record transactions are supported starting with Server version 8.0+
// Transactions are supported starting with Server version 8.0+
AtomicInteger counter = new AtomicInteger();
int threadsNumber = 5;
AsyncUtils.executeConcurrently(threadsNumber, () -> {
Expand All @@ -343,7 +343,7 @@ public void rollbackTransaction_multipleThreads() {

@Test
public void multipleWritesInTransaction_multipleThreads() {
// Multi-record transactions are supported starting with Server version 8.0+
// Transactions are supported starting with Server version 8.0+
AtomicInteger counter = new AtomicInteger();
int threadsNumber = 5;
AsyncUtils.executeConcurrently(threadsNumber, () -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public class ReactiveAerospikeTemplateTransactionUnitTests extends BaseReactiveI

@BeforeAll
public void beforeAll() {
TestUtils.checkAssumption(serverVersionSupport.isMRTSupported(),
TestUtils.checkAssumption(serverVersionSupport.isTxnSupported(),
"Skipping transactions tests because Aerospike Server 8.0.0+ is required", log);
when(mockTxManager.getReactiveTransaction(any()))
.thenReturn(Mono.just(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public ReactiveAerospikeTransactionTestUtils(IAerospikeReactorClient client, Rea

protected Mono<Void> verifyOngoingTransaction_withPropagation(SampleClasses.DocumentWithPrimitiveIntId document,
int propagationType, int numberOfSuspendCalls) {
// Multi-record transactions are supported starting with Server version 8.0+
// Transactions are supported starting with Server version 8.0+
AerospikeReactiveTransactionManager trackedTxManager = spy(txManager);
DefaultTransactionDefinition tranDefinition = new DefaultTransactionDefinition();
tranDefinition.setPropagationBehavior(propagationType);
Expand Down
Loading
Loading