Java Code Examples for org.apache.flink.queryablestate.messages.KvStateInternalRequest#getSerializedKeyAndNamespace()

The following examples show how to use org.apache.flink.queryablestate.messages.KvStateInternalRequest#getSerializedKeyAndNamespace() . 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: KvStateServerHandler.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Override
public CompletableFuture<KvStateResponse> handleRequest(final long requestId, final KvStateInternalRequest request) {
	final CompletableFuture<KvStateResponse> responseFuture = new CompletableFuture<>();

	try {
		final KvStateEntry<?, ?, ?> kvState = registry.getKvState(request.getKvStateId());
		if (kvState == null) {
			responseFuture.completeExceptionally(new UnknownKvStateIdException(getServerName(), request.getKvStateId()));
		} else {
			byte[] serializedKeyAndNamespace = request.getSerializedKeyAndNamespace();

			byte[] serializedResult = getSerializedValue(kvState, serializedKeyAndNamespace);
			if (serializedResult != null) {
				responseFuture.complete(new KvStateResponse(serializedResult));
			} else {
				responseFuture.completeExceptionally(new UnknownKeyOrNamespaceException(getServerName()));
			}
		}
		return responseFuture;
	} catch (Throwable t) {
		String errMsg = "Error while processing request with ID " + requestId +
				". Caused by: " + ExceptionUtils.stringifyException(t);
		responseFuture.completeExceptionally(new RuntimeException(errMsg));
		return responseFuture;
	}
}
 
Example 2
Source File: KvStateServerHandler.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public CompletableFuture<KvStateResponse> handleRequest(final long requestId, final KvStateInternalRequest request) {
	final CompletableFuture<KvStateResponse> responseFuture = new CompletableFuture<>();

	try {
		final KvStateEntry<?, ?, ?> kvState = registry.getKvState(request.getKvStateId());
		if (kvState == null) {
			responseFuture.completeExceptionally(new UnknownKvStateIdException(getServerName(), request.getKvStateId()));
		} else {
			byte[] serializedKeyAndNamespace = request.getSerializedKeyAndNamespace();

			byte[] serializedResult = getSerializedValue(kvState, serializedKeyAndNamespace);
			if (serializedResult != null) {
				responseFuture.complete(new KvStateResponse(serializedResult));
			} else {
				responseFuture.completeExceptionally(new UnknownKeyOrNamespaceException(getServerName()));
			}
		}
		return responseFuture;
	} catch (Throwable t) {
		String errMsg = "Error while processing request with ID " + requestId +
				". Caused by: " + ExceptionUtils.stringifyException(t);
		responseFuture.completeExceptionally(new RuntimeException(errMsg));
		return responseFuture;
	}
}
 
Example 3
Source File: KvStateServerHandler.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public CompletableFuture<KvStateResponse> handleRequest(final long requestId, final KvStateInternalRequest request) {
	final CompletableFuture<KvStateResponse> responseFuture = new CompletableFuture<>();

	try {
		final KvStateEntry<?, ?, ?> kvState = registry.getKvState(request.getKvStateId());
		if (kvState == null) {
			responseFuture.completeExceptionally(new UnknownKvStateIdException(getServerName(), request.getKvStateId()));
		} else {
			byte[] serializedKeyAndNamespace = request.getSerializedKeyAndNamespace();

			byte[] serializedResult = getSerializedValue(kvState, serializedKeyAndNamespace);
			if (serializedResult != null) {
				responseFuture.complete(new KvStateResponse(serializedResult));
			} else {
				responseFuture.completeExceptionally(new UnknownKeyOrNamespaceException(getServerName()));
			}
		}
		return responseFuture;
	} catch (Throwable t) {
		String errMsg = "Error while processing request with ID " + requestId +
				". Caused by: " + ExceptionUtils.stringifyException(t);
		responseFuture.completeExceptionally(new RuntimeException(errMsg));
		return responseFuture;
	}
}