org.apache.flink.metrics.CharacterFilter Java Examples

The following examples show how to use org.apache.flink.metrics.CharacterFilter. 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: AbstractMetricGroup.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the fully qualified metric name using the configured delimiter for the reporter with the given index, for example
 * {@code "host-7.taskmanager-2.window_word_count.my-mapper.metricName"}.
 *
 * @param metricName metric name
 * @param filter character filter which is applied to the scope components if not null.
 * @param reporterIndex index of the reporter whose delimiter should be used
 * @param delimiter delimiter to use
 * @return fully qualified metric name
 */
public String getMetricIdentifier(String metricName, CharacterFilter filter, int reporterIndex, char delimiter) {
	if (scopeStrings.length == 0 || (reporterIndex < 0 || reporterIndex >= scopeStrings.length)) {
		String newScopeString;
		if (filter != null) {
			newScopeString = ScopeFormat.concat(filter, delimiter, scopeComponents);
			metricName = filter.filterCharacters(metricName);
		} else {
			newScopeString = ScopeFormat.concat(delimiter, scopeComponents);
		}
		return newScopeString + delimiter + metricName;
	} else {
		if (scopeStrings[reporterIndex] == null) {
			if (filter != null) {
				scopeStrings[reporterIndex] = ScopeFormat.concat(filter, delimiter, scopeComponents);
			} else {
				scopeStrings[reporterIndex] = ScopeFormat.concat(delimiter, scopeComponents);
			}
		}
		if (filter != null) {
			metricName = filter.filterCharacters(metricName);
		}
		return scopeStrings[reporterIndex] + delimiter + metricName;
	}
}
 
Example #2
Source File: OperatorMetricGroup.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
protected QueryScopeInfo.OperatorQueryScopeInfo createQueryServiceMetricInfo(CharacterFilter filter) {
	return new QueryScopeInfo.OperatorQueryScopeInfo(
		this.parent.parent.jobId.toString(),
		this.parent.vertexId.toString(),
		this.parent.subtaskIndex,
		filter.filterCharacters(this.operatorName));
}
 
Example #3
Source File: AbstractMetricGroup.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the logical scope of this group, for example
 * {@code "taskmanager.job.task"}.
 *
 * @param filter character filter which is applied to the scope components
 * @param delimiter delimiter to use for concatenating scope components
 * @param reporterIndex index of the reporter
 * @return logical scope
 */
String getLogicalScope(CharacterFilter filter, char delimiter, int reporterIndex) {
	if (logicalScopeStrings.length == 0 || (reporterIndex < 0 || reporterIndex >= logicalScopeStrings.length)) {
		return createLogicalScope(filter, delimiter);
	} else {
		if (logicalScopeStrings[reporterIndex] == null) {
			logicalScopeStrings[reporterIndex] = createLogicalScope(filter, delimiter);
		}
		return logicalScopeStrings[reporterIndex];
	}
}
 
Example #4
Source File: AbstractMetricGroup.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the logical scope of this group, for example
 * {@code "taskmanager.job.task"}.
 *
 * @param filter character filter which is applied to the scope components
 * @param delimiter delimiter to use for concatenating scope components
 * @param reporterIndex index of the reporter
 * @return logical scope
 */
String getLogicalScope(CharacterFilter filter, char delimiter, int reporterIndex) {
	if (logicalScopeStrings.length == 0 || (reporterIndex < 0 || reporterIndex >= logicalScopeStrings.length)) {
		return createLogicalScope(filter, delimiter);
	} else {
		if (logicalScopeStrings[reporterIndex] == null) {
			logicalScopeStrings[reporterIndex] = createLogicalScope(filter, delimiter);
		}
		return logicalScopeStrings[reporterIndex];
	}
}
 
Example #5
Source File: AbstractMetricGroup.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the metric query service scope for this group.
 *
 * @param filter character filter
 * @return query service scope
    */
public QueryScopeInfo getQueryServiceMetricInfo(CharacterFilter filter) {
	if (queryServiceScopeInfo == null) {
		queryServiceScopeInfo = createQueryServiceMetricInfo(filter);
	}
	return queryServiceScopeInfo;
}
 
Example #6
Source File: AbstractMetricGroup.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the metric query service scope for this group.
 *
 * @param filter character filter
 * @return query service scope
    */
public QueryScopeInfo getQueryServiceMetricInfo(CharacterFilter filter) {
	if (queryServiceScopeInfo == null) {
		queryServiceScopeInfo = createQueryServiceMetricInfo(filter);
	}
	return queryServiceScopeInfo;
}
 
Example #7
Source File: ScopeFormat.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Concatenates the given component names separated by the delimiter character. Additionally
 * the character filter is applied to all component names.
 *
 * @param filter Character filter to be applied to the component names
 * @param delimiter Delimiter to separate component names
 * @param components Array of component names
 * @return The concatenated component name
 */
