org.apache.flink.runtime.messages.FlinkJobNotFoundException Java Examples

The following examples show how to use org.apache.flink.runtime.messages.FlinkJobNotFoundException. 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: Dispatcher.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public CompletableFuture<JobResult> requestJobResult(JobID jobId, Time timeout) {
	final CompletableFuture<JobManagerRunner> jobManagerRunnerFuture = jobManagerRunnerFutures.get(jobId);

	if (jobManagerRunnerFuture == null) {
		final ArchivedExecutionGraph archivedExecutionGraph = archivedExecutionGraphStore.get(jobId);

		if (archivedExecutionGraph == null) {
			return FutureUtils.completedExceptionally(new FlinkJobNotFoundException(jobId));
		} else {
			return CompletableFuture.completedFuture(JobResult.createFrom(archivedExecutionGraph));
		}
	} else {
		return jobManagerRunnerFuture.thenCompose(JobManagerRunner::getResultFuture).thenApply(JobResult::createFrom);
	}
}
 
Example #2
Source File: Dispatcher.java    From flink with Apache License 2.0 6 votes vote down vote up
@Nonnull
private Collection<JobGraph> recoverJobGraphs(Collection<JobID> jobIds) throws Exception {
	final List<JobGraph> jobGraphs = new ArrayList<>(jobIds.size());

	for (JobID jobId : jobIds) {
		final JobGraph jobGraph = recoverJob(jobId);

		if (jobGraph == null) {
			throw new FlinkJobNotFoundException(jobId);
		}

		jobGraphs.add(jobGraph);
	}

	return jobGraphs;
}
 
Example #3
Source File: Dispatcher.java    From flink with Apache License 2.0 6 votes vote down vote up
private CompletableFuture<JobMasterGateway> getJobMasterGatewayFuture(JobID jobId) {
	final CompletableFuture<JobManagerRunner> jobManagerRunnerFuture = jobManagerRunnerFutures.get(jobId);

	if (jobManagerRunnerFuture == null) {
		return FutureUtils.completedExceptionally(new FlinkJobNotFoundException(jobId));
	} else {
		final CompletableFuture<JobMasterGateway> leaderGatewayFuture = jobManagerRunnerFuture.thenCompose(JobManagerRunner::getLeaderGatewayFuture);
		return leaderGatewayFuture.thenApplyAsync(
			(JobMasterGateway jobMasterGateway) -> {
				// check whether the retrieved JobMasterGateway belongs still to a running JobMaster
				if (jobManagerRunnerFutures.containsKey(jobId)) {
					return jobMasterGateway;
				} else {
					throw new CompletionException(new FlinkJobNotFoundException(jobId));
				}
			},
			getMainThreadExecutor());
	}
}
 
Example #4
Source File: JobMaster.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public CompletableFuture<Acknowledge> notifyKvStateRegistered(
		final JobID jobId,
		final JobVertexID jobVertexId,
		final KeyGroupRange keyGroupRange,
		final String registrationName,
		final KvStateID kvStateId,
		final InetSocketAddress kvStateServerAddress) {

	try {
		schedulerNG.notifyKvStateRegistered(jobId, jobVertexId, keyGroupRange, registrationName, kvStateId, kvStateServerAddress);
		return CompletableFuture.completedFuture(Acknowledge.get());
	} catch (FlinkJobNotFoundException e) {
		log.info("Error while receiving notification about key-value state registration", e);
		return FutureUtils.completedExceptionally(e);
	}
}
 
Example #5
Source File: AbstractExecutionGraphHandler.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
protected CompletableFuture<R> handleRequest(@Nonnull HandlerRequest<EmptyRequestBody, M> request, @Nonnull RestfulGateway gateway) throws RestHandlerException {
	JobID jobId = request.getPathParameter(JobIDPathParameter.class);

	CompletableFuture<AccessExecutionGraph> executionGraphFuture = executionGraphCache.getExecutionGraph(jobId, gateway);

	return executionGraphFuture.thenApplyAsync(
		executionGraph -> {
			try {
				return handleRequest(request, executionGraph);
			} catch (RestHandlerException rhe) {
				throw new CompletionException(rhe);
			}
		}, executor)
		.exceptionally(throwable -> {
			throwable = ExceptionUtils.stripCompletionException(throwable);
			if (throwable instanceof FlinkJobNotFoundException) {
				throw new CompletionException(
					new NotFoundException(String.format("Job %s not found", jobId), throwable));
			} else {
				throw new CompletionException(throwable);
			}
		});
}
 
