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

The following examples show how to use org.apache.flink.shaded.netty4.io.netty.buffer.ByteBuf#readLong() . 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: KvStateInternalRequest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public KvStateInternalRequest deserializeMessage(ByteBuf buf) {
	KvStateID kvStateId = new KvStateID(buf.readLong(), buf.readLong());

	int length = buf.readInt();
	Preconditions.checkArgument(length >= 0,
			"Negative length for key and namespace. " +
					"This indicates a serialization error.");

	byte[] serializedKeyAndNamespace = new byte[length];
	if (length > 0) {
		buf.readBytes(serializedKeyAndNamespace);
	}
	return new KvStateInternalRequest(kvStateId, serializedKeyAndNamespace);
}
 
Example 2
Source File: MessageSerializer.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * De-serializes the {@link RequestFailure} sent to the
 * {@link org.apache.flink.queryablestate.network.Client} in case of
 * protocol related errors.
 * <pre>
 *  <b>The buffer is expected to be at the correct position.</b>
 * </pre>
 * @param buf	The {@link ByteBuf} containing the serialized failure message.
 * @return		The failure message.
 */
public static RequestFailure deserializeRequestFailure(final ByteBuf buf) throws IOException, ClassNotFoundException {
	long requestId = buf.readLong();

	Throwable cause;
	try (ByteBufInputStream bis = new ByteBufInputStream(buf);
			ObjectInputStream in = new ObjectInputStream(bis)) {
		cause = (Throwable) in.readObject();
	}
	return new RequestFailure(requestId, cause);
}
 
Example 3
Source File: KvStateInternalRequest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public KvStateInternalRequest deserializeMessage(ByteBuf buf) {
	KvStateID kvStateId = new KvStateID(buf.readLong(), buf.readLong());

	int length = buf.readInt();
	Preconditions.checkArgument(length >= 0,
			"Negative length for key and namespace. " +
					"This indicates a serialization error.");

	byte[] serializedKeyAndNamespace = new byte[length];
	if (length > 0) {
		buf.readBytes(serializedKeyAndNamespace);
	}
	return new KvStateInternalRequest(kvStateId, serializedKeyAndNamespace);
}
 
Example 4
Source File: KvStateRequest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public KvStateRequest deserializeMessage(ByteBuf buf) {
	JobID jobId = new JobID(buf.readLong(), buf.readLong());

	int statenameLength = buf.readInt();
	Preconditions.checkArgument(statenameLength >= 0,
			"Negative length for state name. " +
					"This indicates a serialization error.");

	String stateName = "";
	if (statenameLength > 0) {
		byte[] name = new byte[statenameLength];
		buf.readBytes(name);
		stateName = new String(name, ConfigConstants.DEFAULT_CHARSET);
	}

	int keyHashCode = buf.readInt();

	int knamespaceLength = buf.readInt();
	Preconditions.checkArgument(knamespaceLength >= 0,
			"Negative length for key and namespace. " +
					"This indicates a serialization error.");

	byte[] serializedKeyAndNamespace = new byte[knamespaceLength];
	if (knamespaceLength > 0) {
		buf.readBytes(serializedKeyAndNamespace);
	}
	return new KvStateRequest(jobId, stateName, keyHashCode, serializedKeyAndNamespace);
}
 
Example 5
Source File: MessageSerializer.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * De-serializes the {@link RequestFailure} sent to the
 * {@link org.apache.flink.queryablestate.network.Client} in case of
 * protocol related errors.
 * <pre>
 *  <b>The buffer is expected to be at the correct position.</b>
 * </pre>
 * @param buf	The {@link ByteBuf} containing the serialized failure message.
 * @return		The failure message.
 */
public static RequestFailure deserializeRequestFailure(final ByteBuf buf) throws IOException, ClassNotFoundException {
	long requestId = buf.readLong();

	Throwable cause;
	try (ByteBufInputStream bis = new ByteBufInputStream(buf);
			ObjectInputStream in = new ObjectInputStream(bis)) {
		cause = (Throwable) in.readObject();
	}
	return new RequestFailure(requestId, cause);
}
 
Example 6
Source File: KvStateRequest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Override
public KvStateRequest deserializeMessage(ByteBuf buf) {
	JobID jobId = new JobID(buf.readLong(), buf.readLong());

	int statenameLength = buf.readInt();
	Preconditions.checkArgument(statenameLength >= 0,
			"Negative length for state name. " +
					"This indicates a serialization error.");

	String stateName = "";
	if (statenameLength > 0) {
		byte[] name = new byte[statenameLength];
		buf.readBytes(name);
		stateName = new String(name, ConfigConstants.DEFAULT_CHARSET);
	}

	int keyHashCode = buf.readInt();

	int knamespaceLength = buf.readInt();
	Preconditions.checkArgument(knamespaceLength >= 0,
			"Negative length for key and namespace. " +
					"This indicates a serialization error.");

	byte[] serializedKeyAndNamespace = new byte[knamespaceLength];
	if (knamespaceLength > 0) {
		buf.readBytes(serializedKeyAndNamespace);
	}
	return new KvStateRequest(jobId, stateName, keyHashCode, serializedKeyAndNamespace);
}
 
Example 7
Source File: MessageSerializer.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
/**
 * De-serializes the {@link RequestFailure} sent to the
 * {@link org.apache.flink.queryablestate.network.Client} in case of
 * protocol related errors.
 * <pre>
 *  <b>The buffer is expected to be at the correct position.</b>
 * </pre>
 * @param buf	The {@link ByteBuf} containing the serialized failure message.
 * @return		The failure message.
 */
