Java Code Examples for org.apache.flink.runtime.rest.messages.JobIDPathParameter

The following examples show how to use org.apache.flink.runtime.rest.messages.JobIDPathParameter. These examples are extracted from open source projects. 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 Project: flink   Author: apache   File: SavepointHandlers.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected CompletableFuture<String> triggerOperation(HandlerRequest<SavepointTriggerRequestBody, SavepointTriggerMessageParameters> request, RestfulGateway gateway) throws RestHandlerException {
	final JobID jobId = request.getPathParameter(JobIDPathParameter.class);
	final String requestedTargetDirectory = request.getRequestBody().getTargetDirectory();

	if (requestedTargetDirectory == null && defaultSavepointDir == null) {
		throw new RestHandlerException(
				String.format("Config key [%s] is not set. Property [%s] must be provided.",
					CheckpointingOptions.SAVEPOINT_DIRECTORY.key(),
					SavepointTriggerRequestBody.FIELD_NAME_TARGET_DIRECTORY),
				HttpResponseStatus.BAD_REQUEST);
	}

	final boolean cancelJob = request.getRequestBody().isCancelJob();
	final String targetDirectory = requestedTargetDirectory != null ? requestedTargetDirectory : defaultSavepointDir;
	return gateway.triggerSavepoint(jobId, targetDirectory, cancelJob, RpcUtils.INF_TIMEOUT);
}
 
Example #2
Source Project: Flink-CEPplus   Author: ljygz   File: AbstractExecutionGraphHandler.java    License: 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 #3
Source Project: Flink-CEPplus   Author: ljygz   File: TaskCheckpointStatisticDetailsHandler.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public Collection<ArchivedJson> archiveJsonWithPath(AccessExecutionGraph graph) throws IOException {
	CheckpointStatsSnapshot stats = graph.getCheckpointStatsSnapshot();
	if (stats == null) {
		return Collections.emptyList();
	}
	CheckpointStatsHistory history = stats.getHistory();
	List<ArchivedJson> archive = new ArrayList<>(history.getCheckpoints().size());
	for (AbstractCheckpointStats checkpoint : history.getCheckpoints()) {
		for (TaskStateStats subtaskStats : checkpoint.getAllTaskStateStats()) {
			ResponseBody json = createCheckpointDetails(checkpoint, subtaskStats);
			String path = getMessageHeaders().getTargetRestEndpointURL()
				.replace(':' + JobIDPathParameter.KEY, graph.getJobID().toString())
				.replace(':' + CheckpointIdPathParameter.KEY, String.valueOf(checkpoint.getCheckpointId()))
				.replace(':' + JobVertexIdPathParameter.KEY, subtaskStats.getJobVertexId().toString());
			archive.add(new ArchivedJson(path, json));
		}
	}
	return archive;
}
 
Example #4
Source Project: Flink-CEPplus   Author: ljygz   File: CheckpointStatisticDetailsHandler.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public Collection<ArchivedJson> archiveJsonWithPath(AccessExecutionGraph graph) throws IOException {
	CheckpointStatsSnapshot stats = graph.getCheckpointStatsSnapshot();
	if (stats == null) {
		return Collections.emptyList();
	}
	CheckpointStatsHistory history = stats.getHistory();
	List<ArchivedJson> archive = new ArrayList<>(history.getCheckpoints().size());
	for (AbstractCheckpointStats checkpoint : history.getCheckpoints()) {
		ResponseBody json = CheckpointStatistics.generateCheckpointStatistics(checkpoint, true);
		String path = getMessageHeaders().getTargetRestEndpointURL()
			.replace(':' + JobIDPathParameter.KEY, graph.getJobID().toString())
			.replace(':' + CheckpointIdPathParameter.KEY, String.valueOf(checkpoint.getCheckpointId()));
		archive.add(new ArchivedJson(path, json));
	}
	return archive;
}
 
