Java Code Examples for org.apache.flink.runtime.clusterframework.types.ResourceID#getResourceIdString()

The following examples show how to use org.apache.flink.runtime.clusterframework.types.ResourceID#getResourceIdString() . 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: MetricQueryService.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
/**
 * Starts the MetricQueryService actor in the given actor system.
 *
 * @param actorSystem The actor system running the MetricQueryService
 * @param resourceID resource ID to disambiguate the actor name
 * @return actor reference to the MetricQueryService
 */
public static ActorRef startMetricQueryService(
	ActorSystem actorSystem,
	ResourceID resourceID,
	long maximumFramesize) {

	String actorName = resourceID == null
		? METRIC_QUERY_SERVICE_NAME
		: METRIC_QUERY_SERVICE_NAME + "_" + resourceID.getResourceIdString();

	return actorSystem.actorOf(Props.create(MetricQueryService.class, maximumFramesize), actorName);
}
 
Example 2
Source File: MetricQueryService.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Starts the MetricQueryService actor in the given actor system.
 *
 * @param rpcService The rpcService running the MetricQueryService
 * @param resourceID resource ID to disambiguate the actor name
 * @return actor reference to the MetricQueryService
 */
public static MetricQueryService createMetricQueryService(
	RpcService rpcService,
	ResourceID resourceID,
	long maximumFrameSize) {

	String endpointId = resourceID == null
		? METRIC_QUERY_SERVICE_NAME
		: METRIC_QUERY_SERVICE_NAME + "_" + resourceID.getResourceIdString();

	return new MetricQueryService(rpcService, endpointId, maximumFrameSize);
}
 
Example 3
Source File: MetricQueryService.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Starts the MetricQueryService actor in the given actor system.
 *
 * @param rpcService The rpcService running the MetricQueryService
 * @param resourceID resource ID to disambiguate the actor name
 * @return actor reference to the MetricQueryService
 */
public static MetricQueryService createMetricQueryService(
	RpcService rpcService,
	ResourceID resourceID,
	long maximumFrameSize) {

	String endpointId = resourceID == null
		? METRIC_QUERY_SERVICE_NAME
		: METRIC_QUERY_SERVICE_NAME + "_" + resourceID.getResourceIdString();

	return new MetricQueryService(rpcService, endpointId, maximumFrameSize);
}
 
Example 4
Source File: TaskManagerIdPathParameter.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Override
protected String convertToString(ResourceID value) {
	return value.getResourceIdString();
}
 
Example 5
Source File: TaskManagersFilterQueryParameter.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Override
public String convertValueToString(ResourceID value) {
	return value.getResourceIdString();
}
 
