use of com.ctrip.xpipe.payload.StringInOutPayload in project x-pipe by ctripcorp.
the class BulkStringParser method getWriteByteBuf.
@Override
protected ByteBuf getWriteByteBuf() {
if (payload == null) {
if (logger.isInfoEnabled()) {
logger.info("[getWriteBytes][payload null]");
}
return Unpooled.wrappedBuffer(new byte[0]);
}
if ((payload instanceof StringInOutPayload) || (payload instanceof ByteArrayOutputStreamPayload)) {
try {
ByteArrayWritableByteChannel channel = new ByteArrayWritableByteChannel();
payload.out(channel);
byte[] content = channel.getResult();
String length = String.valueOf((char) DOLLAR_BYTE) + content.length + RedisClientProtocol.CRLF;
return Unpooled.wrappedBuffer(length.getBytes(), content, RedisClientProtocol.CRLF.getBytes());
} catch (IOException e) {
logger.error("[getWriteBytes]", e);
return Unpooled.wrappedBuffer(new byte[0]);
}
}
throw new UnsupportedOperationException();
}
Aggregations