@Override
  public void channelRead0(final ChannelHandlerContext ctx, final RPCMessage msg)
      throws IOException {
    switch (msg.getType()) {
      case RPC_BLOCK_READ_REQUEST:
        assert msg instanceof RPCBlockReadRequest;
        mBlockHandler.handleBlockReadRequest(ctx, (RPCBlockReadRequest) msg);
        break;
      case RPC_BLOCK_WRITE_REQUEST:
        assert msg instanceof RPCBlockWriteRequest;
        mBlockHandler.handleBlockWriteRequest(ctx, (RPCBlockWriteRequest) msg);
        break;
      case RPC_FILE_READ_REQUEST:
        assert msg instanceof RPCFileReadRequest;
        mUnderFileSystemHandler.handleFileReadRequest(ctx, (RPCFileReadRequest) msg);
        break;
      case RPC_FILE_WRITE_REQUEST:
        assert msg instanceof RPCFileWriteRequest;
        mUnderFileSystemHandler.handleFileWriteRequest(ctx, (RPCFileWriteRequest) msg);
        break;
      case RPC_ERROR_RESPONSE:
        // TODO(peis): Fix this, we should not assert here.
        assert msg instanceof RPCErrorResponse;
        LOG.error("Received an error response from the client: " + msg.toString());
        break;
      default:
        RPCErrorResponse resp = new RPCErrorResponse(RPCResponse.Status.UNKNOWN_MESSAGE_ERROR);
        ctx.writeAndFlush(resp);
        // TODO(peis): Fix this. We should not throw an exception here.
        throw new IllegalArgumentException(
            "No handler implementation for rpc msg type: " + msg.getType());
    }
  }
@Override
  public void channelRead0(final ChannelHandlerContext ctx, final RPCMessage msg)
      throws IOException {
    switch (msg.getType()) {
      case RPC_BLOCK_READ_REQUEST:
        assert msg instanceof RPCBlockReadRequest;
        mBlockHandler.handleBlockReadRequest(ctx, (RPCBlockReadRequest) msg);
        break;
      case RPC_BLOCK_WRITE_REQUEST:
        assert msg instanceof RPCBlockWriteRequest;
        mBlockHandler.handleBlockWriteRequest(ctx, (RPCBlockWriteRequest) msg);
        break;
      case RPC_FILE_READ_REQUEST:
        assert msg instanceof RPCFileReadRequest;
        mUnderFileSystemHandler.handleFileReadRequest(ctx, (RPCFileReadRequest) msg);
        break;
      case RPC_FILE_WRITE_REQUEST:
        assert msg instanceof RPCFileWriteRequest;
        mUnderFileSystemHandler.handleFileWriteRequest(ctx, (RPCFileWriteRequest) msg);
        break;
      case RPC_ERROR_RESPONSE:
       
        assert msg instanceof RPCErrorResponse;
        LOG.error("Received an error response from the client: " + msg.toString());
        break;
      default:
        RPCErrorResponse resp = new RPCErrorResponse(RPCResponse.Status.UNKNOWN_MESSAGE_ERROR);
        ctx.writeAndFlush(resp);
       
        throw new IllegalArgumentException(
            "No handler implementation for rpc msg type: " + msg.getType());
    }
  }
@override public void channelread0(final channelhandlercontext ctx, final rpcmessage msg) throws ioexception { switch (msg.gettype()) { case rpc_block_read_request: assert msg instanceof rpcblockreadrequest; mblockhandler.handleblockreadrequest(ctx, (rpcblockreadrequest) msg); break; case rpc_block_write_request: assert msg instanceof rpcblockwriterequest; mblockhandler.handleblockwriterequest(ctx, (rpcblockwriterequest) msg); break; case rpc_file_read_request: assert msg instanceof rpcfilereadrequest; munderfilesystemhandler.handlefilereadrequest(ctx, (rpcfilereadrequest) msg); break; case rpc_file_write_request: assert msg instanceof rpcfilewriterequest; munderfilesystemhandler.handlefilewriterequest(ctx, (rpcfilewriterequest) msg); break; case rpc_error_response: assert msg instanceof rpcerrorresponse; log.error("received an error response from the client: " + msg.tostring()); break; default: rpcerrorresponse resp = new rpcerrorresponse(rpcresponse.status.unknown_message_error); ctx.writeandflush(resp); throw new illegalargumentexception( "no handler implementation for rpc msg type: " + msg.gettype()); } }