Example #5
Source Project: Flink-CEPplus   Author: ljygz   File: SavepointHandlers.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected CompletableFuture<String> triggerOperation(HandlerRequest<SavepointTriggerRequestBody, SavepointTriggerMessageParameters> request, RestfulGateway gateway) throws RestHandlerException {
	final JobID jobId = request.getPathParameter(JobIDPathParameter.class);
	final String requestedTargetDirectory = request.getRequestBody().getTargetDirectory();

	if (requestedTargetDirectory == null && defaultSavepointDir == null) {
		throw new RestHandlerException(
				String.format("Config key [%s] is not set. Property [%s] must be provided.",
					CheckpointingOptions.SAVEPOINT_DIRECTORY.key(),
					SavepointTriggerRequestBody.FIELD_NAME_TARGET_DIRECTORY),
				HttpResponseStatus.BAD_REQUEST);
	}

	final boolean cancelJob = request.getRequestBody().isCancelJob();
	final String targetDirectory = requestedTargetDirectory != null ? requestedTargetDirectory : defaultSavepointDir;
	return gateway.triggerSavepoint(jobId, targetDirectory, cancelJob, RpcUtils.INF_TIMEOUT);
}
 
Example #6
Source Project: flink   Author: apache   File: CheckpointStatisticDetailsHandler.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public Collection<ArchivedJson> archiveJsonWithPath(AccessExecutionGraph graph) throws IOException {
	CheckpointStatsSnapshot stats = graph.getCheckpointStatsSnapshot();
	if (stats == null) {
		return Collections.emptyList();
	}
	CheckpointStatsHistory history = stats.getHistory();
	List<ArchivedJson> archive = new ArrayList<>(history.getCheckpoints().size());
	for (AbstractCheckpointStats checkpoint : history.getCheckpoints()) {
		ResponseBody json = CheckpointStatistics.generateCheckpointStatistics(checkpoint, true);
		String path = getMessageHeaders().getTargetRestEndpointURL()
			.replace(':' + JobIDPathParameter.KEY, graph.getJobID().toString())
			.replace(':' + CheckpointIdPathParameter.KEY, String.valueOf(checkpoint.getCheckpointId()));
		archive.add(new ArchivedJson(path, json));
	}
	return archive;
}
 
Example #7
Source Project: Flink-CEPplus   Author: ljygz   File: JobExecutionResultHandler.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected CompletableFuture<JobExecutionResultResponseBody> handleRequest(
		@Nonnull final HandlerRequest<EmptyRequestBody, JobMessageParameters> request,
		@Nonnull final RestfulGateway gateway) throws RestHandlerException {

	final JobID jobId = request.getPathParameter(JobIDPathParameter.class);

	final CompletableFuture<JobStatus> jobStatusFuture = gateway.requestJobStatus(jobId, timeout);

	return jobStatusFuture.thenCompose(
		jobStatus -> {
			if (jobStatus.isGloballyTerminalState()) {
				return gateway
					.requestJobResult(jobId, timeout)
					.thenApply(JobExecutionResultResponseBody::created);
			} else {
				return CompletableFuture.completedFuture(
					JobExecutionResultResponseBody.inProgress());
			}
		}).exceptionally(throwable -> {
			throw propagateException(throwable);
		});
}
 
Example #8
Source Project: Flink-CEPplus   Author: ljygz   File: RescalingHandlers.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected CompletableFuture<Acknowledge> triggerOperation(HandlerRequest<EmptyRequestBody, RescalingTriggerMessageParameters> request, RestfulGateway gateway) throws RestHandlerException {
	final JobID jobId = request.getPathParameter(JobIDPathParameter.class);
	final List<Integer> queryParameter = request.getQueryParameter(RescalingParallelismQueryParameter.class);

	if (queryParameter.isEmpty()) {
		throw new RestHandlerException("No new parallelism was specified.", HttpResponseStatus.BAD_REQUEST);
	}

	final int newParallelism = queryParameter.get(0);

	final CompletableFuture<Acknowledge> rescalingFuture = gateway.rescaleJob(
		jobId,
		newParallelism,
		RescalingBehaviour.STRICT,
		RpcUtils.INF_TIMEOUT);

	return rescalingFuture;
}
 
