Java Code Examples for org.apache.flink.runtime.metrics.groups.UnregisteredMetricGroups#createUnregisteredOperatorMetricGroup()

The following examples show how to use org.apache.flink.runtime.metrics.groups.UnregisteredMetricGroups#createUnregisteredOperatorMetricGroup() . 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: LatencyStatsTest.java    From flink with Apache License 2.0 6 votes vote down vote up
private static void testLatencyStats(
	final LatencyStats.Granularity granularity,
	final Consumer<List<Tuple2<String, Histogram>>> verifier) {

	final AbstractMetricGroup<?> dummyGroup = UnregisteredMetricGroups.createUnregisteredOperatorMetricGroup();
	final TestMetricRegistry registry = new TestMetricRegistry();
	final MetricGroup parentGroup = new GenericMetricGroup(registry, dummyGroup, PARENT_GROUP_NAME);

	final LatencyStats latencyStats = new LatencyStats(
		parentGroup,
		MetricOptions.LATENCY_HISTORY_SIZE.defaultValue(),
		OPERATOR_SUBTASK_INDEX,
		OPERATOR_ID,
		granularity);

	latencyStats.reportLatency(new LatencyMarker(0L, SOURCE_ID_1, 0));
	latencyStats.reportLatency(new LatencyMarker(0L, SOURCE_ID_1, 0));
	latencyStats.reportLatency(new LatencyMarker(0L, SOURCE_ID_1, 1));
	latencyStats.reportLatency(new LatencyMarker(0L, SOURCE_ID_2, 2));
	latencyStats.reportLatency(new LatencyMarker(0L, SOURCE_ID_2, 3));

	verifier.accept(registry.latencyHistograms);
}
 
Example 2
Source File: TestingSourceOperator.java    From flink with Apache License 2.0 6 votes vote down vote up
public TestingSourceOperator(
		SourceReader<T, MockSourceSplit> reader,
		WatermarkStrategy<T> watermarkStrategy,
		ProcessingTimeService timeService,
		OperatorEventGateway eventGateway,
		int subtaskIndex,
		int parallelism) {

	super(
		(context) -> reader,
		eventGateway,
		new MockSourceSplitSerializer(),
		watermarkStrategy,
		timeService);

	this.subtaskIndex = subtaskIndex;
	this.parallelism = parallelism;
	this.metrics = UnregisteredMetricGroups.createUnregisteredOperatorMetricGroup();
}
 
Example 3
Source File: LatencyStatsTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
private static void testLatencyStats(
	final LatencyStats.Granularity granularity,
	final Consumer<List<Tuple2<String, Histogram>>> verifier) {

	final AbstractMetricGroup<?> dummyGroup = UnregisteredMetricGroups.createUnregisteredOperatorMetricGroup();
	final TestMetricRegistry registry = new TestMetricRegistry();
	final MetricGroup parentGroup = new GenericMetricGroup(registry, dummyGroup, PARENT_GROUP_NAME);

	final LatencyStats latencyStats = new LatencyStats(
		parentGroup,
		MetricOptions.LATENCY_HISTORY_SIZE.defaultValue(),
		OPERATOR_SUBTASK_INDEX,
		OPERATOR_ID,
		granularity);

	latencyStats.reportLatency(new LatencyMarker(0L, SOURCE_ID_1, 0));
	latencyStats.reportLatency(new LatencyMarker(0L, SOURCE_ID_1, 0));
	latencyStats.reportLatency(new LatencyMarker(0L, SOURCE_ID_1, 1));
	latencyStats.reportLatency(new LatencyMarker(0L, SOURCE_ID_2, 2));
	latencyStats.reportLatency(new LatencyMarker(0L, SOURCE_ID_2, 3));

	verifier.accept(registry.latencyHistograms);
}
 
Example 4
Source File: LatencyStatsTest.java    From flink with Apache License 2.0 6 votes vote down vote up
private static void testLatencyStats(
	final LatencyStats.Granularity granularity,
	final Consumer<List<Tuple2<String, Histogram>>> verifier) {

	final AbstractMetricGroup<?> dummyGroup = UnregisteredMetricGroups.createUnregisteredOperatorMetricGroup();
	final TestMetricRegistry registry = new TestMetricRegistry();
	final MetricGroup parentGroup = new GenericMetricGroup(registry, dummyGroup, PARENT_GROUP_NAME);

	final LatencyStats latencyStats = new LatencyStats(
		parentGroup,
		MetricOptions.LATENCY_HISTORY_SIZE.defaultValue(),
		OPERATOR_SUBTASK_INDEX,
		OPERATOR_ID,
		granularity);

	latencyStats.reportLatency(new LatencyMarker(0L, SOURCE_ID_1, 0));
	latencyStats.reportLatency(new LatencyMarker(0L, SOURCE_ID_1, 0));
	latencyStats.reportLatency(new LatencyMarker(0L, SOURCE_ID_1, 1));
	latencyStats.reportLatency(new LatencyMarker(0L, SOURCE_ID_2, 2));
	latencyStats.reportLatency(new LatencyMarker(0L, SOURCE_ID_2, 3));

	verifier.accept(registry.latencyHistograms);
}
 