public static String concat(CharacterFilter filter, Character delimiter, String... components) {
	StringBuilder sb = new StringBuilder();
	sb.append(filter.filterCharacters(components[0]));
	for (int x = 1; x < components.length; x++) {
		sb.append(delimiter);
		sb.append(filter.filterCharacters(components[x]));
	}
	return sb.toString();
}
 
Example #8
Source File: AbstractMetricGroupTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public void checkScopes(Metric metric, String metricName, MetricGroup group) {
	// the first call determines which filter is applied to all future calls; in this case no filter is used at all
	assertEquals("A-B-C-D-1", group.getMetricIdentifier(metricName));
	// from now on the scope string is cached and should not be reliant on the given filter
	assertEquals("A-B-C-D-1", group.getMetricIdentifier(metricName, FILTER_C));
	assertEquals("A-B-C-D-1", group.getMetricIdentifier(metricName, this));
	// the metric name however is still affected by the filter as it is not cached
	assertEquals("A-B-C-D-4", group.getMetricIdentifier(metricName, new CharacterFilter() {
		@Override
		public String filterCharacters(String input) {
			return input.replace("B", "X").replace("1", "4");
		}
	}));
}
 
Example #9
Source File: AbstractMetricGroupTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public void checkScopes(Metric metric, String metricName, MetricGroup group) {
	// the first call determines which filter is applied to all future calls; in this case no filter is used at all
	assertEquals("A-B-C-D-1", group.getMetricIdentifier(metricName));
	// from now on the scope string is cached and should not be reliant on the given filter
	assertEquals("A-B-C-D-1", group.getMetricIdentifier(metricName, FILTER_C));
	assertEquals("A-B-C-D-1", group.getMetricIdentifier(metricName, this));
	// the metric name however is still affected by the filter as it is not cached
	assertEquals("A-B-C-D-4", group.getMetricIdentifier(metricName, new CharacterFilter() {
		@Override
		public String filterCharacters(String input) {
			return input.replace("B", "X").replace("1", "4");
		}
	}));
}
 
Example #10
Source File: TaskMetricGroup.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Override
protected QueryScopeInfo.TaskQueryScopeInfo createQueryServiceMetricInfo(CharacterFilter filter) {
	return new QueryScopeInfo.TaskQueryScopeInfo(
		this.parent.jobId.toString(),
		String.valueOf(this.vertexId),
		this.subtaskIndex);
}
 
Example #11
Source File: TaskMetricGroup.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
protected QueryScopeInfo.TaskQueryScopeInfo createQueryServiceMetricInfo(CharacterFilter filter) {
	return new QueryScopeInfo.TaskQueryScopeInfo(
		this.parent.jobId.toString(),
		String.valueOf(this.vertexId),
		this.subtaskIndex);
}
 
Example #12
Source File: ScopeFormat.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
/**
 * Concatenates the given component names separated by the delimiter character. Additionally
 * the character filter is applied to all component names.
 *
 * @param filter Character filter to be applied to the component names
 * @param delimiter Delimiter to separate component names
 * @param components Array of component names
 * @return The concatenated component name
 */
public static String concat(CharacterFilter filter, Character delimiter, String... components) {
	StringBuilder sb = new StringBuilder();
	sb.append(filter.filterCharacters(components[0]));
	for (int x = 1; x < components.length; x++) {
		sb.append(delimiter);
		sb.append(filter.filterCharacters(components[x]));
	}
	return sb.toString();
}
 
Example #13
Source File: AbstractMetricGroupTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Override
public void checkScopes(Metric metric, String metricName, MetricGroup group) {
	// the first call determines which filter is applied to all future calls; in this case no filter is used at all
	assertEquals("A-B-C-D-1", group.getMetricIdentifier(metricName));
	// from now on the scope string is cached and should not be reliant on the given filter
	assertEquals("A-B-C-D-1", group.getMetricIdentifier(metricName, FILTER_C));
	assertEquals("A-B-C-D-1", group.getMetricIdentifier(metricName, this));
	// the metric name however is still affected by the filter as it is not cached
	assertEquals("A-B-C-D-4", group.getMetricIdentifier(metricName, new CharacterFilter() {
		@Override
		public String filterCharacters(String input) {
			return input.replace("B", "X").replace("1", "4");
		}
	}));
}
 
Example #14
Source File: AbstractMetricGroupTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Override
public void checkScopes(Metric metric, String metricName, MetricGroup group) {
	// the first call determines which filter is applied to all future calls
	assertEquals("A!B!X!D!1", group.getMetricIdentifier(metricName, this));
	// from now on the scope string is cached and should not be reliant on the given filter
	assertEquals("A!B!X!D!1", group.getMetricIdentifier(metricName));
	assertEquals("A!B!X!D!1", group.getMetricIdentifier(metricName, FILTER_C));
	// the metric name however is still affected by the filter as it is not cached
	assertEquals("A!B!X!D!3", group.getMetricIdentifier(metricName, new CharacterFilter() {
		@Override
		public String filterCharacters(String input) {
			return input.replace("A", "X").replace("1", "3");
		}
	}));
}
 
