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

The following examples show how to use org.apache.flink.runtime.rest.messages.ResponseBody. 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: CheckpointStatisticDetailsHandler.java    From flink with 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 #2
Source File: TaskCheckpointStatisticDetailsHandler.java    From Flink-CEPplus with 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 #3
Source File: CheckpointStatisticDetailsHandler.java    From Flink-CEPplus with 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 #4
Source File: RestClient.java    From flink with Apache License 2.0 6 votes vote down vote up
public <M extends MessageHeaders<R, P, U>, U extends MessageParameters, R extends RequestBody, P extends ResponseBody> CompletableFuture<P> sendRequest(
		String targetAddress,
		int targetPort,
		M messageHeaders,
		U messageParameters,
		R request,
		Collection<FileUpload> fileUploads) throws IOException {
	return sendRequest(
		targetAddress,
		targetPort,
		messageHeaders,
		messageParameters,
		request,
		fileUploads,
		RestAPIVersion.getLatestVersion(messageHeaders.getSupportedAPIVersions()));
}
 
Example #5
Source File: HandlerUtils.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * Sends the given response and status code to the given channel.
 *
 * @param channelHandlerContext identifying the open channel
 * @param httpRequest originating http request
 * @param response which should be sent
 * @param statusCode of the message to send
 * @param headers additional header values
 * @param <P> type of the response
 */
public static <P extends ResponseBody> CompletableFuture<Void> sendResponse(
		ChannelHandlerContext channelHandlerContext,
		HttpRequest httpRequest,
		P response,
		HttpResponseStatus statusCode,
		Map<String, String> headers) {
	StringWriter sw = new StringWriter();
	try {
		mapper.writeValue(sw, response);
	} catch (IOException ioe) {
		LOG.error("Internal server error. Could not map response to JSON.", ioe);
		return sendErrorResponse(
			channelHandlerContext,
			httpRequest,
			new ErrorResponseBody("Internal server error. Could not map response to JSON."),
			HttpResponseStatus.INTERNAL_SERVER_ERROR,
			headers);
	}
	return sendResponse(
		channelHandlerContext,
		httpRequest,
		sw.toString(),
		statusCode,
		headers);
}
 
Example #6
Source File: RestClient.java    From flink with Apache License 2.0 6 votes vote down vote up
private static <P extends ResponseBody> CompletableFuture<P> parseResponse(JsonResponse rawResponse, JavaType responseType) {
	CompletableFuture<P> responseFuture = new CompletableFuture<>();
	final JsonParser jsonParser = objectMapper.treeAsTokens(rawResponse.json);
	try {
		P response = objectMapper.readValue(jsonParser, responseType);
		responseFuture.complete(response);
	} catch (IOException originalException) {
		// the received response did not matched the expected response type

		// lets see if it is an ErrorResponse instead
		try {
			ErrorResponseBody error = objectMapper.treeToValue(rawResponse.getJson(), ErrorResponseBody.class);
			responseFuture.completeExceptionally(new RestClientException(error.errors.toString(), rawResponse.getHttpResponseStatus()));
		} catch (JsonProcessingException jpe2) {
			// if this fails it is either the expected type or response type was wrong, most likely caused
			// by a client/search MessageHeaders mismatch
			LOG.error("Received response was neither of the expected type ({}) nor an error. Response={}", responseType, rawResponse, jpe2);
			responseFuture.completeExceptionally(
				new RestClientException(
					"Response was neither of the expected type(" + responseType + ") nor an error.",
					originalException,
					rawResponse.getHttpResponseStatus()));
		}
	}
	return responseFuture;
}
 
Example #7
Source File: HandlerUtils.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
/**
 * Sends the given response and status code to the given channel.
 *
 * @param channelHandlerContext identifying the open channel
 * @param httpRequest originating http request
 * @param response which should be sent
 * @param statusCode of the message to send
 * @param headers additional header values
 * @param <P> type of the response
 */
