Search in sources :

Example 1 with GetStoreIdRequestHandler

use of org.neo4j.causalclustering.catchup.storecopy.GetStoreIdRequestHandler in project neo4j by neo4j.

the class CatchupServer method start.

@Override
public synchronized void start() throws Throwable {
    if (channel != null) {
        return;
    }
    workerGroup = new NioEventLoopGroup(0, threadFactory);
    ServerBootstrap bootstrap = new ServerBootstrap().group(workerGroup).channel(NioServerSocketChannel.class).localAddress(listenAddress.socketAddress()).childHandler(new ChannelInitializer<SocketChannel>() {

        @Override
        protected void initChannel(SocketChannel ch) {
            CatchupServerProtocol protocol = new CatchupServerProtocol();
            ChannelPipeline pipeline = ch.pipeline();
            pipeline.addLast(new LengthFieldBasedFrameDecoder(Integer.MAX_VALUE, 0, 4, 0, 4));
            pipeline.addLast(new LengthFieldPrepender(4));
            pipeline.addLast(new VersionDecoder(logProvider));
            pipeline.addLast(new VersionPrepender());
            pipeline.addLast(new ResponseMessageTypeEncoder());
            pipeline.addLast(new RequestMessageTypeEncoder());
            pipeline.addLast(new TxPullResponseEncoder());
            pipeline.addLast(new CoreSnapshotEncoder());
            pipeline.addLast(new GetStoreIdResponseEncoder());
            pipeline.addLast(new StoreCopyFinishedResponseEncoder());
            pipeline.addLast(new TxStreamFinishedResponseEncoder());
            pipeline.addLast(new FileChunkEncoder());
            pipeline.addLast(new FileHeaderEncoder());
            pipeline.addLast(new ServerMessageTypeHandler(protocol, logProvider));
            pipeline.addLast(decoders(protocol));
            pipeline.addLast(new TxPullRequestHandler(protocol, storeIdSupplier, dataSourceAvailabilitySupplier, transactionIdStoreSupplier, logicalTransactionStoreSupplier, txPullBatchSize, monitors, logProvider));
            pipeline.addLast(new ChunkedWriteHandler());
            pipeline.addLast(new GetStoreRequestHandler(protocol, dataSourceSupplier, checkPointerSupplier, fs, pageCache, logProvider, storeCopyCheckPointMutex));
            pipeline.addLast(new GetStoreIdRequestHandler(protocol, storeIdSupplier));
            if (coreState != null) {
                pipeline.addLast(new CoreSnapshotRequestHandler(protocol, coreState));
            }
            pipeline.addLast(new ExceptionLoggingHandler(log));
            pipeline.addLast(new ExceptionMonitoringHandler(monitors.newMonitor(ExceptionMonitoringHandler.Monitor.class, CatchupServer.class)));
            pipeline.addLast(new ExceptionSwallowingHandler());
        }
    });
    try {
        channel = bootstrap.bind().syncUninterruptibly().channel();
    } catch (Exception e) {
        //noinspection ConstantConditions
        if (e instanceof BindException) {
            userLog.error("Address is already bound for setting: " + CausalClusteringSettings.transaction_listen_address + " with value: " + listenAddress);
            log.error("Address is already bound for setting: " + CausalClusteringSettings.transaction_listen_address + " with value: " + listenAddress, e);
            throw e;
        }
    }
}
Also used : SocketChannel(io.netty.channel.socket.SocketChannel) NioServerSocketChannel(io.netty.channel.socket.nio.NioServerSocketChannel) ExceptionSwallowingHandler(org.neo4j.causalclustering.handlers.ExceptionSwallowingHandler) VersionPrepender(org.neo4j.causalclustering.VersionPrepender) TxStreamFinishedResponseEncoder(org.neo4j.causalclustering.catchup.tx.TxStreamFinishedResponseEncoder) GetStoreIdResponseEncoder(org.neo4j.causalclustering.catchup.storecopy.GetStoreIdResponseEncoder) LengthFieldPrepender(io.netty.handler.codec.LengthFieldPrepender) CoreSnapshotRequestHandler(org.neo4j.causalclustering.core.state.snapshot.CoreSnapshotRequestHandler) ExceptionLoggingHandler(org.neo4j.causalclustering.handlers.ExceptionLoggingHandler) FileHeaderEncoder(org.neo4j.causalclustering.catchup.storecopy.FileHeaderEncoder) LengthFieldBasedFrameDecoder(io.netty.handler.codec.LengthFieldBasedFrameDecoder) NioEventLoopGroup(io.netty.channel.nio.NioEventLoopGroup) TxPullRequestHandler(org.neo4j.causalclustering.catchup.tx.TxPullRequestHandler) GetStoreRequestHandler(org.neo4j.causalclustering.catchup.storecopy.GetStoreRequestHandler) FileChunkEncoder(org.neo4j.causalclustering.catchup.storecopy.FileChunkEncoder) BindException(java.net.BindException) VersionDecoder(org.neo4j.causalclustering.VersionDecoder) TxPullResponseEncoder(org.neo4j.causalclustering.catchup.tx.TxPullResponseEncoder) StoreCopyFinishedResponseEncoder(org.neo4j.causalclustering.catchup.storecopy.StoreCopyFinishedResponseEncoder) ServerBootstrap(io.netty.bootstrap.ServerBootstrap) ChannelPipeline(io.netty.channel.ChannelPipeline) BindException(java.net.BindException) ExceptionMonitoringHandler(org.neo4j.causalclustering.handlers.ExceptionMonitoringHandler) CoreSnapshotEncoder(org.neo4j.causalclustering.core.state.snapshot.CoreSnapshotEncoder) ChunkedWriteHandler(io.netty.handler.stream.ChunkedWriteHandler) GetStoreIdRequestHandler(org.neo4j.causalclustering.catchup.storecopy.GetStoreIdRequestHandler)

