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

The following examples show how to use org.apache.flink.runtime.rest.messages.JobPlanInfo. 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: JarPlanHandler.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
public JarPlanHandler(
		final GatewayRetriever<? extends RestfulGateway> leaderRetriever,
		final Time timeout,
		final Map<String, String> responseHeaders,
		final MessageHeaders<JarPlanRequestBody, JobPlanInfo, JarPlanMessageParameters> messageHeaders,
		final Path jarDir,
		final Configuration configuration,
		final Executor executor) {
	this(
		leaderRetriever,
		timeout,
		responseHeaders,
		messageHeaders,
		jarDir,
		configuration,
		executor,
		jobGraph -> new JobPlanInfo(JsonPlanGenerator.generatePlan(jobGraph)));
}
 
Example #2
Source File: JobPlanHandler.java    From flink with Apache License 2.0 6 votes vote down vote up
public JobPlanHandler(
	GatewayRetriever<? extends RestfulGateway> leaderRetriever,
	Time timeout,
	Map<String, String> headers,
	MessageHeaders<EmptyRequestBody, JobPlanInfo, JobMessageParameters> messageHeaders,
	ExecutionGraphCache executionGraphCache,
	Executor executor) {

	super(
		leaderRetriever,
		timeout,
		headers,
		messageHeaders,
		executionGraphCache,
		executor);
}
 
Example #3
Source File: JarPlanHandlerParameterTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@BeforeClass
public static void setup() throws Exception {
	init();
	handler = new JarPlanHandler(
		gatewayRetriever,
		timeout,
		responseHeaders,
		JarPlanHeaders.getInstance(),
		jarDir,
		new Configuration(),
		executor,
		jobGraph -> {
			LAST_SUBMITTED_JOB_GRAPH_REFERENCE.set(jobGraph);
			return new JobPlanInfo(JsonPlanGenerator.generatePlan(jobGraph));
		});
}
 
Example #4
Source File: JarPlanHandlerParameterTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@BeforeClass
public static void setup() throws Exception {
	init();
	handler = new JarPlanHandler(
		gatewayRetriever,
		timeout,
		responseHeaders,
		JarPlanGetHeaders.getInstance(),
		jarDir,
		new Configuration(),
		executor,
		jobGraph -> {
			LAST_SUBMITTED_JOB_GRAPH_REFERENCE.set(jobGraph);
			return new JobPlanInfo(JsonPlanGenerator.generatePlan(jobGraph));
		});
}
 
Example #5
Source File: JobPlanHandler.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
public JobPlanHandler(
	GatewayRetriever<? extends RestfulGateway> leaderRetriever,
	Time timeout,
	Map<String, String> headers,
	MessageHeaders<EmptyRequestBody, JobPlanInfo, JobMessageParameters> messageHeaders,
	ExecutionGraphCache executionGraphCache,
	Executor executor) {

	super(
		leaderRetriever,
		timeout,
		headers,
		messageHeaders,
		executionGraphCache,
		executor);
}
 
Example #6
Source File: JarPlanHandler.java    From flink with Apache License 2.0 6 votes vote down vote up
public JarPlanHandler(
		final GatewayRetriever<? extends RestfulGateway> leaderRetriever,
		final Time timeout,
		final Map<String, String> responseHeaders,
		final MessageHeaders<JarPlanRequestBody, JobPlanInfo, JarPlanMessageParameters> messageHeaders,
		final Path jarDir,
		final Configuration configuration,
		final Executor executor) {
	this(
		leaderRetriever,
		timeout,
		responseHeaders,
		messageHeaders,
		jarDir,
		configuration,
		executor,
		jobGraph -> new JobPlanInfo(JsonPlanGenerator.generatePlan(jobGraph)));
}
 
Example #7
Source File: JarPlanHandler.java    From flink with Apache License 2.0 6 votes vote down vote up
public JarPlanHandler(
		final GatewayRetriever<? extends RestfulGateway> leaderRetriever,
		final Time timeout,
		final Map<String, String> responseHeaders,
		final MessageHeaders<JarPlanRequestBody, JobPlanInfo, JarPlanMessageParameters> messageHeaders,
		final Path jarDir,
		final Configuration configuration,
		final Executor executor) {
	this(
		leaderRetriever,
		timeout,
		responseHeaders,
		messageHeaders,
		jarDir,
		configuration,
		executor,
		jobGraph -> new JobPlanInfo(JsonPlanGenerator.generatePlan(jobGraph)));
}
 