Example #6
Source File: LegacyScheduler.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public KvStateLocation requestKvStateLocation(final JobID jobId, final String registrationName) throws UnknownKvStateLocation, FlinkJobNotFoundException {
	mainThreadExecutor.assertRunningInMainThread();

	// sanity check for the correct JobID
	if (jobGraph.getJobID().equals(jobId)) {
		if (log.isDebugEnabled()) {
			log.debug("Lookup key-value state for job {} with registration " +
				"name {}.", jobGraph.getJobID(), registrationName);
		}

		final KvStateLocationRegistry registry = executionGraph.getKvStateLocationRegistry();
		final KvStateLocation location = registry.getKvStateLocation(registrationName);
		if (location != null) {
			return location;
		} else {
			throw new UnknownKvStateLocation(registrationName);
		}
	} else {
		if (log.isDebugEnabled()) {
			log.debug("Request of key-value state location for unknown job {} received.", jobId);
		}
		throw new FlinkJobNotFoundException(jobId);
	}
}
 
Example #7
Source File: LegacyScheduler.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public void notifyKvStateRegistered(final JobID jobId, final JobVertexID jobVertexId, final KeyGroupRange keyGroupRange, final String registrationName, final KvStateID kvStateId, final InetSocketAddress kvStateServerAddress) throws FlinkJobNotFoundException {
	mainThreadExecutor.assertRunningInMainThread();

	if (jobGraph.getJobID().equals(jobId)) {
		if (log.isDebugEnabled()) {
			log.debug("Key value state registered for job {} under name {}.",
				jobGraph.getJobID(), registrationName);
		}

		try {
			executionGraph.getKvStateLocationRegistry().notifyKvStateRegistered(
				jobVertexId, keyGroupRange, registrationName, kvStateId, kvStateServerAddress);
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
	} else {
		throw new FlinkJobNotFoundException(jobId);
	}
}
 
Example #8
Source File: LegacyScheduler.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public void notifyKvStateUnregistered(final JobID jobId, final JobVertexID jobVertexId, final KeyGroupRange keyGroupRange, final String registrationName) throws FlinkJobNotFoundException {
	mainThreadExecutor.assertRunningInMainThread();

	if (jobGraph.getJobID().equals(jobId)) {
		if (log.isDebugEnabled()) {
			log.debug("Key value state unregistered for job {} under name {}.",
				jobGraph.getJobID(), registrationName);
		}

		try {
			executionGraph.getKvStateLocationRegistry().notifyKvStateUnregistered(
				jobVertexId, keyGroupRange, registrationName);
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
	} else {
		throw new FlinkJobNotFoundException(jobId);
	}
}
 
Example #9
Source File: JobExecutionResultHandlerTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testPropagateFlinkJobNotFoundExceptionAsRestHandlerException() throws Exception {
	final TestingRestfulGateway testingRestfulGateway = TestingRestfulGateway.newBuilder()
		.setRequestJobStatusFunction(
			jobId -> FutureUtils.completedExceptionally(new FlinkJobNotFoundException(jobId))
		)
		.build();

	try {
		jobExecutionResultHandler.handleRequest(
			testRequest,
			testingRestfulGateway).get();
		fail("Expected exception not thrown");
	} catch (final ExecutionException e) {
		final Throwable cause = ExceptionUtils.stripCompletionException(e.getCause());
		assertThat(cause, instanceOf(RestHandlerException.class));
		assertThat(
			((RestHandlerException) cause).getHttpResponseStatus(),
			equalTo(HttpResponseStatus.NOT_FOUND));
	}
}
 
Example #10
Source File: Dispatcher.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Override
public CompletableFuture<JobResult> requestJobResult(JobID jobId, Time timeout) {
	final CompletableFuture<JobManagerRunner> jobManagerRunnerFuture = jobManagerRunnerFutures.get(jobId);

	if (jobManagerRunnerFuture == null) {
		final ArchivedExecutionGraph archivedExecutionGraph = archivedExecutionGraphStore.get(jobId);

		if (archivedExecutionGraph == null) {
			return FutureUtils.completedExceptionally(new FlinkJobNotFoundException(jobId));
		} else {
			return CompletableFuture.completedFuture(JobResult.createFrom(archivedExecutionGraph));
		}
	} else {
		return jobManagerRunnerFuture.thenCompose(JobManagerRunner::getResultFuture).thenApply(JobResult::createFrom);
	}
}
 
Example #11
Source File: Dispatcher.java    From flink with Apache License 2.0 6 votes vote down vote up
private CompletableFuture<JobMasterGateway> getJobMasterGatewayFuture(JobID jobId) {
	final CompletableFuture<JobManagerRunner> jobManagerRunnerFuture = jobManagerRunnerFutures.get(jobId);

	if (jobManagerRunnerFuture == null) {
		return FutureUtils.completedExceptionally(new FlinkJobNotFoundException(jobId));
	} else {
		final CompletableFuture<JobMasterGateway> leaderGatewayFuture = jobManagerRunnerFuture.thenCompose(JobManagerRunner::getJobMasterGateway);
		return leaderGatewayFuture.thenApplyAsync(
			(JobMasterGateway jobMasterGateway) -> {
				// check whether the retrieved JobMasterGateway belongs still to a running JobMaster
				if (jobManagerRunnerFutures.containsKey(jobId)) {
					return jobMasterGateway;
				} else {
					throw new CompletionException(new FlinkJobNotFoundException(jobId));
				}
			},
			getMainThreadExecutor());
	}
}
 
Example #12
Source File: JobMaster.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public CompletableFuture<Acknowledge> notifyKvStateRegistered(
		final JobID jobId,
		final JobVertexID jobVertexId,
		final KeyGroupRange keyGroupRange,
		final String registrationName,
		final KvStateID kvStateId,
		final InetSocketAddress kvStateServerAddress) {

	try {
		schedulerNG.notifyKvStateRegistered(jobId, jobVertexId, keyGroupRange, registrationName, kvStateId, kvStateServerAddress);
		return CompletableFuture.completedFuture(Acknowledge.get());
	} catch (FlinkJobNotFoundException e) {
		log.info("Error while receiving notification about key-value state registration", e);
		return FutureUtils.completedExceptionally(e);
	}
}
 
Example #13
Source File: AbstractExecutionGraphHandler.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
protected CompletableFuture<R> handleRequest(@Nonnull HandlerRequest<EmptyRequestBody, M> request, @Nonnull RestfulGateway gateway) throws RestHandlerException {
	JobID jobId = request.getPathParameter(JobIDPathParameter.class);

	CompletableFuture<AccessExecutionGraph> executionGraphFuture = executionGraphCache.getExecutionGraph(jobId, gateway);

	return executionGraphFuture.thenApplyAsync(
		executionGraph -> {
			try {
				return handleRequest(request, executionGraph);
			} catch (RestHandlerException rhe) {
				throw new CompletionException(rhe);
			}
		}, executor)
		.exceptionally(throwable -> {
			throwable = ExceptionUtils.stripCompletionException(throwable);
			if (throwable instanceof FlinkJobNotFoundException) {
				throw new CompletionException(
					new NotFoundException(String.format("Job %s not found", jobId), throwable));
			} else {
				throw new CompletionException(throwable);
			}
		});
}
 
Example #14
Source File: SchedulerBase.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public KvStateLocation requestKvStateLocation(final JobID jobId, final String registrationName) throws UnknownKvStateLocation, FlinkJobNotFoundException {
	mainThreadExecutor.assertRunningInMainThread();

	// sanity check for the correct JobID
	if (jobGraph.getJobID().equals(jobId)) {
		if (log.isDebugEnabled()) {
			log.debug("Lookup key-value state for job {} with registration " +
				"name {}.", jobGraph.getJobID(), registrationName);
		}

		final KvStateLocationRegistry registry = executionGraph.getKvStateLocationRegistry();
		final KvStateLocation location = registry.getKvStateLocation(registrationName);
		if (location != null) {
			return location;
		} else {
			throw new UnknownKvStateLocation(registrationName);
		}
	} else {
		if (log.isDebugEnabled()) {
			log.debug("Request of key-value state location for unknown job {} received.", jobId);
		}
		throw new FlinkJobNotFoundException(jobId);
	}
}
 
Example #15
Source File: SchedulerBase.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public void notifyKvStateRegistered(final JobID jobId, final JobVertexID jobVertexId, final KeyGroupRange keyGroupRange, final String registrationName, final KvStateID kvStateId, final InetSocketAddress kvStateServerAddress) throws FlinkJobNotFoundException {
	mainThreadExecutor.assertRunningInMainThread();

	if (jobGraph.getJobID().equals(jobId)) {
		if (log.isDebugEnabled()) {
			log.debug("Key value state registered for job {} under name {}.",
				jobGraph.getJobID(), registrationName);
		}

		try {
			executionGraph.getKvStateLocationRegistry().notifyKvStateRegistered(
				jobVertexId, keyGroupRange, registrationName, kvStateId, kvStateServerAddress);
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
	} else {
		throw new FlinkJobNotFoundException(jobId);
	}
}
 
Example #16
Source File: SchedulerBase.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public void notifyKvStateUnregistered(final JobID jobId, final JobVertexID jobVertexId, final KeyGroupRange keyGroupRange, final String registrationName) throws FlinkJobNotFoundException {
	mainThreadExecutor.assertRunningInMainThread();

	if (jobGraph.getJobID().equals(jobId)) {
		if (log.isDebugEnabled()) {
			log.debug("Key value state unregistered for job {} under name {}.",
				jobGraph.getJobID(), registrationName);
		}

		try {
			executionGraph.getKvStateLocationRegistry().notifyKvStateUnregistered(
				jobVertexId, keyGroupRange, registrationName);
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
	} else {
		throw new FlinkJobNotFoundException(jobId);
	}
}
 
Example #17
Source File: JobExecutionResultHandlerTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testPropagateFlinkJobNotFoundExceptionAsRestHandlerException() throws Exception {
	final TestingRestfulGateway testingRestfulGateway = new TestingRestfulGateway.Builder()
		.setRequestJobStatusFunction(
			jobId -> FutureUtils.completedExceptionally(new FlinkJobNotFoundException(jobId))
		)
		.build();

	try {
		jobExecutionResultHandler.handleRequest(
			testRequest,
			testingRestfulGateway).get();
		fail("Expected exception not thrown");
	} catch (final ExecutionException e) {
		final Throwable cause = ExceptionUtils.stripCompletionException(e.getCause());
		assertThat(cause, instanceOf(RestHandlerException.class));
		assertThat(
			((RestHandlerException) cause).getHttpResponseStatus(),
			equalTo(HttpResponseStatus.NOT_FOUND));
	}
}
 
Example #18
Source File: Dispatcher.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public CompletableFuture<JobResult> requestJobResult(JobID jobId, Time timeout) {
	final CompletableFuture<JobManagerRunner> jobManagerRunnerFuture = jobManagerRunnerFutures.get(jobId);

	if (jobManagerRunnerFuture == null) {
		final ArchivedExecutionGraph archivedExecutionGraph = archivedExecutionGraphStore.get(jobId);

		if (archivedExecutionGraph == null) {
			return FutureUtils.completedExceptionally(new FlinkJobNotFoundException(jobId));
		} else {
			return CompletableFuture.completedFuture(JobResult.createFrom(archivedExecutionGraph));
		}
	} else {
		return jobManagerRunnerFuture.thenCompose(JobManagerRunner::getResultFuture).thenApply(JobResult::createFrom);
	}
}
 
Example #19
Source File: AbstractExecutionGraphHandler.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Override
protected CompletableFuture<R> handleRequest(@Nonnull HandlerRequest<EmptyRequestBody, M> request, @Nonnull RestfulGateway gateway) throws RestHandlerException {
	JobID jobId = request.getPathParameter(JobIDPathParameter.class);

	CompletableFuture<AccessExecutionGraph> executionGraphFuture = executionGraphCache.getExecutionGraph(jobId, gateway);

	return executionGraphFuture.thenApplyAsync(
		executionGraph -> {
			try {
				return handleRequest(request, executionGraph);
			} catch (RestHandlerException rhe) {
				throw new CompletionException(rhe);
			}
		}, executor)
		.exceptionally(throwable -> {
			throwable = ExceptionUtils.stripCompletionException(throwable);
			if (throwable instanceof FlinkJobNotFoundException) {
				throw new CompletionException(
					new NotFoundException(String.format("Job %s not found", jobId), throwable));
			} else {
				throw new CompletionException(throwable);
			}
		});
}
 
Example #20
Source File: JobMaster.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Override
public CompletableFuture<KvStateLocation> requestKvStateLocation(final JobID jobId, final String registrationName) {
	// sanity check for the correct JobID
	if (jobGraph.getJobID().equals(jobId)) {
		if (log.isDebugEnabled()) {
			log.debug("Lookup key-value state for job {} with registration " +
				"name {}.", jobGraph.getJobID(), registrationName);
		}

		final KvStateLocationRegistry registry = executionGraph.getKvStateLocationRegistry();
		final KvStateLocation location = registry.getKvStateLocation(registrationName);
		if (location != null) {
			return CompletableFuture.completedFuture(location);
		} else {
			return FutureUtils.completedExceptionally(new UnknownKvStateLocation(registrationName));
		}
	} else {
		if (log.isDebugEnabled()) {
			log.debug("Request of key-value state location for unknown job {} received.", jobId);
		}
		return FutureUtils.completedExceptionally(new FlinkJobNotFoundException(jobId));
	}
}
 
Example #21
Source File: Dispatcher.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
private CompletableFuture<JobMasterGateway> getJobMasterGatewayFuture(JobID jobId) {
	final CompletableFuture<JobManagerRunner> jobManagerRunnerFuture = jobManagerRunnerFutures.get(jobId);

	if (jobManagerRunnerFuture == null) {
		return FutureUtils.completedExceptionally(new FlinkJobNotFoundException(jobId));
	} else {
		final CompletableFuture<JobMasterGateway> leaderGatewayFuture = jobManagerRunnerFuture.thenCompose(JobManagerRunner::getLeaderGatewayFuture);
		return leaderGatewayFuture.thenApplyAsync(
			(JobMasterGateway jobMasterGateway) -> {
				// check whether the retrieved JobMasterGateway belongs still to a running JobMaster
				if (jobManagerRunnerFutures.containsKey(jobId)) {
					return jobMasterGateway;
				} else {
					throw new CompletionException(new FlinkJobNotFoundException(jobId));
				}
			},
			getMainThreadExecutor());
	}
}
 
Example #22
Source File: Dispatcher.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Nonnull
private Collection<JobGraph> recoverJobGraphs(Collection<JobID> jobIds) throws Exception {
	final List<JobGraph> jobGraphs = new ArrayList<>(jobIds.size());

	for (JobID jobId : jobIds) {
		final JobGraph jobGraph = recoverJob(jobId);

		if (jobGraph == null) {
			throw new FlinkJobNotFoundException(jobId);
		}

		jobGraphs.add(jobGraph);
	}

	return jobGraphs;
}
 
Example #23
Source File: JobExecutionResultHandlerTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Test
public void testPropagateFlinkJobNotFoundExceptionAsRestHandlerException() throws Exception {
	final TestingRestfulGateway testingRestfulGateway = TestingRestfulGateway.newBuilder()
		.setRequestJobStatusFunction(
			jobId -> FutureUtils.completedExceptionally(new FlinkJobNotFoundException(jobId))
		)
		.build();

	try {
		jobExecutionResultHandler.handleRequest(
			testRequest,
			testingRestfulGateway).get();
		fail("Expected exception not thrown");
	} catch (final ExecutionException e) {
		final Throwable cause = ExceptionUtils.stripCompletionException(e.getCause());
		assertThat(cause, instanceOf(RestHandlerException.class));
		assertThat(
			((RestHandlerException) cause).getHttpResponseStatus(),
			equalTo(HttpResponseStatus.NOT_FOUND));
	}
}
 
Example #24
Source File: JobMasterTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testRequestKvStateOfWrongJob() throws Exception {
	final JobGraph graph = createKvJobGraph();

	final JobMaster jobMaster = createJobMaster(
		configuration,
		graph,
		haServices,
		new TestingJobManagerSharedServicesBuilder().build(),
		heartbeatServices);

	CompletableFuture<Acknowledge> startFuture = jobMaster.start(jobMasterId);
	final JobMasterGateway jobMasterGateway = jobMaster.getSelfGateway(JobMasterGateway.class);

	try {
		// wait for the start to complete
		startFuture.get(testingTimeout.toMilliseconds(), TimeUnit.MILLISECONDS);

		// lookup location
		try {
			jobMasterGateway.requestKvStateLocation(new JobID(), "unknown").get();
			fail("Expected to fail with FlinkJobNotFoundException");
		} catch (Exception e) {
			assertTrue(ExceptionUtils.findThrowable(e, FlinkJobNotFoundException.class).isPresent());
		}
	} finally {
		RpcUtils.terminateRpcEndpoint(jobMaster, testingTimeout);
	}
}
 
Example #25
Source File: DispatcherTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testThrowExceptionIfJobExecutionResultNotFound() throws Exception {
	dispatcher = createAndStartDispatcher(heartbeatServices, haServices, new ExpectedJobIdJobManagerRunnerFactory(TEST_JOB_ID, createdJobManagerRunnerLatch));

	final DispatcherGateway dispatcherGateway = dispatcher.getSelfGateway(DispatcherGateway.class);
	try {
		dispatcherGateway.requestJob(new JobID(), TIMEOUT).get();
	} catch (ExecutionException e) {
		final Throwable throwable = ExceptionUtils.stripExecutionException(e);
		assertThat(throwable, instanceOf(FlinkJobNotFoundException.class));
	}
}
 
Example #26
Source File: JobMasterTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testRequestKvStateWithIrrelevantRegistration() throws Exception {
	final JobGraph graph = createKvJobGraph();

	final JobMaster jobMaster = createJobMaster(
		configuration,
		graph,
		haServices,
		new TestingJobManagerSharedServicesBuilder().build(),
		heartbeatServices);

	CompletableFuture<Acknowledge> startFuture = jobMaster.start(jobMasterId);
	final JobMasterGateway jobMasterGateway = jobMaster.getSelfGateway(JobMasterGateway.class);

	try {
		// wait for the start to complete
		startFuture.get(testingTimeout.toMilliseconds(), TimeUnit.MILLISECONDS);

		// register an irrelevant KvState
		try {
			jobMasterGateway.notifyKvStateRegistered(
				new JobID(),
				new JobVertexID(),
				new KeyGroupRange(0, 0),
				"any-name",
				new KvStateID(),
				new InetSocketAddress(InetAddress.getLocalHost(), 1233)).get();
			fail("Expected to fail with FlinkJobNotFoundException.");
		} catch (Exception e) {
			assertTrue(ExceptionUtils.findThrowable(e, FlinkJobNotFoundException.class).isPresent());
		}
	} finally {
		RpcUtils.terminateRpcEndpoint(jobMaster, testingTimeout);
	}
}
 
Example #27
Source File: SavepointITCase.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Test
public void testTriggerSavepointForNonExistingJob() throws Exception {
	// Config
	final int numTaskManagers = 1;
	final int numSlotsPerTaskManager = 1;

	final Configuration config = new Configuration();
	config.setString(CheckpointingOptions.SAVEPOINT_DIRECTORY, savepointDir.toURI().toString());

	final MiniClusterWithClientResource cluster = new MiniClusterWithClientResource(
		new MiniClusterResourceConfiguration.Builder()
			.setConfiguration(config)
			.setNumberTaskManagers(numTaskManagers)
			.setNumberSlotsPerTaskManager(numSlotsPerTaskManager)
			.build());
	cluster.before();
	final ClusterClient<?> client = cluster.getClusterClient();

	final JobID jobID = new JobID();

	try {
		client.triggerSavepoint(jobID, null).get();

		fail();
	} catch (ExecutionException e) {
		assertTrue(ExceptionUtils.findThrowable(e, FlinkJobNotFoundException.class).isPresent());
		assertTrue(ExceptionUtils.findThrowableWithMessage(e, jobID.toString()).isPresent());
	} finally {
		cluster.after();
	}
}
 
Example #28
Source File: DefaultExecutionGraphCacheTest.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Tests that a failure in requesting an AccessExecutionGraph from the gateway, will not create
 * a cache entry --> another cache request will trigger a new gateway request.
 */
@Test
public void testImmediateCacheInvalidationAfterFailure() throws Exception {
	final Time timeout = Time.milliseconds(100L);
	final Time timeToLive = Time.hours(1L);

	// let's first answer with a JobNotFoundException and then only with the correct result
	final CountingRestfulGateway restfulGateway = createCountingRestfulGateway(
		expectedJobId,
		FutureUtils.completedExceptionally(new FlinkJobNotFoundException(expectedJobId)),
		CompletableFuture.completedFuture(expectedExecutionGraph));

	try (ExecutionGraphCache executionGraphCache = new DefaultExecutionGraphCache(timeout, timeToLive)) {
		CompletableFuture<AccessExecutionGraph> executionGraphFuture = executionGraphCache.getExecutionGraph(expectedJobId, restfulGateway);

		try {
			executionGraphFuture.get();

			fail("The execution graph future should have been completed exceptionally.");
		} catch (ExecutionException ee) {
			assertTrue(ee.getCause() instanceof FlinkException);
		}

		CompletableFuture<AccessExecutionGraph> executionGraphFuture2 = executionGraphCache.getExecutionGraph(expectedJobId, restfulGateway);

		assertEquals(expectedExecutionGraph, executionGraphFuture2.get());
	}
}
 
Example #29
Source File: JobExecutionResultHandler.java    From flink with Apache License 2.0 5 votes vote down vote up
private static CompletionException propagateException(final Throwable throwable) {
	final Throwable cause = ExceptionUtils.stripCompletionException(throwable);

	if (cause instanceof FlinkJobNotFoundException) {
		throw new CompletionException(new RestHandlerException(
			throwable.getMessage(),
			HttpResponseStatus.NOT_FOUND,
			throwable));
	} else {
		throw new CompletionException(throwable);
	}
}
 
Example #30
Source File: JobMaster.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Override
public CompletableFuture<Acknowledge> notifyKvStateRegistered(
		final JobID jobId,
		final JobVertexID jobVertexId,
		final KeyGroupRange keyGroupRange,
		final String registrationName,
		final KvStateID kvStateId,
		final InetSocketAddress kvStateServerAddress) {
	if (jobGraph.getJobID().equals(jobId)) {
		if (log.isDebugEnabled()) {
			log.debug("Key value state registered for job {} under name {}.",
				jobGraph.getJobID(), registrationName);
		}

		try {
			executionGraph.getKvStateLocationRegistry().notifyKvStateRegistered(
				jobVertexId, keyGroupRange, registrationName, kvStateId, kvStateServerAddress);

			return CompletableFuture.completedFuture(Acknowledge.get());
		} catch (Exception e) {
			log.error("Failed to notify KvStateRegistry about registration {}.", registrationName, e);
			return FutureUtils.completedExceptionally(e);
		}
	} else {
		if (log.isDebugEnabled()) {
			log.debug("Notification about key-value state registration for unknown job {} received.", jobId);
		}
		return FutureUtils.completedExceptionally(new FlinkJobNotFoundException(jobId));
	}
}