class MiniDispatcher extends Dispatcher {

	@Override
	public CompletableFuture<JobResult> requestJobResult(JobID jobId, Time timeout) {
		final CompletableFuture<JobResult> jobResultFuture = super.requestJobResult(jobId, timeout);

		if (executionMode == ClusterEntrypoint.ExecutionMode.NORMAL) {
			// terminate the MiniDispatcher once we served the first JobResult successfully
			jobResultFuture.thenAccept((JobResult result) -> {
				ApplicationStatus status = result.getSerializedThrowable().isPresent() ?
						ApplicationStatus.FAILED : ApplicationStatus.SUCCEEDED;

				LOG.debug("Shutting down cluster because someone retrieved the job result.");
				shutDownFuture.complete(status);
			});
		} else {
			LOG.debug("Not shutting down cluster after someone retrieved the job result.");
		}

		return jobResultFuture;
	}

	public  MiniDispatcher(
			RpcService rpcService,
			DispatcherId fencingToken,
			DispatcherServices dispatcherServices,
			DispatcherBootstrap dispatcherBootstrap,
			JobClusterEntrypoint.ExecutionMode executionMode);

}