org.apache.flink.runtime.rest.handler.HandlerRequestException Java Examples

The following examples show how to use org.apache.flink.runtime.rest.handler.HandlerRequestException. 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: JarHandlerParameterTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
private static <REQB extends JarRequestBody, M extends JarMessageParameters>
HandlerRequest<REQB, M> createRequest(
	REQB requestBody, M parameters, M unresolvedMessageParameters, Path jar)
	throws HandlerRequestException {

	final Map<String, List<String>> queryParameterAsMap = parameters.getQueryParameters().stream()
		.filter(MessageParameter::isResolved)
		.collect(Collectors.toMap(
			MessageParameter::getKey,
			JarHandlerParameterTest::getValuesAsString
		));

	return new HandlerRequest<>(
		requestBody,
		unresolvedMessageParameters,
		Collections.singletonMap(JarIdPathParameter.KEY, jar.getFileName().toString()),
		queryParameterAsMap,
		Collections.emptyList()
	);
}
 
Example #2
Source File: JarHandlerParameterTest.java    From flink with Apache License 2.0 6 votes vote down vote up
private static <REQB extends JarRequestBody, M extends JarMessageParameters>
HandlerRequest<REQB, M> createRequest(
	REQB requestBody, M parameters, M unresolvedMessageParameters, Path jar)
	throws HandlerRequestException {

	final Map<String, List<String>> queryParameterAsMap = parameters.getQueryParameters().stream()
		.filter(MessageParameter::isResolved)
		.collect(Collectors.toMap(
			MessageParameter::getKey,
			JarHandlerParameterTest::getValuesAsString
		));

	return new HandlerRequest<>(
		requestBody,
		unresolvedMessageParameters,
		Collections.singletonMap(JarIdPathParameter.KEY, jar.getFileName().toString()),
		queryParameterAsMap,
		Collections.emptyList()
	);
}
 
Example #3
Source File: JarHandlerParameterTest.java    From flink with Apache License 2.0 6 votes vote down vote up
private static <REQB extends JarRequestBody, M extends JarMessageParameters>
HandlerRequest<REQB, M> createRequest(
	REQB requestBody, M parameters, M unresolvedMessageParameters, Path jar)
	throws HandlerRequestException {

	final Map<String, List<String>> queryParameterAsMap = parameters.getQueryParameters().stream()
		.filter(MessageParameter::isResolved)
		.collect(Collectors.toMap(
			MessageParameter::getKey,
			JarHandlerParameterTest::getValuesAsString
		));

	return new HandlerRequest<>(
		requestBody,
		unresolvedMessageParameters,
		Collections.singletonMap(JarIdPathParameter.KEY, jar.getFileName().toString()),
		queryParameterAsMap,
		Collections.emptyList()
	);
}
 
Example #4
Source File: StopWithSavepointHandlersTest.java    From flink with Apache License 2.0 5 votes vote down vote up
private static HandlerRequest<EmptyRequestBody, SavepointStatusMessageParameters> savepointStatusRequest(
		final TriggerId triggerId) throws HandlerRequestException {
	final Map<String, String> pathParameters = new HashMap<>();
	pathParameters.put(JobIDPathParameter.KEY, JOB_ID.toString());
	pathParameters.put(TriggerIdPathParameter.KEY, triggerId.toString());

	return new HandlerRequest<>(
			EmptyRequestBody.getInstance(),
			new SavepointStatusMessageParameters(),
			pathParameters,
			Collections.emptyMap());
}
 
Example #5
Source File: AbstractAsynchronousOperationHandlersTest.java    From flink with Apache License 2.0 5 votes vote down vote up
private static HandlerRequest<EmptyRequestBody, TriggerMessageParameters> statusOperationRequest(TriggerId triggerId) throws HandlerRequestException {
	return new HandlerRequest<>(
		EmptyRequestBody.getInstance(),
		new TriggerMessageParameters(),
		Collections.singletonMap(TriggerIdPathParameter.KEY, triggerId.toString()),
		Collections.emptyMap());
}
 
