Search in sources :

Example 1 with StreamConfig

use of com.ning.metrics.meteo.binder.StreamConfig in project meteo by pierre.

the class TestPublishersCompilerStreamConfig method setUp.

@BeforeTest
public void setUp() {
    // Build the following configuration
    //     {
    //         "publishers": [
    //             {
    //                 "name": "OpenTSDB",
    //                 "type": "com.ning.metrics.meteo.publishers.OpenTSDBListener",
    //                 "host": "opentsdb.company.com",
    //                 "port": 4242
    //             }
    //         ],
    //
    //         "streams": [
    //             {
    //                 "name": "TPs of visit",
    //
    //                 "sql": [
    //                     "select tp90 from visit output last every 1 second"
    //                 ],
    //
    //                 "routes": [
    //                     {
    //                         "name": "OpenTSDB",
    //                         "filters": [ "predict", "tp90" ],
    //                         "timeAttribute": "visit_date"
    //                     }
    //                 ]
    //             }
    //         ]
    //     }
    statementsConfig = new StatementsConfig();
    final DummyPublisherConfig globalPublisherConfig = new DummyPublisherConfig();
    globalPublisherConfig.setName("OpenTSDB");
    globalPublisherConfig.setType("com.ning.metrics.meteo.publishers.OpenTSDBListener");
    globalPublisherConfig.setHost("opentsdb.company.com");
    globalPublisherConfig.setPort(4242);
    statementsConfig.setPublishers(Arrays.asList((PublisherConfig) globalPublisherConfig));
    final StreamConfig streamConfig = new StreamConfig();
    streamConfig.setName("TPs of Visit");
    streamConfig.setSql(Arrays.asList("select tp90 from visit output last every 1 second"));
    final HashMap<String, Object> localPublisherConfig = new HashMap<String, Object>();
    localPublisherConfig.put("name", "OpenTSDB");
    localPublisherConfig.put("filters", (Arrays.asList("predict", "tp90")));
    localPublisherConfig.put("timeAttribute", "visit_date");
    streamConfig.setRoutes(Arrays.<HashMap<String, Object>>asList(localPublisherConfig));
    statementsConfig.setStatementConfigs(Arrays.asList(streamConfig));
}
Also used : HashMap(java.util.HashMap) StatementsConfig(com.ning.metrics.meteo.binder.StatementsConfig) StreamConfig(com.ning.metrics.meteo.binder.StreamConfig) BeforeTest(org.testng.annotations.BeforeTest)

Example 2 with StreamConfig

use of com.ning.metrics.meteo.binder.StreamConfig in project meteo by pierre.

the class TestPublishersCompilerStreamConfig method testInstantiateListener.

@Test(groups = "fast")
public void testInstantiateListener() throws Exception {
    final PublishersCompiler compiler = new PublishersCompiler(statementsConfig.getPublishers(), new ArrayList<StreamConfig>(), null);
    final StreamConfig streamConfig = statementsConfig.getStatements().get(0);
    compiler.configurePublishersForStream(streamConfig);
    final String streamName = streamConfig.getName();
    final PublisherConfig publisherConfig = compiler.getStreamConfigs().get(streamName).getPublishers().get(0);
    assertTrue(publisherConfig instanceof DummyPublisherConfig);
    final DummyPublisherConfig config = (DummyPublisherConfig) publisherConfig;
    assertEquals(config.getName(), "OpenTSDB");
    assertEquals(config.getType(), "com.ning.metrics.meteo.publishers.OpenTSDBListener");
    assertEquals(config.getHost(), "opentsdb.company.com");
    assertEquals((int) config.getPort(), 4242);
    assertEquals(config.getType(), "com.ning.metrics.meteo.publishers.OpenTSDBListener");
    assertEquals(config.getFilters().get(0).toString(), "predict");
    assertEquals(config.getFilters().get(1).toString(), "tp90");
    assertEquals(config.getTimeAttribute(), "visit_date");
}
Also used : StreamConfig(com.ning.metrics.meteo.binder.StreamConfig) BeforeTest(org.testng.annotations.BeforeTest) Test(org.testng.annotations.Test)

Aggregations

StreamConfig (com.ning.metrics.meteo.binder.StreamConfig)2 BeforeTest (org.testng.annotations.BeforeTest)2 StatementsConfig (com.ning.metrics.meteo.binder.StatementsConfig)1 HashMap (java.util.HashMap)1 Test (org.testng.annotations.Test)1