Skip to content

Improve NettyChannelTracker #802

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 14, 2021
Merged
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 @@ -98,9 +98,9 @@ public void channelReleased( Channel channel )
{
decrementInUse( channel );
incrementIdle( channel );
channel.closeFuture().addListener( closeListener );
} );

channel.closeFuture().addListener( closeListener );
log.debug( "Channel [0x%s] released back to the pool", channel.id() );
}

Expand All @@ -111,9 +111,9 @@ public void channelAcquired( Channel channel )
{
incrementInUse( channel );
decrementIdle( channel );
channel.closeFuture().removeListener( closeListener );
} );

channel.closeFuture().removeListener( closeListener );
log.debug( "Channel [0x%s] acquired from the pool. Local address: %s, remote address: %s", channel.id(), channel.localAddress(),
channel.remoteAddress() );
}
Expand Down Expand Up @@ -188,7 +188,13 @@ private void incrementInUse( Channel channel )

private void decrementInUse( Channel channel )
{
decrement( channel, addressToInUseChannelCount );
BoltServerAddress address = serverAddress( channel );
if ( !addressToInUseChannelCount.containsKey( address ) )
{
throw new IllegalStateException( "No count exists for address '" + address + "' in the 'in use' count" );
}
Integer count = addressToInUseChannelCount.get( address );
addressToInUseChannelCount.put( address, count - 1 );
}

private void incrementIdle( Channel channel )
Expand All @@ -198,7 +204,13 @@ private void incrementIdle( Channel channel )

private void decrementIdle( Channel channel )
{
decrement( channel, addressToIdleChannelCount );
BoltServerAddress address = serverAddress( channel );
if ( !addressToIdleChannelCount.containsKey( address ) )
{
throw new IllegalStateException( "No count exists for address '" + address + "' in the 'idle' count" );
}
Integer count = addressToIdleChannelCount.get( address );
addressToIdleChannelCount.put( address, count - 1 );
}

private void increment( Channel channel, Map<BoltServerAddress,Integer> countMap )
Expand All @@ -207,15 +219,4 @@ private void increment( Channel channel, Map<BoltServerAddress,Integer> countMap
Integer count = countMap.computeIfAbsent( address, k -> 0 );
countMap.put( address, count + 1 );
}

private void decrement( Channel channel, Map<BoltServerAddress,Integer> countMap )
{
BoltServerAddress address = serverAddress( channel );
if ( !countMap.containsKey( address ) )
{
throw new IllegalStateException( "No count exist for address '" + address + "'" );
}
Integer count = countMap.get( address );
countMap.put( address, count - 1 );
}
}