public static <P extends ResponseBody> CompletableFuture<Void> sendResponse(
		ChannelHandlerContext channelHandlerContext,
		HttpRequest httpRequest,
		P response,
		HttpResponseStatus statusCode,
		Map<String, String> headers) {
	StringWriter sw = new StringWriter();
	try {
		mapper.writeValue(sw, response);
	} catch (IOException ioe) {
		LOG.error("Internal server error. Could not map response to JSON.", ioe);
		return sendErrorResponse(
			channelHandlerContext,
			httpRequest,
			new ErrorResponseBody("Internal server error. Could not map response to JSON."),
			HttpResponseStatus.INTERNAL_SERVER_ERROR,
			headers);
	}
	return sendResponse(
		channelHandlerContext,
		httpRequest,
		sw.toString(),
		statusCode,
		headers);
}
 
Example #8
Source File: CheckpointStatisticDetailsHandler.java    From flink with 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 #9
Source File: RestClient.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
public <M extends MessageHeaders<R, P, U>, U extends MessageParameters, R extends RequestBody, P extends ResponseBody> CompletableFuture<P> sendRequest(
		String targetAddress,
		int targetPort,
		M messageHeaders,
		U messageParameters,
		R request,
		Collection<FileUpload> fileUploads) throws IOException {
	return sendRequest(
		targetAddress,
		targetPort,
		messageHeaders,
		messageParameters,
		request,
		fileUploads,
		RestAPIVersion.getLatestVersion(messageHeaders.getSupportedAPIVersions()));
}
 
Example #10
Source File: TaskCheckpointStatisticDetailsHandler.java    From flink with 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 #11
Source File: RestClusterClientTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Nonnull
private RestClient createRestClient() throws ConfigurationException {
	return new RestClient(RestClientConfiguration.fromConfiguration(restConfig), executor) {
		@Override
		public <M extends MessageHeaders<R, P, U>, U extends MessageParameters, R extends RequestBody, P extends ResponseBody> CompletableFuture<P>
		sendRequest(
			final String targetAddress,
			final int targetPort,
			final M messageHeaders,
			final U messageParameters,
			final R request,
			final Collection<FileUpload> files) throws IOException {
			if (failHttpRequest.test(messageHeaders, messageParameters, request)) {
				return FutureUtils.completedExceptionally(new IOException("expected"));
			} else {
				return super.sendRequest(targetAddress, targetPort, messageHeaders, messageParameters, request, files);
			}
		}
	};
}
 
Example #12
Source File: RestClusterClientTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Nonnull
private RestClient createRestClient() throws ConfigurationException {
	return new RestClient(RestClientConfiguration.fromConfiguration(restConfig), executor) {
		@Override
		public <M extends MessageHeaders<R, P, U>, U extends MessageParameters, R extends RequestBody, P extends ResponseBody> CompletableFuture<P>
		sendRequest(
			final String targetAddress,
			final int targetPort,
			final M messageHeaders,
			final U messageParameters,
			final R request,
			final Collection<FileUpload> files) throws IOException {
			if (failHttpRequest.test(messageHeaders, messageParameters, request)) {
				return FutureUtils.completedExceptionally(new IOException("expected"));
			} else {
				return super.sendRequest(targetAddress, targetPort, messageHeaders, messageParameters, request, files);
			}
		}
	};
}
 
