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

add Aerospike ClintPolicy maxSocketIdle property override #237

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
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import io.netty.channel.nio.NioEventLoopGroup;
import org.janusgraph.diskstorage.configuration.Configuration;

import static com.playtika.janusgraph.aerospike.ConfigOptions.AEROSPIKE_CLIENT_MAX_SOCKET_IDLE;
import static com.playtika.janusgraph.aerospike.ConfigOptions.AEROSPIKE_CONNECTIONS_PER_NODE;
import static com.playtika.janusgraph.aerospike.ConfigOptions.AEROSPIKE_MIN_CONNECTIONS_PER_NODE;
import static com.playtika.janusgraph.aerospike.ConfigOptions.AEROSPIKE_READ_TIMEOUT;
Expand All @@ -36,6 +37,9 @@ public ClientPolicy clientPolicy() {
clientPolicy.password = configuration.has(AUTH_PASSWORD) ? configuration.get(AUTH_PASSWORD) : null;
clientPolicy.minConnsPerNode = configuration.get(AEROSPIKE_MIN_CONNECTIONS_PER_NODE);
clientPolicy.maxConnsPerNode = configuration.get(AEROSPIKE_CONNECTIONS_PER_NODE);
clientPolicy.maxSocketIdle = configuration.has(AEROSPIKE_CLIENT_MAX_SOCKET_IDLE)
? configuration.get(AEROSPIKE_CLIENT_MAX_SOCKET_IDLE)
: clientPolicy.maxSocketIdle;
clientPolicy.readPolicyDefault = readPolicy();
clientPolicy.scanPolicyDefault = scanPolicy();
clientPolicy.queryPolicyDefault = queryPolicy();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,8 @@ public class ConfigOptions {
"ids-block-ttl", "How long keep history of ids block in milliseconds, default to one week",
ConfigOption.Type.LOCAL, 604800000L);

public static final ConfigOption<Integer> AEROSPIKE_CLIENT_MAX_SOCKET_IDLE = new ConfigOption<>(STORAGE_NS,
"aerospike-client-max-socket-idle", "Maximum socket idle in seconds. If server's proto-fd-idle-ms is zero (no reap), then maxSocketIdle should also be zero",
ConfigOption.Type.LOCAL, 0);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package com.playtika.janusgraph.aerospike;

import com.aerospike.client.policy.ClientPolicy;
import org.junit.ClassRule;
import org.junit.Test;
import org.testcontainers.containers.GenericContainer;

import static com.playtika.janusgraph.aerospike.AerospikeTestUtils.getAerospikeConfiguration;
import static com.playtika.janusgraph.aerospike.AerospikeTestUtils.getAerospikeContainer;
import static org.assertj.core.api.AssertionsForClassTypes.assertThat;

public class AerospikePolicyProviderTest {

@ClassRule
public static GenericContainer<?> container = getAerospikeContainer();

@Test
public void shouldReturnDefaultClientPolicyMaxSocketIdle() {
var aerospikePolicyProvider = new AerospikePolicyProvider(
getAerospikeConfiguration(container)
);

var clientPolicy = aerospikePolicyProvider.clientPolicy();

assertThat(clientPolicy.maxSocketIdle)
.isEqualTo(new ClientPolicy().maxSocketIdle);
}

@Test
public void shouldOverrideClientPolicyMaxSocketIdle() {
var clientMaxSocketIdle = 55;
var aerospikePolicyProvider = new AerospikePolicyProvider(
getAerospikeConfiguration(container)
.set(ConfigOptions.AEROSPIKE_CLIENT_MAX_SOCKET_IDLE, clientMaxSocketIdle)
);

var clientPolicy = aerospikePolicyProvider.clientPolicy();

assertThat(clientPolicy.maxSocketIdle).isEqualTo(clientMaxSocketIdle);
}
}
Loading