Java Code Examples for org.apache.flink.shaded.netty4.io.netty.buffer.ByteBuf#readBoolean()

The following examples show how to use org.apache.flink.shaded.netty4.io.netty.buffer.ByteBuf#readBoolean() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NettyMessage.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
static ErrorResponse readFrom(ByteBuf buffer) throws Exception {
	try (ObjectInputStream ois = new ObjectInputStream(new ByteBufInputStream(buffer))) {
		Object obj = ois.readObject();

		if (!(obj instanceof Throwable)) {
			throw new ClassCastException("Read object expected to be of type Throwable, " +
					"actual type is " + obj.getClass() + ".");
		} else {
			if (buffer.readBoolean()) {
				InputChannelID receiverId = InputChannelID.fromByteBuf(buffer);
				return new ErrorResponse((Throwable) obj, receiverId);
			} else {
				return new ErrorResponse((Throwable) obj);
			}
		}
	}
}
 
Example 2
Source File: NettyMessage.java    From flink with Apache License 2.0 6 votes vote down vote up
static ErrorResponse readFrom(ByteBuf buffer) throws Exception {
	try (ObjectInputStream ois = new ObjectInputStream(new ByteBufInputStream(buffer))) {
		Object obj = ois.readObject();

		if (!(obj instanceof Throwable)) {
			throw new ClassCastException("Read object expected to be of type Throwable, " +
					"actual type is " + obj.getClass() + ".");
		} else {
			if (buffer.readBoolean()) {
				InputChannelID receiverId = InputChannelID.fromByteBuf(buffer);
				return new ErrorResponse((Throwable) obj, receiverId);
			} else {
				return new ErrorResponse((Throwable) obj);
			}
		}
	}
}
 
Example 3
Source File: NettyMessage.java    From flink with Apache License 2.0 6 votes vote down vote up
static ErrorResponse readFrom(ByteBuf buffer) throws Exception {
	try (ObjectInputStream ois = new ObjectInputStream(new ByteBufInputStream(buffer))) {
		Object obj = ois.readObject();

		if (!(obj instanceof Throwable)) {
			throw new ClassCastException("Read object expected to be of type Throwable, " +
					"actual type is " + obj.getClass() + ".");
		} else {
			if (buffer.readBoolean()) {
				InputChannelID receiverId = InputChannelID.fromByteBuf(buffer);
				return new ErrorResponse((Throwable) obj, receiverId);
			} else {
				return new ErrorResponse((Throwable) obj);
			}
		}
	}
}
 
Example 4
Source File: NettyMessage.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
static BufferResponse readFrom(ByteBuf buffer) {
	InputChannelID receiverId = InputChannelID.fromByteBuf(buffer);
	int sequenceNumber = buffer.readInt();
	int backlog = buffer.readInt();
	boolean isBuffer = buffer.readBoolean();
	int size = buffer.readInt();

	ByteBuf retainedSlice = buffer.readSlice(size).retain();
	return new BufferResponse(retainedSlice, isBuffer, sequenceNumber, receiverId, backlog);
}
 
Example 5
Source File: NettyMessage.java    From flink with Apache License 2.0 5 votes vote down vote up
static BufferResponse readFrom(ByteBuf buffer) {
	InputChannelID receiverId = InputChannelID.fromByteBuf(buffer);
	int sequenceNumber = buffer.readInt();
	int backlog = buffer.readInt();
	boolean isBuffer = buffer.readBoolean();
	int size = buffer.readInt();

	ByteBuf retainedSlice = buffer.readSlice(size).retain();
	return new BufferResponse(retainedSlice, isBuffer, sequenceNumber, receiverId, backlog);
}
 
Example 6
Source File: NettyMessage.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Parses the message header part and composes a new BufferResponse with an empty data buffer. The
 * data buffer will be filled in later.
 *
 * @param messageHeader the serialized message header.
 * @param bufferAllocator the allocator for network buffer.
 * @return a BufferResponse object with the header parsed and the data buffer to fill in later. The
 *			data buffer will be null if the target channel has been released or the buffer size is 0.
 */
static BufferResponse readFrom(ByteBuf messageHeader, NetworkBufferAllocator bufferAllocator) {
	InputChannelID receiverId = InputChannelID.fromByteBuf(messageHeader);
	int sequenceNumber = messageHeader.readInt();
	int backlog = messageHeader.readInt();
	Buffer.DataType dataType = Buffer.DataType.values()[messageHeader.readByte()];
	boolean isCompressed = messageHeader.readBoolean();
	int size = messageHeader.readInt();

	Buffer dataBuffer = null;

	if (size != 0) {
		if (dataType.isBuffer()) {
			dataBuffer = bufferAllocator.allocatePooledNetworkBuffer(receiverId);
		} else {
			dataBuffer = bufferAllocator.allocateUnPooledNetworkBuffer(size, dataType);
		}
	}

	if (dataBuffer != null) {
		dataBuffer.setCompressed(isCompressed);
	}

	return new BufferResponse(
		dataBuffer,
		dataType,
		isCompressed,
		sequenceNumber,
		receiverId,
		backlog,
		size);
}