org.apache.flink.runtime.metrics.scope.ScopeFormat Java Examples

The following examples show how to use org.apache.flink.runtime.metrics.scope.ScopeFormat. 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: MetricGroupTest.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * Verifies that existing key/value groups are returned when calling {@link MetricGroup#addGroup(String)}.
 */
@Test
public void testNameCollisionAfterKeyValueGroup() {
	MetricRegistry registry = NoOpMetricRegistry.INSTANCE;
	GenericMetricGroup root = new GenericMetricGroup(registry, new DummyAbstractMetricGroup(registry), "root");

	String key = "key";
	String value = "value";

	root.addGroup(key, value);
	MetricGroup group = root.addGroup(key).addGroup(value);

	String variableValue = group.getAllVariables().get(ScopeFormat.asVariable("key"));
	assertEquals(value, variableValue);

	String identifier = group.getMetricIdentifier("metric");
	assertTrue("Key is missing from metric identifier.", identifier.contains("key"));
	assertTrue("Value is missing from metric identifier.", identifier.contains("value"));

	String logicalScope = ((AbstractMetricGroup) group).getLogicalScope(new DummyCharacterFilter());
	assertTrue("Key is missing from logical scope.", logicalScope.contains(key));
	assertFalse("Value is present in logical scope.", logicalScope.contains(value));
}
 
Example #2
Source File: ReporterSetupTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testVariableExclusionParsing() throws Exception {
	final String excludedVariable1 = "foo";
	final String excludedVariable2 = "foo";
	final Configuration config = new Configuration();
	config.setString(ConfigConstants.METRICS_REPORTER_PREFIX + "test." + ConfigConstants.METRICS_REPORTER_FACTORY_CLASS_SUFFIX, TestReporterFactory.class.getName());
	config.setString(ConfigConstants.METRICS_REPORTER_PREFIX + "test." + ConfigConstants.METRICS_REPORTER_EXCLUDED_VARIABLES, excludedVariable1 + ";" + excludedVariable2);

	final List<ReporterSetup> reporterSetups = ReporterSetup.fromConfiguration(config, null);

	assertEquals(1, reporterSetups.size());

	final ReporterSetup reporterSetup = reporterSetups.get(0);

	assertThat(reporterSetup.getExcludedVariables(), hasItems(ScopeFormat.asVariable(excludedVariable1), ScopeFormat.asVariable(excludedVariable2)));
}
 
Example #3
Source File: TaskMetricGroupTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testOperatorNameTruncation() throws Exception {
	Configuration cfg = new Configuration();
	cfg.setString(MetricOptions.SCOPE_NAMING_OPERATOR, ScopeFormat.SCOPE_OPERATOR_NAME);
	MetricRegistryImpl registry = new MetricRegistryImpl(MetricRegistryConfiguration.fromConfiguration(cfg));
	TaskManagerMetricGroup tm = new TaskManagerMetricGroup(registry, "host", "id");
	TaskManagerJobMetricGroup job = new TaskManagerJobMetricGroup(registry, tm, new JobID(), "jobname");
	TaskMetricGroup taskMetricGroup = new TaskMetricGroup(registry, job, new JobVertexID(), new AbstractID(), "task", 0, 0);

	String originalName = new String(new char[100]).replace("\0", "-");
	OperatorMetricGroup operatorMetricGroup = taskMetricGroup.getOrAddOperator(originalName);

	String storedName = operatorMetricGroup.getScopeComponents()[0];
	Assert.assertEquals(TaskMetricGroup.METRICS_OPERATOR_NAME_MAX_LENGTH, storedName.length());
	Assert.assertEquals(originalName.substring(0, TaskMetricGroup.METRICS_OPERATOR_NAME_MAX_LENGTH), storedName);
	registry.shutdown().get();
}
 
Example #4
Source File: MetricGroupTest.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * Verifies that existing key/value groups are returned when calling {@link MetricGroup#addGroup(String)}.
 */
@Test
public void testNameCollisionAfterKeyValueGroup() {
	MetricRegistry registry = NoOpMetricRegistry.INSTANCE;
	GenericMetricGroup root = new GenericMetricGroup(registry, new DummyAbstractMetricGroup(registry), "root");

	String key = "key";
	String value = "value";

	root.addGroup(key, value);
	MetricGroup group = root.addGroup(key).addGroup(value);

	String variableValue = group.getAllVariables().get(ScopeFormat.asVariable("key"));
	assertEquals(value, variableValue);

	String identifier = group.getMetricIdentifier("metric");
	assertTrue("Key is missing from metric identifier.", identifier.contains("key"));
	assertTrue("Value is missing from metric identifier.", identifier.contains("value"));

	String logicalScope = ((AbstractMetricGroup) group).getLogicalScope(new DummyCharacterFilter());
	assertTrue("Key is missing from logical scope.", logicalScope.contains(key));
	assertFalse("Value is present in logical scope.", logicalScope.contains(value));
}
 
Example #5
Source File: MetricGroupTest.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * Verifies that calling {@link MetricGroup#addGroup(String, String)} if a generic group with the key and value name
 * already exists goes through the generic code path.
 */
@Test
public void testNameCollisionForKeyAndValueAfterGenericGroup() {
	MetricRegistry registry = NoOpMetricRegistry.INSTANCE;
	GenericMetricGroup root = new GenericMetricGroup(registry, new DummyAbstractMetricGroup(registry), "root");

	String key = "key";
	String value = "value";

	root.addGroup(key).addGroup(value);
	MetricGroup group = root.addGroup(key, value);

	String variableValue = group.getAllVariables().get(ScopeFormat.asVariable("key"));
	assertNull(variableValue);

	String identifier = group.getMetricIdentifier("metric");
	assertTrue("Key is missing from metric identifier.", identifier.contains("key"));
	assertTrue("Value is missing from metric identifier.", identifier.contains("value"));

	String logicalScope = ((AbstractMetricGroup) group).getLogicalScope(new DummyCharacterFilter());
	assertTrue("Key is missing from logical scope.", logicalScope.contains(key));
	assertTrue("Value is missing from logical scope.", logicalScope.contains(value));
}
 
Example #6
Source File: MetricGroupTest.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * Verifies that calling {@link MetricGroup#addGroup(String, String)} if a generic group with the key name already
 * exists goes through the generic code path.
 */
@Test
public void testNameCollisionForKeyAfterGenericGroup() {
	MetricRegistry registry = NoOpMetricRegistry.INSTANCE;
	GenericMetricGroup root = new GenericMetricGroup(registry, new DummyAbstractMetricGroup(registry), "root");

	String key = "key";
	String value = "value";

	root.addGroup(key);
	MetricGroup group = root.addGroup(key, value);

	String variableValue = group.getAllVariables().get(ScopeFormat.asVariable("key"));
	assertNull(variableValue);

	String identifier = group.getMetricIdentifier("metric");
	assertTrue("Key is missing from metric identifier.", identifier.contains("key"));
	assertTrue("Value is missing from metric identifier.", identifier.contains("value"));

	String logicalScope = ((AbstractMetricGroup) group).getLogicalScope(new DummyCharacterFilter());
	assertTrue("Key is missing from logical scope.", logicalScope.contains(key));
	assertTrue("Value is missing from logical scope.", logicalScope.contains(value));
}
 
Example #7
Source File: MetricGroupTest.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * Verifies the basic behavior when defining user-defined variables.
 */
@Test
public void testUserDefinedVariable() {
	MetricRegistry registry = NoOpMetricRegistry.INSTANCE;
	GenericMetricGroup root = new GenericMetricGroup(registry, new DummyAbstractMetricGroup(registry), "root");

	String key = "key";
	String value = "value";
	MetricGroup group = root.addGroup(key, value);

	String variableValue = group.getAllVariables().get(ScopeFormat.asVariable("key"));
	assertEquals(value, variableValue);

	String identifier = group.getMetricIdentifier("metric");
	assertTrue("Key is missing from metric identifier.", identifier.contains("key"));
	assertTrue("Value is missing from metric identifier.", identifier.contains("value"));

	String logicalScope = ((AbstractMetricGroup) group).getLogicalScope(new DummyCharacterFilter());
	assertTrue("Key is missing from logical scope.", logicalScope.contains(key));
	assertFalse("Value is present in logical scope.", logicalScope.contains(value));
}
 
Example #8
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 #9
Source File: TaskMetricGroupTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testOperatorNameTruncation() throws Exception {
	Configuration cfg = new Configuration();
	cfg.setString(MetricOptions.SCOPE_NAMING_OPERATOR, ScopeFormat.SCOPE_OPERATOR_NAME);
	MetricRegistryImpl registry = new MetricRegistryImpl(MetricRegistryConfiguration.fromConfiguration(cfg));
	TaskManagerMetricGroup tm = new TaskManagerMetricGroup(registry, "host", "id");
	TaskManagerJobMetricGroup job = new TaskManagerJobMetricGroup(registry, tm, new JobID(), "jobname");
	TaskMetricGroup taskMetricGroup = new TaskMetricGroup(registry, job, new JobVertexID(), new AbstractID(), "task", 0, 0);

	String originalName = new String(new char[100]).replace("\0", "-");
	OperatorMetricGroup operatorMetricGroup = taskMetricGroup.getOrAddOperator(originalName);

	String storedName = operatorMetricGroup.getScopeComponents()[0];
	Assert.assertEquals(TaskMetricGroup.METRICS_OPERATOR_NAME_MAX_LENGTH, storedName.length());
	Assert.assertEquals(originalName.substring(0, TaskMetricGroup.METRICS_OPERATOR_NAME_MAX_LENGTH), storedName);
	registry.shutdown().get();
}
 
Example #10
Source File: MetricGroupTest.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * Verifies that calling {@link MetricGroup#addGroup(String, String)} if a generic group with the key and value name
 * already exists goes through the generic code path.
 */
@Test
public void testNameCollisionForKeyAndValueAfterGenericGroup() {
	MetricRegistry registry = NoOpMetricRegistry.INSTANCE;
	GenericMetricGroup root = new GenericMetricGroup(registry, new DummyAbstractMetricGroup(registry), "root");

	String key = "key";
	String value = "value";

	root.addGroup(key).addGroup(value);
	MetricGroup group = root.addGroup(key, value);

	String variableValue = group.getAllVariables().get(ScopeFormat.asVariable("key"));
	assertNull(variableValue);

	String identifier = group.getMetricIdentifier("metric");
	assertTrue("Key is missing from metric identifier.", identifier.contains("key"));
	assertTrue("Value is missing from metric identifier.", identifier.contains("value"));

	String logicalScope = ((AbstractMetricGroup) group).getLogicalScope(new DummyCharacterFilter());
	assertTrue("Key is missing from logical scope.", logicalScope.contains(key));
	assertTrue("Value is missing from logical scope.", logicalScope.contains(value));
}
 
Example #11
Source File: MetricGroupTest.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * Verifies that calling {@link MetricGroup#addGroup(String, String)} if a generic group with the key name already
 * exists goes through the generic code path.
 */
@Test
public void testNameCollisionForKeyAfterGenericGroup() {
	MetricRegistry registry = NoOpMetricRegistry.INSTANCE;
	GenericMetricGroup root = new GenericMetricGroup(registry, new DummyAbstractMetricGroup(registry), "root");

	String key = "key";
	String value = "value";

	root.addGroup(key);
	MetricGroup group = root.addGroup(key, value);

	String variableValue = group.getAllVariables().get(ScopeFormat.asVariable("key"));
	assertNull(variableValue);

	String identifier = group.getMetricIdentifier("metric");
	assertTrue("Key is missing from metric identifier.", identifier.contains("key"));
	assertTrue("Value is missing from metric identifier.", identifier.contains("value"));

	String logicalScope = ((AbstractMetricGroup) group).getLogicalScope(new DummyCharacterFilter());
	assertTrue("Key is missing from logical scope.", logicalScope.contains(key));
	assertTrue("Value is missing from logical scope.", logicalScope.contains(value));
}
 
Example #12
Source File: MetricGroupTest.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * Verifies the basic behavior when defining user-defined variables.
 */
@Test
public void testUserDefinedVariable() {
	MetricRegistry registry = NoOpMetricRegistry.INSTANCE;
	GenericMetricGroup root = new GenericMetricGroup(registry, new DummyAbstractMetricGroup(registry), "root");

	String key = "key";
	String value = "value";
	MetricGroup group = root.addGroup(key, value);

	String variableValue = group.getAllVariables().get(ScopeFormat.asVariable("key"));
	assertEquals(value, variableValue);

	String identifier = group.getMetricIdentifier("metric");
	assertTrue("Key is missing from metric identifier.", identifier.contains("key"));
	assertTrue("Value is missing from metric identifier.", identifier.contains("value"));

	String logicalScope = ((AbstractMetricGroup) group).getLogicalScope(new DummyCharacterFilter());
	assertTrue("Key is missing from logical scope.", logicalScope.contains(key));
	assertFalse("Value is present in logical scope.", logicalScope.contains(value));
}
 
Example #13
Source File: TaskMetricGroupTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Test
public void testOperatorNameTruncation() throws Exception {
	Configuration cfg = new Configuration();
	cfg.setString(MetricOptions.SCOPE_NAMING_OPERATOR, ScopeFormat.SCOPE_OPERATOR_NAME);
	MetricRegistryImpl registry = new MetricRegistryImpl(MetricRegistryConfiguration.fromConfiguration(cfg));
	TaskManagerMetricGroup tm = new TaskManagerMetricGroup(registry, "host", "id");
	TaskManagerJobMetricGroup job = new TaskManagerJobMetricGroup(registry, tm, new JobID(), "jobname");
	TaskMetricGroup taskMetricGroup = new TaskMetricGroup(registry, job, new JobVertexID(), new AbstractID(), "task", 0, 0);

	String originalName = new String(new char[100]).replace("\0", "-");
	OperatorMetricGroup operatorMetricGroup = taskMetricGroup.getOrAddOperator(originalName);

	String storedName = operatorMetricGroup.getScopeComponents()[0];
	Assert.assertEquals(TaskMetricGroup.METRICS_OPERATOR_NAME_MAX_LENGTH, storedName.length());
	Assert.assertEquals(originalName.substring(0, TaskMetricGroup.METRICS_OPERATOR_NAME_MAX_LENGTH), storedName);
	registry.shutdown().get();
}
 
Example #14
Source File: MetricGroupTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
/**
 * Verifies that existing key/value groups are returned when calling {@link MetricGroup#addGroup(String)}.
 */
@Test
public void testNameCollisionAfterKeyValueGroup() {
	MetricRegistry registry = NoOpMetricRegistry.INSTANCE;
	GenericMetricGroup root = new GenericMetricGroup(registry, new DummyAbstractMetricGroup(registry), "root");

	String key = "key";
	String value = "value";

	root.addGroup(key, value);
	MetricGroup group = root.addGroup(key).addGroup(value);

	String variableValue = group.getAllVariables().get(ScopeFormat.asVariable("key"));
	assertEquals(value, variableValue);

	String identifier = group.getMetricIdentifier("metric");
	assertTrue("Key is missing from metric identifier.", identifier.contains("key"));
	assertTrue("Value is missing from metric identifier.", identifier.contains("value"));

	String logicalScope = ((AbstractMetricGroup) group).getLogicalScope(new DummyCharacterFilter());
	assertTrue("Key is missing from logical scope.", logicalScope.contains(key));
	assertFalse("Value is present in logical scope.", logicalScope.contains(value));
}
 
Example #15
Source File: MetricGroupTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
/**
 * Verifies that calling {@link MetricGroup#addGroup(String, String)} if a generic group with the key and value name
 * already exists goes through the generic code path.
 */
@Test
public void testNameCollisionForKeyAndValueAfterGenericGroup() {
	MetricRegistry registry = NoOpMetricRegistry.INSTANCE;
	GenericMetricGroup root = new GenericMetricGroup(registry, new DummyAbstractMetricGroup(registry), "root");

	String key = "key";
	String value = "value";

	root.addGroup(key).addGroup(value);
	MetricGroup group = root.addGroup(key, value);

	String variableValue = group.getAllVariables().get(ScopeFormat.asVariable("key"));
	assertNull(variableValue);

	String identifier = group.getMetricIdentifier("metric");
	assertTrue("Key is missing from metric identifier.", identifier.contains("key"));
	assertTrue("Value is missing from metric identifier.", identifier.contains("value"));

	String logicalScope = ((AbstractMetricGroup) group).getLogicalScope(new DummyCharacterFilter());
	assertTrue("Key is missing from logical scope.", logicalScope.contains(key));
	assertTrue("Value is missing from logical scope.", logicalScope.contains(value));
}
 
Example #16
Source File: MetricGroupTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
/**
 * Verifies the basic behavior when defining user-defined variables.
 */
@Test
public void testUserDefinedVariable() {
	MetricRegistry registry = NoOpMetricRegistry.INSTANCE;
	GenericMetricGroup root = new GenericMetricGroup(registry, new DummyAbstractMetricGroup(registry), "root");

	String key = "key";
	String value = "value";
	MetricGroup group = root.addGroup(key, value);

	String variableValue = group.getAllVariables().get(ScopeFormat.asVariable("key"));
	assertEquals(value, variableValue);

	String identifier = group.getMetricIdentifier("metric");
	assertTrue("Key is missing from metric identifier.", identifier.contains("key"));
	assertTrue("Value is missing from metric identifier.", identifier.contains("value"));

	String logicalScope = ((AbstractMetricGroup) group).getLogicalScope(new DummyCharacterFilter());
	assertTrue("Key is missing from logical scope.", logicalScope.contains(key));
	assertFalse("Value is present in logical scope.", logicalScope.contains(value));
}
 
Example #17
Source File: MetricGroupTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
/**
 * Verifies that calling {@link MetricGroup#addGroup(String, String)} if a generic group with the key name already
 * exists goes through the generic code path.
 */
@Test
public void testNameCollisionForKeyAfterGenericGroup() {
	MetricRegistry registry = NoOpMetricRegistry.INSTANCE;
	GenericMetricGroup root = new GenericMetricGroup(registry, new DummyAbstractMetricGroup(registry), "root");

	String key = "key";
	String value = "value";

	root.addGroup(key);
	MetricGroup group = root.addGroup(key, value);

	String variableValue = group.getAllVariables().get(ScopeFormat.asVariable("key"));
	assertNull(variableValue);

	String identifier = group.getMetricIdentifier("metric");
	assertTrue("Key is missing from metric identifier.", identifier.contains("key"));
	assertTrue("Value is missing from metric identifier.", identifier.contains("value"));

	String logicalScope = ((AbstractMetricGroup) group).getLogicalScope(new DummyCharacterFilter());
	assertTrue("Key is missing from logical scope.", logicalScope.contains(key));
	assertTrue("Value is missing from logical scope.", logicalScope.contains(value));
}
 
Example #18
Source File: TaskMetricGroup.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
protected void putVariables(Map<String, String> variables) {
	variables.put(ScopeFormat.SCOPE_TASK_VERTEX_ID, vertexId.toString());
	variables.put(ScopeFormat.SCOPE_TASK_NAME, taskName);
	variables.put(ScopeFormat.SCOPE_TASK_ATTEMPT_ID, executionId.toString());
	variables.put(ScopeFormat.SCOPE_TASK_ATTEMPT_NUM, String.valueOf(attemptNumber));
	variables.put(ScopeFormat.SCOPE_TASK_SUBTASK_INDEX, String.valueOf(subtaskIndex));
}
 
Example #19
Source File: OperatorGroupTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testVariables() {
	JobID jid = new JobID();
	JobVertexID tid = new JobVertexID();
	AbstractID eid = new AbstractID();
	OperatorID oid = new OperatorID();

	TaskManagerMetricGroup tmGroup = new TaskManagerMetricGroup(registry, "theHostName", "test-tm-id");
	TaskManagerJobMetricGroup jmGroup = new TaskManagerJobMetricGroup(registry, tmGroup, jid, "myJobName");
	TaskMetricGroup taskGroup = new TaskMetricGroup(
		registry, jmGroup,  tid,  eid, "aTaskName", 11, 0);
	OperatorMetricGroup opGroup = new OperatorMetricGroup(registry, taskGroup, oid, "myOpName");

	Map<String, String> variables = opGroup.getAllVariables();

	testVariable(variables, ScopeFormat.SCOPE_HOST, "theHostName");
	testVariable(variables, ScopeFormat.SCOPE_TASKMANAGER_ID, "test-tm-id");
	testVariable(variables, ScopeFormat.SCOPE_JOB_ID, jid.toString());
	testVariable(variables, ScopeFormat.SCOPE_JOB_NAME, "myJobName");
	testVariable(variables, ScopeFormat.SCOPE_TASK_VERTEX_ID, tid.toString());
	testVariable(variables, ScopeFormat.SCOPE_TASK_NAME, "aTaskName");
	testVariable(variables, ScopeFormat.SCOPE_TASK_ATTEMPT_ID, eid.toString());
	testVariable(variables, ScopeFormat.SCOPE_TASK_SUBTASK_INDEX, "11");
	testVariable(variables, ScopeFormat.SCOPE_TASK_ATTEMPT_NUM, "0");
	testVariable(variables, ScopeFormat.SCOPE_OPERATOR_ID, oid.toString());
	testVariable(variables, ScopeFormat.SCOPE_OPERATOR_NAME, "myOpName");
}
 
Example #20
Source File: AbstractMetricGroupTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetAllVariablesWithExclusions() {
	MetricRegistry registry = NoOpMetricRegistry.INSTANCE;

	AbstractMetricGroup<?> group = new ProcessMetricGroup(registry, "host");
	assertEquals(group.getAllVariables(-1, Collections.singleton(ScopeFormat.SCOPE_HOST)).size(), 0);
}
 
Example #21
Source File: AbstractMetricGroupTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetAllVariablesWithOutExclusions() {
	MetricRegistry registry = NoOpMetricRegistry.INSTANCE;

	AbstractMetricGroup<?> group = new ProcessMetricGroup(registry, "host");
	assertThat(group.getAllVariables(), IsMapContaining.hasKey(ScopeFormat.SCOPE_HOST));
}
 
Example #22
Source File: TaskMetricGroup.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
protected void putVariables(Map<String, String> variables) {
	variables.put(ScopeFormat.SCOPE_TASK_VERTEX_ID, vertexId.toString());
	variables.put(ScopeFormat.SCOPE_TASK_NAME, taskName);
	variables.put(ScopeFormat.SCOPE_TASK_ATTEMPT_ID, executionId.toString());
	variables.put(ScopeFormat.SCOPE_TASK_ATTEMPT_NUM, String.valueOf(attemptNumber));
	variables.put(ScopeFormat.SCOPE_TASK_SUBTASK_INDEX, String.valueOf(subtaskIndex));
}
 
Example #23
Source File: OperatorGroupTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Test
public void testVariables() {
	JobID jid = new JobID();
	JobVertexID tid = new JobVertexID();
	AbstractID eid = new AbstractID();
	OperatorID oid = new OperatorID();

	TaskManagerMetricGroup tmGroup = new TaskManagerMetricGroup(registry, "theHostName", "test-tm-id");
	TaskManagerJobMetricGroup jmGroup = new TaskManagerJobMetricGroup(registry, tmGroup, jid, "myJobName");
	TaskMetricGroup taskGroup = new TaskMetricGroup(
		registry, jmGroup,  tid,  eid, "aTaskName", 11, 0);
	OperatorMetricGroup opGroup = new OperatorMetricGroup(registry, taskGroup, oid, "myOpName");

	Map<String, String> variables = opGroup.getAllVariables();

	testVariable(variables, ScopeFormat.SCOPE_HOST, "theHostName");
	testVariable(variables, ScopeFormat.SCOPE_TASKMANAGER_ID, "test-tm-id");
	testVariable(variables, ScopeFormat.SCOPE_JOB_ID, jid.toString());
	testVariable(variables, ScopeFormat.SCOPE_JOB_NAME, "myJobName");
	testVariable(variables, ScopeFormat.SCOPE_TASK_VERTEX_ID, tid.toString());
	testVariable(variables, ScopeFormat.SCOPE_TASK_NAME, "aTaskName");
	testVariable(variables, ScopeFormat.SCOPE_TASK_ATTEMPT_ID, eid.toString());
	testVariable(variables, ScopeFormat.SCOPE_TASK_SUBTASK_INDEX, "11");
	testVariable(variables, ScopeFormat.SCOPE_TASK_ATTEMPT_NUM, "0");
	testVariable(variables, ScopeFormat.SCOPE_OPERATOR_ID, oid.toString());
	testVariable(variables, ScopeFormat.SCOPE_OPERATOR_NAME, "myOpName");
}
 
Example #24
Source File: ReporterSetup.java    From flink with Apache License 2.0 5 votes vote down vote up
public Set<String> getExcludedVariables() {
	String excludedVariablesList = configuration.getString(ConfigConstants.METRICS_REPORTER_EXCLUDED_VARIABLES, null);
	if (excludedVariablesList == null) {
		return Collections.emptySet();
	} else {
		final Set<String> excludedVariables = new HashSet<>();
		for (String exclusion : excludedVariablesList.split(";")) {
			excludedVariables.add(ScopeFormat.asVariable(exclusion));
		}
		return Collections.unmodifiableSet(excludedVariables);
	}
}
 
Example #25
Source File: OperatorGroupTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testVariables() {
	JobID jid = new JobID();
	JobVertexID tid = new JobVertexID();
	AbstractID eid = new AbstractID();
	OperatorID oid = new OperatorID();

	TaskManagerMetricGroup tmGroup = new TaskManagerMetricGroup(registry, "theHostName", "test-tm-id");
	TaskManagerJobMetricGroup jmGroup = new TaskManagerJobMetricGroup(registry, tmGroup, jid, "myJobName");
	TaskMetricGroup taskGroup = new TaskMetricGroup(
		registry, jmGroup,  tid,  eid, "aTaskName", 11, 0);
	OperatorMetricGroup opGroup = new OperatorMetricGroup(registry, taskGroup, oid, "myOpName");

	Map<String, String> variables = opGroup.getAllVariables();

	testVariable(variables, ScopeFormat.SCOPE_HOST, "theHostName");
	testVariable(variables, ScopeFormat.SCOPE_TASKMANAGER_ID, "test-tm-id");
	testVariable(variables, ScopeFormat.SCOPE_JOB_ID, jid.toString());
	testVariable(variables, ScopeFormat.SCOPE_JOB_NAME, "myJobName");
	testVariable(variables, ScopeFormat.SCOPE_TASK_VERTEX_ID, tid.toString());
	testVariable(variables, ScopeFormat.SCOPE_TASK_NAME, "aTaskName");
	testVariable(variables, ScopeFormat.SCOPE_TASK_ATTEMPT_ID, eid.toString());
	testVariable(variables, ScopeFormat.SCOPE_TASK_SUBTASK_INDEX, "11");
	testVariable(variables, ScopeFormat.SCOPE_TASK_ATTEMPT_NUM, "0");
	testVariable(variables, ScopeFormat.SCOPE_OPERATOR_ID, oid.toString());
	testVariable(variables, ScopeFormat.SCOPE_OPERATOR_NAME, "myOpName");
}
 
Example #26
Source File: TaskMetricGroup.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Override
protected void putVariables(Map<String, String> variables) {
	variables.put(ScopeFormat.SCOPE_TASK_VERTEX_ID, vertexId.toString());
	variables.put(ScopeFormat.SCOPE_TASK_NAME, taskName);
	variables.put(ScopeFormat.SCOPE_TASK_ATTEMPT_ID, executionId.toString());
	variables.put(ScopeFormat.SCOPE_TASK_ATTEMPT_NUM, String.valueOf(attemptNumber));
	variables.put(ScopeFormat.SCOPE_TASK_SUBTASK_INDEX, String.valueOf(subtaskIndex));
}
 
Example #27
Source File: OperatorMetricGroup.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Override
protected void putVariables(Map<String, String> variables) {
	variables.put(ScopeFormat.SCOPE_OPERATOR_ID, String.valueOf(operatorID));
	variables.put(ScopeFormat.SCOPE_OPERATOR_NAME, operatorName);
	// we don't enter the subtask_index as the task group does that already
}
 
Example #28
Source File: JobMetricGroup.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Override
protected void putVariables(Map<String, String> variables) {
	variables.put(ScopeFormat.SCOPE_JOB_ID, jobId.toString());
	variables.put(ScopeFormat.SCOPE_JOB_NAME, jobName);
}
 
Example #29
Source File: JobManagerMetricGroup.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Override
protected void putVariables(Map<String, String> variables) {
	variables.put(ScopeFormat.SCOPE_HOST, hostname);
}
 
Example #30
Source File: GenericValueMetricGroup.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
protected void putVariables(Map<String, String> variables) {
	variables.put(ScopeFormat.asVariable(this.key), value);
}