Search in sources :

Example 6 with MetricsCollector

use of com.twitter.heron.common.utils.metrics.MetricsCollector in project incubator-heron by apache.

the class Slave method registerTasksWithSlave.

private void registerTasksWithSlave() {
    // Create a new MetricsCollector with the clean slaveLooper and register its task
    metricsCollector = new MetricsCollector(slaveLooper, metricsOutCommunicator);
    // registering the handling of control msg
    handleControlMessage();
// instance task will be registered when instance.start() is called
}
Also used : MetricsCollector(com.twitter.heron.common.utils.metrics.MetricsCollector)

Example 7 with MetricsCollector

use of com.twitter.heron.common.utils.metrics.MetricsCollector in project incubator-heron by apache.

the class GlobalMetricsTest method testGlobalMetrics.

@Test
public void testGlobalMetrics() {
    MetricsCollector fakeCollector = new MetricsCollector(new FakeWakeableLooper(), null);
    TopologyContext fakeContext = new TopologyContextImpl(new HashMap<String, Object>(), TopologyAPI.Topology.getDefaultInstance(), new HashMap<Integer, String>(), 0, fakeCollector);
    GlobalMetrics.init(fakeContext, Duration.ofSeconds(5));
    GlobalMetrics.incr("mycounter");
    Map<String, Long> metricsContent = GlobalMetrics.getUnderlyingCounter().getValueAndReset();
    assertTrue(metricsContent.containsKey("mycounter"));
    assertEquals(1, metricsContent.size());
    assertEquals(new Long(1), metricsContent.get("mycounter"));
    // Increment two different counters
    GlobalMetrics.incr("mycounter1");
    GlobalMetrics.incr("mycounter2");
    GlobalMetrics.incr("mycounter1");
    metricsContent = GlobalMetrics.getUnderlyingCounter().getValueAndReset();
    assertTrue(metricsContent.containsKey("mycounter"));
    assertTrue(metricsContent.containsKey("mycounter1"));
    assertTrue(metricsContent.containsKey("mycounter2"));
    assertEquals(3L, metricsContent.size());
    assertEquals(new Long(0), metricsContent.get("mycounter"));
    assertEquals(new Long(1), metricsContent.get("mycounter2"));
    assertEquals(new Long(2), metricsContent.get("mycounter1"));
}
Also used : MetricsCollector(com.twitter.heron.common.utils.metrics.MetricsCollector) TopologyContextImpl(com.twitter.heron.common.utils.topology.TopologyContextImpl) TopologyContext(com.twitter.heron.api.topology.TopologyContext) Test(org.junit.Test)

Aggregations

MetricsCollector (com.twitter.heron.common.utils.metrics.MetricsCollector)7 Test (org.junit.Test)4 MultiCountMetric (com.twitter.heron.api.metric.MultiCountMetric)2 TopologyContext (com.twitter.heron.api.topology.TopologyContext)2 Communicator (com.twitter.heron.common.basics.Communicator)2 SlaveLooper (com.twitter.heron.common.basics.SlaveLooper)2 PhysicalPlanHelper (com.twitter.heron.common.utils.misc.PhysicalPlanHelper)2 TopologyContextImpl (com.twitter.heron.common.utils.topology.TopologyContextImpl)2 SinkExecutor (com.twitter.heron.metricsmgr.executor.SinkExecutor)2 SinkContextImpl (com.twitter.heron.metricsmgr.sink.SinkContextImpl)2 MetricsRecord (com.twitter.heron.spi.metricsmgr.metrics.MetricsRecord)2 IMetricsSink (com.twitter.heron.spi.metricsmgr.sink.IMetricsSink)2 SinkContext (com.twitter.heron.spi.metricsmgr.sink.SinkContext)2 PhysicalPlanUtilTest (com.twitter.heron.simulator.utils.PhysicalPlanUtilTest)1 TopologyManagerTest (com.twitter.heron.simulator.utils.TopologyManagerTest)1