Example #6
Source File: AbstractAsynchronousOperationHandlersTest.java    From flink with Apache License 2.0 5 votes vote down vote up
private static HandlerRequest<EmptyRequestBody, TriggerMessageParameters> statusOperationRequest(TriggerId triggerId) throws HandlerRequestException {
	return new HandlerRequest<>(
		EmptyRequestBody.getInstance(),
		new TriggerMessageParameters(),
		Collections.singletonMap(TriggerIdPathParameter.KEY, triggerId.toString()),
		Collections.emptyMap());
}
 
Example #7
Source File: JarDeleteHandlerTest.java    From flink with Apache License 2.0 5 votes vote down vote up
private static HandlerRequest<EmptyRequestBody, JarDeleteMessageParameters> createRequest(
		final String jarFileName) throws HandlerRequestException {
	return new HandlerRequest<>(
		EmptyRequestBody.getInstance(),
		new JarDeleteMessageParameters(),
		Collections.singletonMap(JarIdPathParameter.KEY, jarFileName),
		Collections.emptyMap());
}
 
Example #8
Source File: JarUploadHandlerTest.java    From flink with Apache License 2.0 5 votes vote down vote up
private static HandlerRequest<EmptyRequestBody, EmptyMessageParameters> createRequest(
		final Path uploadedFile) throws HandlerRequestException, IOException {
	return new HandlerRequest<>(
		EmptyRequestBody.getInstance(),
		EmptyMessageParameters.getInstance(),
		Collections.emptyMap(),
		Collections.emptyMap(),
		Collections.singleton(uploadedFile.toFile()));
}
 
Example #9
Source File: AbstractTaskManagerFileHandlerTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void setup() throws IOException, HandlerRequestException {
	final Configuration configuration = new Configuration();
	configuration.setString(BlobServerOptions.STORAGE_DIRECTORY, temporaryFolder.newFolder().getAbsolutePath());

	blobServer = new BlobServer(configuration, new VoidBlobStore());

	handlerRequest = new HandlerRequest<>(
		EmptyRequestBody.getInstance(),
		new TaskManagerFileMessageParameters(),
		Collections.singletonMap(TaskManagerIdPathParameter.KEY, EXPECTED_TASK_MANAGER_ID.getResourceIdString()),
		Collections.emptyMap());
}
 
Example #10
Source File: TaskManagerLogListHandlerTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws HandlerRequestException {
	resourceManagerGateway = new TestingResourceManagerGateway();
	taskManagerLogListHandler = new TaskManagerLogListHandler(
		() -> CompletableFuture.completedFuture(null),
		TestingUtils.TIMEOUT(),
		Collections.emptyMap(),
		TaskManagerLogsHeaders.getInstance(),
		() -> CompletableFuture.completedFuture(resourceManagerGateway));
	handlerRequest = createRequest(EXPECTED_TASK_MANAGER_ID);
}
 
Example #11
Source File: TaskManagerLogListHandlerTest.java    From flink with Apache License 2.0 5 votes vote down vote up
private static HandlerRequest<EmptyRequestBody, TaskManagerMessageParameters> createRequest(ResourceID taskManagerId) throws HandlerRequestException {
	Map<String, String> pathParameters = new HashMap<>();
	pathParameters.put(TaskManagerIdPathParameter.KEY, taskManagerId.toString());
	Map<String, List<String>> queryParameters = Collections.emptyMap();

	return new HandlerRequest<>(
		EmptyRequestBody.getInstance(),
		new TaskManagerMessageParameters(),
		pathParameters,
		queryParameters);
}
 
Example #12
Source File: JobExceptionsHandlerTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetJobExceptionsInfo() throws HandlerRequestException {
	final JobExceptionsHandler jobExceptionsHandler = new JobExceptionsHandler(
		() -> null,
		TestingUtils.TIMEOUT(),
		Collections.emptyMap(),
		JobExceptionsHeaders.getInstance(),
		new DefaultExecutionGraphCache(TestingUtils.TIMEOUT(), TestingUtils.TIMEOUT()),
		TestingUtils.defaultExecutor());
	final int numExceptions = 20;
	final AccessExecutionGraph archivedExecutionGraph = createAccessExecutionGraph(numExceptions);
	checkExceptionLimit(jobExceptionsHandler, archivedExecutionGraph, numExceptions, 10);
	checkExceptionLimit(jobExceptionsHandler, archivedExecutionGraph, numExceptions, numExceptions);
	checkExceptionLimit(jobExceptionsHandler, archivedExecutionGraph, numExceptions, 30);
}
 
