Search in sources :

Example 41 with MetricRegistry

use of org.apache.flink.runtime.metrics.MetricRegistry in project flink by apache.

the class TaskMetricGroupTest method testCreateQueryServiceMetricInfo.

@Test
public void testCreateQueryServiceMetricInfo() {
    JobID jid = new JobID();
    AbstractID vid = new AbstractID();
    AbstractID eid = new AbstractID();
    MetricRegistry registry = new MetricRegistry(MetricRegistryConfiguration.defaultMetricRegistryConfiguration());
    TaskManagerMetricGroup tm = new TaskManagerMetricGroup(registry, "host", "id");
    TaskManagerJobMetricGroup job = new TaskManagerJobMetricGroup(registry, tm, jid, "jobname");
    TaskMetricGroup task = new TaskMetricGroup(registry, job, vid, eid, "taskName", 4, 5);
    QueryScopeInfo.TaskQueryScopeInfo info = task.createQueryServiceMetricInfo(new DummyCharacterFilter());
    assertEquals("", info.scope);
    assertEquals(jid.toString(), info.jobID);
    assertEquals(vid.toString(), info.vertexID);
    assertEquals(4, info.subtaskIndex);
}
Also used : QueryScopeInfo(org.apache.flink.runtime.metrics.dump.QueryScopeInfo) MetricRegistry(org.apache.flink.runtime.metrics.MetricRegistry) DummyCharacterFilter(org.apache.flink.runtime.metrics.util.DummyCharacterFilter) AbstractID(org.apache.flink.util.AbstractID) JobID(org.apache.flink.api.common.JobID) Test(org.junit.Test)

Example 42 with MetricRegistry

use of org.apache.flink.runtime.metrics.MetricRegistry in project flink by apache.

the class JobManagerGroupTest method testGenerateScopeDefault.

// ------------------------------------------------------------------------
//  scope name tests
// ------------------------------------------------------------------------
@Test
public void testGenerateScopeDefault() {
    MetricRegistry registry = new MetricRegistry(MetricRegistryConfiguration.defaultMetricRegistryConfiguration());
    JobManagerMetricGroup group = new JobManagerMetricGroup(registry, "localhost");
    assertArrayEquals(new String[] { "localhost", "jobmanager" }, group.getScopeComponents());
    assertEquals("localhost.jobmanager.name", group.getMetricIdentifier("name"));
    registry.shutdown();
}
Also used : MetricRegistry(org.apache.flink.runtime.metrics.MetricRegistry) Test(org.junit.Test)

Example 43 with MetricRegistry

use of org.apache.flink.runtime.metrics.MetricRegistry in project flink by apache.

the class MetricGroupRegistrationTest method testDuplicateGroupName.

/**
	 * Verifies that when attempting to create a group with the name of an existing one the existing one will be returned instead.
	 */
@Test
public void testDuplicateGroupName() {
    Configuration config = new Configuration();
    MetricRegistry registry = new MetricRegistry(MetricRegistryConfiguration.fromConfiguration(config));
    MetricGroup root = new TaskManagerMetricGroup(registry, "host", "id");
    MetricGroup group1 = root.addGroup("group");
    MetricGroup group2 = root.addGroup("group");
    MetricGroup group3 = root.addGroup("group");
    Assert.assertTrue(group1 == group2 && group2 == group3);
    registry.shutdown();
}
Also used : Configuration(org.apache.flink.configuration.Configuration) MetricRegistryConfiguration(org.apache.flink.runtime.metrics.MetricRegistryConfiguration) MetricRegistry(org.apache.flink.runtime.metrics.MetricRegistry) MetricGroup(org.apache.flink.metrics.MetricGroup) Test(org.junit.Test)

Example 44 with MetricRegistry

use of org.apache.flink.runtime.metrics.MetricRegistry in project flink by apache.

the class MetricGroupRegistrationTest method testMetricInstantiation.

/**
	 * Verifies that group methods instantiate the correct metric with the given name.
	 */