Example #9
Source Project: flink   Author: flink-tpc-ds   File: JobVertexBackPressureHandlerTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testAbsentBackPressure() throws Exception {
	final Map<String, String> pathParameters = new HashMap<>();
	pathParameters.put(JobIDPathParameter.KEY, TEST_JOB_ID_BACK_PRESSURE_STATS_ABSENT.toString());
	pathParameters.put(JobVertexIdPathParameter.KEY, new JobVertexID().toString());

	final HandlerRequest<EmptyRequestBody, JobVertexMessageParameters> request =
		new HandlerRequest<>(
			EmptyRequestBody.getInstance(),
			new JobVertexMessageParameters(), pathParameters, Collections.emptyMap());

	final CompletableFuture<JobVertexBackPressureInfo> jobVertexBackPressureInfoCompletableFuture =
		jobVertexBackPressureHandler.handleRequest(request, restfulGateway);
	final JobVertexBackPressureInfo jobVertexBackPressureInfo = jobVertexBackPressureInfoCompletableFuture.get();

	assertThat(jobVertexBackPressureInfo.getStatus(), equalTo(VertexBackPressureStatus.DEPRECATED));
}
 
Example #10
Source Project: flink   Author: apache   File: ClientCoordinationHandler.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected CompletableFuture<ClientCoordinationResponseBody> handleRequest(
		@Nonnull HandlerRequest<ClientCoordinationRequestBody, ClientCoordinationMessageParameters> request,
		@Nonnull RestfulGateway gateway) throws RestHandlerException {
	JobID jobId = request.getPathParameter(JobIDPathParameter.class);
	OperatorID operatorId = request.getPathParameter(OperatorIDPathParameter.class);
	SerializedValue<CoordinationRequest> serializedRequest =
		request.getRequestBody().getSerializedCoordinationRequest();
	CompletableFuture<CoordinationResponse> responseFuture =
		gateway.deliverCoordinationRequestToCoordinator(jobId, operatorId, serializedRequest, timeout);
	return responseFuture.thenApply(
		coordinationResponse -> {
			try {
				return new ClientCoordinationResponseBody(new SerializedValue<>(coordinationResponse));
			} catch (IOException e) {
				throw new CompletionException(
					new RestHandlerException(
						"Failed to serialize coordination response",
						HttpResponseStatus.INTERNAL_SERVER_ERROR,
						e));
			}
		});
}
 
Example #11
Source Project: flink   Author: flink-tpc-ds   File: AggregatingSubtasksMetricsHandler.java    License: Apache License 2.0 6 votes vote down vote up
@Nonnull
@Override
Collection<? extends MetricStore.ComponentMetricStore> getStores(MetricStore store, HandlerRequest<EmptyRequestBody, AggregatedSubtaskMetricsParameters> request) {
	JobID jobID = request.getPathParameter(JobIDPathParameter.class);
	JobVertexID taskID = request.getPathParameter(JobVertexIdPathParameter.class);

	Collection<String> subtaskRanges = request.getQueryParameter(SubtasksFilterQueryParameter.class);
	if (subtaskRanges.isEmpty()) {
		MetricStore.TaskMetricStore taskMetricStore = store.getTaskMetricStore(jobID.toString(), taskID.toString());
		if (taskMetricStore != null) {
			return taskMetricStore.getAllSubtaskMetricStores();
		} else {
			return Collections.emptyList();
		}
	} else {
		Iterable<Integer> subtasks = getIntegerRangeFromString(subtaskRanges);
		Collection<MetricStore.ComponentMetricStore> subtaskStores = new ArrayList<>(8);
		for (int subtask : subtasks) {
			MetricStore.ComponentMetricStore subtaskMetricStore = store.getSubtaskMetricStore(jobID.toString(), taskID.toString(), subtask);
			if (subtaskMetricStore != null) {
				subtaskStores.add(subtaskMetricStore);
			}
		}
		return subtaskStores;
	}
}
 
Example #12
Source Project: flink   Author: flink-tpc-ds   File: SavepointHandlers.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected CompletableFuture<String> triggerOperation(
		final HandlerRequest<StopWithSavepointRequestBody, SavepointTriggerMessageParameters> request,
		final RestfulGateway gateway) throws RestHandlerException {

	final JobID jobId = request.getPathParameter(JobIDPathParameter.class);
	final String requestedTargetDirectory = request.getRequestBody().getTargetDirectory();

	if (requestedTargetDirectory == null && defaultSavepointDir == null) {
		throw new RestHandlerException(
				String.format("Config key [%s] is not set. Property [%s] must be provided.",
						CheckpointingOptions.SAVEPOINT_DIRECTORY.key(),
						StopWithSavepointRequestBody.FIELD_NAME_TARGET_DIRECTORY),
				HttpResponseStatus.BAD_REQUEST);
	}

	final boolean advanceToEndOfEventTime = request.getRequestBody().shouldDrain();
	final String targetDirectory = requestedTargetDirectory != null ? requestedTargetDirectory : defaultSavepointDir;
	return gateway.stopWithSavepoint(jobId, targetDirectory, advanceToEndOfEventTime, RpcUtils.INF_TIMEOUT);
}
 