Example #8
Source File: JobPlanHandler.java    From flink with Apache License 2.0 6 votes vote down vote up
public JobPlanHandler(
	GatewayRetriever<? extends RestfulGateway> leaderRetriever,
	Time timeout,
	Map<String, String> headers,
	MessageHeaders<EmptyRequestBody, JobPlanInfo, JobMessageParameters> messageHeaders,
	ExecutionGraphCache executionGraphCache,
	Executor executor) {

	super(
		leaderRetriever,
		timeout,
		headers,
		messageHeaders,
		executionGraphCache,
		executor);
}
 
Example #9
Source File: JarPlanHandlerParameterTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@BeforeClass
public static void setup() throws Exception {
	init();
	handler = new JarPlanHandler(
		gatewayRetriever,
		timeout,
		responseHeaders,
		JarPlanGetHeaders.getInstance(),
		jarDir,
		new Configuration(),
		executor,
		jobGraph -> {
			LAST_SUBMITTED_JOB_GRAPH_REFERENCE.set(jobGraph);
			return new JobPlanInfo(JsonPlanGenerator.generatePlan(jobGraph));
		});
}
 
Example #10
Source File: JarSubmissionITCase.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testJarSubmission() throws Exception {
	final TestingDispatcherGateway restfulGateway = new TestingDispatcherGateway.Builder()
		.setBlobServerPort(blobServerResource.getBlobServerPort())
		.setSubmitFunction(jobGraph -> CompletableFuture.completedFuture(Acknowledge.get()))
		.build();
	final JarHandlers handlers = new JarHandlers(temporaryFolder.newFolder().toPath(), restfulGateway);
	final JarUploadHandler uploadHandler = handlers.uploadHandler;
	final JarListHandler listHandler = handlers.listHandler;
	final JarPlanHandler planHandler = handlers.planHandler;
	final JarRunHandler runHandler = handlers.runHandler;
	final JarDeleteHandler deleteHandler = handlers.deleteHandler;

	// targetDir property is set via surefire configuration
	final Path originalJar = Paths.get(System.getProperty("targetDir")).resolve("test-program.jar");
	final Path jar = Files.copy(originalJar, temporaryFolder.getRoot().toPath().resolve("test-program.jar"));

	final String storedJarPath = uploadJar(uploadHandler, jar, restfulGateway);
	final String storedJarName = Paths.get(storedJarPath).getFileName().toString();

	final JarListInfo postUploadListResponse = listJars(listHandler, restfulGateway);
	Assert.assertEquals(1, postUploadListResponse.jarFileList.size());
	final JarListInfo.JarFileInfo listEntry = postUploadListResponse.jarFileList.iterator().next();
	Assert.assertEquals(jar.getFileName().toString(), listEntry.name);
	Assert.assertEquals(storedJarName, listEntry.id);

	final JobPlanInfo planResponse = showPlan(planHandler, storedJarName, restfulGateway);
	// we're only interested in the core functionality so checking for a small detail is sufficient
	Assert.assertThat(planResponse.getJsonPlan(), containsString("TestProgram.java:29"));

	runJar(runHandler, storedJarName, restfulGateway);

	deleteJar(deleteHandler, storedJarName, restfulGateway);

	final JarListInfo postDeleteListResponse = listJars(listHandler, restfulGateway);
	Assert.assertEquals(0, postDeleteListResponse.jarFileList.size());
}
 
Example #11
Source File: JarHandlers.java    From flink with Apache License 2.0 5 votes vote down vote up
public static JobPlanInfo showPlan(JarPlanHandler handler, String jarName, RestfulGateway restfulGateway) throws Exception {
	JarPlanMessageParameters planParameters = JarPlanGetHeaders.getInstance().getUnresolvedMessageParameters();
	HandlerRequest<JarPlanRequestBody, JarPlanMessageParameters> planRequest = new HandlerRequest<>(
		new JarPlanRequestBody(),
		planParameters,
		Collections.singletonMap(planParameters.jarIdPathParameter.getKey(), jarName),
		Collections.emptyMap(),
		Collections.emptyList());
	return handler.handleRequest(planRequest, restfulGateway)
		.get();
}
 
