Skip to content
Open
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 @@ -58,6 +58,9 @@

public class ManagedRelpConnectionWithMetrics implements IManagedRelpConnection {

private static final int DEFAULT_SEND_RESERVOIR_SIZE = 10000;
private static final int DEFAULT_CONNECT_RESERVOIR_SIZE = 10000;

private final Logger logger;
private final IRelpConnection relpConnection;
private boolean hasConnected;
Expand All @@ -82,8 +85,8 @@ public ManagedRelpConnectionWithMetrics(
relpConnection,
name,
metricRegistry,
new SlidingWindowReservoir(10000),
new SlidingWindowReservoir(10000)
new SlidingWindowReservoir(DEFAULT_SEND_RESERVOIR_SIZE),
new SlidingWindowReservoir(DEFAULT_CONNECT_RESERVOIR_SIZE)
);
}

Expand Down
51 changes: 40 additions & 11 deletions src/main/java/com/teragrep/aer_02/config/RelpConnectionConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,18 @@

public final class RelpConnectionConfig {

private static final int DEFAULT_CONNECTION_TIMEOUT = 2500;
private static final int DEFAULT_TRANSACTION_READ_TIMEOUT = 1500;
private static final int DEFAULT_TRANSACTION_WRITE_TIMEOUT = 1500;
private static final int DEFAULT_RETRY_INTERVAL = 500;
private static final int DEFAULT_CONNECTION_PORT = 601;
private static final String DEFAULT_CONNECTION_ADDRESS = "localhost";
private static final int DEFAULT_REBIND_AMOUNT = 100000;
private static final String DEFAULT_REBIND_ENABLED = "true";
private static final long DEFAULT_IDLE_DURATION = 150000L;
private static final String DEFAULT_IDLE_ENABLED = "false";
private static final String DEFAULT_CONNECTION_KEEPALIVE = "true";

private final int connectTimeout;
private final int readTimeout;
private final int writeTimeout;
Expand All @@ -68,17 +80,34 @@ public final class RelpConnectionConfig {

public RelpConnectionConfig(final Sourceable configSource) {
this(
Integer.parseInt(configSource.source("relp.connection.timeout", "2500")),
Integer.parseInt(configSource.source("relp.transaction.read.timeout", "1500")),
Integer.parseInt(configSource.source("relp.transaction.write.timeout", "1500")),
Integer.parseInt(configSource.source("relp.connection.retry.interval", "500")),
Integer.parseInt(configSource.source("relp.connection.port", "601")),
configSource.source("relp.connection.address", "localhost"),
Integer.parseInt(configSource.source("relp.rebind.request.amount", "100000")),
Boolean.parseBoolean(configSource.source("relp.rebind.enabled", "true")),
Duration.parse(configSource.source("relp.max.idle.duration", Duration.ofMillis(150000L).toString())),
Boolean.parseBoolean(configSource.source("relp.max.idle.enabled", "false")),
Boolean.parseBoolean(configSource.source("relp.connection.keepalive", "true"))
Integer
.parseInt(
configSource.source("relp.connection.timeout", String.valueOf(DEFAULT_CONNECTION_TIMEOUT))
),
Integer
.parseInt(
configSource
.source(
"relp.transaction.read.timeout",
String.valueOf(DEFAULT_TRANSACTION_READ_TIMEOUT)
)
),
Integer
.parseInt(
configSource
.source(
"relp.transaction.write.timeout",
String.valueOf(DEFAULT_TRANSACTION_WRITE_TIMEOUT)
)
),
Integer
.parseInt(
configSource
.source("relp.connection.retry.interval", String.valueOf(DEFAULT_RETRY_INTERVAL))
),
Integer.parseInt(configSource.source("relp.connection.port", String.valueOf(DEFAULT_CONNECTION_PORT))),
configSource.source("relp.connection.address", DEFAULT_CONNECTION_ADDRESS),
Integer.parseInt(configSource.source("relp.rebind.request.amount", String.valueOf(DEFAULT_REBIND_AMOUNT))), Boolean.parseBoolean(configSource.source("relp.rebind.enabled", DEFAULT_REBIND_ENABLED)), Duration.parse(configSource.source("relp.max.idle.duration", Duration.ofMillis(DEFAULT_IDLE_DURATION).toString())), Boolean.parseBoolean(configSource.source("relp.max.idle.enabled", DEFAULT_IDLE_ENABLED)), Boolean.parseBoolean(configSource.source("relp.connection.keepalive", DEFAULT_CONNECTION_KEEPALIVE))

);
}
Expand Down