Search in sources :

Example 6 with ExceptionInfo

use of org.apache.heron.spi.metricsmgr.metrics.ExceptionInfo in project heron by twitter.

the class MetricsManagerServerTest method testMetricsManagerServer.

/**
 * Method: addSinkCommunicator(Communicator<MetricsRecord> communicator)
 */
@Test
public void testMetricsManagerServer() throws InterruptedException {
    String name = "test_communicator";
    CountDownLatch offersLatch = new CountDownLatch(MESSAGE_SIZE);
    Communicator<MetricsRecord> sinkCommunicator = CommunicatorTestHelper.spyCommunicator(new Communicator<MetricsRecord>(), offersLatch);
    metricsManagerServer.addSinkCommunicator(name, sinkCommunicator);
    serverTester.start();
    HeronServerTester.await(offersLatch);
    int messages = 0;
    while (!sinkCommunicator.isEmpty()) {
        int exceptions = 0;
        int metrics = 0;
        MetricsRecord record = sinkCommunicator.poll();
        Assert.assertEquals("hostname:0/component/instance-id", record.getSource());
        Assert.assertEquals("default", record.getContext());
        for (MetricsInfo info : record.getMetrics()) {
            Assert.assertEquals(METRIC_NAME, info.getName());
            Assert.assertEquals(METRIC_VALUE, info.getValue());
            metrics++;
        }
        Assert.assertEquals(METRICS_COUNT, metrics);
        for (ExceptionInfo info : record.getExceptions()) {
            Assert.assertEquals(STACK_TRACE, info.getStackTrace());
            Assert.assertEquals(LAST_TIME, info.getLastTime());
            Assert.assertEquals(FIRST_TIME, info.getFirstTime());
            Assert.assertEquals(LOGGING, info.getLogging());
            Assert.assertEquals(EXCEPTION_COUNT, info.getCount());
            exceptions++;
        }
        Assert.assertEquals(METRICS_COUNT, exceptions);
        messages++;
    }
    Assert.assertEquals(MESSAGE_SIZE, messages);
}
Also used : MetricsInfo(org.apache.heron.spi.metricsmgr.metrics.MetricsInfo) MetricsRecord(org.apache.heron.spi.metricsmgr.metrics.MetricsRecord) CountDownLatch(java.util.concurrent.CountDownLatch) ExceptionInfo(org.apache.heron.spi.metricsmgr.metrics.ExceptionInfo) Test(org.junit.Test)

Example 7 with ExceptionInfo

use of org.apache.heron.spi.metricsmgr.metrics.ExceptionInfo in project heron by twitter.

the class SinkExecutorTest method constructMetricsRecord.

private MetricsRecord constructMetricsRecord() {
    List<MetricsInfo> metricsInfos = new ArrayList<>();
    // We add EXPECTED_RECORDS MetricsInfo into a MetricsRecord
    for (int i = 0; i < EXPECTED_RECORDS; i++) {
        MetricsInfo metricsInfo = new MetricsInfo(METRICS_NAME + i, METRICS_VALUE + i);
        metricsInfos.add(metricsInfo);
    }
    // We add EXPECTED_RECORDS ExceptionInfo into a MetricsRecord
    List<ExceptionInfo> exceptionInfos = new ArrayList<>();
    for (int i = 0; i < EXPECTED_RECORDS; i++) {
        String stackTrace = EXCEPTION_STACK_TRACE + i;
        String lastTime = EXCEPTION_LAST_TIME + i;
        String firstTime = EXCEPTION_FIRST_TIME + i;
        String logging = EXCEPTION_LOGGING + i;
        ExceptionInfo info = new ExceptionInfo(stackTrace, lastTime, firstTime, i, logging);
        exceptionInfos.add(info);
    }
    return new MetricsRecord(RECORD_SOURCE, metricsInfos, exceptionInfos, RECORD_CONTEXT);
}
Also used : MetricsInfo(org.apache.heron.spi.metricsmgr.metrics.MetricsInfo) MetricsRecord(org.apache.heron.spi.metricsmgr.metrics.MetricsRecord) ArrayList(java.util.ArrayList) ExceptionInfo(org.apache.heron.spi.metricsmgr.metrics.ExceptionInfo)

Aggregations

ExceptionInfo (org.apache.heron.spi.metricsmgr.metrics.ExceptionInfo)7 MetricsInfo (org.apache.heron.spi.metricsmgr.metrics.MetricsInfo)7 MetricsRecord (org.apache.heron.spi.metricsmgr.metrics.MetricsRecord)4 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 TopologyManager (org.apache.heron.proto.tmanager.TopologyManager)2 Test (org.junit.Test)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 LinkedList (java.util.LinkedList)1 Map (java.util.Map)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 Metrics (org.apache.heron.proto.system.Metrics)1