Search in sources :

Example 6 with QueryCache

use of com.linkedin.thirdeye.client.cache.QueryCache in project pinot by linkedin.

the class TabularTest method main.

public static void main(String[] args) throws Exception {
    TabularViewRequest request = new TabularViewRequest();
    String collection = "thirdeyeAbook";
    DateTime baselineStart = new DateTime(2016, 3, 23, 00, 00);
    List<MetricExpression> metricExpressions = new ArrayList<>();
    metricExpressions.add(new MetricExpression("__COUNT", "__COUNT"));
    request.setCollection(collection);
    request.setBaselineStart(baselineStart);
    request.setBaselineEnd(baselineStart.plusDays(1));
    request.setCurrentStart(baselineStart.plusDays(7));
    request.setCurrentEnd(baselineStart.plusDays(8));
    request.setTimeGranularity(new TimeGranularity(1, TimeUnit.HOURS));
    request.setMetricExpressions(metricExpressions);
    // TODO
    PinotThirdEyeClient pinotThirdEyeClient = PinotThirdEyeClient.getDefaultTestClient();
    // make
    // this
    // configurable;
    QueryCache queryCache = new QueryCache(pinotThirdEyeClient, Executors.newFixedThreadPool(10));
    TabularViewHandler handler = new TabularViewHandler(queryCache);
    TabularViewResponse response = handler.process(request);
    ObjectMapper mapper = new ObjectMapper();
    String jsonResponse = mapper.writeValueAsString(response);
    System.out.println(jsonResponse);
}
Also used : PinotThirdEyeClient(com.linkedin.thirdeye.client.pinot.PinotThirdEyeClient) QueryCache(com.linkedin.thirdeye.client.cache.QueryCache) TabularViewHandler(com.linkedin.thirdeye.dashboard.views.tabular.TabularViewHandler) ArrayList(java.util.ArrayList) TimeGranularity(com.linkedin.thirdeye.api.TimeGranularity) TabularViewResponse(com.linkedin.thirdeye.dashboard.views.tabular.TabularViewResponse) MetricExpression(com.linkedin.thirdeye.client.MetricExpression) DateTime(org.joda.time.DateTime) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) TabularViewRequest(com.linkedin.thirdeye.dashboard.views.tabular.TabularViewRequest)

Example 7 with QueryCache

use of com.linkedin.thirdeye.client.cache.QueryCache in project pinot by linkedin.

the class TimeOnTimeTest method main.

public static void main(String[] args) throws Exception {
    // TODO
    PinotThirdEyeClient pinotThirdEyeClient = PinotThirdEyeClient.getDefaultTestClient();
    // make
    // this
    // configurable;
    // PinotThirdEyeClient pinotThirdEyeClient =
    // PinotThirdEyeClient.fromHostList("localhost", 8100, "localhost:8099");
    QueryCache queryCache = new QueryCache(pinotThirdEyeClient, Executors.newFixedThreadPool(10));
    // QueryCache queryCache = new QueryCache(pinotThirdEyeClient, Executors.newCachedThreadPool());
    TimeOnTimeComparisonRequest comparisonRequest;
    comparisonRequest = generateGroupByTimeRequest();
    // comparisonRequest = generateGroupByDimensionRequest();
    // comparisonRequest = generateGroupByTimeAndDimension();
    TimeOnTimeComparisonHandler handler = new TimeOnTimeComparisonHandler(queryCache);
    // long start;
    // long end;
    // // Thread.sleep(30000);
    // for (int i = 0; i < 5; i++) {
    // start = System.currentTimeMillis();
    // handler.handle(comparisonRequest);
    // end = System.currentTimeMillis();
    // System.out.println("Time taken:" + (end - start));
    // }
    // System.exit(0);
    long start = System.currentTimeMillis();
    TimeOnTimeComparisonResponse response = handler.handle(comparisonRequest);
    long end = System.currentTimeMillis();
    System.out.println("Time taken:" + (end - start));
    for (Metric metric : response.getRow(0).getMetrics()) {
        System.out.print(metric.getMetricName() + "\t\t");
    }
    System.out.println();
    for (int i = 0; i < response.getNumRows(); i++) {
        System.out.println(response.getRow(i));
    }
    System.exit(0);
}
Also used : PinotThirdEyeClient(com.linkedin.thirdeye.client.pinot.PinotThirdEyeClient) QueryCache(com.linkedin.thirdeye.client.cache.QueryCache) Metric(com.linkedin.thirdeye.client.comparison.Row.Metric)

Aggregations

QueryCache (com.linkedin.thirdeye.client.cache.QueryCache)7 PinotThirdEyeClient (com.linkedin.thirdeye.client.pinot.PinotThirdEyeClient)6 TimeGranularity (com.linkedin.thirdeye.api.TimeGranularity)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 MetricExpression (com.linkedin.thirdeye.client.MetricExpression)3 ArrayList (java.util.ArrayList)3 DateTime (org.joda.time.DateTime)3 ResultSetGroup (com.linkedin.pinot.client.ResultSetGroup)2 MetricDataset (com.linkedin.thirdeye.client.cache.MetricDataset)2 PinotQuery (com.linkedin.thirdeye.client.pinot.PinotQuery)2 DatasetConfigDTO (com.linkedin.thirdeye.datalayer.dto.DatasetConfigDTO)2 MetricConfigDTO (com.linkedin.thirdeye.datalayer.dto.MetricConfigDTO)2 CacheBuilder (com.google.common.cache.CacheBuilder)1 LoadingCache (com.google.common.cache.LoadingCache)1 RemovalListener (com.google.common.cache.RemovalListener)1 RemovalNotification (com.google.common.cache.RemovalNotification)1 ResultSet (com.linkedin.pinot.client.ResultSet)1 ThirdEyeAnomalyConfiguration (com.linkedin.thirdeye.anomaly.ThirdEyeAnomalyConfiguration)1 MonitorConfiguration (com.linkedin.thirdeye.anomaly.monitor.MonitorConfiguration)1 ThirdEyeClient (com.linkedin.thirdeye.client.ThirdEyeClient)1