public static RequestFailure deserializeRequestFailure(final ByteBuf buf) throws IOException, ClassNotFoundException {
	long requestId = buf.readLong();

	Throwable cause;
	try (ByteBufInputStream bis = new ByteBufInputStream(buf);
			ObjectInputStream in = new ObjectInputStream(bis)) {
		cause = (Throwable) in.readObject();
	}
	return new RequestFailure(requestId, cause);
}
 
Example 8
Source File: KvStateInternalRequest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Override
public KvStateInternalRequest deserializeMessage(ByteBuf buf) {
	KvStateID kvStateId = new KvStateID(buf.readLong(), buf.readLong());

	int length = buf.readInt();
	Preconditions.checkArgument(length >= 0,
			"Negative length for key and namespace. " +
					"This indicates a serialization error.");

	byte[] serializedKeyAndNamespace = new byte[length];
	if (length > 0) {
		buf.readBytes(serializedKeyAndNamespace);
	}
	return new KvStateInternalRequest(kvStateId, serializedKeyAndNamespace);
}
 
Example 9
Source File: KvStateRequest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public KvStateRequest deserializeMessage(ByteBuf buf) {
	JobID jobId = new JobID(buf.readLong(), buf.readLong());

	int statenameLength = buf.readInt();
	Preconditions.checkArgument(statenameLength >= 0,
			"Negative length for state name. " +
					"This indicates a serialization error.");

	String stateName = "";
	if (statenameLength > 0) {
		byte[] name = new byte[statenameLength];
		buf.readBytes(name);
		stateName = new String(name, ConfigConstants.DEFAULT_CHARSET);
	}

	int keyHashCode = buf.readInt();

	int knamespaceLength = buf.readInt();
	Preconditions.checkArgument(knamespaceLength >= 0,
			"Negative length for key and namespace. " +
					"This indicates a serialization error.");

	byte[] serializedKeyAndNamespace = new byte[knamespaceLength];
	if (knamespaceLength > 0) {
		buf.readBytes(serializedKeyAndNamespace);
	}
	return new KvStateRequest(jobId, stateName, keyHashCode, serializedKeyAndNamespace);
}
 
Example 10
Source File: IntermediateResultPartitionID.java    From flink with Apache License 2.0 4 votes vote down vote up
public static IntermediateResultPartitionID fromByteBuf(ByteBuf buf) {
	long lower = buf.readLong();
	long upper = buf.readLong();
	return new IntermediateResultPartitionID(lower, upper);
}
 
Example 11
Source File: ExecutionAttemptID.java    From flink with Apache License 2.0 4 votes vote down vote up
public static ExecutionAttemptID fromByteBuf(ByteBuf buf) {
	long lower = buf.readLong();
	long upper = buf.readLong();
	return new ExecutionAttemptID(lower, upper);
}
 
Example 12
Source File: InputChannelID.java    From flink with Apache License 2.0 4 votes vote down vote up
public static InputChannelID fromByteBuf(ByteBuf buf) {
	long lower = buf.readLong();
	long upper = buf.readLong();
	return new InputChannelID(lower, upper);
}
 
Example 13
Source File: IntermediateResultPartitionID.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
public static IntermediateResultPartitionID fromByteBuf(ByteBuf buf) {
	long lower = buf.readLong();
	long upper = buf.readLong();
	return new IntermediateResultPartitionID(lower, upper);
}
 
Example 14
Source File: IntermediateDataSetID.java    From flink with Apache License 2.0 4 votes vote down vote up
public static IntermediateDataSetID fromByteBuf(ByteBuf buf) {
	final long lower = buf.readLong();
	final long upper = buf.readLong();
	return new IntermediateDataSetID(lower, upper);
}
 
Example 15
Source File: ExecutionAttemptID.java    From flink with Apache License 2.0 4 votes vote down vote up
public static ExecutionAttemptID fromByteBuf(ByteBuf buf) {
	long lower = buf.readLong();
	long upper = buf.readLong();
	return new ExecutionAttemptID(lower, upper);
}
 
Example 16
Source File: InputChannelID.java    From flink with Apache License 2.0 4 votes vote down vote up
public static InputChannelID fromByteBuf(ByteBuf buf) {
	long lower = buf.readLong();
	long upper = buf.readLong();
	return new InputChannelID(lower, upper);
}
 
Example 17
Source File: ExecutionAttemptID.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
public static ExecutionAttemptID fromByteBuf(ByteBuf buf) {
	long lower = buf.readLong();
	long upper = buf.readLong();
	return new ExecutionAttemptID(lower, upper);
}
 
Example 18
Source File: MessageSerializer.java    From flink with Apache License 2.0 2 votes vote down vote up
/**
 * De-serializes the header and returns the {@link MessageType}.
 * <pre>
 *  <b>The buffer is expected to be at the request id position.</b>
 * </pre>
 * @param buf	The {@link ByteBuf} containing the serialized request id.
 * @return		The request id.
 */
public static long getRequestId(final ByteBuf buf) {
	return buf.readLong();
}
 
Example 19
Source File: MessageSerializer.java    From Flink-CEPplus with Apache License 2.0 2 votes vote down vote up
/**
 * De-serializes the header and returns the {@link MessageType}.
 * <pre>
 *  <b>The buffer is expected to be at the request id position.</b>
 * </pre>
 * @param buf	The {@link ByteBuf} containing the serialized request id.
 * @return		The request id.
 */
public static long getRequestId(final ByteBuf buf) {
	return buf.readLong();
}
 
Example 20
Source File: MessageSerializer.java    From flink with Apache License 2.0 2 votes vote down vote up
/**
 * De-serializes the header and returns the {@link MessageType}.
 * <pre>
 *  <b>The buffer is expected to be at the request id position.</b>
 * </pre>
 * @param buf	The {@link ByteBuf} containing the serialized request id.
 * @return		The request id.
 */
public static long getRequestId(final ByteBuf buf) {
	return buf.readLong();
}