Example #13
Source Project: flink   Author: apache   File: AggregatingSubtasksMetricsHandler.java    License: Apache License 2.0 6 votes vote down vote up
@Nonnull
@Override
Collection<? extends MetricStore.ComponentMetricStore> getStores(MetricStore store, HandlerRequest<EmptyRequestBody, AggregatedSubtaskMetricsParameters> request) {
	JobID jobID = request.getPathParameter(JobIDPathParameter.class);
	JobVertexID taskID = request.getPathParameter(JobVertexIdPathParameter.class);

	Collection<String> subtaskRanges = request.getQueryParameter(SubtasksFilterQueryParameter.class);
	if (subtaskRanges.isEmpty()) {
		MetricStore.TaskMetricStore taskMetricStore = store.getTaskMetricStore(jobID.toString(), taskID.toString());
		if (taskMetricStore != null) {
			return taskMetricStore.getAllSubtaskMetricStores();
		} else {
			return Collections.emptyList();
		}
	} else {
		Iterable<Integer> subtasks = getIntegerRangeFromString(subtaskRanges);
		Collection<MetricStore.ComponentMetricStore> subtaskStores = new ArrayList<>(8);
		for (int subtask : subtasks) {
			MetricStore.ComponentMetricStore subtaskMetricStore = store.getSubtaskMetricStore(jobID.toString(), taskID.toString(), subtask);
			if (subtaskMetricStore != null) {
				subtaskStores.add(subtaskMetricStore);
			}
		}
		return subtaskStores;
	}
}
 
Example #14
Source Project: flink   Author: flink-tpc-ds   File: JobExecutionResultHandler.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected CompletableFuture<JobExecutionResultResponseBody> handleRequest(
		@Nonnull final HandlerRequest<EmptyRequestBody, JobMessageParameters> request,
		@Nonnull final RestfulGateway gateway) throws RestHandlerException {

	final JobID jobId = request.getPathParameter(JobIDPathParameter.class);

	final CompletableFuture<JobStatus> jobStatusFuture = gateway.requestJobStatus(jobId, timeout);

	return jobStatusFuture.thenCompose(
		jobStatus -> {
			if (jobStatus.isGloballyTerminalState()) {
				return gateway
					.requestJobResult(jobId, timeout)
					.thenApply(JobExecutionResultResponseBody::created);
			} else {
				return CompletableFuture.completedFuture(
					JobExecutionResultResponseBody.inProgress());
			}
		}).exceptionally(throwable -> {
			throw propagateException(throwable);
		});
}
 
Example #15
Source Project: flink   Author: apache   File: JobExceptionsHandler.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Collection<ArchivedJson> archiveJsonWithPath(AccessExecutionGraph graph) throws IOException {
	ResponseBody json = createJobExceptionsInfo(graph, MAX_NUMBER_EXCEPTION_TO_REPORT);
	String path = getMessageHeaders().getTargetRestEndpointURL()
		.replace(':' + JobIDPathParameter.KEY, graph.getJobID().toString());
	return Collections.singletonList(new ArchivedJson(path, json));
}
 
