Search in sources :

Example 11 with NIOLooper

use of com.twitter.heron.common.basics.NIOLooper in project heron by twitter.

the class MetricsCacheTest method testMetricCache.

@Test
public void testMetricCache() throws IOException {
    // prepare config files
    SystemConfig systemConfig = SystemConfig.newBuilder(true).putAll(CONFIG_SYSTEM_PATH, true).build();
    MetricsSinksConfig sinksConfig = new MetricsSinksConfig(CONFIG_SINK_PATH);
    // initialize metric cache, except looper
    MetricsCache mc = new MetricsCache(systemConfig, sinksConfig, new NIOLooper());
    mc.addMetrics(TopologyMaster.PublishMetrics.newBuilder().addMetrics(TopologyMaster.MetricDatum.newBuilder().setComponentName("c1").setInstanceId("i1").setName("__jvm-uptime-secs").setTimestamp(System.currentTimeMillis()).setValue("0.1")).addExceptions(TopologyMaster.TmasterExceptionLog.newBuilder().setComponentName("c1").setHostname("h1").setInstanceId("i1").setStacktrace("s1").setLogging("l1").setCount(1).setFirsttime(String.valueOf(System.currentTimeMillis())).setLasttime(String.valueOf(System.currentTimeMillis()))).build());
    // query last 10 seconds
    TopologyMaster.MetricResponse response = mc.getMetrics(TopologyMaster.MetricRequest.newBuilder().setComponentName("c1").addInstanceId("i1").setInterval(10).addMetric("__jvm-uptime-secs").build());
    assertEquals(response.getMetricCount(), 1);
    assertEquals(response.getMetric(0).getInstanceId(), "i1");
    assertEquals(response.getMetric(0).getMetricCount(), 1);
    assertEquals(response.getMetric(0).getMetric(0).getName(), "__jvm-uptime-secs");
    assertEquals(response.getMetric(0).getMetric(0).getValue(), "0.1");
}
Also used : MetricsSinksConfig(com.twitter.heron.metricsmgr.MetricsSinksConfig) SystemConfig(com.twitter.heron.common.config.SystemConfig) NIOLooper(com.twitter.heron.common.basics.NIOLooper) TopologyMaster(com.twitter.heron.proto.tmaster.TopologyMaster) Test(org.junit.Test)

Aggregations

NIOLooper (com.twitter.heron.common.basics.NIOLooper)11 Before (org.junit.Before)6 IOException (java.io.IOException)4 SlaveLooper (com.twitter.heron.common.basics.SlaveLooper)3 InstanceControlMsg (com.twitter.heron.instance.InstanceControlMsg)3 GatewayMetrics (com.twitter.heron.metrics.GatewayMetrics)3 MultiCountMetric (com.twitter.heron.api.metric.MultiCountMetric)2 HeronSocketOptions (com.twitter.heron.common.network.HeronSocketOptions)2 SystemConfig (com.twitter.heron.common.config.SystemConfig)1 MetricsSinksConfig (com.twitter.heron.metricsmgr.MetricsSinksConfig)1 TopologyMaster (com.twitter.heron.proto.tmaster.TopologyMaster)1 Test (org.junit.Test)1