diff --git a/.gitignore b/.gitignore index a1c2a238..d94c381d 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,28 @@ # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml hs_err_pid* + +target/ +!.mvn/wrapper/maven-wrapper.jar + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +nbproject/private/ +build/ +nbbuild/ +dist/ +nbdist/ +.nb-gradle/ diff --git a/aerospike-benchmark/src/main/java/com/playtika/janusgraph/aerospike/benchmark/Configurations.java b/aerospike-benchmark/src/main/java/com/playtika/janusgraph/aerospike/benchmark/Configurations.java index 37a75d12..c156f394 100644 --- a/aerospike-benchmark/src/main/java/com/playtika/janusgraph/aerospike/benchmark/Configurations.java +++ b/aerospike-benchmark/src/main/java/com/playtika/janusgraph/aerospike/benchmark/Configurations.java @@ -27,7 +27,6 @@ static ModifiableConfiguration getAerospikeConfiguration(GenericContainer contai config.set(GRAPH_PREFIX, "test"); //!!! need to prevent small batches mutations as we use deferred locking approach !!! config.set(BUFFER_SIZE, AEROSPIKE_BUFFER_SIZE); - config.set(TEST_ENVIRONMENT, true); //for test purposes only return config; } diff --git a/aerospike-container/src/main/java/com/aerospike/AerospikeContainerUtils.java b/aerospike-container/src/main/java/com/aerospike/AerospikeContainerUtils.java index abb9a594..1b7b5386 100644 --- a/aerospike-container/src/main/java/com/aerospike/AerospikeContainerUtils.java +++ b/aerospike-container/src/main/java/com/aerospike/AerospikeContainerUtils.java @@ -37,7 +37,28 @@ public static GenericContainer startAerospikeContainer(AerospikeProperties prope .withStartupTimeout(startupTimeout); aerospike.start(); + configureEnterpriseServer(properties, aerospike); return aerospike; } -} \ No newline at end of file + private static void configureEnterpriseServer(AerospikeProperties properties, + GenericContainer aerospikeContainer) { + AsadmCommandExecutor asadmCommandExecutor = new AsadmCommandExecutor(aerospikeContainer); + String namespace = properties.getNamespace(); + /* + By default, the value of this metric is 90%, we set it to 100% to prevent stopping writes for the Aerospike + Enterprise container during high consumption of system memory. For the Aerospike Community Edition, this metric is not used. + Documentation: https://aerospike.com/docs/server/reference/configuration#stop-writes-sys-memory-pct + */ + log.info("Switching off 'stop-writes-sys-memory-pct'... "); + asadmCommandExecutor.execute(String.format("manage config namespace %s param stop-writes-sys-memory-pct to 100", namespace)); + log.info("Success switching off 'stop-writes-sys-memory-pct'"); + + if (properties.isDurableDelete()) { + log.info("Setting up 'disallow-expunge' to true..."); + asadmCommandExecutor.execute(String.format("manage config namespace %s param disallow-expunge to true", namespace)); + log.info("Success setting up 'disallow-expunge' to true"); + } + } + +} diff --git a/aerospike-container/src/main/java/com/aerospike/AerospikeProperties.java b/aerospike-container/src/main/java/com/aerospike/AerospikeProperties.java index dd11adf2..b7e27019 100644 --- a/aerospike-container/src/main/java/com/aerospike/AerospikeProperties.java +++ b/aerospike-container/src/main/java/com/aerospike/AerospikeProperties.java @@ -25,13 +25,12 @@ public class AerospikeProperties { - static final String AEROSPIKE_BEAN_NAME = "aerospike"; - boolean enabled = true; - String dockerImage = "aerospike:ce-6.2.0.2"; + String dockerImage = "aerospike/aerospike-server-enterprise:6.3.0.16_1"; String namespace = "TEST"; String host = "localhost"; int port = 3000; + boolean durableDelete = true; public boolean isEnabled() { return enabled; @@ -72,4 +71,12 @@ public int getPort() { public void setPort(int port) { this.port = port; } + + public boolean isDurableDelete() { + return durableDelete; + } + + public void setDurableDelete(boolean durableDelete) { + this.durableDelete = durableDelete; + } } diff --git a/aerospike-container/src/main/java/com/aerospike/AsadmCommandExecutor.java b/aerospike-container/src/main/java/com/aerospike/AsadmCommandExecutor.java new file mode 100644 index 00000000..cc11884f --- /dev/null +++ b/aerospike-container/src/main/java/com/aerospike/AsadmCommandExecutor.java @@ -0,0 +1,46 @@ +package com.aerospike; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.testcontainers.containers.Container; +import org.testcontainers.containers.GenericContainer; + +public class AsadmCommandExecutor { + + private static final Logger log = LoggerFactory.getLogger(AsadmCommandExecutor.class); + + private final GenericContainer aerospikeContainer; + + public AsadmCommandExecutor(GenericContainer aerospikeContainer) { + this.aerospikeContainer = aerospikeContainer; + } + + public void execute(String command) { + try { + Container.ExecResult result = aerospikeContainer.execInContainer("asadm", "--enable", "-e", command); + logStdout(result); + if (result.getExitCode() != 0 || isBadResponse(result)) { + throw new IllegalStateException(String.format("Failed to execute \"asadm --enable -e '%s'\": \nstdout:\n%s\nstderr:\n%s", + command, result.getStdout(), result.getStderr())); + } + } catch (Exception ex) { + throw new IllegalStateException(String.format("Failed to execute \"asadm\"", ex)); + } + } + + private boolean isBadResponse(Container.ExecResult execResult) { + String stdout = execResult.getStdout(); + /* + Example of the stdout without error: + ~Set Namespace Param stop-writes-sys-memory-pct to 100~ + Node|Response + 728bb242e58c:3000|ok + Number of rows: 1 + */ + return !stdout.contains("|ok"); + } + + private static void logStdout(Container.ExecResult result) { + log.debug("Aerospike asadm util stdout: \n{}\n{}", result.getStdout(), result.getStderr()); + } +} diff --git a/aerospike-storage-backend/src/main/java/com/playtika/janusgraph/aerospike/AerospikePolicyProvider.java b/aerospike-storage-backend/src/main/java/com/playtika/janusgraph/aerospike/AerospikePolicyProvider.java index 1f823335..d67f427d 100644 --- a/aerospike-storage-backend/src/main/java/com/playtika/janusgraph/aerospike/AerospikePolicyProvider.java +++ b/aerospike-storage-backend/src/main/java/com/playtika/janusgraph/aerospike/AerospikePolicyProvider.java @@ -67,6 +67,7 @@ public WritePolicy writePolicy() { writePolicy.totalTimeout = configuration.get(AEROSPIKE_WRITE_TIMEOUT); writePolicy.socketTimeout = configuration.get(AEROSPIKE_SOCKET_TIMEOUT); writePolicy.maxRetries = NO_RETRIES; + writePolicy.durableDelete = !configuration.get(TEST_ENVIRONMENT);; return writePolicy; } @@ -75,7 +76,7 @@ public WritePolicy deletePolicy() { deletePolicy.expiration = -1; deletePolicy.totalTimeout = configuration.get(AEROSPIKE_WRITE_TIMEOUT); deletePolicy.socketTimeout = configuration.get(AEROSPIKE_SOCKET_TIMEOUT); - deletePolicy.durableDelete = !configuration.get(TEST_ENVIRONMENT); + deletePolicy.durableDelete = !configuration.get(TEST_ENVIRONMENT);; deletePolicy.maxRetries = NO_RETRIES; return deletePolicy; } diff --git a/aerospike-storage-backend/src/test/java/com/playtika/janusgraph/aerospike/AerospikeTestUtils.java b/aerospike-storage-backend/src/test/java/com/playtika/janusgraph/aerospike/AerospikeTestUtils.java index 80b2dc07..eb665923 100644 --- a/aerospike-storage-backend/src/test/java/com/playtika/janusgraph/aerospike/AerospikeTestUtils.java +++ b/aerospike-storage-backend/src/test/java/com/playtika/janusgraph/aerospike/AerospikeTestUtils.java @@ -13,7 +13,6 @@ import static com.playtika.janusgraph.aerospike.ConfigOptions.IDS_NAMESPACE; import static com.playtika.janusgraph.aerospike.ConfigOptions.NAMESPACE; import static com.playtika.janusgraph.aerospike.ConfigOptions.SCAN_PARALLELISM; -import static com.playtika.janusgraph.aerospike.ConfigOptions.TEST_ENVIRONMENT; import static com.playtika.janusgraph.aerospike.ConfigOptions.WAL_NAMESPACE; import static com.playtika.janusgraph.aerospike.util.AerospikeUtils.isEmptyNamespace; import static com.playtika.janusgraph.aerospike.util.AerospikeUtils.truncateNamespace; @@ -50,7 +49,6 @@ public static ModifiableConfiguration getAerospikeConfiguration(GenericContainer config.set(GRAPH_PREFIX, "test"); //!!! need to prevent small batches mutations as we use deferred locking approach !!! config.set(BUFFER_SIZE, AEROSPIKE_BUFFER_SIZE); - config.set(TEST_ENVIRONMENT, true); //for test purposes only config.set(SCAN_PARALLELISM, 100); return config; }