Aggregations

ServerBootstrap (io.netty.bootstrap.ServerBootstrap)1 ChannelPipeline (io.netty.channel.ChannelPipeline)1 NioEventLoopGroup (io.netty.channel.nio.NioEventLoopGroup)1 SocketChannel (io.netty.channel.socket.SocketChannel)1 NioServerSocketChannel (io.netty.channel.socket.nio.NioServerSocketChannel)1 LengthFieldBasedFrameDecoder (io.netty.handler.codec.LengthFieldBasedFrameDecoder)1 LengthFieldPrepender (io.netty.handler.codec.LengthFieldPrepender)1 ChunkedWriteHandler (io.netty.handler.stream.ChunkedWriteHandler)1 BindException (java.net.BindException)1 VersionDecoder (org.neo4j.causalclustering.VersionDecoder)1 VersionPrepender (org.neo4j.causalclustering.VersionPrepender)1 FileChunkEncoder (org.neo4j.causalclustering.catchup.storecopy.FileChunkEncoder)1 FileHeaderEncoder (org.neo4j.causalclustering.catchup.storecopy.FileHeaderEncoder)1 GetStoreIdRequestHandler (org.neo4j.causalclustering.catchup.storecopy.GetStoreIdRequestHandler)1 GetStoreIdResponseEncoder (org.neo4j.causalclustering.catchup.storecopy.GetStoreIdResponseEncoder)1 GetStoreRequestHandler (org.neo4j.causalclustering.catchup.storecopy.GetStoreRequestHandler)1 StoreCopyFinishedResponseEncoder (org.neo4j.causalclustering.catchup.storecopy.StoreCopyFinishedResponseEncoder)1 TxPullRequestHandler (org.neo4j.causalclustering.catchup.tx.TxPullRequestHandler)1 TxPullResponseEncoder (org.neo4j.causalclustering.catchup.tx.TxPullResponseEncoder)1 TxStreamFinishedResponseEncoder (org.neo4j.causalclustering.catchup.tx.TxStreamFinishedResponseEncoder)1