Example #13
Source File: JobExceptionsHandlerTest.java    From flink with Apache License 2.0 5 votes vote down vote up
private static HandlerRequest<EmptyRequestBody, JobExceptionsMessageParameters> createRequest(JobID jobId, int size) throws HandlerRequestException {
	final Map<String, String> pathParameters = new HashMap<>();
	pathParameters.put(JobIDPathParameter.KEY, jobId.toString());
	final Map<String, List<String>> queryParameters = new HashMap<>();
	queryParameters.put(UpperLimitExceptionParameter.KEY, Collections.singletonList("" + size));

	return new HandlerRequest<>(
		EmptyRequestBody.getInstance(),
		new JobExceptionsMessageParameters(),
		pathParameters,
		queryParameters);
}
 
Example #14
Source File: SavepointHandlersTest.java    From flink with Apache License 2.0 5 votes vote down vote up
private static HandlerRequest<SavepointTriggerRequestBody, SavepointTriggerMessageParameters> triggerSavepointRequest(
		final String targetDirectory
) throws HandlerRequestException {
	return new HandlerRequest<>(
		new SavepointTriggerRequestBody(targetDirectory, false),
		new SavepointTriggerMessageParameters(),
		Collections.singletonMap(JobIDPathParameter.KEY, JOB_ID.toString()),
		Collections.emptyMap());
}
 
Example #15
Source File: SavepointHandlersTest.java    From flink with Apache License 2.0 5 votes vote down vote up
private static HandlerRequest<EmptyRequestBody, SavepointStatusMessageParameters> savepointStatusRequest(
		final TriggerId triggerId) throws HandlerRequestException {
		final Map<String, String> pathParameters = new HashMap<>();
	pathParameters.put(JobIDPathParameter.KEY, JOB_ID.toString());
	pathParameters.put(TriggerIdPathParameter.KEY, triggerId.toString());

	return new HandlerRequest<>(
		EmptyRequestBody.getInstance(),
		new SavepointStatusMessageParameters(),
		pathParameters,
		Collections.emptyMap());
}
 
Example #16
Source File: StopWithSavepointHandlersTest.java    From flink with Apache License 2.0 5 votes vote down vote up
private static HandlerRequest<StopWithSavepointRequestBody, SavepointTriggerMessageParameters> triggerSavepointRequest(
		final String targetDirectory
) throws HandlerRequestException {
	return new HandlerRequest<>(
			new StopWithSavepointRequestBody(targetDirectory, false),
			new SavepointTriggerMessageParameters(),
			Collections.singletonMap(JobIDPathParameter.KEY, JOB_ID.toString()),
			Collections.emptyMap());
}
 
Example #17
Source File: StopWithSavepointHandlersTest.java    From flink with Apache License 2.0 5 votes vote down vote up
private static HandlerRequest<EmptyRequestBody, SavepointStatusMessageParameters> savepointStatusRequest(
		final TriggerId triggerId) throws HandlerRequestException {
	final Map<String, String> pathParameters = new HashMap<>();
	pathParameters.put(JobIDPathParameter.KEY, JOB_ID.toString());
	pathParameters.put(TriggerIdPathParameter.KEY, triggerId.toString());

	return new HandlerRequest<>(
			EmptyRequestBody.getInstance(),
			new SavepointStatusMessageParameters(),
			pathParameters,
			Collections.emptyMap());
}
 
