// Send a response with no data since the stats is not supported or not yet available
if (results == null) {
ByteBuffer responseBuffer = ByteBuffer.allocate(8);
responseBuffer.putLong(requestId);
byte responseBytes[] = CompressionService.compressBytes(responseBuffer.array());
BinaryPayloadMessage bpm = new BinaryPayloadMessage( new byte[] {payloadType}, responseBytes);
m_mailbox.send(returnAddress, bpm);
return;
}
ByteBuffer[] bufs = new ByteBuffer[results.length];
int statbytes = 0;
for (int i = 0; i < results.length; i++) {
bufs[i] = results[i].getBuffer();
bufs[i].position(0);
statbytes += bufs[i].remaining();
}
ByteBuffer responseBuffer = ByteBuffer.allocate(
8 + // requestId
4 * results.length + // length prefix for each stats table
+ statbytes);
responseBuffer.putLong(requestId);
for (int i = 0; i < bufs.length; i++) {
responseBuffer.putInt(bufs[i].remaining());
responseBuffer.put(bufs[i]);
}
byte responseBytes[] = CompressionService.compressBytes(responseBuffer.array());
BinaryPayloadMessage bpm = new BinaryPayloadMessage( new byte[] {payloadType}, responseBytes);
m_mailbox.send(returnAddress, bpm);
}