From db26e98803e4f6b3997b3602cbbc1ef6a1473c1e Mon Sep 17 00:00:00 2001 From: Andrew Kerr Date: Fri, 13 Apr 2018 14:17:18 +0100 Subject: [PATCH] Log handshake initiation --- .../handshake/HandshakeClientInitializer.java | 18 +++++++++++------- .../handshake/HandshakeServerInitializer.java | 2 ++ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/enterprise/causal-clustering/src/main/java/org/neo4j/causalclustering/protocol/handshake/HandshakeClientInitializer.java b/enterprise/causal-clustering/src/main/java/org/neo4j/causalclustering/protocol/handshake/HandshakeClientInitializer.java index e085a7803d29f..fb3afc8647c6e 100644 --- a/enterprise/causal-clustering/src/main/java/org/neo4j/causalclustering/protocol/handshake/HandshakeClientInitializer.java +++ b/enterprise/causal-clustering/src/main/java/org/neo4j/causalclustering/protocol/handshake/HandshakeClientInitializer.java @@ -46,7 +46,7 @@ public class HandshakeClientInitializer extends ChannelInitializer protocolInstaller; private final NettyPipelineBuilderFactory pipelineBuilderFactory; - private final TimeoutStrategy timeoutStrategy; + private final TimeoutStrategy handshakeDelay; private final Log log; public HandshakeClientInitializer( ApplicationProtocolRepository applicationProtocolRepository, ModifierProtocolRepository modifierProtocolRepository, @@ -59,7 +59,7 @@ public HandshakeClientInitializer( ApplicationProtocolRepository applicationProt this.timeout = handshakeTimeout; this.protocolInstaller = protocolInstallerRepository; this.pipelineBuilderFactory = pipelineBuilderFactory; - this.timeoutStrategy = new ExponentialBackoffStrategy( 1, 2000, MILLISECONDS ); + this.handshakeDelay = new ExponentialBackoffStrategy( 1, 2000, MILLISECONDS ); } private void installHandlers( Channel channel, HandshakeClient handshakeClient ) throws Exception @@ -79,14 +79,16 @@ protected void initChannel( SocketChannel channel ) throws Exception HandshakeClient handshakeClient = new HandshakeClient(); installHandlers( channel, handshakeClient ); - scheduleHandshake( channel, handshakeClient, timeoutStrategy.newTimeout() ); + log.info( "Scheduling handshake (and timeout) local %s remote %s", channel.localAddress(), channel.remoteAddress() ); + + scheduleHandshake( channel, handshakeClient, handshakeDelay.newTimeout() ); scheduleTimeout( channel, handshakeClient ); } /** * schedules the handshake initiation after the connection attempt */ - private void scheduleHandshake( SocketChannel ch, HandshakeClient handshakeClient, TimeoutStrategy.Timeout timeout ) + private void scheduleHandshake( SocketChannel ch, HandshakeClient handshakeClient, TimeoutStrategy.Timeout handshakeDelay ) { ch.eventLoop().schedule( () -> { @@ -96,14 +98,14 @@ private void scheduleHandshake( SocketChannel ch, HandshakeClient handshakeClien } else if ( ch.isOpen() ) { - timeout.increment(); - scheduleHandshake( ch, handshakeClient, timeout ); + handshakeDelay.increment(); + scheduleHandshake( ch, handshakeClient, handshakeDelay ); } else { handshakeClient.failIfNotDone( "Channel closed" ); } - }, timeout.getMillis(), MILLISECONDS ); + }, handshakeDelay.getMillis(), MILLISECONDS ); } private void scheduleTimeout( SocketChannel ch, HandshakeClient handshakeClient ) @@ -118,6 +120,8 @@ private void scheduleTimeout( SocketChannel ch, HandshakeClient handshakeClient private void initiateHandshake( Channel channel, HandshakeClient handshakeClient ) { + log.info( "Initiating handshake local %s remote %s", channel.localAddress(), channel.remoteAddress() ); + SimpleNettyChannel channelWrapper = new SimpleNettyChannel( channel, log ); CompletableFuture handshake = handshakeClient.initiate( channelWrapper, applicationProtocolRepository, modifierProtocolRepository ); diff --git a/enterprise/causal-clustering/src/main/java/org/neo4j/causalclustering/protocol/handshake/HandshakeServerInitializer.java b/enterprise/causal-clustering/src/main/java/org/neo4j/causalclustering/protocol/handshake/HandshakeServerInitializer.java index 3a85223bc6a86..ab28f18fb2b68 100644 --- a/enterprise/causal-clustering/src/main/java/org/neo4j/causalclustering/protocol/handshake/HandshakeServerInitializer.java +++ b/enterprise/causal-clustering/src/main/java/org/neo4j/causalclustering/protocol/handshake/HandshakeServerInitializer.java @@ -57,6 +57,8 @@ public HandshakeServerInitializer( ApplicationProtocolRepository applicationProt @Override public void initChannel( SocketChannel ch ) throws Exception { + log.info( "Installing handshake server local %s remote %s", ch.localAddress(), ch.remoteAddress() ); + pipelineBuilderFactory.server( ch, log ) .addFraming() .add( "handshake_server_encoder", new ServerMessageEncoder() )