Example #16
Source Project: flink   Author: apache   File: JobVertexBackPressureHandlerTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testGetBackPressure() throws Exception {
	final Map<String, String> pathParameters = new HashMap<>();
	pathParameters.put(JobIDPathParameter.KEY, TEST_JOB_ID_BACK_PRESSURE_STATS_AVAILABLE.toString());
	pathParameters.put(JobVertexIdPathParameter.KEY, new JobVertexID().toString());

	final HandlerRequest<EmptyRequestBody, JobVertexMessageParameters> request =
		new HandlerRequest<>(
			EmptyRequestBody.getInstance(),
			new JobVertexMessageParameters(), pathParameters, Collections.emptyMap());

	final CompletableFuture<JobVertexBackPressureInfo> jobVertexBackPressureInfoCompletableFuture =
		jobVertexBackPressureHandler.handleRequest(request, restfulGateway);
	final JobVertexBackPressureInfo jobVertexBackPressureInfo = jobVertexBackPressureInfoCompletableFuture.get();

	assertThat(jobVertexBackPressureInfo.getStatus(), equalTo(VertexBackPressureStatus.OK));
	assertThat(jobVertexBackPressureInfo.getBackpressureLevel(), equalTo(HIGH));

	assertThat(jobVertexBackPressureInfo.getSubtasks()
		.stream()
		.map(JobVertexBackPressureInfo.SubtaskBackPressureInfo::getRatio)
		.collect(Collectors.toList()), contains(1.0, 0.5, 0.1));

	assertThat(jobVertexBackPressureInfo.getSubtasks()
		.stream()
		.map(JobVertexBackPressureInfo.SubtaskBackPressureInfo::getBackpressureLevel)
		.collect(Collectors.toList()), contains(HIGH, LOW, OK));

	assertThat(jobVertexBackPressureInfo.getSubtasks()
		.stream()
		.map(JobVertexBackPressureInfo.SubtaskBackPressureInfo::getSubtask)
		.collect(Collectors.toList()), contains(0, 1, 2));
}
 
Example #17
Source Project: flink   Author: flink-tpc-ds   File: JobVertexBackPressureHandlerTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testGetBackPressure() throws Exception {
	final Map<String, String> pathParameters = new HashMap<>();
	pathParameters.put(JobIDPathParameter.KEY, TEST_JOB_ID_BACK_PRESSURE_STATS_AVAILABLE.toString());
	pathParameters.put(JobVertexIdPathParameter.KEY, new JobVertexID().toString());

	final HandlerRequest<EmptyRequestBody, JobVertexMessageParameters> request =
		new HandlerRequest<>(
			EmptyRequestBody.getInstance(),
			new JobVertexMessageParameters(), pathParameters, Collections.emptyMap());

	final CompletableFuture<JobVertexBackPressureInfo> jobVertexBackPressureInfoCompletableFuture =
		jobVertexBackPressureHandler.handleRequest(request, restfulGateway);
	final JobVertexBackPressureInfo jobVertexBackPressureInfo = jobVertexBackPressureInfoCompletableFuture.get();

	assertThat(jobVertexBackPressureInfo.getStatus(), equalTo(VertexBackPressureStatus.OK));
	assertThat(jobVertexBackPressureInfo.getBackpressureLevel(), equalTo(HIGH));

	assertThat(jobVertexBackPressureInfo.getSubtasks()
		.stream()
		.map(JobVertexBackPressureInfo.SubtaskBackPressureInfo::getRatio)
		.collect(Collectors.toList()), contains(1.0, 0.5, 0.1));

	assertThat(jobVertexBackPressureInfo.getSubtasks()
		.stream()
		.map(JobVertexBackPressureInfo.SubtaskBackPressureInfo::getBackpressureLevel)
		.collect(Collectors.toList()), contains(HIGH, LOW, OK));

	assertThat(jobVertexBackPressureInfo.getSubtasks()
		.stream()
		.map(JobVertexBackPressureInfo.SubtaskBackPressureInfo::getSubtask)
		.collect(Collectors.toList()), contains(0, 1, 2));
}
 
Example #18
Source Project: flink   Author: apache   File: SubtasksTimesHandler.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Collection<ArchivedJson> archiveJsonWithPath(AccessExecutionGraph graph) throws IOException {
	Collection<? extends AccessExecutionJobVertex> allVertices = graph.getAllVertices().values();
	List<ArchivedJson> archive = new ArrayList<>(allVertices.size());
	for (AccessExecutionJobVertex task : allVertices) {
		ResponseBody json = createSubtaskTimesInfo(task);
		String path = getMessageHeaders().getTargetRestEndpointURL()
			.replace(':' + JobIDPathParameter.KEY, graph.getJobID().toString())
			.replace(':' + JobVertexIdPathParameter.KEY, task.getJobVertexId().toString());
		archive.add(new ArchivedJson(path, json));
	}
	return archive;
}
 
