org.apache.flink.runtime.rest.messages.MessageQueryParameter Java Examples

The following examples show how to use org.apache.flink.runtime.rest.messages.MessageQueryParameter. 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: HandlerRequestUtils.java    From flink with Apache License 2.0 6 votes vote down vote up
public static <X, P extends MessageQueryParameter<X>, R extends RequestBody, M extends MessageParameters> X getQueryParameter(
		final HandlerRequest<R, M> request,
		final Class<P> queryParameterClass,
		final X defaultValue) throws RestHandlerException {

	final List<X> values = request.getQueryParameter(queryParameterClass);
	final X value;
	if (values.size() > 1) {
		throw new RestHandlerException(
			String.format("Expected only one value %s.", values),
			HttpResponseStatus.BAD_REQUEST);
	} else if (values.size() == 1) {
		value = values.get(0);
	} else {
		value = defaultValue;
	}
	return value;
}
 
Example #2
Source File: HandlerRequestUtils.java    From flink with Apache License 2.0 6 votes vote down vote up
public static <X, P extends MessageQueryParameter<X>, R extends RequestBody, M extends MessageParameters> X getQueryParameter(
		final HandlerRequest<R, M> request,
		final Class<P> queryParameterClass,
		final X defaultValue) throws RestHandlerException {

	final List<X> values = request.getQueryParameter(queryParameterClass);
	final X value;
	if (values.size() > 1) {
		throw new RestHandlerException(
			String.format("Expected only one value %s.", values),
			HttpResponseStatus.BAD_REQUEST);
	} else if (values.size() == 1) {
		value = values.get(0);
	} else {
		value = defaultValue;
	}
	return value;
}
 
Example #3
Source File: HandlerRequestUtils.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
public static <X, P extends MessageQueryParameter<X>, R extends RequestBody, M extends MessageParameters> X getQueryParameter(
		final HandlerRequest<R, M> request,
		final Class<P> queryParameterClass,
		final X defaultValue) throws RestHandlerException {

	final List<X> values = request.getQueryParameter(queryParameterClass);
	final X value;
	if (values.size() > 1) {
		throw new RestHandlerException(
			String.format("Expected only one value %s.", values),
			HttpResponseStatus.BAD_REQUEST);
	} else if (values.size() == 1) {
		value = values.get(0);
	} else {
		value = defaultValue;
	}
	return value;
}
 
Example #4
Source File: HandlerRequest.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the value of the {@link MessageQueryParameter} for the given class.
 *
 * @param parameterClass class of the parameter
 * @param <X>            the value type that the parameter contains
 * @param <QP>           type of the query parameter
 * @return query parameter value for the given class, or an empty list if no parameter value exists for the given class
 */
public <X, QP extends MessageQueryParameter<X>> List<X> getQueryParameter(Class<QP> parameterClass) {
	@SuppressWarnings("unchecked")
	QP queryParameter = (QP) queryParameters.get(parameterClass);
	if (queryParameter == null) {
		return Collections.emptyList();
	} else {
		return queryParameter.getValue();
	}
}
 
Example #5
Source File: JarRunMessageParameters.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public Collection<MessageQueryParameter<?>> getQueryParameters() {
	Collection<MessageQueryParameter<?>> pars = new ArrayList<>(Arrays.asList(
		allowNonRestoredStateQueryParameter,
		savepointPathQueryParameter));
	pars.addAll(super.getQueryParameters());
	return Collections.unmodifiableCollection(pars);
}
 
Example #6
Source File: RestAPIDocGenerator.java    From flink with Apache License 2.0 5 votes vote down vote up
private static String createQueryParameterHtmlList(Collection<MessageQueryParameter<?>> queryParameters) {
	StringBuilder queryParameterList = new StringBuilder();
	queryParameters.stream()
		.sorted((param1, param2) -> Boolean.compare(param1.isMandatory(), param2.isMandatory()))
		.forEach(parameter ->
			queryParameterList.append(
				String.format("<li><code>%s</code> (%s): %s</li>\n",
					parameter.getKey(),
					parameter.isMandatory() ? "mandatory" : "optional",
					parameter.getDescription())
			));
	return queryParameterList.toString();
}
 
