@Test public void testCompressInputForProtobuf() throws IOException { Echo.EchoRequest request = Echo.EchoRequest.newBuilder().setMessage("hello").build(); ByteBuf byteBuf = compress.compressInput(request, protobufRpcMethodInfo); System.out.println(byteBuf.readableBytes()); }
@Override public ByteBuf compressInput(Object proto, RpcMethodInfo rpcMethodInfo) throws IOException { int protoSize = rpcMethodInfo.getInputSerializedSize(proto); ByteBuf resBuf = Unpooled.buffer(protoSize); OutputStream outputStream = new ByteBufOutputStream(resBuf); outputStream = new DeflaterOutputStream(outputStream); CodedOutputStream codedOutputStream = CodedOutputStream.newInstance(outputStream, protoSize); rpcMethodInfo.inputWriteToStream(proto, codedOutputStream); outputStream.close(); return resBuf; }
ZlibCompress implements Compress { @Override public ByteBuf compressInput(Object proto, RpcMethodInfo rpcMethodInfo) throws IOException { int protoSize = rpcMethodInfo.getInputSerializedSize(proto); ByteBuf resBuf = Unpooled.buffer(protoSize); OutputStream outputStream = new ByteBufOutputStream(resBuf); outputStream = new DeflaterOutputStream(outputStream); CodedOutputStream codedOutputStream = CodedOutputStream.newInstance(outputStream, protoSize); rpcMethodInfo.inputWriteToStream(proto, codedOutputStream); outputStream.close(); return resBuf; } }
ZlibCompress implements Compress { @Override public ByteBuf compressInput(Object proto, RpcMethodInfo rpcMethodInfo) throws IOException { int protoSize = rpcMethodInfo.getInputSerializedSize(proto); ByteBuf resBuf = Unpooled.buffer(protoSize); OutputStream outputStream = new ByteBufOutputStream(resBuf); outputStream = new DeflaterOutputStream(outputStream); CodedOutputStream codedOutputStream = CodedOutputStream.newInstance(outputStream, protoSize); rpcMethodInfo.inputWriteToStream(proto, codedOutputStream); outputStream.close(); return resBuf; }  }
ZlibCompress implements Compress { @Override public ByteBuf compressInput(Object proto, RpcMethodInfo rpcMethodInfo) throws IOException { int protoSize = rpcMethodInfo.getInputSerializedSize(proto); ByteBuf resBuf = Unpooled.buffer(protoSize); OutputStream outputStream = new ByteBufOutputStream(resBuf); outputStream = new DeflaterOutputStream(outputStream); CodedOutputStream codedOutputStream = CodedOutputStream.newInstance(outputStream, protoSize); rpcMethodInfo.inputWriteToStream(proto, codedOutputStream); outputStream.close(); return resBuf; }  @Override ByteBuf compressInput(Object proto, RpcMethodInfo rpcMethodInfo); @Override Object uncompressOutput(ByteBuf byteBuf, RpcMethodInfo rpcMethodInfo); @Override Object uncompressOutput(byte[] bytes, RpcMethodInfo rpcMethodInfo); @Override Object uncompressOutput(DynamicCompositeByteBuf byteBuf, RpcMethodInfo rpcMethodInfo); @Override Object uncompressInput(ByteBuf byteBuf, RpcMethodInfo rpcMethodInfo); @Override Object uncompressInput(byte[] bytes, RpcMethodInfo rpcMethodInfo); @Override Object uncompressInput(DynamicCompositeByteBuf byteBuf, RpcMethodInfo rpcMethodInfo); @Override ByteBuf compressOutput(Object proto, RpcMethodInfo rpcMethodInfo); }
ZlibCompress implements Compress { @Override public ByteBuf compressInput(Object proto, RpcMethodInfo rpcMethodInfo) throws IOException { int protoSize = rpcMethodInfo.getInputSerializedSize(proto); ByteBuf resBuf = Unpooled.buffer(protoSize); OutputStream outputStream = new ByteBufOutputStream(resBuf); outputStream = new DeflaterOutputStream(outputStream); CodedOutputStream codedOutputStream = CodedOutputStream.newInstance(outputStream, protoSize); rpcMethodInfo.inputWriteToStream(proto, codedOutputStream); outputStream.close(); return resBuf; }  @Override ByteBuf compressInput(Object proto, RpcMethodInfo rpcMethodInfo); @Override Object uncompressOutput(ByteBuf byteBuf, RpcMethodInfo rpcMethodInfo); @Override Object uncompressOutput(byte[] bytes, RpcMethodInfo rpcMethodInfo); @Override Object uncompressOutput(DynamicCompositeByteBuf byteBuf, RpcMethodInfo rpcMethodInfo); @Override Object uncompressInput(ByteBuf byteBuf, RpcMethodInfo rpcMethodInfo); @Override Object uncompressInput(byte[] bytes, RpcMethodInfo rpcMethodInfo); @Override Object uncompressInput(DynamicCompositeByteBuf byteBuf, RpcMethodInfo rpcMethodInfo); @Override ByteBuf compressOutput(Object proto, RpcMethodInfo rpcMethodInfo);  }