Example #12
Source File: JarSubmissionITCase.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testJarSubmission() throws Exception {
	final TestingDispatcherGateway restfulGateway = new TestingDispatcherGateway.Builder()
		.setBlobServerPort(blobServerResource.getBlobServerPort())
		.setSubmitFunction(jobGraph -> CompletableFuture.completedFuture(Acknowledge.get()))
		.build();
	final JarHandlers handlers = new JarHandlers(temporaryFolder.newFolder().toPath(), restfulGateway);
	final JarUploadHandler uploadHandler = handlers.uploadHandler;
	final JarListHandler listHandler = handlers.listHandler;
	final JarPlanHandler planHandler = handlers.planHandler;
	final JarRunHandler runHandler = handlers.runHandler;
	final JarDeleteHandler deleteHandler = handlers.deleteHandler;

	// targetDir property is set via surefire configuration
	final Path originalJar = Paths.get(System.getProperty("targetDir")).resolve("test-program.jar");
	final Path jar = Files.copy(originalJar, temporaryFolder.getRoot().toPath().resolve("test-program.jar"));

	final String storedJarPath = uploadJar(uploadHandler, jar, restfulGateway);
	final String storedJarName = Paths.get(storedJarPath).getFileName().toString();

	final JarListInfo postUploadListResponse = listJars(listHandler, restfulGateway);
	Assert.assertEquals(1, postUploadListResponse.jarFileList.size());
	final JarListInfo.JarFileInfo listEntry = postUploadListResponse.jarFileList.iterator().next();
	Assert.assertEquals(jar.getFileName().toString(), listEntry.name);
	Assert.assertEquals(storedJarName, listEntry.id);

	final JobPlanInfo planResponse = showPlan(planHandler, storedJarName, restfulGateway);
	// we're only interested in the core functionality so checking for a small detail is sufficient
	Assert.assertThat(planResponse.getJsonPlan(), containsString("TestProgram.java:30"));

	runJar(runHandler, storedJarName, restfulGateway);

	deleteJar(deleteHandler, storedJarName, restfulGateway);

	final JarListInfo postDeleteListResponse = listJars(listHandler, restfulGateway);
	Assert.assertEquals(0, postDeleteListResponse.jarFileList.size());
}
 
Example #13
Source File: JarPlanHandler.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
protected CompletableFuture<JobPlanInfo> handleRequest(
		@Nonnull final HandlerRequest<JarPlanRequestBody, JarPlanMessageParameters> request,
		@Nonnull final RestfulGateway gateway) throws RestHandlerException {
	final JarHandlerContext context = JarHandlerContext.fromRequest(request, jarDir, log);

	return CompletableFuture.supplyAsync(() -> {
		final JobGraph jobGraph = context.toJobGraph(configuration, true);
		return planGenerator.apply(jobGraph);
	}, executor);
}
 
Example #14
Source File: JarPlanHandler.java    From flink with Apache License 2.0 5 votes vote down vote up
public JarPlanHandler(
		final GatewayRetriever<? extends RestfulGateway> leaderRetriever,
		final Time timeout,
		final Map<String, String> responseHeaders,
		final MessageHeaders<JarPlanRequestBody, JobPlanInfo, JarPlanMessageParameters> messageHeaders,
		final Path jarDir,
		final Configuration configuration,
		final Executor executor,
		final Function<JobGraph, JobPlanInfo> planGenerator) {
	super(leaderRetriever, timeout, responseHeaders, messageHeaders);
	this.jarDir = requireNonNull(jarDir);
	this.configuration = requireNonNull(configuration);
	this.executor = requireNonNull(executor);
	this.planGenerator = planGenerator;
}
 
