org.apache.flink.runtime.rest.messages.taskmanager.TaskManagerIdPathParameter Java Examples

The following examples show how to use org.apache.flink.runtime.rest.messages.taskmanager.TaskManagerIdPathParameter. 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: TaskManagerLogListHandler.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
protected CompletableFuture<LogListInfo> handleRequest(
		@Nonnull HandlerRequest<EmptyRequestBody, TaskManagerMessageParameters> request,
		@Nonnull ResourceManagerGateway gateway) throws RestHandlerException {
	final ResourceID taskManagerId = request.getPathParameter(TaskManagerIdPathParameter.class);
	final ResourceManagerGateway resourceManagerGateway = getResourceManagerGateway(resourceManagerGatewayRetriever);
	final CompletableFuture<Collection<LogInfo>> logsWithLengthFuture = resourceManagerGateway.requestTaskManagerLogList(taskManagerId, timeout);

	return logsWithLengthFuture.thenApply(LogListInfo::new).exceptionally(
		(throwable) -> {
			final Throwable strippedThrowable = ExceptionUtils.stripCompletionException(throwable);
			if (strippedThrowable instanceof UnknownTaskExecutorException) {
				throw new CompletionException(
					new RestHandlerException(
						"Could not find TaskExecutor " + taskManagerId,
						HttpResponseStatus.NOT_FOUND,
						strippedThrowable
					));
			} else {
				throw new CompletionException(throwable);
			}
		});
}
 
Example #2
Source File: TaskManagerMetricsHandler.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Nullable
@Override
protected MetricStore.ComponentMetricStore getComponentMetricStore(
		final HandlerRequest<EmptyRequestBody, TaskManagerMetricsMessageParameters> request,
		final MetricStore metricStore) {
	final ResourceID taskManagerId = request.getPathParameter(TaskManagerIdPathParameter.class);
	return metricStore.getTaskManagerMetricStore(taskManagerId.toString());
}
 
Example #3
Source File: TaskManagerLogListHandlerTest.java    From flink with Apache License 2.0 5 votes vote down vote up
private static HandlerRequest<EmptyRequestBody, TaskManagerMessageParameters> createRequest(ResourceID taskManagerId) throws HandlerRequestException {
	Map<String, String> pathParameters = new HashMap<>();
	pathParameters.put(TaskManagerIdPathParameter.KEY, taskManagerId.toString());
	Map<String, List<String>> queryParameters = Collections.emptyMap();

	return new HandlerRequest<>(
		EmptyRequestBody.getInstance(),
		new TaskManagerMessageParameters(),
		pathParameters,
		queryParameters);
}
 
Example #4
Source File: AbstractTaskManagerFileHandlerTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void setup() throws IOException, HandlerRequestException {
	final Configuration configuration = new Configuration();
	configuration.setString(BlobServerOptions.STORAGE_DIRECTORY, temporaryFolder.newFolder().getAbsolutePath());

	blobServer = new BlobServer(configuration, new VoidBlobStore());

	handlerRequest = new HandlerRequest<>(
		EmptyRequestBody.getInstance(),
		new TaskManagerMessageParameters(),
		Collections.singletonMap(TaskManagerIdPathParameter.KEY, EXPECTED_TASK_MANAGER_ID.getResourceIdString()),
		Collections.emptyMap());
}
 
Example #5
Source File: AbstractTaskManagerFileHandlerTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void setup() throws IOException, HandlerRequestException {
	final Configuration configuration = new Configuration();
	configuration.setString(BlobServerOptions.STORAGE_DIRECTORY, temporaryFolder.newFolder().getAbsolutePath());

	blobServer = new BlobServer(configuration, new VoidBlobStore());

	handlerRequest = new HandlerRequest<>(
		EmptyRequestBody.getInstance(),
		new TaskManagerFileMessageParameters(),
		Collections.singletonMap(TaskManagerIdPathParameter.KEY, EXPECTED_TASK_MANAGER_ID.getResourceIdString()),
		Collections.emptyMap());
}
 
Example #6
Source File: TaskManagerMetricsHandler.java    From flink with Apache License 2.0 5 votes vote down vote up
@Nullable
@Override
protected MetricStore.ComponentMetricStore getComponentMetricStore(
		final HandlerRequest<EmptyRequestBody, TaskManagerMetricsMessageParameters> request,
		final MetricStore metricStore) {
	final ResourceID taskManagerId = request.getPathParameter(TaskManagerIdPathParameter.class);
	return metricStore.getTaskManagerMetricStore(taskManagerId.toString());
}
 
Example #7
Source File: TaskManagerMetricsHandler.java    From flink with Apache License 2.0 5 votes vote down vote up
@Nullable
@Override
protected MetricStore.ComponentMetricStore getComponentMetricStore(
		final HandlerRequest<EmptyRequestBody, TaskManagerMetricsMessageParameters> request,
		final MetricStore metricStore) {
	final ResourceID taskManagerId = request.getPathParameter(TaskManagerIdPathParameter.class);
	return metricStore.getTaskManagerMetricStore(taskManagerId.toString());
}
 