Example #18
Source File: JobConfigHandlerTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void handleRequest_executionConfigWithSecretValues_excludesSecretValuesFromResponse() throws HandlerRequestException {
	final JobConfigHandler jobConfigHandler = new JobConfigHandler(
		() -> null,
		TestingUtils.TIMEOUT(),
		Collections.emptyMap(),
		JobConfigHeaders.getInstance(),
		new DefaultExecutionGraphCache(TestingUtils.TIMEOUT(), TestingUtils.TIMEOUT()),
		TestingUtils.defaultExecutor());

	final Map<String, String> globalJobParameters = new HashMap<>();
	globalJobParameters.put("foobar", "barfoo");
	globalJobParameters.put("bar.secret.foo", "my secret");
	globalJobParameters.put("password.to.my.safe", "12345");

	final ArchivedExecutionConfig archivedExecutionConfig = new ArchivedExecutionConfigBuilder()
		.setGlobalJobParameters(globalJobParameters)
		.build();
	final AccessExecutionGraph archivedExecutionGraph = new ArchivedExecutionGraphBuilder()
		.setArchivedExecutionConfig(archivedExecutionConfig)
		.build();
	final HandlerRequest<EmptyRequestBody, JobMessageParameters> handlerRequest = createRequest(archivedExecutionGraph.getJobID());

	final JobConfigInfo jobConfigInfoResponse = jobConfigHandler.handleRequest(handlerRequest, archivedExecutionGraph);

	final Map<String, String> filteredGlobalJobParameters = filterSecretValues(globalJobParameters);

	assertThat(jobConfigInfoResponse.getExecutionConfigInfo().getGlobalJobParameters(), is(equalTo(filteredGlobalJobParameters)));
}
 
Example #19
Source File: JobConfigHandlerTest.java    From flink with Apache License 2.0 5 votes vote down vote up
private HandlerRequest<EmptyRequestBody, JobMessageParameters> createRequest(JobID jobId) throws HandlerRequestException {
	final Map<String, String> pathParameters = new HashMap<>();
	pathParameters.put(JobIDPathParameter.KEY, jobId.toString());

	return new HandlerRequest<>(
		EmptyRequestBody.getInstance(),
		new JobMessageParameters(),
		pathParameters,
		Collections.emptyMap());
}
 
Example #20
Source File: JobManagerLogListHandlerTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void setupClass() throws HandlerRequestException {
	testRequest = new HandlerRequest<>(
		EmptyRequestBody.getInstance(),
		EmptyMessageParameters.getInstance(),
		Collections.emptyMap(),
		Collections.emptyMap());
}
 
Example #21
Source File: JarDeleteHandlerTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
private static HandlerRequest<EmptyRequestBody, JarDeleteMessageParameters> createRequest(
		final String jarFileName) throws HandlerRequestException {
	return new HandlerRequest<>(
		EmptyRequestBody.getInstance(),
		new JarDeleteMessageParameters(),
		Collections.singletonMap(JarIdPathParameter.KEY, jarFileName),
		Collections.emptyMap());
}
 
Example #22
Source File: JarUploadHandlerTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
private static HandlerRequest<EmptyRequestBody, EmptyMessageParameters> createRequest(
		final Path uploadedFile) throws HandlerRequestException, IOException {
	return new HandlerRequest<>(
		EmptyRequestBody.getInstance(),
		EmptyMessageParameters.getInstance(),
		Collections.emptyMap(),
		Collections.emptyMap(),
		Collections.singleton(uploadedFile.toFile()));
}
 
Example #23
Source File: AbstractTaskManagerFileHandlerTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void setup() throws IOException, HandlerRequestException {
	final Configuration configuration = new Configuration();
	configuration.setString(BlobServerOptions.STORAGE_DIRECTORY, temporaryFolder.newFolder().getAbsolutePath());

	blobServer = new BlobServer(configuration, new VoidBlobStore());

	handlerRequest = new HandlerRequest<>(
		EmptyRequestBody.getInstance(),
		new TaskManagerMessageParameters(),
		Collections.singletonMap(TaskManagerIdPathParameter.KEY, EXPECTED_TASK_MANAGER_ID.getResourceIdString()),
		Collections.emptyMap());
}
 
