Search in sources :

Example 1 with RPCMessageDecoder

use of alluxio.network.protocol.RPCMessageDecoder in project alluxio by Alluxio.

the class AlluxioBlockStoreTest method before.

@Before
public void before() throws Exception {
    mBlockWorkerClient = PowerMockito.mock(BlockWorkerClient.class);
    mMasterClient = PowerMockito.mock(BlockMasterClient.class);
    mChannel = PowerMockito.mock(Channel.class);
    mPipeline = PowerMockito.mock(ChannelPipeline.class);
    mContext = PowerMockito.mock(FileSystemContext.class);
    // Mock block store context to return our mock clients
    Mockito.when(mContext.createBlockWorkerClient(Mockito.any(WorkerNetAddress.class))).thenReturn(mBlockWorkerClient);
    mLocalAddr = new InetSocketAddress(NetworkAddressUtils.getLocalHostName(), 0);
    Mockito.when(mBlockWorkerClient.getDataServerAddress()).thenReturn(mLocalAddr);
    Mockito.when(mContext.acquireBlockMasterClientResource()).thenReturn(new DummyCloseableResource<>(mMasterClient));
    mBlockStore = new AlluxioBlockStore(mContext, WORKER_HOSTNAME_LOCAL);
    Mockito.when(mContext.acquireNettyChannel(Mockito.any(InetSocketAddress.class))).thenReturn(mChannel);
    Mockito.when(mChannel.pipeline()).thenReturn(mPipeline);
    Mockito.when(mPipeline.last()).thenReturn(new RPCMessageDecoder());
    Mockito.when(mPipeline.addLast(Mockito.any(ChannelHandler.class))).thenReturn(mPipeline);
}
Also used : RPCMessageDecoder(alluxio.network.protocol.RPCMessageDecoder) WorkerNetAddress(alluxio.wire.WorkerNetAddress) InetSocketAddress(java.net.InetSocketAddress) Channel(io.netty.channel.Channel) FileSystemContext(alluxio.client.file.FileSystemContext) ChannelHandler(io.netty.channel.ChannelHandler) ChannelPipeline(io.netty.channel.ChannelPipeline) Before(org.junit.Before)

Example 2 with RPCMessageDecoder

use of alluxio.network.protocol.RPCMessageDecoder in project alluxio by Alluxio.

the class PipelineHandler method initChannel.

@Override
protected void initChannel(SocketChannel ch) throws Exception {
    ChannelPipeline pipeline = ch.pipeline();
    pipeline.addLast("frameDecoder", RPCMessage.createFrameDecoder());
    pipeline.addLast("RPCMessageDecoder", new RPCMessageDecoder());
    pipeline.addLast("RPCMessageEncoder", new RPCMessageEncoder());
    pipeline.addLast("dataServerHandler", mDataServerHandler);
    pipeline.addLast("dataServerBlockReadHandler", new DataServerBlockReadHandler(NettyExecutors.BLOCK_READER_EXECUTOR, mWorker.getBlockWorker(), mFileTransferType));
    pipeline.addLast("dataServerUfsBlockReadHandler", new DataServerUfsBlockReadHandler(NettyExecutors.UFS_BLOCK_READER_EXECUTOR, mWorker.getBlockWorker()));
    pipeline.addLast("dataServerBlockWriteHandler", new DataServerBlockWriteHandler(NettyExecutors.BLOCK_WRITER_EXECUTOR, mWorker.getBlockWorker()));
    // DataServerFileReadHandler is deprecated. It is here for backward compatibility.
    pipeline.addLast("dataServerFileReadHandler", new DataServerUFSFileReadHandler(NettyExecutors.UFS_BLOCK_READER_EXECUTOR, mWorker.getFileSystemWorker()));
    pipeline.addLast("dataServerFileWriteHandler", new DataServerUFSFileWriteHandler(NettyExecutors.FILE_WRITER_EXECUTOR, mWorker.getFileSystemWorker()));
}
Also used : RPCMessageEncoder(alluxio.network.protocol.RPCMessageEncoder) RPCMessageDecoder(alluxio.network.protocol.RPCMessageDecoder) ChannelPipeline(io.netty.channel.ChannelPipeline)

Aggregations

RPCMessageDecoder (alluxio.network.protocol.RPCMessageDecoder)2 ChannelPipeline (io.netty.channel.ChannelPipeline)2 FileSystemContext (alluxio.client.file.FileSystemContext)1 RPCMessageEncoder (alluxio.network.protocol.RPCMessageEncoder)1 WorkerNetAddress (alluxio.wire.WorkerNetAddress)1 Channel (io.netty.channel.Channel)1 ChannelHandler (io.netty.channel.ChannelHandler)1 InetSocketAddress (java.net.InetSocketAddress)1 Before (org.junit.Before)1