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

The following examples show how to use org.apache.flink.runtime.rest.messages.taskmanager.TaskManagerMetricsInfo. 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: TaskManagerDetailsHandler.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
private static List<TaskManagerMetricsInfo.GarbageCollectorInfo> createGarbageCollectorInfo(MetricStore.TaskManagerMetricStore taskManagerMetricStore) {
	Preconditions.checkNotNull(taskManagerMetricStore);

	ArrayList<TaskManagerMetricsInfo.GarbageCollectorInfo> garbageCollectorInfos = new ArrayList<>(taskManagerMetricStore.garbageCollectorNames.size());

	for (String garbageCollectorName: taskManagerMetricStore.garbageCollectorNames) {
		final String count = taskManagerMetricStore.getMetric("Status.JVM.GarbageCollector." + garbageCollectorName + ".Count", null);
		final String time = taskManagerMetricStore.getMetric("Status.JVM.GarbageCollector." + garbageCollectorName + ".Time", null);

		if (count != null && time != null) {
			garbageCollectorInfos.add(
				new TaskManagerMetricsInfo.GarbageCollectorInfo(
					garbageCollectorName,
					Long.valueOf(count),
					Long.valueOf(time)));
		}
	}

	return garbageCollectorInfos;
}
 
Example #2
Source File: TaskManagerDetailsHandler.java    From flink with Apache License 2.0 6 votes vote down vote up
private static List<TaskManagerMetricsInfo.GarbageCollectorInfo> createGarbageCollectorInfo(MetricStore.TaskManagerMetricStore taskManagerMetricStore) {
	Preconditions.checkNotNull(taskManagerMetricStore);

	ArrayList<TaskManagerMetricsInfo.GarbageCollectorInfo> garbageCollectorInfos = new ArrayList<>(taskManagerMetricStore.garbageCollectorNames.size());

	for (String garbageCollectorName: taskManagerMetricStore.garbageCollectorNames) {
		final String count = taskManagerMetricStore.getMetric("Status.JVM.GarbageCollector." + garbageCollectorName + ".Count", null);
		final String time = taskManagerMetricStore.getMetric("Status.JVM.GarbageCollector." + garbageCollectorName + ".Time", null);

		if (count != null && time != null) {
			garbageCollectorInfos.add(
				new TaskManagerMetricsInfo.GarbageCollectorInfo(
					garbageCollectorName,
					Long.valueOf(count),
					Long.valueOf(time)));
		}
	}

	return garbageCollectorInfos;
}
 
Example #3
Source File: TaskManagerDetailsHandler.java    From flink with Apache License 2.0 6 votes vote down vote up
private static List<TaskManagerMetricsInfo.GarbageCollectorInfo> createGarbageCollectorInfo(MetricStore.TaskManagerMetricStore taskManagerMetricStore) {
	Preconditions.checkNotNull(taskManagerMetricStore);

	ArrayList<TaskManagerMetricsInfo.GarbageCollectorInfo> garbageCollectorInfos = new ArrayList<>(taskManagerMetricStore.garbageCollectorNames.size());

	for (String garbageCollectorName: taskManagerMetricStore.garbageCollectorNames) {
		final String count = taskManagerMetricStore.getMetric("Status.JVM.GarbageCollector." + garbageCollectorName + ".Count", null);
		final String time = taskManagerMetricStore.getMetric("Status.JVM.GarbageCollector." + garbageCollectorName + ".Time", null);

		if (count != null && time != null) {
			garbageCollectorInfos.add(
				new TaskManagerMetricsInfo.GarbageCollectorInfo(
					garbageCollectorName,
					Long.valueOf(count),
					Long.valueOf(time)));
		}
	}

	return garbageCollectorInfos;
}
 
Example #4
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);
				}
			}
		);
}
 
