Skip to content

Commit

Permalink
fixes apache#139 heartbeat configurable (apache#146)
Browse files Browse the repository at this point in the history
* fix apache#142 delete defaultEventExecutorGroup

* fix apache#139 netty heartbeat configurable
  • Loading branch information
slievrly authored Jan 17, 2019
1 parent b3a236c commit ed4eddb
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
2 changes: 2 additions & 0 deletions config/src/main/resources/application.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ transport {
type = "TCP"
#NIO NATIVE
server = "NIO"
#enable heartbeat
heartbeat = true
#thread factory for netty
thread-factory {
boss-thread-prefix = "NettyBoss"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,13 @@ public class NettyBaseConfig {
*/
protected static final TransportProtocolType TRANSPORT_PROTOCOL_TYPE;

protected static final int MAX_WRITE_IDLE_SECONDS = 0;
private static final int DEFAULT_WRITE_IDLE_SECONDS = 5;

protected static final int MAX_READ_IDLE_SECONDS = MAX_WRITE_IDLE_SECONDS * 3;
private static final int READIDLE_BASE_WRITEIDLE = 3;

protected static final int MAX_WRITE_IDLE_SECONDS;

protected static final int MAX_READ_IDLE_SECONDS;

protected static final int MAX_ALL_IDLE_SECONDS = 0;

Expand Down Expand Up @@ -154,6 +158,13 @@ public class NettyBaseConfig {
default:
throw new IllegalArgumentException("unsupported.");
}
boolean enableHeartbeat = CONFIG.getBoolean("transport.heartbeat", false);
if (enableHeartbeat) {
MAX_WRITE_IDLE_SECONDS = DEFAULT_WRITE_IDLE_SECONDS;
} else {
MAX_WRITE_IDLE_SECONDS = 0;
}
MAX_READ_IDLE_SECONDS = MAX_WRITE_IDLE_SECONDS * READIDLE_BASE_WRITEIDLE;
}

private static void raiseUnsupportedTransportError() throws RuntimeException {
Expand Down
2 changes: 2 additions & 0 deletions examples/src/main/resources/application.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ transport {
type = "TCP"
#NIO NATIVE
server = "NIO"
#enable heartbeat
heartbeat = true
#thread factory for netty
thread-factory {
boss-thread-prefix = "NettyBoss"
Expand Down
2 changes: 2 additions & 0 deletions server/src/main/resources/application.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ transport {
type = "TCP"
#NIO NATIVE
server = "NIO"
#enable heartbeat
heartbeat = true
#thread factory for netty
thread-factory {
boss-thread-prefix = "NettyBoss"
Expand Down

0 comments on commit ed4eddb

Please sign in to comment.