Example #15
Source File: JarSubmissionITCase.java    From flink with Apache License 2.0 5 votes vote down vote up
private static JobPlanInfo showPlan(JarPlanHandler handler, String jarName, RestfulGateway restfulGateway) throws Exception {
	JarPlanMessageParameters planParameters = JarPlanGetHeaders.getInstance().getUnresolvedMessageParameters();
	HandlerRequest<JarPlanRequestBody, JarPlanMessageParameters> planRequest = new HandlerRequest<>(
		new JarPlanRequestBody(),
		planParameters,
		Collections.singletonMap(planParameters.jarIdPathParameter.getKey(), jarName),
		Collections.emptyMap(),
		Collections.emptyList());
	return handler.handleRequest(planRequest, restfulGateway)
		.get();
}
 
Example #16
Source File: JarPlanHandler.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
protected CompletableFuture<JobPlanInfo> handleRequest(
		@Nonnull final HandlerRequest<JarPlanRequestBody, JarPlanMessageParameters> request,
		@Nonnull final RestfulGateway gateway) throws RestHandlerException {
	final JarHandlerContext context = JarHandlerContext.fromRequest(request, jarDir, log);

	return CompletableFuture.supplyAsync(() -> {
		final JobGraph jobGraph = context.toJobGraph(configuration);
		return planGenerator.apply(jobGraph);
	}, executor);
}
 
Example #17
Source File: JarPlanHandler.java    From flink with Apache License 2.0 5 votes vote down vote up
public JarPlanHandler(
		final GatewayRetriever<? extends RestfulGateway> leaderRetriever,
		final Time timeout,
		final Map<String, String> responseHeaders,
		final MessageHeaders<JarPlanRequestBody, JobPlanInfo, JarPlanMessageParameters> messageHeaders,
		final Path jarDir,
		final Configuration configuration,
		final Executor executor,
		final Function<JobGraph, JobPlanInfo> planGenerator) {
	super(leaderRetriever, timeout, responseHeaders, messageHeaders);
	this.jarDir = requireNonNull(jarDir);
	this.configuration = requireNonNull(configuration);
	this.executor = requireNonNull(executor);
	this.planGenerator = planGenerator;
}
 
Example #18
Source File: JarSubmissionITCase.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
private static JobPlanInfo showPlan(JarPlanHandler handler, String jarName, RestfulGateway restfulGateway) throws Exception {
	JarPlanMessageParameters planParameters = JarPlanHeaders.getInstance().getUnresolvedMessageParameters();
	HandlerRequest<JarPlanRequestBody, JarPlanMessageParameters> planRequest = new HandlerRequest<>(
		new JarPlanRequestBody(),
		planParameters,
		Collections.singletonMap(planParameters.jarIdPathParameter.getKey(), jarName),
		Collections.emptyMap(),
		Collections.emptyList());
	return handler.handleRequest(planRequest, restfulGateway)
		.get();
}
 
Example #19
Source File: JarSubmissionITCase.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Test
public void testJarSubmission() throws Exception {
	final TestingDispatcherGateway restfulGateway = new TestingDispatcherGateway.Builder()
		.setBlobServerPort(blobServerResource.getBlobServerPort())
		.setSubmitFunction(jobGraph -> CompletableFuture.completedFuture(Acknowledge.get()))
		.build();
	final JarHandlers handlers = new JarHandlers(temporaryFolder.newFolder().toPath(), restfulGateway);
	final JarUploadHandler uploadHandler = handlers.uploadHandler;
	final JarListHandler listHandler = handlers.listHandler;
	final JarPlanHandler planHandler = handlers.planHandler;
	final JarRunHandler runHandler = handlers.runHandler;
	final JarDeleteHandler deleteHandler = handlers.deleteHandler;

	// targetDir property is set via surefire configuration
	final Path originalJar = Paths.get(System.getProperty("targetDir")).resolve("test-program.jar");
	final Path jar = Files.copy(originalJar, temporaryFolder.getRoot().toPath().resolve("test-program.jar"));

	final String storedJarPath = uploadJar(uploadHandler, jar, restfulGateway);
	final String storedJarName = Paths.get(storedJarPath).getFileName().toString();

	final JarListInfo postUploadListResponse = listJars(listHandler, restfulGateway);
	Assert.assertEquals(1, postUploadListResponse.jarFileList.size());
	final JarListInfo.JarFileInfo listEntry = postUploadListResponse.jarFileList.iterator().next();
	Assert.assertEquals(jar.getFileName().toString(), listEntry.name);
	Assert.assertEquals(storedJarName, listEntry.id);

	final JobPlanInfo planResponse = showPlan(planHandler, storedJarName, restfulGateway);
	// we're only interested in the core functionality so checking for a small detail is sufficient
	Assert.assertThat(planResponse.getJsonPlan(), containsString("TestProgram.java:29"));

	runJar(runHandler, storedJarName, restfulGateway);

	deleteJar(deleteHandler, storedJarName, restfulGateway);

	final JarListInfo postDeleteListResponse = listJars(listHandler, restfulGateway);
	Assert.assertEquals(0, postDeleteListResponse.jarFileList.size());
}
 
