flink-instrumentation/workspace/flink-1.4.1-instrumented/flink-1.4.1/flink-runtime/src/main/java/org/apache/flink/runtime/io/network/netty/NettyMessage.java
/**
	 * Allocates a new (header and contents) buffer and adds some header information for the frame
	 * decoder.
	 *
	 * <p>If the <tt>length</tt> is unknown, you must write the actual length after adding the
	 * contents as an integer to position <tt>0</tt>!
	 *
	 * @param allocator
	 * 		byte buffer allocator to use
	 * @param id
	 * 		{@link NettyMessage} subclass ID
	 * @param length
	 * 		content length (or <tt>-1</tt> if unknown)
	 *
	 * @return a newly allocated direct buffer with header data written for {@link
	 * NettyMessageDecoder}
	 */
Allocates a new (header and contents) buffer and adds some header information for the frame
decoder.

If the length is unknown, you must write the actual length after adding the
contents as an integer to position 0!

@param allocator
byte buffer allocator to use
@param id
NettyMessage subclass ID
@param length
content length (or -1 if unknown)

@return a newly allocated direct buffer with header data written for {@link
NettyMessageDecoder}
Allocates a new ( header and contents ) buffer and adds some header information for the frame decoder . If the length is unknown you must write the actual length after adding the contents as an integer to position 0! @param allocator byte buffer allocator to use @param id NettyMessage subclass ID @param length content length ( or - 1 if unknown ) @return a newly allocated direct buffer with header data written for { @link NettyMessageDecoder }
private static ByteBuf allocateBuffer(ByteBufAllocator allocator, byte id, int length) {
		checkArgument(length <= Integer.MAX_VALUE - HEADER_LENGTH);
		final ByteBuf buffer;
		if (length != -1) {
			buffer = allocator.directBuffer(HEADER_LENGTH + length);
		} else {
			buffer = allocator.directBuffer();
		}
		buffer.writeInt(HEADER_LENGTH + length);
		buffer.writeInt(MAGIC_NUMBER);
		buffer.writeByte(id);
		return buffer;
	}
private static ByteBuf allocateBuffer ( ByteBufAllocator allocator , byte id , int length ) { checkArgument ( length <= Integer . MAX_VALUE - HEADER_LENGTH ) ; final ByteBuf buffer ; if ( length != - 1 ) { buffer = allocator . directBuffer ( HEADER_LENGTH + length ) ; } else { buffer = allocator . directBuffer ( ) ; } buffer . writeInt ( HEADER_LENGTH + length ) ; buffer . writeInt ( MAGIC_NUMBER ) ; buffer . writeByte ( id ) ; return buffer ; }
Allocates a new (header and contents) buffer and adds some header information for the frame
 decoder.
Allocates a new ( header and contents ) buffer and adds some header information for the frame decoder .
// content length unknown -> start with the default initial size (rather than HEADER_LENGTH only):