Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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 @@ -7,6 +7,7 @@
import com.aerospike.client.async.NettyEventLoops;
import com.aerospike.client.policy.ClientPolicy;
import com.aerospike.client.policy.Policy;
import com.aerospike.client.policy.Replica;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
import jakarta.validation.constraints.NotNull;
Expand Down Expand Up @@ -45,6 +46,8 @@ public class AerospikePropertyConfiguration {
private int totalTimeout;
private int connectTimeout;
private int minConnsPerNode;
private int maxConnsPerNode;
private Replica readPolicy = Replica.MASTER;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will drop with error without extra config:

Caused by: com.aerospike.client.AerospikeException: Error -1: asyncMaxConnsPerNode 0 must be >= event loop count 4
        at com.aerospike.client.cluster.Cluster.<init>(Cluster.java:328)
        at com.aerospike.client.AerospikeClient.<init>(AerospikeClient.java:299)
        at com.aerospike.client.AerospikeClient.<init>(AerospikeClient.java:247)
        at org.prebid.cache.repository.aerospike.AerospikePropertyConfiguration.client(AerospikePropertyConfiguration.java:110)
        at org.prebid.cache.repository.aerospike.AerospikePropertyConfiguration$$SpringCGLIB$$0.CGLIB$client$12(<generated>)
        at org.prebid.cache.repository.aerospike.AerospikePropertyConfiguration$$SpringCGLIB$$FastClass$$1.invoke(<generated>)
        at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:258)
        at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:331)
        at org.prebid.cache.repository.aerospike.AerospikePropertyConfiguration$$SpringCGLIB$$0.client(<generated>)
        at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
        at java.base/java.lang.reflect.Method.invoke(Method.java:580)
        at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:140)
        ... 67 more

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May I suggest that you use the default settings?

    private int maxConnsPerNode = 100;
    private Replica readPolicy = Replica.SEQUENCE;
/**
   * Replica algorithm used to determine the target node for a partition derived from a key
   * or requested in a scan/query.
   * <p>
   * Default: {@link Replica#SEQUENCE}
   */
  public Replica replica = Replica.SEQUENCE;
/**
   * Maximum number of synchronous connections allowed per server node.  Transactions will go
   * through retry logic and potentially fail with "ResultCode.NO_MORE_CONNECTIONS" if the maximum
   * number of connections would be exceeded.
   * <p>
   * The number of connections used per node depends on concurrent commands in progress
   * plus sub-commands used for parallel multi-node commands (batch, scan, and query).
   * One connection will be used for each command.
   * <p>
   * Default: 100
   */
  public int maxConnsPerNode = 100;


private static final int DEFAULT_PORT = 3000;

Expand All @@ -71,6 +74,7 @@ Policy readPolicy() {
final Policy policy = new Policy();
policy.setConnectTimeout(connectTimeout);
policy.setTimeouts(socketTimeout, totalTimeout);
policy.setReplica(readPolicy);
return policy;
}

Expand All @@ -94,6 +98,7 @@ ClientPolicy clientPolicy() {
ClientPolicy clientPolicy = new ClientPolicy();
clientPolicy.eventLoops = eventLoops();
clientPolicy.minConnsPerNode = minConnsPerNode;
clientPolicy.maxConnsPerNode = maxConnsPerNode;
return clientPolicy;
}

Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ spring:
total_timeout: 1000
connect_timeout: 0
min_conns_per_node: 0
max_conns_per_node: 100
read_policy: master

---
# dev
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ class PrebidCacheContainerConfig(
"spring.aerospike.first_backoff" to "300",
"spring.aerospike.max_backoff" to "1000",
"spring.aerospike.max_retry" to "3",
"spring.aerospike.namespace" to aerospikeNamespace
"spring.aerospike.namespace" to aerospikeNamespace,
"spring.aerospike.max_conns_per_node" to "100",
"spring.aerospike.read_policy" to "master"
)

private fun getModuleStorageRedisConfig(
Expand Down
Loading