Example 5
Source File: BinaryOperatorTestBase.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public OperatorMetricGroup getMetricGroup() {
	return UnregisteredMetricGroups.createUnregisteredOperatorMetricGroup();
}
 
Example 6
Source File: AbstractStreamOperatorV2.java    From flink with Apache License 2.0 4 votes vote down vote up
public AbstractStreamOperatorV2(StreamOperatorParameters<OUT> parameters, int numberOfInputs) {
	inputWatermarks = new long[numberOfInputs];
	Arrays.fill(inputWatermarks, Long.MIN_VALUE);
	final Environment environment = parameters.getContainingTask().getEnvironment();
	config = parameters.getStreamConfig();
	CountingOutput<OUT> countingOutput;
	OperatorMetricGroup operatorMetricGroup;
	try {
		operatorMetricGroup = environment.getMetricGroup().getOrAddOperator(config.getOperatorID(), config.getOperatorName());
		countingOutput = new CountingOutput(parameters.getOutput(), operatorMetricGroup.getIOMetricGroup().getNumRecordsOutCounter());
		if (config.isChainStart()) {
			operatorMetricGroup.getIOMetricGroup().reuseInputMetricsForTask();
		}
		if (config.isChainEnd()) {
			operatorMetricGroup.getIOMetricGroup().reuseOutputMetricsForTask();
		}
	} catch (Exception e) {
		LOG.warn("An error occurred while instantiating task metrics.", e);
		countingOutput = null;
		operatorMetricGroup = null;
	}

	if (countingOutput == null || operatorMetricGroup == null) {
		metrics = UnregisteredMetricGroups.createUnregisteredOperatorMetricGroup();
		output = parameters.getOutput();
	}
	else {
		metrics = operatorMetricGroup;
		output = countingOutput;
	}

	latencyStats = createLatencyStats(
		environment.getTaskManagerInfo().getConfiguration(),
		parameters.getContainingTask().getIndexInSubtaskGroup());

	processingTimeService = Preconditions.checkNotNull(parameters.getProcessingTimeService());
	executionConfig = parameters.getContainingTask().getExecutionConfig();
	userCodeClassLoader = parameters.getContainingTask().getUserCodeClassLoader();
	cancelables = parameters.getContainingTask().getCancelables();

	runtimeContext = new StreamingRuntimeContext(
		environment,
		environment.getAccumulatorRegistry().getUserMap(),
		operatorMetricGroup,
		getOperatorID(),
		processingTimeService,
		null,
		environment.getExternalResourceInfoProvider());
}
 
Example 7
Source File: BinaryOperatorTestBase.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public OperatorMetricGroup getMetricGroup() {
	return UnregisteredMetricGroups.createUnregisteredOperatorMetricGroup();
}
 
Example 8
Source File: UnaryOperatorTestBase.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public OperatorMetricGroup getMetricGroup() {
	return UnregisteredMetricGroups.createUnregisteredOperatorMetricGroup();
}
 
Example 9
Source File: DriverTestBase.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public OperatorMetricGroup getMetricGroup() {
	return UnregisteredMetricGroups.createUnregisteredOperatorMetricGroup();
}
 
Example 10
Source File: TestTaskContext.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public OperatorMetricGroup getMetricGroup() {
	return UnregisteredMetricGroups.createUnregisteredOperatorMetricGroup();
}
 
Example 11
Source File: TestTaskContext.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Override
public OperatorMetricGroup getMetricGroup() {
	return UnregisteredMetricGroups.createUnregisteredOperatorMetricGroup();
}
 
Example 12
Source File: UnaryOperatorTestBase.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public OperatorMetricGroup getMetricGroup() {
	return UnregisteredMetricGroups.createUnregisteredOperatorMetricGroup();
}
 
Example 13
Source File: DriverTestBase.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public OperatorMetricGroup getMetricGroup() {
	return UnregisteredMetricGroups.createUnregisteredOperatorMetricGroup();
}
 
Example 14
Source File: TestTaskContext.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public OperatorMetricGroup getMetricGroup() {
	return UnregisteredMetricGroups.createUnregisteredOperatorMetricGroup();
}
 
Example 15
Source File: BinaryOperatorTestBase.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Override
public OperatorMetricGroup getMetricGroup() {
	return UnregisteredMetricGroups.createUnregisteredOperatorMetricGroup();
}
 
Example 16
Source File: UnaryOperatorTestBase.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Override
public OperatorMetricGroup getMetricGroup() {
	return UnregisteredMetricGroups.createUnregisteredOperatorMetricGroup();
}
 
Example 17
Source File: DriverTestBase.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Override
public OperatorMetricGroup getMetricGroup() {
	return UnregisteredMetricGroups.createUnregisteredOperatorMetricGroup();
}