Example #13
Source File: RestClient.java    From flink with Apache License 2.0 6 votes vote down vote up
private static <P extends ResponseBody> CompletableFuture<P> parseResponse(JsonResponse rawResponse, JavaType responseType) {
	CompletableFuture<P> responseFuture = new CompletableFuture<>();
	final JsonParser jsonParser = objectMapper.treeAsTokens(rawResponse.json);
	try {
		P response = objectMapper.readValue(jsonParser, responseType);
		responseFuture.complete(response);
	} catch (IOException originalException) {
		// the received response did not matched the expected response type

		// lets see if it is an ErrorResponse instead
		try {
			ErrorResponseBody error = objectMapper.treeToValue(rawResponse.getJson(), ErrorResponseBody.class);
			responseFuture.completeExceptionally(new RestClientException(error.errors.toString(), rawResponse.getHttpResponseStatus()));
		} catch (JsonProcessingException jpe2) {
			// if this fails it is either the expected type or response type was wrong, most likely caused
			// by a client/search MessageHeaders mismatch
			LOG.error("Received response was neither of the expected type ({}) nor an error. Response={}", responseType, rawResponse, jpe2);
			responseFuture.completeExceptionally(
				new RestClientException(
					"Response was neither of the expected type(" + responseType + ") nor an error.",
					originalException,
					rawResponse.getHttpResponseStatus()));
		}
	}
	return responseFuture;
}
 
Example #14
Source File: RestClusterClientTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Nonnull
private RestClient createRestClient() throws ConfigurationException {
	return new RestClient(RestClientConfiguration.fromConfiguration(restConfig), executor) {
		@Override
		public <M extends MessageHeaders<R, P, U>, U extends MessageParameters, R extends RequestBody, P extends ResponseBody> CompletableFuture<P>
		sendRequest(
			final String targetAddress,
			final int targetPort,
			final M messageHeaders,
			final U messageParameters,
			final R request,
			final Collection<FileUpload> files) throws IOException {
			if (failHttpRequest.test(messageHeaders, messageParameters, request)) {
				return FutureUtils.completedExceptionally(new IOException("expected"));
			} else {
				return super.sendRequest(targetAddress, targetPort, messageHeaders, messageParameters, request, files);
			}
		}
	};
}
 
Example #15
Source File: RestClient.java    From flink with Apache License 2.0 6 votes vote down vote up
public <M extends MessageHeaders<R, P, U>, U extends MessageParameters, R extends RequestBody, P extends ResponseBody> CompletableFuture<P> sendRequest(
		String targetAddress,
		int targetPort,
		M messageHeaders,
		U messageParameters,
		R request,
		Collection<FileUpload> fileUploads) throws IOException {
	return sendRequest(
		targetAddress,
		targetPort,
		messageHeaders,
		messageParameters,
		request,
		fileUploads,
		RestAPIVersion.getLatestVersion(messageHeaders.getSupportedAPIVersions()));
}
 
Example #16
Source File: HandlerUtils.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * Sends the given response and status code to the given channel.
 *
 * @param channelHandlerContext identifying the open channel
 * @param httpRequest originating http request
 * @param response which should be sent
 * @param statusCode of the message to send
 * @param headers additional header values
 * @param <P> type of the response
 */
public static <P extends ResponseBody> CompletableFuture<Void> sendResponse(
		ChannelHandlerContext channelHandlerContext,
		HttpRequest httpRequest,
		P response,
		HttpResponseStatus statusCode,
		Map<String, String> headers) {
	StringWriter sw = new StringWriter();
	try {
		mapper.writeValue(sw, response);
	} catch (IOException ioe) {
		LOG.error("Internal server error. Could not map response to JSON.", ioe);
		return sendErrorResponse(
			channelHandlerContext,
			httpRequest,
			new ErrorResponseBody("Internal server error. Could not map response to JSON."),
			HttpResponseStatus.INTERNAL_SERVER_ERROR,
			headers);
	}
	return sendResponse(
		channelHandlerContext,
		httpRequest,
		sw.toString(),
		statusCode,
		headers);
}
 
Example #17
Source File: TaskCheckpointStatisticDetailsHandler.java    From flink with 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 #18
Source File: JobConfigHandler.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public Collection<ArchivedJson> archiveJsonWithPath(AccessExecutionGraph graph) throws IOException {
	ResponseBody json = createJobConfigInfo(graph);
	String path = getMessageHeaders().getTargetRestEndpointURL()
		.replace(':' + JobIDPathParameter.KEY, graph.getJobID().toString());
	return Collections.singleton(new ArchivedJson(path, json));
}
 
