本文整理汇总了Java中org.apache.flink.configuration.MetricOptions类的典型用法代码示例。如果您正苦于以下问题:Java MetricOptions类的具体用法?Java MetricOptions怎么用?Java MetricOptions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MetricOptions类属于org.apache.flink.configuration包,在下文中一共展示了MetricOptions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testGenerateScopeCustom
import org.apache.flink.configuration.MetricOptions; //导入依赖的package包/类
@Test
public void testGenerateScopeCustom() {
Configuration cfg = new Configuration();
cfg.setString(MetricOptions.SCOPE_NAMING_TM, "abc");
cfg.setString(MetricOptions.SCOPE_NAMING_TM_JOB, "def");
cfg.setString(MetricOptions.SCOPE_NAMING_TASK, "<tm_id>.<job_id>.<task_id>.<task_attempt_id>");
MetricRegistryImpl registry = new MetricRegistryImpl(MetricRegistryConfiguration.fromConfiguration(cfg));
JobID jid = new JobID();
JobVertexID vertexId = new JobVertexID();
AbstractID executionId = new AbstractID();
TaskManagerMetricGroup tmGroup = new TaskManagerMetricGroup(registry, "theHostName", "test-tm-id");
TaskManagerJobMetricGroup jmGroup = new TaskManagerJobMetricGroup(registry, tmGroup, jid, "myJobName");
TaskMetricGroup taskGroup = new TaskMetricGroup(
registry, jmGroup, vertexId, executionId, "aTaskName", 13, 2);
assertArrayEquals(
new String[]{"test-tm-id", jid.toString(), vertexId.toString(), executionId.toString()},
taskGroup.getScopeComponents());
assertEquals(
String.format("test-tm-id.%s.%s.%s.name", jid, vertexId, executionId),
taskGroup.getMetricIdentifier("name"));
registry.shutdown();
}
示例2: testGenerateScopeWilcard
import org.apache.flink.configuration.MetricOptions; //导入依赖的package包/类
@Test
public void testGenerateScopeWilcard() {
Configuration cfg = new Configuration();
cfg.setString(MetricOptions.SCOPE_NAMING_TASK, "*.<task_attempt_id>.<subtask_index>");
MetricRegistryImpl registry = new MetricRegistryImpl(MetricRegistryConfiguration.fromConfiguration(cfg));
AbstractID executionId = new AbstractID();
TaskManagerMetricGroup tmGroup = new TaskManagerMetricGroup(registry, "theHostName", "test-tm-id");
TaskManagerJobMetricGroup jmGroup = new TaskManagerJobMetricGroup(registry, tmGroup, new JobID(), "myJobName");
TaskMetricGroup taskGroup = new TaskMetricGroup(
registry, jmGroup, new JobVertexID(), executionId, "aTaskName", 13, 1);
assertArrayEquals(
new String[]{"theHostName", "taskmanager", "test-tm-id", "myJobName", executionId.toString(), "13"},
taskGroup.getScopeComponents());
assertEquals(
"theHostName.taskmanager.test-tm-id.myJobName." + executionId + ".13.name",
taskGroup.getMetricIdentifier("name"));
registry.shutdown();
}
示例3: testOperatorNameTruncation
import org.apache.flink.configuration.MetricOptions; //导入依赖的package包/类
@Test
public void testOperatorNameTruncation() {
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.addOperator(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);
}
示例4: testGenerateScopeCustom
import org.apache.flink.configuration.MetricOptions; //导入依赖的package包/类
@Test
public void testGenerateScopeCustom() {
Configuration cfg = new Configuration();
cfg.setString(MetricOptions.SCOPE_NAMING_TM, "abc");
cfg.setString(MetricOptions.SCOPE_NAMING_TM_JOB, "some-constant.<job_name>");
MetricRegistryImpl registry = new MetricRegistryImpl(MetricRegistryConfiguration.fromConfiguration(cfg));
JobID jid = new JobID();
TaskManagerMetricGroup tmGroup = new TaskManagerMetricGroup(registry, "theHostName", "test-tm-id");
JobMetricGroup jmGroup = new TaskManagerJobMetricGroup(registry, tmGroup, jid, "myJobName");
assertArrayEquals(
new String[] { "some-constant", "myJobName" },
jmGroup.getScopeComponents());
assertEquals(
"some-constant.myJobName.name",
jmGroup.getMetricIdentifier("name"));
registry.shutdown();
}
示例5: testGenerateScopeCustomWildcard
import org.apache.flink.configuration.MetricOptions; //导入依赖的package包/类
@Test
public void testGenerateScopeCustomWildcard() {
Configuration cfg = new Configuration();
cfg.setString(MetricOptions.SCOPE_NAMING_TM, "peter.<tm_id>");
cfg.setString(MetricOptions.SCOPE_NAMING_TM_JOB, "*.some-constant.<job_id>");
MetricRegistryImpl registry = new MetricRegistryImpl(MetricRegistryConfiguration.fromConfiguration(cfg));
JobID jid = new JobID();
TaskManagerMetricGroup tmGroup = new TaskManagerMetricGroup(registry, "theHostName", "test-tm-id");
JobMetricGroup jmGroup = new TaskManagerJobMetricGroup(registry, tmGroup, jid, "myJobName");
assertArrayEquals(
new String[] { "peter", "test-tm-id", "some-constant", jid.toString() },
jmGroup.getScopeComponents());
assertEquals(
"peter.test-tm-id.some-constant." + jid + ".name",
jmGroup.getMetricIdentifier("name"));
registry.shutdown();
}
示例6: testGenerateScopeCustom
import org.apache.flink.configuration.MetricOptions; //导入依赖的package包/类
@Test
public void testGenerateScopeCustom() {
Configuration cfg = new Configuration();
cfg.setString(MetricOptions.SCOPE_NAMING_JM, "abc");
cfg.setString(MetricOptions.SCOPE_NAMING_JM_JOB, "some-constant.<job_name>");
MetricRegistryImpl registry = new MetricRegistryImpl(MetricRegistryConfiguration.fromConfiguration(cfg));
JobID jid = new JobID();
JobManagerMetricGroup tmGroup = new JobManagerMetricGroup(registry, "theHostName");
JobMetricGroup jmGroup = new JobManagerJobMetricGroup(registry, tmGroup, jid, "myJobName");
assertArrayEquals(
new String[] { "some-constant", "myJobName" },
jmGroup.getScopeComponents());
assertEquals(
"some-constant.myJobName.name",
jmGroup.getMetricIdentifier("name"));
registry.shutdown();
}
示例7: testGenerateScopeCustomWildcard
import org.apache.flink.configuration.MetricOptions; //导入依赖的package包/类
@Test
public void testGenerateScopeCustomWildcard() {
Configuration cfg = new Configuration();
cfg.setString(MetricOptions.SCOPE_NAMING_JM, "peter");
cfg.setString(MetricOptions.SCOPE_NAMING_JM_JOB, "*.some-constant.<job_id>");
MetricRegistryImpl registry = new MetricRegistryImpl(MetricRegistryConfiguration.fromConfiguration(cfg));
JobID jid = new JobID();
JobManagerMetricGroup tmGroup = new JobManagerMetricGroup(registry, "theHostName");
JobMetricGroup jmGroup = new JobManagerJobMetricGroup(registry, tmGroup, jid, "myJobName");
assertArrayEquals(
new String[] { "peter", "some-constant", jid.toString() },
jmGroup.getScopeComponents());
assertEquals(
"peter.some-constant." + jid + ".name",
jmGroup.getMetricIdentifier("name"));
registry.shutdown();
}
示例8: testScopeCachingForMultipleReporters
import org.apache.flink.configuration.MetricOptions; //导入依赖的package包/类
@Test
public void testScopeCachingForMultipleReporters() throws Exception {
Configuration config = new Configuration();
config.setString(MetricOptions.SCOPE_NAMING_TM, "A.B.C.D");
config.setString(ConfigConstants.METRICS_REPORTER_PREFIX + "test1." + ConfigConstants.METRICS_REPORTER_CLASS_SUFFIX, TestReporter1.class.getName());
config.setString(ConfigConstants.METRICS_REPORTER_PREFIX + "test1." + ConfigConstants.METRICS_REPORTER_SCOPE_DELIMITER, "-");
config.setString(ConfigConstants.METRICS_REPORTER_PREFIX + "test2." + ConfigConstants.METRICS_REPORTER_CLASS_SUFFIX, TestReporter2.class.getName());
config.setString(ConfigConstants.METRICS_REPORTER_PREFIX + "test2." + ConfigConstants.METRICS_REPORTER_SCOPE_DELIMITER, "!");
MetricRegistryImpl testRegistry = new MetricRegistryImpl(MetricRegistryConfiguration.fromConfiguration(config));
try {
MetricGroup tmGroup = new TaskManagerMetricGroup(testRegistry, "host", "id");
tmGroup.counter("1");
assertEquals("Reporters were not properly instantiated", 2, testRegistry.getReporters().size());
for (MetricReporter reporter : testRegistry.getReporters()) {
ScopeCheckingTestReporter typedReporter = (ScopeCheckingTestReporter) reporter;
if (typedReporter.failureCause != null) {
throw typedReporter.failureCause;
}
}
} finally {
testRegistry.shutdown();
}
}
示例9: testScopeGenerationWithoutReporters
import org.apache.flink.configuration.MetricOptions; //导入依赖的package包/类
@Test
public void testScopeGenerationWithoutReporters() {
Configuration config = new Configuration();
config.setString(MetricOptions.SCOPE_NAMING_TM, "A.B.C.D");
MetricRegistryImpl testRegistry = new MetricRegistryImpl(MetricRegistryConfiguration.fromConfiguration(config));
try {
TaskManagerMetricGroup group = new TaskManagerMetricGroup(testRegistry, "host", "id");
assertEquals("MetricReporters list should be empty", 0, testRegistry.getReporters().size());
// default delimiter should be used
assertEquals("A.B.X.D.1", group.getMetricIdentifier("1", FILTER_C));
// no caching should occur
assertEquals("A.X.C.D.1", group.getMetricIdentifier("1", FILTER_B));
// invalid reporter indices do not throw errors
assertEquals("A.X.C.D.1", group.getMetricIdentifier("1", FILTER_B, -1));
assertEquals("A.X.C.D.1", group.getMetricIdentifier("1", FILTER_B, 2));
} finally {
testRegistry.shutdown();
}
}
示例10: testMultipleReporterInstantiation
import org.apache.flink.configuration.MetricOptions; //导入依赖的package包/类
/**
* Verifies that multiple reporters are instantiated correctly.
*/
@Test
public void testMultipleReporterInstantiation() {
Configuration config = new Configuration();
config.setString(MetricOptions.REPORTERS_LIST, "test1, test2,test3");
config.setString(ConfigConstants.METRICS_REPORTER_PREFIX + "test1." + ConfigConstants.METRICS_REPORTER_CLASS_SUFFIX, TestReporter11.class.getName());
config.setString(ConfigConstants.METRICS_REPORTER_PREFIX + "test2." + ConfigConstants.METRICS_REPORTER_CLASS_SUFFIX, TestReporter12.class.getName());
config.setString(ConfigConstants.METRICS_REPORTER_PREFIX + "test3." + ConfigConstants.METRICS_REPORTER_CLASS_SUFFIX, TestReporter13.class.getName());
MetricRegistry metricRegistry = new MetricRegistry(MetricRegistryConfiguration.fromConfiguration(config));
assertTrue(metricRegistry.getReporters().size() == 3);
Assert.assertTrue(TestReporter11.wasOpened);
Assert.assertTrue(TestReporter12.wasOpened);
Assert.assertTrue(TestReporter13.wasOpened);
metricRegistry.shutdown();
}
示例11: testScopeConfig
import org.apache.flink.configuration.MetricOptions; //导入依赖的package包/类
/**
* Verifies that the scope configuration is properly extracted.
*/
@Test
public void testScopeConfig() {
Configuration config = new Configuration();
config.setString(MetricOptions.SCOPE_NAMING_TM, "A");
config.setString(MetricOptions.SCOPE_NAMING_TM_JOB, "B");
config.setString(MetricOptions.SCOPE_NAMING_TASK, "C");
config.setString(MetricOptions.SCOPE_NAMING_OPERATOR, "D");
ScopeFormats scopeConfig = ScopeFormats.fromConfig(config);
assertEquals("A", scopeConfig.getTaskManagerFormat().format());
assertEquals("B", scopeConfig.getTaskManagerJobFormat().format());
assertEquals("C", scopeConfig.getTaskFormat().format());
assertEquals("D", scopeConfig.getOperatorFormat().format());
}
示例12: testConfigurableDelimiterForReporters
import org.apache.flink.configuration.MetricOptions; //导入依赖的package包/类
@Test
public void testConfigurableDelimiterForReporters() {
Configuration config = new Configuration();
config.setString(MetricOptions.REPORTERS_LIST, "test1,test2,test3");
config.setString(ConfigConstants.METRICS_REPORTER_PREFIX + "test1." + ConfigConstants.METRICS_REPORTER_SCOPE_DELIMITER, "_");
config.setString(ConfigConstants.METRICS_REPORTER_PREFIX + "test1." + ConfigConstants.METRICS_REPORTER_CLASS_SUFFIX, TestReporter.class.getName());
config.setString(ConfigConstants.METRICS_REPORTER_PREFIX + "test2." + ConfigConstants.METRICS_REPORTER_SCOPE_DELIMITER, "-");
config.setString(ConfigConstants.METRICS_REPORTER_PREFIX + "test2." + ConfigConstants.METRICS_REPORTER_CLASS_SUFFIX, TestReporter.class.getName());
config.setString(ConfigConstants.METRICS_REPORTER_PREFIX + "test3." + ConfigConstants.METRICS_REPORTER_SCOPE_DELIMITER, "AA");
config.setString(ConfigConstants.METRICS_REPORTER_PREFIX + "test3." + ConfigConstants.METRICS_REPORTER_CLASS_SUFFIX, TestReporter.class.getName());
MetricRegistry registry = new MetricRegistry(MetricRegistryConfiguration.fromConfiguration(config));
assertEquals(GLOBAL_DEFAULT_DELIMITER, registry.getDelimiter());
assertEquals('_', registry.getDelimiter(0));
assertEquals('-', registry.getDelimiter(1));
assertEquals(GLOBAL_DEFAULT_DELIMITER, registry.getDelimiter(2));
assertEquals(GLOBAL_DEFAULT_DELIMITER, registry.getDelimiter(3));
assertEquals(GLOBAL_DEFAULT_DELIMITER, registry.getDelimiter(-1));
registry.shutdown();
}
示例13: testExceptionIsolation
import org.apache.flink.configuration.MetricOptions; //导入依赖的package包/类
@Test
public void testExceptionIsolation() throws Exception {
Configuration config = new Configuration();
config.setString(MetricOptions.REPORTERS_LIST, "test1,test2");
config.setString(ConfigConstants.METRICS_REPORTER_PREFIX + "test1." + ConfigConstants.METRICS_REPORTER_CLASS_SUFFIX, FailingReporter.class.getName());
config.setString(ConfigConstants.METRICS_REPORTER_PREFIX + "test2." + ConfigConstants.METRICS_REPORTER_CLASS_SUFFIX, TestReporter7.class.getName());
MetricRegistry registry = new MetricRegistry(MetricRegistryConfiguration.fromConfiguration(config));
Counter metric = new SimpleCounter();
registry.register(metric, "counter", new MetricGroupTest.DummyAbstractMetricGroup(registry));
assertEquals(metric, TestReporter7.addedMetric);
assertEquals("counter", TestReporter7.addedMetricName);
registry.unregister(metric, "counter", new MetricGroupTest.DummyAbstractMetricGroup(registry));
assertEquals(metric, TestReporter7.removedMetric);
assertEquals("counter", TestReporter7.removedMetricName);
registry.shutdown();
}
示例14: testReporterInclusion
import org.apache.flink.configuration.MetricOptions; //导入依赖的package包/类
/**
* Verifies that the reporter name list is correctly used to determine which reporters should be instantiated.
*/
@Test
public void testReporterInclusion() {
Configuration config = new Configuration();
config.setString(MetricOptions.REPORTERS_LIST, "test");
config.setString(ConfigConstants.METRICS_REPORTER_PREFIX + "test." + ConfigConstants.METRICS_REPORTER_CLASS_SUFFIX, TestReporter1.class.getName());
config.setString(ConfigConstants.METRICS_REPORTER_PREFIX + "test1." + ConfigConstants.METRICS_REPORTER_CLASS_SUFFIX, TestReporter11.class.getName());
MetricRegistryImpl metricRegistry = new MetricRegistryImpl(MetricRegistryConfiguration.fromConfiguration(config));
assertTrue(metricRegistry.getReporters().size() == 1);
Assert.assertTrue(TestReporter1.wasOpened);
Assert.assertFalse(TestReporter11.wasOpened);
metricRegistry.shutdown();
}
示例15: testConfigurableDelimiterForReportersInGroup
import org.apache.flink.configuration.MetricOptions; //导入依赖的package包/类
@Test
public void testConfigurableDelimiterForReportersInGroup() {
Configuration config = new Configuration();
config.setString(ConfigConstants.METRICS_REPORTER_PREFIX + "test1." + ConfigConstants.METRICS_REPORTER_SCOPE_DELIMITER, "_");
config.setString(ConfigConstants.METRICS_REPORTER_PREFIX + "test1." + ConfigConstants.METRICS_REPORTER_CLASS_SUFFIX, TestReporter8.class.getName());
config.setString(ConfigConstants.METRICS_REPORTER_PREFIX + "test2." + ConfigConstants.METRICS_REPORTER_SCOPE_DELIMITER, "-");
config.setString(ConfigConstants.METRICS_REPORTER_PREFIX + "test2." + ConfigConstants.METRICS_REPORTER_CLASS_SUFFIX, TestReporter8.class.getName());
config.setString(ConfigConstants.METRICS_REPORTER_PREFIX + "test3." + ConfigConstants.METRICS_REPORTER_SCOPE_DELIMITER, "AA");
config.setString(ConfigConstants.METRICS_REPORTER_PREFIX + "test3." + ConfigConstants.METRICS_REPORTER_CLASS_SUFFIX, TestReporter8.class.getName());
config.setString(ConfigConstants.METRICS_REPORTER_PREFIX + "test4." + ConfigConstants.METRICS_REPORTER_CLASS_SUFFIX, TestReporter8.class.getName());
config.setString(MetricOptions.SCOPE_NAMING_TM, "A.B");
MetricRegistryImpl registry = new MetricRegistryImpl(MetricRegistryConfiguration.fromConfiguration(config));
List<MetricReporter> reporters = registry.getReporters();
((TestReporter8) reporters.get(0)).expectedDelimiter = '_'; //test1 reporter
((TestReporter8) reporters.get(1)).expectedDelimiter = '-'; //test2 reporter
((TestReporter8) reporters.get(2)).expectedDelimiter = GLOBAL_DEFAULT_DELIMITER; //test3 reporter, because 'AA' - not correct delimiter
((TestReporter8) reporters.get(3)).expectedDelimiter = GLOBAL_DEFAULT_DELIMITER; //for test4 reporter use global delimiter
TaskManagerMetricGroup group = new TaskManagerMetricGroup(registry, "host", "id");
group.counter("C");
group.close();
registry.shutdown();
assertEquals(4, TestReporter8.numCorrectDelimitersForRegister);
assertEquals(4, TestReporter8.numCorrectDelimitersForUnregister);
}