Example #7
Source File: JarMessageParameters.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public Collection<MessageQueryParameter<?>> getQueryParameters() {
	return Collections.unmodifiableList(Arrays.asList(
		programArgsQueryParameter,
		programArgQueryParameter,
		entryClassQueryParameter,
		parallelismQueryParameter));
}
 
Example #8
Source File: AbstractAggregatedMetricsParameters.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public Collection<MessageQueryParameter<?>> getQueryParameters() {
	return Collections.unmodifiableCollection(Arrays.asList(
		metrics,
		aggs,
		selector
	));
}
 
Example #9
Source File: JarMessageParameters.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public Collection<MessageQueryParameter<?>> getQueryParameters() {
	return Collections.unmodifiableList(Arrays.asList(
		programArgsQueryParameter,
		programArgQueryParameter,
		entryClassQueryParameter,
		parallelismQueryParameter));
}
 
Example #10
Source File: AbstractAggregatedMetricsParameters.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public Collection<MessageQueryParameter<?>> getQueryParameters() {
	return Collections.unmodifiableCollection(Arrays.asList(
		metrics,
		aggs,
		selector
	));
}
 
Example #11
Source File: HandlerRequestUtils.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the value of a query parameter, or {@code null} if the query parameter is not set.
 * @throws RestHandlerException If the query parameter is repeated.
 */
public static <X, P extends MessageQueryParameter<X>, R extends RequestBody, M extends MessageParameters> X getQueryParameter(
		final HandlerRequest<R, M> request,
		final Class<P> queryParameterClass) throws RestHandlerException {

	return getQueryParameter(request, queryParameterClass, null);
}
 
Example #12
Source File: HandlerRequest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the value of the {@link MessageQueryParameter} for the given class.
 *
 * @param parameterClass class of the parameter
 * @param <X>            the value type that the parameter contains
 * @param <QP>           type of the query parameter
 * @return query parameter value for the given class, or an empty list if no parameter value exists for the given class
 */
public <X, QP extends MessageQueryParameter<X>> List<X> getQueryParameter(Class<QP> parameterClass) {
	@SuppressWarnings("unchecked")
	QP queryParameter = (QP) queryParameters.get(parameterClass);
	if (queryParameter == null) {
		return Collections.emptyList();
	} else {
		return queryParameter.getValue();
	}
}
 
Example #13
Source File: JarRunMessageParameters.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public Collection<MessageQueryParameter<?>> getQueryParameters() {
	Collection<MessageQueryParameter<?>> pars = new ArrayList<>(Arrays.asList(
		allowNonRestoredStateQueryParameter,
		savepointPathQueryParameter));
	pars.addAll(super.getQueryParameters());
	return Collections.unmodifiableCollection(pars);
}
 
Example #14
Source File: RestAPIDocGenerator.java    From flink with Apache License 2.0 5 votes vote down vote up
private static String createQueryParameterHtmlList(Collection<MessageQueryParameter<?>> queryParameters) {
	StringBuilder queryParameterList = new StringBuilder();
	queryParameters.stream()
		.sorted((param1, param2) -> Boolean.compare(param1.isMandatory(), param2.isMandatory()))
		.forEach(parameter ->
			queryParameterList.append(
				String.format("<li><code>%s</code> (%s): %s</li>\n",
					parameter.getKey(),
					parameter.isMandatory() ? "mandatory" : "optional",
					parameter.getDescription())
			));
	return queryParameterList.toString();
}
 
Example #15
Source File: AbstractAggregatedMetricsParameters.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Override
public Collection<MessageQueryParameter<?>> getQueryParameters() {
	return Collections.unmodifiableCollection(Arrays.asList(
		metrics,
		aggs,
		selector
	));
}
 
Example #16
Source File: HandlerRequestUtils.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the value of a query parameter, or {@code null} if the query parameter is not set.
 * @throws RestHandlerException If the query parameter is repeated.
 */
public static <X, P extends MessageQueryParameter<X>, R extends RequestBody, M extends MessageParameters> X getQueryParameter(
		final HandlerRequest<R, M> request,
		final Class<P> queryParameterClass) throws RestHandlerException {

	return getQueryParameter(request, queryParameterClass, null);
}
 
