HADOOP-8084. Updates ProtoBufRpc engine to not do an unnecessary copy for RPC request/response. Contributed by Devaraj Das.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1291602 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Devaraj Das 2012-02-21 05:19:53 +00:00
parent 5ee495e6f3
commit ae7e43139d
2 changed files with 11 additions and 6 deletions

View File

@ -86,6 +86,9 @@ Trunk (unreleased changes)
HADOOP-8070. Add a standalone benchmark for RPC call performance. (todd) HADOOP-8070. Add a standalone benchmark for RPC call performance. (todd)
HADOOP-8084. Updates ProtoBufRpc engine to not do an unnecessary copy
for RPC request/response. (ddas)
BUG FIXES BUG FIXES
HADOOP-8018. Hudson auto test for HDFS has started throwing javadoc HADOOP-8018. Hudson auto test for HDFS has started throwing javadoc

View File

@ -34,6 +34,7 @@ import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.classification.InterfaceAudience; import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.classification.InterfaceStability; import org.apache.hadoop.classification.InterfaceStability;
import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.io.DataOutputOutputStream;
import org.apache.hadoop.io.Writable; import org.apache.hadoop.io.Writable;
import org.apache.hadoop.ipc.Client.ConnectionId; import org.apache.hadoop.ipc.Client.ConnectionId;
import org.apache.hadoop.ipc.RPC.RpcInvoker; import org.apache.hadoop.ipc.RPC.RpcInvoker;
@ -45,6 +46,7 @@ import org.apache.hadoop.ipc.protobuf.HadoopRpcProtos.HadoopRpcResponseProto.Res
import org.apache.hadoop.security.UserGroupInformation; import org.apache.hadoop.security.UserGroupInformation;
import org.apache.hadoop.security.token.SecretManager; import org.apache.hadoop.security.token.SecretManager;
import org.apache.hadoop.security.token.TokenIdentifier; import org.apache.hadoop.security.token.TokenIdentifier;
import org.apache.hadoop.util.ProtoUtil;
import org.apache.hadoop.util.StringUtils; import org.apache.hadoop.util.StringUtils;
import com.google.common.annotations.VisibleForTesting; import com.google.common.annotations.VisibleForTesting;
@ -268,13 +270,13 @@ public class ProtobufRpcEngine implements RpcEngine {
@Override @Override
public void write(DataOutput out) throws IOException { public void write(DataOutput out) throws IOException {
out.writeInt(message.toByteArray().length); ((Message)message).writeDelimitedTo(
out.write(message.toByteArray()); DataOutputOutputStream.constructOutputStream(out));
} }
@Override @Override
public void readFields(DataInput in) throws IOException { public void readFields(DataInput in) throws IOException {
int length = in.readInt(); int length = ProtoUtil.readRawVarint32(in);
byte[] bytes = new byte[length]; byte[] bytes = new byte[length];
in.readFully(bytes); in.readFully(bytes);
message = HadoopRpcRequestProto.parseFrom(bytes); message = HadoopRpcRequestProto.parseFrom(bytes);
@ -297,13 +299,13 @@ public class ProtobufRpcEngine implements RpcEngine {
@Override @Override
public void write(DataOutput out) throws IOException { public void write(DataOutput out) throws IOException {
out.writeInt(message.toByteArray().length); ((Message)message).writeDelimitedTo(
out.write(message.toByteArray()); DataOutputOutputStream.constructOutputStream(out));
} }
@Override @Override
public void readFields(DataInput in) throws IOException { public void readFields(DataInput in) throws IOException {
int length = in.readInt(); int length = ProtoUtil.readRawVarint32(in);
byte[] bytes = new byte[length]; byte[] bytes = new byte[length];
in.readFully(bytes); in.readFully(bytes);
message = HadoopRpcResponseProto.parseFrom(bytes); message = HadoopRpcResponseProto.parseFrom(bytes);