@Test
public void testMetricInstantiation() {
    Configuration config = new Configuration();
    config.setString(ConfigConstants.METRICS_REPORTERS_LIST, "test");
    config.setString(ConfigConstants.METRICS_REPORTER_PREFIX + "test." + ConfigConstants.METRICS_REPORTER_CLASS_SUFFIX, TestReporter1.class.getName());
    MetricRegistry registry = new MetricRegistry(MetricRegistryConfiguration.fromConfiguration(config));
    MetricGroup root = new TaskManagerMetricGroup(registry, "host", "id");
    Counter counter = root.counter("counter");
    assertEquals(counter, TestReporter1.lastPassedMetric);
    assertEquals("counter", TestReporter1.lastPassedName);
    Gauge<Object> gauge = root.gauge("gauge", new Gauge<Object>() {

        @Override
        public Object getValue() {
            return null;
        }
    });
    Assert.assertEquals(gauge, TestReporter1.lastPassedMetric);
    assertEquals("gauge", TestReporter1.lastPassedName);
    Histogram histogram = root.histogram("histogram", new Histogram() {

        @Override
        public void update(long value) {
        }

        @Override
        public long getCount() {
            return 0;
        }

        @Override
        public HistogramStatistics getStatistics() {
            return null;
        }
    });
    Assert.assertEquals(histogram, TestReporter1.lastPassedMetric);
    assertEquals("histogram", TestReporter1.lastPassedName);
    registry.shutdown();
}
Also used : Histogram(org.apache.flink.metrics.Histogram) Counter(org.apache.flink.metrics.Counter) Configuration(org.apache.flink.configuration.Configuration) MetricRegistryConfiguration(org.apache.flink.runtime.metrics.MetricRegistryConfiguration) MetricRegistry(org.apache.flink.runtime.metrics.MetricRegistry) MetricGroup(org.apache.flink.metrics.MetricGroup) HistogramStatistics(org.apache.flink.metrics.HistogramStatistics) Test(org.junit.Test)

Example 45 with MetricRegistry

use of org.apache.flink.runtime.metrics.MetricRegistry in project flink by apache.

the class MetricGroupTest method testCreateQueryServiceMetricInfo.

@Test
public void testCreateQueryServiceMetricInfo() {
    JobID jid = new JobID();
    AbstractID vid = new AbstractID();
    AbstractID eid = new AbstractID();
    MetricRegistry registry = new MetricRegistry(defaultMetricRegistryConfiguration);
    TaskManagerMetricGroup tm = new TaskManagerMetricGroup(registry, "host", "id");
    TaskManagerJobMetricGroup job = new TaskManagerJobMetricGroup(registry, tm, jid, "jobname");
    TaskMetricGroup task = new TaskMetricGroup(registry, job, vid, eid, "taskName", 4, 5);
    GenericMetricGroup userGroup1 = new GenericMetricGroup(registry, task, "hello");
    GenericMetricGroup userGroup2 = new GenericMetricGroup(registry, userGroup1, "world");
    QueryScopeInfo.TaskQueryScopeInfo info1 = (QueryScopeInfo.TaskQueryScopeInfo) userGroup1.createQueryServiceMetricInfo(new DummyCharacterFilter());
    assertEquals("hello", info1.scope);
    assertEquals(jid.toString(), info1.jobID);
    assertEquals(vid.toString(), info1.vertexID);
    assertEquals(4, info1.subtaskIndex);
    QueryScopeInfo.TaskQueryScopeInfo info2 = (QueryScopeInfo.TaskQueryScopeInfo) userGroup2.createQueryServiceMetricInfo(new DummyCharacterFilter());
    assertEquals("hello.world", info2.scope);
    assertEquals(jid.toString(), info2.jobID);
    assertEquals(vid.toString(), info2.vertexID);
    assertEquals(4, info2.subtaskIndex);
}
Also used : QueryScopeInfo(org.apache.flink.runtime.metrics.dump.QueryScopeInfo) MetricRegistry(org.apache.flink.runtime.metrics.MetricRegistry) DummyCharacterFilter(org.apache.flink.runtime.metrics.util.DummyCharacterFilter) AbstractID(org.apache.flink.util.AbstractID) JobID(org.apache.flink.api.common.JobID) Test(org.junit.Test)

Aggregations

MetricRegistry (org.apache.flink.runtime.metrics.MetricRegistry)53 Test (org.junit.Test)47 Configuration (org.apache.flink.configuration.Configuration)27 JobID (org.apache.flink.api.common.JobID)26 MetricRegistryConfiguration (org.apache.flink.runtime.metrics.MetricRegistryConfiguration)25 AbstractID (org.apache.flink.util.AbstractID)13 TaskManagerMetricGroup (org.apache.flink.runtime.metrics.groups.TaskManagerMetricGroup)12 MetricReporter (org.apache.flink.metrics.reporter.MetricReporter)7 QueryScopeInfo (org.apache.flink.runtime.metrics.dump.QueryScopeInfo)7 DummyCharacterFilter (org.apache.flink.runtime.metrics.util.DummyCharacterFilter)7 Counter (org.apache.flink.metrics.Counter)4 MetricGroup (org.apache.flink.metrics.MetricGroup)4 ResourceID (org.apache.flink.runtime.clusterframework.types.ResourceID)4 JobGraph (org.apache.flink.runtime.jobgraph.JobGraph)4 ActorRef (akka.actor.ActorRef)3 UUID (java.util.UUID)3 ObjectName (javax.management.ObjectName)3 Time (org.apache.flink.api.common.time.Time)3 Gauge (org.apache.flink.metrics.Gauge)3 SimpleCounter (org.apache.flink.metrics.SimpleCounter)3