Example #19
Source Project: flink   Author: apache   File: JobVertexDetailsHandler.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected JobVertexDetailsInfo handleRequest(
		HandlerRequest<EmptyRequestBody, JobVertexMessageParameters> request,
		AccessExecutionGraph executionGraph) throws NotFoundException {
	JobID jobID = request.getPathParameter(JobIDPathParameter.class);
	JobVertexID jobVertexID = request.getPathParameter(JobVertexIdPathParameter.class);
	AccessExecutionJobVertex jobVertex = executionGraph.getJobVertex(jobVertexID);

	if (jobVertex == null) {
		throw new NotFoundException(String.format("JobVertex %s not found", jobVertexID));
	}

	return createJobVertexDetailsInfo(jobVertex, jobID, metricFetcher);
}
 
Example #20
Source Project: Flink-CEPplus   Author: ljygz   File: SubtaskMetricsHandler.java    License: Apache License 2.0 5 votes vote down vote up
@Nullable
@Override
protected MetricStore.ComponentMetricStore getComponentMetricStore(
		HandlerRequest<EmptyRequestBody, SubtaskMetricsMessageParameters> request,
		MetricStore metricStore) {

	final JobID jobId = request.getPathParameter(JobIDPathParameter.class);
	final JobVertexID vertexId = request.getPathParameter(JobVertexIdPathParameter.class);
	final int subtaskIndex = request.getPathParameter(SubtaskIndexPathParameter.class);

	return metricStore.getSubtaskMetricStore(jobId.toString(), vertexId.toString(), subtaskIndex);
}
 
Example #21
Source Project: flink   Author: flink-tpc-ds   File: SavepointHandlersTest.java    License: 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 #22
Source Project: Flink-CEPplus   Author: ljygz   File: JobMetricsHandler.java    License: Apache License 2.0 5 votes vote down vote up
@Nullable
@Override
protected MetricStore.ComponentMetricStore getComponentMetricStore(
	final HandlerRequest<EmptyRequestBody, JobMetricsMessageParameters> request,
	final MetricStore metricStore) {
	return metricStore.getJobMetricStore(request.getPathParameter(JobIDPathParameter.class).toString());
}
 
Example #23
Source Project: Flink-CEPplus   Author: ljygz   File: JobVertexMetricsHandler.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected MetricStore.ComponentMetricStore getComponentMetricStore(
		HandlerRequest<EmptyRequestBody, JobVertexMetricsMessageParameters> request,
		MetricStore metricStore) {

	final JobID jobId = request.getPathParameter(JobIDPathParameter.class);
	final JobVertexID vertexId = request.getPathParameter(JobVertexIdPathParameter.class);

	return metricStore.getTaskMetricStore(jobId.toString(), vertexId.toString());
}
 
Example #24
Source Project: Flink-CEPplus   Author: ljygz   File: SubtaskExecutionAttemptDetailsHandler.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Collection<ArchivedJson> archiveJsonWithPath(AccessExecutionGraph graph) throws IOException {
	List<ArchivedJson> archive = new ArrayList<>(16);
	for (AccessExecutionJobVertex task : graph.getAllVertices().values()) {
		for (AccessExecutionVertex subtask : task.getTaskVertices()) {
			ResponseBody curAttemptJson = createDetailsInfo(subtask.getCurrentExecutionAttempt(), graph.getJobID(), task.getJobVertexId(), null);
			String curAttemptPath = getMessageHeaders().getTargetRestEndpointURL()
				.replace(':' + JobIDPathParameter.KEY, graph.getJobID().toString())
				.replace(':' + JobVertexIdPathParameter.KEY, task.getJobVertexId().toString())
				.replace(':' + SubtaskIndexPathParameter.KEY, String.valueOf(subtask.getParallelSubtaskIndex()))
				.replace(':' + SubtaskAttemptPathParameter.KEY, String.valueOf(subtask.getCurrentExecutionAttempt().getAttemptNumber()));

			archive.add(new ArchivedJson(curAttemptPath, curAttemptJson));

			for (int x = 0; x < subtask.getCurrentExecutionAttempt().getAttemptNumber(); x++) {
				AccessExecution attempt = subtask.getPriorExecutionAttempt(x);
				if (attempt != null) {
					ResponseBody json = createDetailsInfo(attempt, graph.getJobID(), task.getJobVertexId(), null);
					String path = getMessageHeaders().getTargetRestEndpointURL()
						.replace(':' + JobIDPathParameter.KEY, graph.getJobID().toString())
						.replace(':' + JobVertexIdPathParameter.KEY, task.getJobVertexId().toString())
						.replace(':' + SubtaskIndexPathParameter.KEY, String.valueOf(subtask.getParallelSubtaskIndex()))
						.replace(':' + SubtaskAttemptPathParameter.KEY, String.valueOf(attempt.getAttemptNumber()));
					archive.add(new ArchivedJson(path, json));
				}
			}
		}
	}
	return archive;
}
 