Example #19
Source File: SubtaskExecutionAttemptAccumulatorsHandler.java    From flink with 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 = createAccumulatorInfo(subtask.getCurrentExecutionAttempt());
			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 = createAccumulatorInfo(attempt);
					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 #20
Source File: JobExceptionsHandler.java    From flink with 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 #21
Source File: SubtaskExecutionAttemptDetailsHandler.java    From flink with 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 = SubtaskExecutionAttemptDetailsInfo.create(subtask.getCurrentExecutionAttempt(), null, graph.getJobID(), task.getJobVertexId());
			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 = SubtaskExecutionAttemptDetailsInfo.create(attempt, null, graph.getJobID(), task.getJobVertexId());
					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 #22
Source File: RestClient.java    From flink with Apache License 2.0 5 votes vote down vote up
public <M extends MessageHeaders<R, P, U>, U extends MessageParameters, R extends RequestBody, P extends ResponseBody> CompletableFuture<P> sendRequest(
		String targetAddress,
		int targetPort,
		M messageHeaders,
		U messageParameters,
		R request) throws IOException {
	return sendRequest(targetAddress, targetPort, messageHeaders, messageParameters, request, Collections.emptyList());
}
 
Example #23
Source File: RestClient.java    From flink with Apache License 2.0 5 votes vote down vote up
public <M extends MessageHeaders<R, P, U>, U extends MessageParameters, R extends RequestBody, P extends ResponseBody> CompletableFuture<P> sendRequest(
		String targetAddress,
		int targetPort,
		M messageHeaders,
		U messageParameters,
		R request) throws IOException {
	return sendRequest(targetAddress, targetPort, messageHeaders, messageParameters, request, Collections.emptyList());
}
 
Example #24
Source File: JobDetailsHandler.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public Collection<ArchivedJson> archiveJsonWithPath(AccessExecutionGraph graph) throws IOException {
	ResponseBody json = createJobDetailsInfo(graph, null);
	String path = getMessageHeaders().getTargetRestEndpointURL()
		.replace(':' + JobIDPathParameter.KEY, graph.getJobID().toString());
	return Collections.singleton(new ArchivedJson(path, json));
}
 
Example #25
Source File: JobVertexDetailsHandler.java    From flink with 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 = createJobVertexDetailsInfo(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 #26
Source File: SubtasksTimesHandler.java    From Flink-CEPplus with 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 #27
Source File: SubtaskExecutionAttemptAccumulatorsHandler.java    From flink with 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 = createAccumulatorInfo(subtask.getCurrentExecutionAttempt());
			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 = createAccumulatorInfo(attempt);
					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 #28
Source File: JobConfigHandler.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public Collection<ArchivedJson> archiveJsonWithPath(AccessExecutionGraph graph) throws IOException {
	ResponseBody json = createJobConfigInfo(graph);
	String path = getMessageHeaders().getTargetRestEndpointURL()
		.replace(':' + JobIDPathParameter.KEY, graph.getJobID().toString());
	return Collections.singleton(new ArchivedJson(path, json));
}
 
Example #29
Source File: JobVertexTaskManagersHandler.java    From flink with 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 #30
Source File: RestClusterClient.java    From flink with Apache License 2.0 5 votes vote down vote up
private <M extends MessageHeaders<R, P, U>, U extends MessageParameters, R extends RequestBody, P extends ResponseBody> CompletableFuture<P>
sendRetriableRequest(M messageHeaders, U messageParameters, R request, Collection<FileUpload> filesToUpload, Predicate<Throwable> retryPredicate) {
	return retry(() -> getWebMonitorBaseUrl().thenCompose(webMonitorBaseUrl -> {
		try {
			return restClient.sendRequest(webMonitorBaseUrl.getHost(), webMonitorBaseUrl.getPort(), messageHeaders, messageParameters, request, filesToUpload);
		} catch (IOException e) {
			throw new CompletionException(e);
		}
	}), retryPredicate);
}