use of org.neo4j.bolt.transport.pipeline.UnauthenticatedChannelProtector in project neo4j by neo4j.
the class SocketTransport method channelInitializer.
@Override
public ChannelInitializer<Channel> channelInitializer() {
return new ChannelInitializer<>() {
@Override
public void initChannel(Channel ch) {
ch.config().setAllocator(allocator);
var memoryTracker = new LocalMemoryTracker(memoryPool, 0, 64, null);
ch.closeFuture().addListener(future -> memoryTracker.close());
memoryTracker.allocateHeap(HeapEstimator.sizeOf(ch));
memoryTracker.allocateHeap(UnauthenticatedChannelProtector.SHALLOW_SIZE + BoltChannel.SHALLOW_SIZE);
var channelProtector = new UnauthenticatedChannelProtector(ch, channelTimeout, maxMessageSize, memoryTracker);
BoltChannel boltChannel = newBoltChannel(ch, channelProtector, memoryTracker);
connectionTracker.add(boltChannel);
ch.closeFuture().addListener(future -> connectionTracker.remove(boltChannel));
// install throttles
throttleGroup.install(ch, memoryTracker);
// add a close listener that will uninstall throttles
ch.closeFuture().addListener(future -> throttleGroup.uninstall(ch));
memoryTracker.allocateHeap(TransportSelectionHandler.SHALLOW_SIZE);
TransportSelectionHandler transportSelectionHandler = new TransportSelectionHandler(boltChannel, sslCtx, encryptionRequired, false, logging, boltProtocolFactory, channelProtector, memoryTracker);
ch.pipeline().addLast(transportSelectionHandler);
}
};
}
Aggregations