int totalLength = 0;
while (it.hasNext()) {
key = it.next();
if (it.hasNext()) {
// first n-1 send getq command
Command command = new BinaryGetCommand(key, ByteUtils
.getBytes(key), cmdType, null, OpCode.GET_KEY_QUIETLY,
true);
command.encode();
totalLength += command.getIoBuffer().remaining();
bufferList.add(command.getIoBuffer());
}
}
// last key,create a get command
Command lastCommand = new BinaryGetCommand(key,
ByteUtils.getBytes(key), cmdType, new CountDownLatch(1),
OpCode.GET_KEY, false);
lastCommand.encode();
bufferList.add(lastCommand.getIoBuffer());
totalLength += lastCommand.getIoBuffer().remaining();
IoBuffer mergedBuffer = IoBuffer.allocate(totalLength);
for (IoBuffer buffer : bufferList) {
mergedBuffer.put(buffer.buf());
}