Skip to content

Commit e69fa02

Browse files
Artem LabazinArtem Labazin
authored andcommitted
Add more logs
1 parent 196dc2f commit e69fa02

File tree

6 files changed

+14
-5
lines changed

6 files changed

+14
-5
lines changed

encon/src/main/java/io/appulse/encon/ModuleClient.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import static io.netty.channel.ChannelOption.CONNECT_TIMEOUT_MILLIS;
2020
import static io.netty.channel.ChannelOption.SO_KEEPALIVE;
21+
import static io.netty.channel.ChannelOption.TCP_NODELAY;
2122
import static java.util.concurrent.TimeUnit.SECONDS;
2223
import static lombok.AccessLevel.PRIVATE;
2324

@@ -88,12 +89,14 @@ private CompletableFuture<Connection> createConnection (@NonNull RemoteNode remo
8889
.group(moduleConnection.getWorkerGroup())
8990
.channel(moduleConnection.getClientChannelClass())
9091
.option(SO_KEEPALIVE, true)
92+
.option(TCP_NODELAY, true)
9193
.option(CONNECT_TIMEOUT_MILLIS, 5000)
9294
.handler(HandshakeClientInitializer.builder()
9395
.node(node)
9496
.future(future)
9597
.remote(remote)
9698
.channelCloseAction(remoteNode -> {
99+
log.debug("Closing connection to {}", remoteNode);
97100
node.moduleLookup.remove(remoteNode);
98101
node.moduleConnection.remove(remoteNode);
99102
})

encon/src/main/java/io/appulse/encon/ModuleConnection.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,11 @@ class ModuleConnection implements Closeable {
7777

7878
Map<RemoteNode, CompletableFuture<Connection>> cache;
7979

80-
ModuleConnection (int bossThreads, int workerThreads) {
80+
ModuleConnection (@NonNull String prefix, int bossThreads, int workerThreads) {
8181
cache = new ConcurrentHashMap<>();
8282

83-
val bossThreadFactory = new DefaultThreadFactory("nbg");
84-
val workerThreadFactory = new DefaultThreadFactory("nwg");
83+
val bossThreadFactory = new DefaultThreadFactory(prefix + "-nbg");
84+
val workerThreadFactory = new DefaultThreadFactory(prefix + "-nwg");
8585

8686
if (Epoll.isAvailable()) {
8787
bossGroup = new EpollEventLoopGroup(bossThreads, bossThreadFactory);
@@ -120,10 +120,14 @@ void add (@NonNull CompletableFuture<Connection> future) {
120120

121121
CompletableFuture<Connection> compute (@NonNull RemoteNode remote,
122122
@NonNull Function<RemoteNode, CompletableFuture<Connection>> function) {
123+
if (log.isDebugEnabled()) {
124+
log.debug("Remote node {} exists: {}", remote, cache.containsKey(remote));
125+
}
123126
return cache.computeIfAbsent(remote, function);
124127
}
125128

126129
void remove (@NonNull RemoteNode remote) {
130+
log.debug("Removing connection to {}", remote);
127131
CompletableFuture<Connection> future = cache.remove(remote);
128132
if (future == null) {
129133
return;

encon/src/main/java/io/appulse/encon/ModulePing.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ boolean ping (@NonNull RemoteNode remote) {
9090

9191
try {
9292
mailbox.receive();
93-
mailbox.getNode().remove(mailbox);
93+
mailbox.close();
9494
log.debug("Returning from ping method");
9595
return true;
9696
} catch (Exception ex) {

encon/src/main/java/io/appulse/encon/ModuleServer.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ private void start () {
8080
.node(node)
8181
.consumer(moduleConnection::add)
8282
.channelCloseAction(remote -> {
83+
log.debug("Closing connection to {}", remote);
8384
node.moduleLookup.remove(remote);
8485
node.moduleConnection.remove(remote);
8586
})

encon/src/main/java/io/appulse/encon/Node.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ private Node (@NonNull NodeDescriptor descriptor,
161161
modulePing = new ModulePing(this);
162162
moduleLookup = new ModuleLookup(epmd);
163163
moduleConnection = new ModuleConnection(
164+
descriptor.getShortName(),
164165
config.getServer().getBossThreads(),
165166
config.getServer().getWorkerThreads()
166167
);

encon/src/main/java/io/appulse/encon/connection/handshake/AbstractHandshakeChannelInitializer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ protected void initChannel (SocketChannel socketChannel) throws Exception {
8282
protected void initChannel (SocketChannel socketChannel, AbstractHandshakeHandler handler) {
8383
socketChannel.pipeline()
8484
.addLast("LOGGING", LOGGING_HANDLER)
85-
.addLast("READ_TIMEOUT", new ReadTimeoutHandler(10))
85+
.addLast("READ_TIMEOUT", new ReadTimeoutHandler(5))
8686
.addLast("LENGTH_PREPENDER", LENGTH_FIELD_PREPENDER)
8787
.addLast("LENGTH_DECODER", new LengthFieldBasedFrameDecoder(MAX_VALUE, 0, 2))
8888
.addLast("DECODER", decoder)

0 commit comments

Comments
 (0)