Example #5
Source File: TaskManagerDetailsHandler.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
private static TaskManagerMetricsInfo createTaskManagerMetricsInfo(MetricStore.TaskManagerMetricStore tmMetrics) {

		Preconditions.checkNotNull(tmMetrics);

		long heapUsed = Long.valueOf(tmMetrics.getMetric("Status.JVM.Memory.Heap.Used", "0"));
		long heapCommitted = Long.valueOf(tmMetrics.getMetric("Status.JVM.Memory.Heap.Committed", "0"));
		long heapTotal = Long.valueOf(tmMetrics.getMetric("Status.JVM.Memory.Heap.Max", "0"));

		long nonHeapUsed = Long.valueOf(tmMetrics.getMetric("Status.JVM.Memory.NonHeap.Used", "0"));
		long nonHeapCommitted = Long.valueOf(tmMetrics.getMetric("Status.JVM.Memory.NonHeap.Committed", "0"));
		long nonHeapTotal = Long.valueOf(tmMetrics.getMetric("Status.JVM.Memory.NonHeap.Max", "0"));

		long directCount = Long.valueOf(tmMetrics.getMetric("Status.JVM.Memory.Direct.Count", "0"));
		long directUsed = Long.valueOf(tmMetrics.getMetric("Status.JVM.Memory.Direct.MemoryUsed", "0"));
		long directMax = Long.valueOf(tmMetrics.getMetric("Status.JVM.Memory.Direct.TotalCapacity", "0"));

		long mappedCount = Long.valueOf(tmMetrics.getMetric("Status.JVM.Memory.Mapped.Count", "0"));
		long mappedUsed = Long.valueOf(tmMetrics.getMetric("Status.JVM.Memory.Mapped.MemoryUsed", "0"));
		long mappedMax = Long.valueOf(tmMetrics.getMetric("Status.JVM.Memory.Mapped.TotalCapacity", "0"));

		long memorySegmentsAvailable = Long.valueOf(tmMetrics.getMetric("Status.Network.AvailableMemorySegments", "0"));
		long memorySegmentsTotal = Long.valueOf(tmMetrics.getMetric("Status.Network.TotalMemorySegments", "0"));

		final List<TaskManagerMetricsInfo.GarbageCollectorInfo> garbageCollectorInfo = createGarbageCollectorInfo(tmMetrics);

		return new TaskManagerMetricsInfo(
			heapUsed,
			heapCommitted,
			heapTotal,
			nonHeapUsed,
			nonHeapCommitted,
			nonHeapTotal,
			directCount,
			directUsed,
			directMax,
			mappedCount,
			mappedUsed,
			mappedMax,
			memorySegmentsAvailable,
			memorySegmentsTotal,
			garbageCollectorInfo);
	}
 
Example #6
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 #7
Source File: TaskManagerDetailsHandler.java    From flink with Apache License 2.0 4 votes vote down vote up
private static TaskManagerMetricsInfo createTaskManagerMetricsInfo(MetricStore.TaskManagerMetricStore tmMetrics) {

		Preconditions.checkNotNull(tmMetrics);

		long heapUsed = Long.valueOf(tmMetrics.getMetric("Status.JVM.Memory.Heap.Used", "0"));
		long heapCommitted = Long.valueOf(tmMetrics.getMetric("Status.JVM.Memory.Heap.Committed", "0"));
		long heapTotal = Long.valueOf(tmMetrics.getMetric("Status.JVM.Memory.Heap.Max", "0"));

		long nonHeapUsed = Long.valueOf(tmMetrics.getMetric("Status.JVM.Memory.NonHeap.Used", "0"));
		long nonHeapCommitted = Long.valueOf(tmMetrics.getMetric("Status.JVM.Memory.NonHeap.Committed", "0"));
		long nonHeapTotal = Long.valueOf(tmMetrics.getMetric("Status.JVM.Memory.NonHeap.Max", "0"));

		long directCount = Long.valueOf(tmMetrics.getMetric("Status.JVM.Memory.Direct.Count", "0"));
		long directUsed = Long.valueOf(tmMetrics.getMetric("Status.JVM.Memory.Direct.MemoryUsed", "0"));
		long directMax = Long.valueOf(tmMetrics.getMetric("Status.JVM.Memory.Direct.TotalCapacity", "0"));

		long mappedCount = Long.valueOf(tmMetrics.getMetric("Status.JVM.Memory.Mapped.Count", "0"));
		long mappedUsed = Long.valueOf(tmMetrics.getMetric("Status.JVM.Memory.Mapped.MemoryUsed", "0"));
		long mappedMax = Long.valueOf(tmMetrics.getMetric("Status.JVM.Memory.Mapped.TotalCapacity", "0"));

		long memorySegmentsAvailable = Long.valueOf(tmMetrics.getMetric("Status.Network.AvailableMemorySegments", "0"));
		long memorySegmentsTotal = Long.valueOf(tmMetrics.getMetric("Status.Network.TotalMemorySegments", "0"));

		final List<TaskManagerMetricsInfo.GarbageCollectorInfo> garbageCollectorInfo = createGarbageCollectorInfo(tmMetrics);

		return new TaskManagerMetricsInfo(
			heapUsed,
			heapCommitted,
			heapTotal,
			nonHeapUsed,
			nonHeapCommitted,
			nonHeapTotal,
			directCount,
			directUsed,
			directMax,
			mappedCount,
			mappedUsed,
			mappedMax,
			memorySegmentsAvailable,
			memorySegmentsTotal,
			garbageCollectorInfo);
	}
 
