Apache9 commented on a change in pull request #679: HBASE-23113 IPC Netty Optimization URL: https://github.com/apache/hbase/pull/679#discussion_r331743786
########## File path: hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/AbstractBatchDecoder.java ########## @@ -0,0 +1,442 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * <p> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p> + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.ipc; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.hbase.thirdparty.io.netty.buffer.ByteBuf; +import org.apache.hbase.thirdparty.io.netty.buffer.ByteBufAllocator; +import org.apache.hbase.thirdparty.io.netty.buffer.CompositeByteBuf; +import org.apache.hbase.thirdparty.io.netty.buffer.Unpooled; +import org.apache.hbase.thirdparty.io.netty.channel.ChannelHandlerContext; +import org.apache.hbase.thirdparty.io.netty.channel.ChannelInboundHandlerAdapter; +import org.apache.hbase.thirdparty.io.netty.handler.codec.ByteToMessageDecoder; +import org.apache.hbase.thirdparty.io.netty.handler.codec.DecoderException; +import org.apache.hbase.thirdparty.io.netty.util.internal.RecyclableArrayList; +import org.apache.hbase.thirdparty.io.netty.util.internal.StringUtil; + +/** + * This class mainly hack the {@link org.apache.hbase.thirdparty.io.netty.handler.codec.ByteToMessageDecoder} to provide batch submission capability. + * This can be used the same way as ByteToMessageDecoder except the case your following inbound handler may get a decoded msg, + * which actually is an array list, then you can submit the list of msgs to an executor to process. For example + * <pre> + * if (msg instanceof List) { + * processorManager.getDefaultExecutor().execute(new Runnable() { + * public void run() { + * // batch submit to an executor + * for (Object m : (List<?>) msg) { + * RpcCommandHandler.this.process(ctx, m); + * } + * } + * }); + * } else { + * process(ctx, msg); + * } + * </pre> + * You can check the method {@link AbstractBatchDecoder#channelRead(ChannelHandlerContext, Object)} ()} + * to know the detail modification. + */ +public abstract class AbstractBatchDecoder extends ChannelInboundHandlerAdapter { Review comment: Any idea that why netty does not implement this by default if this could greatly increase the performance? Performance is one of the most important thing in netty. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