Example #8
Source File: AbstractTaskManagerFileHandlerTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void setup() throws IOException, HandlerRequestException {
	final Configuration configuration = new Configuration();
	configuration.setString(BlobServerOptions.STORAGE_DIRECTORY, temporaryFolder.newFolder().getAbsolutePath());

	blobServer = new BlobServer(configuration, new VoidBlobStore());

	handlerRequest = new HandlerRequest<>(
		EmptyRequestBody.getInstance(),
		new TaskManagerMessageParameters(),
		Collections.singletonMap(TaskManagerIdPathParameter.KEY, EXPECTED_TASK_MANAGER_ID.getResourceIdString()),
		Collections.emptyMap());
}
 
Example #9
Source File: TaskManagerThreadDumpHandler.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
protected CompletableFuture<ThreadDumpInfo> handleRequest(
		@Nonnull HandlerRequest<EmptyRequestBody, TaskManagerMessageParameters> request,
		@Nonnull ResourceManagerGateway gateway) throws RestHandlerException {
	final ResourceID taskManagerId = request.getPathParameter(TaskManagerIdPathParameter.class);
	return gateway.requestThreadDump(taskManagerId, timeout);
}
 
Example #10
Source File: TaskManagerMetricsHandlerTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
Map<String, String> getPathParameters() {
	return Collections.singletonMap(TaskManagerIdPathParameter.KEY, TEST_TASK_MANAGER_ID);
}
 
Example #11
Source File: TaskManagerMetricsHeaders.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Override
public String getTargetRestEndpointURL() {
	return "/taskmanagers/:" + TaskManagerIdPathParameter.KEY + "/metrics";
}
 
Example #12
Source File: TaskManagerMetricsHeadersTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@Test
public void testUrl() {
	assertThat(taskManagerMetricsHeaders.getTargetRestEndpointURL(),
		equalTo("/taskmanagers/:" + TaskManagerIdPathParameter.KEY + "/metrics"));
}
 
Example #13
Source File: TaskManagerDetailsHandler.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
protected CompletableFuture<TaskManagerDetailsInfo> handleRequest(
		@Nonnull HandlerRequest<EmptyRequestBody, TaskManagerMessageParameters> request,
		@Nonnull ResourceManagerGateway gateway) throws RestHandlerException {
	final ResourceID taskManagerResourceId = request.getPathParameter(TaskManagerIdPathParameter
		.class);

	CompletableFuture<TaskManagerInfo> taskManagerInfoFuture = gateway.requestTaskManagerInfo(taskManagerResourceId, timeout);

	metricFetcher.update();

	return taskManagerInfoFuture.thenApply(
		(TaskManagerInfo taskManagerInfo) -> {
			final MetricStore.TaskManagerMetricStore tmMetrics =
				metricStore.getTaskManagerMetricStore(taskManagerResourceId.getResourceIdString());

			final TaskManagerMetricsInfo taskManagerMetricsInfo;

			if (tmMetrics != null) {
				log.debug("Create metrics info for TaskManager {}.", taskManagerResourceId);
				taskManagerMetricsInfo = createTaskManagerMetricsInfo(tmMetrics);
			} else {
				log.debug("No metrics for TaskManager {}.", taskManagerResourceId);
				taskManagerMetricsInfo = TaskManagerMetricsInfo.empty();
			}

			return new TaskManagerDetailsInfo(
				taskManagerInfo,
				taskManagerMetricsInfo);
		})
		.exceptionally(
			(Throwable throwable) -> {
				final Throwable strippedThrowable = ExceptionUtils.stripExecutionException(throwable);

				if (strippedThrowable instanceof UnknownTaskExecutorException) {
					throw new CompletionException(
						new RestHandlerException(
							"Could not find TaskExecutor " + taskManagerResourceId + '.',
							HttpResponseStatus.NOT_FOUND,
							strippedThrowable));
				} else {
					throw new CompletionException(strippedThrowable);
				}
			}
		);
}
 
Example #14
Source File: TaskManagerMetricsHeaders.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public String getTargetRestEndpointURL() {
	return "/taskmanagers/:" + TaskManagerIdPathParameter.KEY + "/metrics";
}
 
Example #15
Source File: TaskManagerMetricsHandlerTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
Map<String, String> getPathParameters() {
	return Collections.singletonMap(TaskManagerIdPathParameter.KEY, TEST_TASK_MANAGER_ID);
}
 
Example #16
Source File: TaskManagerMetricsHeadersTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@Test
public void testUrl() {
	assertThat(taskManagerMetricsHeaders.getTargetRestEndpointURL(),
		equalTo("/taskmanagers/:" + TaskManagerIdPathParameter.KEY + "/metrics"));
}
 
