Search in sources :

Example 1 with UnauthenticatedChannelProtector

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);
        }
    };
}
Also used : UnauthenticatedChannelProtector(org.neo4j.bolt.transport.pipeline.UnauthenticatedChannelProtector) BoltChannel(org.neo4j.bolt.BoltChannel) Channel(io.netty.channel.Channel) LocalMemoryTracker(org.neo4j.memory.LocalMemoryTracker) BoltChannel(org.neo4j.bolt.BoltChannel) ChannelInitializer(io.netty.channel.ChannelInitializer)

Aggregations

Channel (io.netty.channel.Channel)1 ChannelInitializer (io.netty.channel.ChannelInitializer)1 BoltChannel (org.neo4j.bolt.BoltChannel)1 UnauthenticatedChannelProtector (org.neo4j.bolt.transport.pipeline.UnauthenticatedChannelProtector)1 LocalMemoryTracker (org.neo4j.memory.LocalMemoryTracker)1