/** * encode the current Control Message into a channel buffer * * @throws Exception */ ChannelBuffer buffer() throws Exception { ChannelBufferOutputStream bout = new ChannelBufferOutputStream(ChannelBuffers.directBuffer(encodeLength())); write(bout); bout.close(); return bout.buffer(); }
/** create a buffer containing the encoding of this batch */ ChannelBuffer buffer() throws Exception { ChannelBufferOutputStream bout = new ChannelBufferOutputStream(ChannelBuffers.directBuffer(encoded_length)); for (TaskMessage msg : msgs) { writeTaskMessage(bout, msg); } // add a END_OF_BATCH indicator ControlMessage.EOB_MESSAGE.write(bout); bout.close(); return bout.buffer(); }