Example #17
Source File: TaskManagerDetailsHandler.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
protected CompletableFuture<TaskManagerDetailsInfo> handleRequest(
		@Nonnull HandlerRequest<EmptyRequestBody, TaskManagerMessageParameters> request,
		@Nonnull ResourceManagerGateway gateway) throws RestHandlerException {
	final ResourceID taskManagerResourceId = request.getPathParameter(TaskManagerIdPathParameter
		.class);

	CompletableFuture<TaskManagerInfo> taskManagerInfoFuture = gateway.requestTaskManagerInfo(taskManagerResourceId, timeout);

	metricFetcher.update();

	return taskManagerInfoFuture.thenApply(
		(TaskManagerInfo taskManagerInfo) -> {
			final MetricStore.TaskManagerMetricStore tmMetrics =
				metricStore.getTaskManagerMetricStore(taskManagerResourceId.getResourceIdString());

			final TaskManagerMetricsInfo taskManagerMetricsInfo;

			if (tmMetrics != null) {
				log.debug("Create metrics info for TaskManager {}.", taskManagerResourceId);
				taskManagerMetricsInfo = createTaskManagerMetricsInfo(tmMetrics);
			} else {
				log.debug("No metrics for TaskManager {}.", taskManagerResourceId);
				taskManagerMetricsInfo = TaskManagerMetricsInfo.empty();
			}

			return new TaskManagerDetailsInfo(
				taskManagerInfo,
				taskManagerMetricsInfo);
		})
		.exceptionally(
			(Throwable throwable) -> {
				final Throwable strippedThrowable = ExceptionUtils.stripExecutionException(throwable);

				if (strippedThrowable instanceof UnknownTaskExecutorException) {
					throw new CompletionException(
						new RestHandlerException(
							"Could not find TaskExecutor " + taskManagerResourceId + '.',
							HttpResponseStatus.NOT_FOUND,
							strippedThrowable));
				} else {
					throw new CompletionException(strippedThrowable);
				}
			}
		);
}
 
Example #18
Source File: TaskManagerMetricsHeaders.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public String getTargetRestEndpointURL() {
	return "/taskmanagers/:" + TaskManagerIdPathParameter.KEY + "/metrics";
}
 
Example #19
Source File: TaskManagerMetricsHandlerTest.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Override
Map<String, String> getPathParameters() {
	return Collections.singletonMap(TaskManagerIdPathParameter.KEY, TEST_TASK_MANAGER_ID);
}
 
Example #20
Source File: TaskManagerMetricsHeadersTest.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Test
public void testUrl() {
	assertThat(taskManagerMetricsHeaders.getTargetRestEndpointURL(),
		equalTo("/taskmanagers/:" + TaskManagerIdPathParameter.KEY + "/metrics"));
}
 
Example #21
Source File: TaskManagerDetailsHandler.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Override
protected CompletableFuture<TaskManagerDetailsInfo> handleRequest(
		@Nonnull HandlerRequest<EmptyRequestBody, TaskManagerMessageParameters> request,
		@Nonnull ResourceManagerGateway gateway) throws RestHandlerException {
	final ResourceID taskManagerResourceId = request.getPathParameter(TaskManagerIdPathParameter
		.class);

	CompletableFuture<TaskManagerInfo> taskManagerInfoFuture = gateway.requestTaskManagerInfo(taskManagerResourceId, timeout);

	metricFetcher.update();

	return taskManagerInfoFuture.thenApply(
		(TaskManagerInfo taskManagerInfo) -> {
			final MetricStore.TaskManagerMetricStore tmMetrics =
				metricStore.getTaskManagerMetricStore(taskManagerResourceId.getResourceIdString());

			final TaskManagerMetricsInfo taskManagerMetricsInfo;

			if (tmMetrics != null) {
				log.debug("Create metrics info for TaskManager {}.", taskManagerResourceId);
				taskManagerMetricsInfo = createTaskManagerMetricsInfo(tmMetrics);
			} else {
				log.debug("No metrics for TaskManager {}.", taskManagerResourceId);
				taskManagerMetricsInfo = TaskManagerMetricsInfo.empty();
			}

			return new TaskManagerDetailsInfo(
				taskManagerInfo,
				taskManagerMetricsInfo);
		})
		.exceptionally(
			(Throwable throwable) -> {
				final Throwable strippedThrowable = ExceptionUtils.stripExecutionException(throwable);

				if (strippedThrowable instanceof UnknownTaskExecutorException) {
					throw new CompletionException(
						new RestHandlerException(
							"Could not find TaskExecutor " + taskManagerResourceId + '.',
							HttpResponseStatus.NOT_FOUND,
							strippedThrowable));
				} else {
					throw new CompletionException(strippedThrowable);
				}
			}
		);
}