Example #17
Source File: HandlerRequest.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the value of the {@link MessageQueryParameter} for the given class.
 *
 * @param parameterClass class of the parameter
 * @param <X>            the value type that the parameter contains
 * @param <QP>           type of the query parameter
 * @return query parameter value for the given class, or an empty list if no parameter value exists for the given class
 */
public <X, QP extends MessageQueryParameter<X>> List<X> getQueryParameter(Class<QP> parameterClass) {
	@SuppressWarnings("unchecked")
	QP queryParameter = (QP) queryParameters.get(parameterClass);
	if (queryParameter == null) {
		return Collections.emptyList();
	} else {
		return queryParameter.getValue();
	}
}
 
Example #18
Source File: HandlerRequestUtils.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the value of a query parameter, or {@code null} if the query parameter is not set.
 * @throws RestHandlerException If the query parameter is repeated.
 */
public static <X, P extends MessageQueryParameter<X>, R extends RequestBody, M extends MessageParameters> X getQueryParameter(
		final HandlerRequest<R, M> request,
		final Class<P> queryParameterClass) throws RestHandlerException {

	return getQueryParameter(request, queryParameterClass, null);
}
 
Example #19
Source File: JarMessageParameters.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Override
public Collection<MessageQueryParameter<?>> getQueryParameters() {
	return Collections.unmodifiableList(Arrays.asList(
		programArgsQueryParameter,
		programArgQueryParameter,
		entryClassQueryParameter,
		parallelismQueryParameter));
}
 
Example #20
Source File: RestAPIDocGenerator.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
private static String createQueryParameterHtmlList(Collection<MessageQueryParameter<?>> queryParameters) {
	StringBuilder queryParameterList = new StringBuilder();
	queryParameters.stream()
		.sorted((param1, param2) -> Boolean.compare(param1.isMandatory(), param2.isMandatory()))
		.forEach(parameter ->
			queryParameterList.append(
				String.format("<li><code>%s</code> (%s): %s</li>\n",
					parameter.getKey(),
					parameter.isMandatory() ? "mandatory" : "optional",
					parameter.getDescription())
			));
	return queryParameterList.toString();
}
 
Example #21
Source File: JarRunMessageParameters.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Override
public Collection<MessageQueryParameter<?>> getQueryParameters() {
	Collection<MessageQueryParameter<?>> pars = new ArrayList<>(Arrays.asList(
		allowNonRestoredStateQueryParameter,
		savepointPathQueryParameter));
	pars.addAll(super.getQueryParameters());
	return Collections.unmodifiableCollection(pars);
}
 
Example #22
Source File: SavepointTriggerMessageParameters.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public Collection<MessageQueryParameter<?>> getQueryParameters() {
	return Collections.emptyList();
}
 
Example #23
Source File: ClusterDataSetDeleteTriggerMessageParameters.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public Collection<MessageQueryParameter<?>> getQueryParameters() {
	return Collections.emptyList();
}
 
Example #24
Source File: TaskManagerMessageParameters.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public Collection<MessageQueryParameter<?>> getQueryParameters() {
	return Collections.emptySet();
}
 
Example #25
Source File: AbstractAsynchronousOperationHandlersTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public Collection<MessageQueryParameter<?>> getQueryParameters() {
	return Collections.emptyList();
}
 
Example #26
Source File: ClusterDataSetDeleteStatusMessageParameters.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public Collection<MessageQueryParameter<?>> getQueryParameters() {
	return Collections.emptyList();
}
 
Example #27
Source File: JarHandlerParameterTest.java    From flink with Apache License 2.0 4 votes vote down vote up
private static <X> List<String> getValuesAsString(MessageQueryParameter<X> parameter) {
	final List<X> values = parameter.getValue();
	return values.stream().map(parameter::convertValueToString).collect(Collectors.toList());
}
 
Example #28
Source File: JarDeleteMessageParameters.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public Collection<MessageQueryParameter<?>> getQueryParameters() {
	return Collections.emptyList();
}
 
Example #29
Source File: RestServerEndpointITCase.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public Collection<MessageQueryParameter<?>> getQueryParameters() {
	return Collections.singleton(jobIDQueryParameter);
}
 
Example #30
Source File: RestServerEndpointITCase.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public Collection<MessageQueryParameter<?>> getQueryParameters() {
	return Collections.singleton(jobIDQueryParameter);
}