Example #15
Source File: OperatorMetricGroup.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
protected QueryScopeInfo.OperatorQueryScopeInfo createQueryServiceMetricInfo(CharacterFilter filter) {
	return new QueryScopeInfo.OperatorQueryScopeInfo(
		this.parent.parent.jobId.toString(),
		this.parent.vertexId.toString(),
		this.parent.subtaskIndex,
		filter.filterCharacters(this.operatorName));
}
 
Example #16
Source File: TaskMetricGroup.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
protected QueryScopeInfo.TaskQueryScopeInfo createQueryServiceMetricInfo(CharacterFilter filter) {
	return new QueryScopeInfo.TaskQueryScopeInfo(
		this.parent.jobId.toString(),
		String.valueOf(this.vertexId),
		this.subtaskIndex);
}
 
Example #17
Source File: AbstractMetricGroup.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the logical scope of this group, for example
 * {@code "taskmanager.job.task"}.
 *
 * @param filter character filter which is applied to the scope components
 * @param delimiter delimiter to use for concatenating scope components
 * @param reporterIndex index of the reporter
 * @return logical scope
 */
String getLogicalScope(CharacterFilter filter, char delimiter, int reporterIndex) {
	if (logicalScopeStrings.length == 0 || (reporterIndex < 0 || reporterIndex >= logicalScopeStrings.length)) {
		return createLogicalScope(filter, delimiter);
	} else {
		if (logicalScopeStrings[reporterIndex] == null) {
			logicalScopeStrings[reporterIndex] = createLogicalScope(filter, delimiter);
		}
		return logicalScopeStrings[reporterIndex];
	}
}
 
Example #18
Source File: MetricGroupTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
protected String getGroupName(CharacterFilter filter) {
	return "";
}
 
Example #19
Source File: JobManagerMetricGroup.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
protected QueryScopeInfo.JobManagerQueryScopeInfo createQueryServiceMetricInfo(CharacterFilter filter) {
	return new QueryScopeInfo.JobManagerQueryScopeInfo();
}
 
Example #20
Source File: FrontMetricGroup.java    From flink with Apache License 2.0 4 votes vote down vote up
public String getLogicalScope(CharacterFilter filter) {
	return parentMetricGroup.getLogicalScope(filter, this.settings.getDelimiter());
}
 
Example #21
Source File: FrontMetricGroup.java    From flink with Apache License 2.0 4 votes vote down vote up
public String getLogicalScope(CharacterFilter filter, char delimiter) {
	return parentMetricGroup.getLogicalScope(filter, delimiter, this.settings.getReporterIndex());
}
 
Example #22
Source File: JobManagerMetricGroup.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
protected QueryScopeInfo.JobManagerQueryScopeInfo createQueryServiceMetricInfo(CharacterFilter filter) {
	return new QueryScopeInfo.JobManagerQueryScopeInfo();
}
 
Example #23
Source File: GenericMetricGroup.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
protected String getGroupName(CharacterFilter filter) {
	return filter.filterCharacters(name);
}
 
Example #24
Source File: GenericMetricGroup.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
protected QueryScopeInfo createQueryServiceMetricInfo(CharacterFilter filter) {
	return parent.getQueryServiceMetricInfo(filter).copy(filter.filterCharacters(this.name));
}
 
Example #25
Source File: OperatorMetricGroup.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
protected String getGroupName(CharacterFilter filter) {
	return "operator";
}
 
Example #26
Source File: GenericValueMetricGroup.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
protected String createLogicalScope(CharacterFilter filter, char delimiter) {
	return parent.getLogicalScope(filter, delimiter);
}
 
Example #27
Source File: MetricGroupTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
protected String getGroupName(CharacterFilter filter) {
	return "";
}
 
Example #28
Source File: AbstractMetricGroup.java    From flink with Apache License 2.0 4 votes vote down vote up
protected String createLogicalScope(CharacterFilter filter, char delimiter) {
	final String groupName = getGroupName(filter);
	return parent == null
		? groupName
		: parent.getLogicalScope(filter, delimiter) + delimiter + groupName;
}
 
Example #29
Source File: ScopeFormat.java    From flink with Apache License 2.0 4 votes vote down vote up
public static String concat(CharacterFilter filter, String... components) {
	return concat(filter, '.', components);
}
 
Example #30
Source File: JobMetricGroup.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
protected QueryScopeInfo.JobQueryScopeInfo createQueryServiceMetricInfo(CharacterFilter filter) {
	return new QueryScopeInfo.JobQueryScopeInfo(this.jobId.toString());
}