Search in sources :

Example 1 with RequestProcessor

use of com.yanghui.elephant.remoting.RequestProcessor in project elephant by yanghuijava.

the class NettyRemotingAbstract method handlerRequestProcessor.

private void handlerRequestProcessor(final ChannelHandlerContext ctx, final RemotingCommand request, Pair<RequestProcessor, ExecutorService> pair) {
    final RequestProcessor requestProcessor = pair.getObject1();
    ExecutorService executorService = pair.getObject2();
    if (executorService == null) {
        RemotingCommand respose = requestProcessor.processRequest(ctx, request);
        if (respose != null)
            ctx.writeAndFlush(respose);
        return;
    }
    executorService.submit(new Runnable() {

        @Override
        public void run() {
            RemotingCommand respose = requestProcessor.processRequest(ctx, request);
            if (respose != null)
                ctx.writeAndFlush(respose);
        }
    });
}
Also used : RemotingCommand(com.yanghui.elephant.remoting.procotol.RemotingCommand) ExecutorService(java.util.concurrent.ExecutorService) RequestProcessor(com.yanghui.elephant.remoting.RequestProcessor)

Aggregations

RequestProcessor (com.yanghui.elephant.remoting.RequestProcessor)1 RemotingCommand (com.yanghui.elephant.remoting.procotol.RemotingCommand)1 ExecutorService (java.util.concurrent.ExecutorService)1