Skip to content
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 @@ -24,6 +24,8 @@ public class ClientConnectionConfig {

private String connectionRequestTimeout;

private boolean tcpNoDelay;

public ClientConnectionConfig() {
}

Expand All @@ -38,14 +40,16 @@ public ClientConnectionConfig() {
* @param connectionRequestTimeout connectionRequestTimeout value in seconds
*/
public ClientConnectionConfig(String totalMaxConnection, String maxConnectionPerRoute, String validateAfterInactivity,
String timeToLive, String socketTimeout, String responseTimeout, String connectionRequestTimeout) {
String timeToLive, String socketTimeout, String responseTimeout, String connectionRequestTimeout,
boolean tcpNoDelay) {
this.totalMaxConnection = totalMaxConnection;
this.maxConnectionPerRoute = maxConnectionPerRoute;
this.validateAfterInactivity = validateAfterInactivity;
this.timeToLive = timeToLive;
this.socketTimeout = socketTimeout;
this.responseTimeout = responseTimeout;
this.connectionRequestTimeout = connectionRequestTimeout;
this.tcpNoDelay = tcpNoDelay;
}

public int getTotalMaxConnection() {
Expand Down Expand Up @@ -104,6 +108,10 @@ public void setConnectionRequestTimeout(String connectionRequestTimeout) {
this.connectionRequestTimeout = connectionRequestTimeout;
}

public boolean getTcpNoDelay() {
return tcpNoDelay;
}

/**
* Checks if pooling connection property values are provided
* @return true
Expand All @@ -120,7 +128,9 @@ public boolean hasPoolingConnMetadata() {
* @return true
*/
public boolean hasIOReactorMetadata() {
return StringUtils.isNotBlank(this.socketTimeout);
return StringUtils.isNotBlank(this.socketTimeout)
|| this.tcpNoDelay;

}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,15 @@ public static IOReactorConfig buildIOReactorConfig(EntityClientConfiguration con
if (config != null && config.hasIOReactorMetadata()) {
return IOReactorConfig.custom()
.setSoTimeout(Timeout.of(config.getConnectionConfigValue(SOCKET_TIMEOUT), TimeUnit.SECONDS))
.setTcpNoDelay(config.getTcpNoDelay())
.setSoKeepAlive(true)
.build();
}
if (connConfig != null && connConfig.hasIOReactorMetadata()) {
return IOReactorConfig.custom()
.setSoTimeout(Timeout.of(connConfig.getSocketTimeout(), TimeUnit.SECONDS))
.setTcpNoDelay(connConfig.getTcpNoDelay())
.setSoKeepAlive(true)
.build();
}
return IOReactorConfig.custom().build(); // default
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public class EntityClientConfiguration extends AuthenticationConfig {
public static final String CONNECTION_REQUEST_TIMEOUT =
"entity.client.connection.request.timeout";
public static final String RESPONSE_TIMEOUT = "entity.client.response.timeout";
public static final String TCP_NO_DELAY = "entity.client.tcp.no.delay";


/**
* Constructor
Expand Down Expand Up @@ -116,6 +118,11 @@ public String getResponseTimeout() {
return getProperty(RESPONSE_TIMEOUT);
}

public boolean getTcpNoDelay() {
return Boolean.parseBoolean(getProperty(TCP_NO_DELAY));
}


/**
* return the Integer value of the property requested
* @return value
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/entity-client.properties.template
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@ entity.client.time.to.live=60
entity.client.socket.timeout=300
entity.client.connection.request.timeout=30
entity.client.response.timeout=60

## controls if Nagle's algorithm is enabled or disabled on a TCP socket.
entity.client.tcp.no.delay=true
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public void testEntityClient_withConnectionConfiguration() throws EntityClientEx
, new ApikeyBasedAuthentication("invalid_test"),
new ClientConnectionConfig("25", "5",
"5", "60", "300",
"30", "60"));
"30", "60", true));

Assertions.assertNotNull(entityClientApi);
Assertions.assertEquals(ApikeyBasedAuthentication.class, entityClientApi.getEntityClientApiConnection().getAuthenticationHandler().getClass());
Expand Down Expand Up @@ -109,7 +109,7 @@ public void testEntityClient_withEntityConfiguration_AndConnectionConfig() throw
EntityApiClient entityClientApi = new EntityApiClient(new EntityClientConfiguration(properties),
new ClientConnectionConfig("25", "5",
"5", "60", "300",
"30", "60"));
"30", "60", false));

Assertions.assertNotNull(entityClientApi);
Assertions.assertEquals(ApikeyBasedAuthentication.class, entityClientApi.getEntityClientApiConnection().getAuthenticationHandler().getClass());
Expand Down