Example 6
Source File: MetricFetcherTest.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Test
public void testUpdate() {
	final Time timeout = Time.seconds(10L);

	// ========= setup TaskManager =================================================================================
	JobID jobID = new JobID();
	ResourceID tmRID = ResourceID.generate();

	// ========= setup JobManager ==================================================================================

	final String jmMetricQueryServicePath = "/jm/" + MetricQueryService.METRIC_QUERY_SERVICE_NAME;
	final String tmMetricQueryServicePath = "/tm/" + MetricQueryService.METRIC_QUERY_SERVICE_NAME + "_" + tmRID.getResourceIdString();

	final TestingRestfulGateway restfulGateway = new TestingRestfulGateway.Builder()
		.setRequestMultipleJobDetailsSupplier(() -> CompletableFuture.completedFuture(new MultipleJobsDetails(Collections.emptyList())))
		.setRequestMetricQueryServicePathsSupplier(() -> CompletableFuture.completedFuture(Collections.singleton(jmMetricQueryServicePath)))
		.setRequestTaskManagerMetricQueryServicePathsSupplier(() -> CompletableFuture.completedFuture(Collections.singleton(Tuple2.of(tmRID, tmMetricQueryServicePath))))
		.build();

	final GatewayRetriever<RestfulGateway> retriever = () -> CompletableFuture.completedFuture(restfulGateway);

	// ========= setup QueryServices ================================================================================
	final MetricQueryServiceGateway jmQueryService = new TestingMetricQueryServiceGateway.Builder()
		.setQueryMetricsSupplier(() -> CompletableFuture.completedFuture(new MetricDumpSerialization.MetricSerializationResult(new byte[0], new byte[0], new byte[0], new byte[0], 0, 0, 0, 0)))
		.build();

	MetricDumpSerialization.MetricSerializationResult requestMetricsAnswer = createRequestDumpAnswer(tmRID, jobID);
	final MetricQueryServiceGateway tmQueryService = new TestingMetricQueryServiceGateway.Builder()
		.setQueryMetricsSupplier(() -> CompletableFuture.completedFuture(requestMetricsAnswer))
		.build();

	final MetricQueryServiceRetriever queryServiceRetriever = (path) -> {
		if (path.equals(jmMetricQueryServicePath))  {
			return CompletableFuture.completedFuture(jmQueryService);
		} else if (path.equals(tmMetricQueryServicePath)) {
			return CompletableFuture.completedFuture(tmQueryService);
		} else {
			throw new IllegalArgumentException("Unexpected argument.");
		}
	};

	// ========= start MetricFetcher testing =======================================================================
	MetricFetcher fetcher = new MetricFetcherImpl<>(
		retriever,
		queryServiceRetriever,
		Executors.directExecutor(),
		timeout,
		MetricOptions.METRIC_FETCHER_UPDATE_INTERVAL.defaultValue());

	// verify that update fetches metrics and updates the store
	fetcher.update();
	MetricStore store = fetcher.getMetricStore();
	synchronized (store) {
		assertEquals("7", store.getJobManagerMetricStore().getMetric("abc.hist_min"));
		assertEquals("6", store.getJobManagerMetricStore().getMetric("abc.hist_max"));
		assertEquals("4.0", store.getJobManagerMetricStore().getMetric("abc.hist_mean"));
		assertEquals("0.5", store.getJobManagerMetricStore().getMetric("abc.hist_median"));
		assertEquals("5.0", store.getJobManagerMetricStore().getMetric("abc.hist_stddev"));
		assertEquals("0.75", store.getJobManagerMetricStore().getMetric("abc.hist_p75"));
		assertEquals("0.9", store.getJobManagerMetricStore().getMetric("abc.hist_p90"));
		assertEquals("0.95", store.getJobManagerMetricStore().getMetric("abc.hist_p95"));
		assertEquals("0.98", store.getJobManagerMetricStore().getMetric("abc.hist_p98"));
		assertEquals("0.99", store.getJobManagerMetricStore().getMetric("abc.hist_p99"));
		assertEquals("0.999", store.getJobManagerMetricStore().getMetric("abc.hist_p999"));

		assertEquals("x", store.getTaskManagerMetricStore(tmRID.toString()).metrics.get("abc.gauge"));
		assertEquals("5.0", store.getJobMetricStore(jobID.toString()).metrics.get("abc.jc"));
		assertEquals("2", store.getTaskMetricStore(jobID.toString(), "taskid").metrics.get("2.abc.tc"));
		assertEquals("1", store.getTaskMetricStore(jobID.toString(), "taskid").metrics.get("2.opname.abc.oc"));
	}
}
 
Example 7
Source File: TaskManagerIdPathParameter.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
protected String convertToString(ResourceID value) {
	return value.getResourceIdString();
}
 
Example 8
Source File: TaskManagersFilterQueryParameter.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public String convertValueToString(ResourceID value) {
	return value.getResourceIdString();
}
 
Example 9
Source File: TaskManagerIdPathParameter.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
protected String convertToString(ResourceID value) {
	return value.getResourceIdString();
}
 
Example 10
Source File: TaskManagersFilterQueryParameter.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public String convertValueToString(ResourceID value) {
	return value.getResourceIdString();
}