Example #20
Source File: JarPlanHandler.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Override
protected CompletableFuture<JobPlanInfo> handleRequest(
		@Nonnull final HandlerRequest<JarPlanRequestBody, JarPlanMessageParameters> request,
		@Nonnull final RestfulGateway gateway) throws RestHandlerException {
	final JarHandlerContext context = JarHandlerContext.fromRequest(request, jarDir, log);

	return CompletableFuture.supplyAsync(() -> {
		final JobGraph jobGraph = context.toJobGraph(configuration);
		return planGenerator.apply(jobGraph);
	}, executor);
}
 
Example #21
Source File: JarPlanHandler.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
public JarPlanHandler(
		final GatewayRetriever<? extends RestfulGateway> leaderRetriever,
		final Time timeout,
		final Map<String, String> responseHeaders,
		final MessageHeaders<JarPlanRequestBody, JobPlanInfo, JarPlanMessageParameters> messageHeaders,
		final Path jarDir,
		final Configuration configuration,
		final Executor executor,
		final Function<JobGraph, JobPlanInfo> planGenerator) {
	super(leaderRetriever, timeout, responseHeaders, messageHeaders);
	this.jarDir = requireNonNull(jarDir);
	this.configuration = requireNonNull(configuration);
	this.executor = requireNonNull(executor);
	this.planGenerator = planGenerator;
}
 
Example #22
Source File: JarPlanHeaders.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Override
public Class<JobPlanInfo> getResponseClass() {
	return JobPlanInfo.class;
}
 
Example #23
Source File: JobPlanHandler.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
protected JobPlanInfo handleRequest(HandlerRequest<EmptyRequestBody, JobMessageParameters> request, AccessExecutionGraph executionGraph) throws RestHandlerException {
	return createJobPlanInfo(executionGraph);
}
 
Example #24
Source File: JobPlanHandler.java    From flink with Apache License 2.0 4 votes vote down vote up
private static JobPlanInfo createJobPlanInfo(AccessExecutionGraph executionGraph) {
	return new JobPlanInfo(executionGraph.getJsonPlan());
}
 
Example #25
Source File: AbstractJarPlanHeaders.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public Class<JobPlanInfo> getResponseClass() {
	return JobPlanInfo.class;
}
 
Example #26
Source File: AbstractJarPlanHeaders.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public Class<JobPlanInfo> getResponseClass() {
	return JobPlanInfo.class;
}
 
Example #27
Source File: JobPlanHandler.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
private static JobPlanInfo createJobPlanInfo(AccessExecutionGraph executionGraph) {
	return new JobPlanInfo(executionGraph.getJsonPlan());
}
 
Example #28
Source File: JobPlanHandler.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Override
protected JobPlanInfo handleRequest(HandlerRequest<EmptyRequestBody, JobMessageParameters> request, AccessExecutionGraph executionGraph) throws RestHandlerException {
	return createJobPlanInfo(executionGraph);
}
 
Example #29
Source File: JobPlanHandler.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
protected JobPlanInfo handleRequest(HandlerRequest<EmptyRequestBody, JobMessageParameters> request, AccessExecutionGraph executionGraph) throws RestHandlerException {
	return createJobPlanInfo(executionGraph);
}
 
Example #30
Source File: JobPlanHandler.java    From flink with Apache License 2.0 4 votes vote down vote up
private static JobPlanInfo createJobPlanInfo(AccessExecutionGraph executionGraph) {
	return new JobPlanInfo(executionGraph.getJsonPlan());
}