Example #24
Source File: SavepointHandlersTest.java    From flink with Apache License 2.0 5 votes vote down vote up
private static HandlerRequest<EmptyRequestBody, SavepointStatusMessageParameters> savepointStatusRequest(
		final TriggerId triggerId) throws HandlerRequestException {
		final Map<String, String> pathParameters = new HashMap<>();
	pathParameters.put(JobIDPathParameter.KEY, JOB_ID.toString());
	pathParameters.put(TriggerIdPathParameter.KEY, triggerId.toString());

	return new HandlerRequest<>(
		EmptyRequestBody.getInstance(),
		new SavepointStatusMessageParameters(),
		pathParameters,
		Collections.emptyMap());
}
 
Example #25
Source File: SavepointHandlersTest.java    From flink with Apache License 2.0 5 votes vote down vote up
private static HandlerRequest<SavepointTriggerRequestBody, SavepointTriggerMessageParameters> triggerSavepointRequest(
		final String targetDirectory
) throws HandlerRequestException {
	return new HandlerRequest<>(
		new SavepointTriggerRequestBody(targetDirectory, false),
		new SavepointTriggerMessageParameters(),
		Collections.singletonMap(JobIDPathParameter.KEY, JOB_ID.toString()),
		Collections.emptyMap());
}
 
Example #26
Source File: AbstractTaskManagerFileHandlerTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void setup() throws IOException, HandlerRequestException {
	final Configuration configuration = new Configuration();
	configuration.setString(BlobServerOptions.STORAGE_DIRECTORY, temporaryFolder.newFolder().getAbsolutePath());

	blobServer = new BlobServer(configuration, new VoidBlobStore());

	handlerRequest = new HandlerRequest<>(
		EmptyRequestBody.getInstance(),
		new TaskManagerMessageParameters(),
		Collections.singletonMap(TaskManagerIdPathParameter.KEY, EXPECTED_TASK_MANAGER_ID.getResourceIdString()),
		Collections.emptyMap());
}
 
Example #27
Source File: JarUploadHandlerTest.java    From flink with Apache License 2.0 5 votes vote down vote up
private static HandlerRequest<EmptyRequestBody, EmptyMessageParameters> createRequest(
		final Path uploadedFile) throws HandlerRequestException, IOException {
	return new HandlerRequest<>(
		EmptyRequestBody.getInstance(),
		EmptyMessageParameters.getInstance(),
		Collections.emptyMap(),
		Collections.emptyMap(),
		Collections.singleton(uploadedFile.toFile()));
}
 
Example #28
Source File: SavepointHandlersTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
private static HandlerRequest<SavepointTriggerRequestBody, SavepointTriggerMessageParameters> triggerSavepointRequest(
		final String targetDirectory
) throws HandlerRequestException {
	return new HandlerRequest<>(
		new SavepointTriggerRequestBody(targetDirectory, false),
		new SavepointTriggerMessageParameters(),
		Collections.singletonMap(JobIDPathParameter.KEY, JOB_ID.toString()),
		Collections.emptyMap());
}
 
Example #29
Source File: JarDeleteHandlerTest.java    From flink with Apache License 2.0 5 votes vote down vote up
private static HandlerRequest<EmptyRequestBody, JarDeleteMessageParameters> createRequest(
		final String jarFileName) throws HandlerRequestException {
	return new HandlerRequest<>(
		EmptyRequestBody.getInstance(),
		new JarDeleteMessageParameters(),
		Collections.singletonMap(JarIdPathParameter.KEY, jarFileName),
		Collections.emptyMap());
}
 
Example #30
Source File: StopWithSavepointHandlersTest.java    From flink with Apache License 2.0 5 votes vote down vote up
private static HandlerRequest<StopWithSavepointRequestBody, SavepointTriggerMessageParameters> triggerSavepointRequest(
		final String targetDirectory
) throws HandlerRequestException {
	return new HandlerRequest<>(
			new StopWithSavepointRequestBody(targetDirectory, false),
			new SavepointTriggerMessageParameters(),
			Collections.singletonMap(JobIDPathParameter.KEY, JOB_ID.toString()),
			Collections.emptyMap());
}