Example #8
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 #9
Source File: TaskManagerDetailsHandler.java    From flink with Apache License 2.0 4 votes vote down vote up
private static TaskManagerMetricsInfo createTaskManagerMetricsInfo(MetricStore.TaskManagerMetricStore tmMetrics) {

		Preconditions.checkNotNull(tmMetrics);

		long heapUsed = Long.valueOf(tmMetrics.getMetric("Status.JVM.Memory.Heap.Used", "0"));
		long heapCommitted = Long.valueOf(tmMetrics.getMetric("Status.JVM.Memory.Heap.Committed", "0"));
		long heapTotal = Long.valueOf(tmMetrics.getMetric("Status.JVM.Memory.Heap.Max", "0"));

		long nonHeapUsed = Long.valueOf(tmMetrics.getMetric("Status.JVM.Memory.NonHeap.Used", "0"));
		long nonHeapCommitted = Long.valueOf(tmMetrics.getMetric("Status.JVM.Memory.NonHeap.Committed", "0"));
		long nonHeapTotal = Long.valueOf(tmMetrics.getMetric("Status.JVM.Memory.NonHeap.Max", "0"));

		long directCount = Long.valueOf(tmMetrics.getMetric("Status.JVM.Memory.Direct.Count", "0"));
		long directUsed = Long.valueOf(tmMetrics.getMetric("Status.JVM.Memory.Direct.MemoryUsed", "0"));
		long directMax = Long.valueOf(tmMetrics.getMetric("Status.JVM.Memory.Direct.TotalCapacity", "0"));

		long mappedCount = Long.valueOf(tmMetrics.getMetric("Status.JVM.Memory.Mapped.Count", "0"));
		long mappedUsed = Long.valueOf(tmMetrics.getMetric("Status.JVM.Memory.Mapped.MemoryUsed", "0"));
		long mappedMax = Long.valueOf(tmMetrics.getMetric("Status.JVM.Memory.Mapped.TotalCapacity", "0"));

		long memorySegmentsAvailable = Long.valueOf(tmMetrics.getMetric("Status.Network.AvailableMemorySegments", "0"));
		long memorySegmentsTotal = Long.valueOf(tmMetrics.getMetric("Status.Network.TotalMemorySegments", "0"));

		final List<TaskManagerMetricsInfo.GarbageCollectorInfo> garbageCollectorInfo = createGarbageCollectorInfo(tmMetrics);

		return new TaskManagerMetricsInfo(
			heapUsed,
			heapCommitted,
			heapTotal,
			nonHeapUsed,
			nonHeapCommitted,
			nonHeapTotal,
			directCount,
			directUsed,
			directMax,
			mappedCount,
			mappedUsed,
			mappedMax,
			memorySegmentsAvailable,
			memorySegmentsTotal,
			garbageCollectorInfo);
	}