capacity += 1 + ByteUtils.stringSize(this.transactionInfo.getTimeout());
}
if (!StringUtils.isBlank(this.transactionInfo.getUniqueQualifier())) {
capacity += 1 + this.transactionInfo.getUniqueQualifier().length();
}
final IoBuffer buffer = IoBuffer.allocate(capacity);
if (this.transactionInfo.getTimeout() > 0) {
if (StringUtils.isBlank(this.transactionInfo.getUniqueQualifier())) {
ByteUtils.setArguments(buffer, MetaEncodeCommand.TRANS_CMD, transactionKey,
this.transactionInfo.getSessionId(), type, this.transactionInfo.getTimeout(), this.opaque);
}
else {
ByteUtils.setArguments(buffer, MetaEncodeCommand.TRANS_CMD, transactionKey,
this.transactionInfo.getSessionId(), type, this.transactionInfo.getTimeout(),
this.transactionInfo.getUniqueQualifier(), this.opaque);
}
}
else {
if (StringUtils.isBlank(this.transactionInfo.getUniqueQualifier())) {
ByteUtils.setArguments(buffer, MetaEncodeCommand.TRANS_CMD, transactionKey,
this.transactionInfo.getSessionId(), type, this.opaque);
}
else {
ByteUtils.setArguments(buffer, MetaEncodeCommand.TRANS_CMD, transactionKey,
this.transactionInfo.getSessionId(), type, this.transactionInfo.getUniqueQualifier(), this.opaque);
}
}
buffer.flip();
return buffer;
}