Example #25
Source Project: Flink-CEPplus   Author: ljygz   File: JobPlanHandler.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Collection<ArchivedJson> archiveJsonWithPath(AccessExecutionGraph graph) throws IOException {
	ResponseBody json = createJobPlanInfo(graph);
	String path = getMessageHeaders().getTargetRestEndpointURL()
		.replace(':' + JobIDPathParameter.KEY, graph.getJobID().toString());
	return Collections.singleton(new ArchivedJson(path, json));
}
 
Example #26
Source Project: Flink-CEPplus   Author: ljygz   File: JobVertexTaskManagersHandler.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected JobVertexTaskManagersInfo handleRequest(
		HandlerRequest<EmptyRequestBody, JobVertexMessageParameters> request,
		AccessExecutionGraph executionGraph) throws RestHandlerException {
	JobID jobID = request.getPathParameter(JobIDPathParameter.class);
	JobVertexID jobVertexID = request.getPathParameter(JobVertexIdPathParameter.class);
	AccessExecutionJobVertex jobVertex = executionGraph.getJobVertex(jobVertexID);

	if (jobVertex == null) {
		throw new NotFoundException(String.format("JobVertex %s not found", jobVertexID));
	}

	return createJobVertexTaskManagersInfo(jobVertex, jobID, metricFetcher);
}
 
Example #27
Source Project: Flink-CEPplus   Author: ljygz   File: JobVertexTaskManagersHandler.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Collection<ArchivedJson> archiveJsonWithPath(AccessExecutionGraph graph) throws IOException {
	Collection<? extends AccessExecutionJobVertex> vertices = graph.getAllVertices().values();
	List<ArchivedJson> archive = new ArrayList<>(vertices.size());
	for (AccessExecutionJobVertex task : vertices) {
		ResponseBody json = createJobVertexTaskManagersInfo(task, graph.getJobID(), null);
		String path = getMessageHeaders().getTargetRestEndpointURL()
			.replace(':' + JobIDPathParameter.KEY, graph.getJobID().toString())
			.replace(':' + JobVertexIdPathParameter.KEY, task.getJobVertexId().toString());
		archive.add(new ArchivedJson(path, json));
	}
	return archive;
}
 
Example #28
Source Project: flink   Author: apache   File: SubtaskExecutionAttemptDetailsHandler.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected SubtaskExecutionAttemptDetailsInfo handleRequest(
		HandlerRequest<EmptyRequestBody, SubtaskAttemptMessageParameters> request,
		AccessExecution execution) throws RestHandlerException {

	final JobID jobID = request.getPathParameter(JobIDPathParameter.class);
	final JobVertexID jobVertexID = request.getPathParameter(JobVertexIdPathParameter.class);

	return SubtaskExecutionAttemptDetailsInfo.create(execution, metricFetcher, jobID, jobVertexID);
}
 
Example #29
Source Project: Flink-CEPplus   Author: ljygz   File: JobsOverviewHandler.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Collection<ArchivedJson> archiveJsonWithPath(AccessExecutionGraph graph) throws IOException {
	ResponseBody json = new MultipleJobsDetails(Collections.singleton(WebMonitorUtils.createDetailsForJob(graph)));
	String path = getMessageHeaders().getTargetRestEndpointURL()
		.replace(':' + JobIDPathParameter.KEY, graph.getJobID().toString());
	return Collections.singletonList(new ArchivedJson(path, json));
}
 
Example #30
Source Project: flink   Author: apache   File: SavepointHandlersTest.java    License: 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());
}