当前位置: 首页>>代码示例>>Java>>正文


Java SQLResponse.setStorageCacheUsed方法代码示例

本文整理汇总了Java中org.apache.kylin.rest.response.SQLResponse.setStorageCacheUsed方法的典型用法代码示例。如果您正苦于以下问题:Java SQLResponse.setStorageCacheUsed方法的具体用法?Java SQLResponse.setStorageCacheUsed怎么用?Java SQLResponse.setStorageCacheUsed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.kylin.rest.response.SQLResponse的用法示例。


在下文中一共展示了SQLResponse.setStorageCacheUsed方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testQueryMetrics

import org.apache.kylin.rest.response.SQLResponse; //导入方法依赖的package包/类
@Test
public void testQueryMetrics() throws Exception {
    System.setProperty("kylin.server.query-metrics-enabled", "true");
    QueryMetricsFacade.init();

    SQLRequest sqlRequest = new SQLRequest();
    sqlRequest.setSql("select * from TEST_KYLIN_FACT");
    sqlRequest.setProject("default");

    SQLResponse sqlResponse = new SQLResponse();
    sqlResponse.setDuration(10);
    sqlResponse.setCube("test_cube");
    sqlResponse.setIsException(false);
    sqlResponse.setTotalScanCount(100);
    List<String> list1 = new ArrayList<>();
    list1.add("111");
    list1.add("112");
    List<String> list2 = new ArrayList<>();
    list2.add("111");
    list2.add("112");
    List<List<String>> results = new ArrayList<>();
    results.add(list1);
    results.add(list2);
    sqlResponse.setResults(results);
    sqlResponse.setStorageCacheUsed(true);

    QueryMetricsFacade.updateMetrics(sqlRequest, sqlResponse);

    Thread.sleep(2000);

    Assert.assertEquals(1L, mBeanServer.getAttribute(objectName, "QueryCount"));
    Assert.assertEquals(1L, mBeanServer.getAttribute(objectName, "QuerySuccessCount"));
    Assert.assertEquals(0L, mBeanServer.getAttribute(objectName, "QueryFailCount"));
    Assert.assertEquals(1L, mBeanServer.getAttribute(objectName, "CacheHitCount"));

    Assert.assertEquals(1L, mBeanServer.getAttribute(objectName, "ScanRowCountNumOps"));
    Assert.assertEquals(100.0, mBeanServer.getAttribute(objectName, "ScanRowCountAvgTime"));
    Assert.assertEquals(100.0, mBeanServer.getAttribute(objectName, "ScanRowCountMaxTime"));
    Assert.assertEquals(100.0, mBeanServer.getAttribute(objectName, "ScanRowCountMinTime"));

    Assert.assertEquals(1L, mBeanServer.getAttribute(objectName, "ResultRowCountNumOps"));
    Assert.assertEquals(2.0, mBeanServer.getAttribute(objectName, "ResultRowCountMaxTime"));
    Assert.assertEquals(2.0, mBeanServer.getAttribute(objectName, "ResultRowCountAvgTime"));
    Assert.assertEquals(2.0, mBeanServer.getAttribute(objectName, "ResultRowCountMinTime"));

    Assert.assertEquals(1L, mBeanServer.getAttribute(objectName, "QueryLatencyNumOps"));
    Assert.assertEquals(10.0, mBeanServer.getAttribute(objectName, "QueryLatencyMaxTime"));
    Assert.assertEquals(10.0, mBeanServer.getAttribute(objectName, "QueryLatencyAvgTime"));
    Assert.assertEquals(10.0, mBeanServer.getAttribute(objectName, "QueryLatencyMinTime"));

    SQLResponse sqlResponse2 = new SQLResponse();
    sqlResponse2.setDuration(10);
    sqlResponse2.setCube("test_cube");
    sqlResponse2.setIsException(true);

    QueryMetricsFacade.updateMetrics(sqlRequest, sqlResponse2);

    Thread.sleep(2000);

    Assert.assertEquals(2L, mBeanServer.getAttribute(objectName, "QueryCount"));
    Assert.assertEquals(1L, mBeanServer.getAttribute(objectName, "QuerySuccessCount"));
    Assert.assertEquals(1L, mBeanServer.getAttribute(objectName, "QueryFailCount"));

    System.clearProperty("kylin.server.query-metrics-enabled");
}
 
开发者ID:apache,项目名称:kylin,代码行数:66,代码来源:QueryMetricsTest.java

示例2: testQueryStatisticsResult

import org.apache.kylin.rest.response.SQLResponse; //导入方法依赖的package包/类
@Test
public void testQueryStatisticsResult() throws Exception {
    System.setProperty("kylin.metrics.reporter-query-enabled", "true");
    QueryMetricsFacade.init();

    SQLRequest sqlRequest = new SQLRequest();
    sqlRequest.setSql("select * from TEST_KYLIN_FACT");
    sqlRequest.setProject("default");

    SQLResponse sqlResponse = new SQLResponse();
    sqlResponse.setDuration(10);
    sqlResponse.setCube("test_cube");
    sqlResponse.setIsException(false);
    sqlResponse.setTotalScanCount(100);
    List<String> list1 = new ArrayList<>();
    list1.add("111");
    list1.add("112");
    List<String> list2 = new ArrayList<>();
    list2.add("111");
    list2.add("112");
    List<List<String>> results = new ArrayList<>();
    results.add(list1);
    results.add(list2);
    sqlResponse.setResults(results);
    sqlResponse.setStorageCacheUsed(true);

    QueryContext context = QueryContext.current();
    int ctxId = 0;
    context.addContext(ctxId, "OLAP", true);
    context.addRPCStatistics(ctxId, "sandbox", "test_cube", "20100101000000_20150101000000", 3L, 3L, 3L, null, 80L,
            0L, 2L, 2L, 0L, 30L);

    sqlResponse.setCubeSegmentStatisticsList(context.getCubeSegmentStatisticsResultList());

    QueryMetricsFacade.updateMetrics(sqlRequest, sqlResponse);

    Thread.sleep(2000);

    System.clearProperty("kylin.server.query-metrics-enabled");
    System.out.println("------------testQueryStatisticsResult done------------");
}
 
开发者ID:apache,项目名称:kylin,代码行数:42,代码来源:QueryMetricsTest.java

示例3: testQueryMetrics

import org.apache.kylin.rest.response.SQLResponse; //导入方法依赖的package包/类
@Test
public void testQueryMetrics() throws Exception {
    System.setProperty("kylin.server.query-metrics2-enabled", "true");
    QueryMetrics2Facade.init();
    SQLRequest sqlRequest = new SQLRequest();
    sqlRequest.setSql("select * from TEST_KYLIN_FACT");
    sqlRequest.setProject("default");
    SQLResponse sqlResponse = new SQLResponse();
    sqlResponse.setDuration(10);
    sqlResponse.setCube("test_cube");
    sqlResponse.setIsException(false);
    sqlResponse.setTotalScanCount(100);
    List<String> list1 = new ArrayList<>();
    list1.add("111");
    list1.add("112");
    List<String> list2 = new ArrayList<>();
    list2.add("111");
    list2.add("112");
    List<List<String>> results = new ArrayList<>();
    results.add(list1);
    results.add(list2);
    sqlResponse.setResults(results);
    sqlResponse.setStorageCacheUsed(true);
    Metrics metrics = MetricsFactory.getInstance();
    QueryMetrics2Facade.updateMetrics(sqlRequest, sqlResponse);
    String prefix = buildCubeMetricPrefix(sqlRequest.getProject(), sqlResponse.getCube().replace("=", "->"));
    Thread.sleep(2000);

    Assert.assertEquals(1L,
            metrics.getCounter(MetricsNameBuilder.buildMetricName(prefix, MetricsConstant.QUERY_COUNT)).getCount());
    Assert.assertEquals(1L,
            metrics.getCounter(MetricsNameBuilder.buildMetricName(prefix, MetricsConstant.QUERY_SUCCESS_COUNT))
                    .getCount());
    Assert.assertEquals(0L, metrics
            .getCounter(MetricsNameBuilder.buildMetricName(prefix, MetricsConstant.QUERY_FAIL_COUNT)).getCount());
    Assert.assertEquals(1L, metrics
            .getCounter(MetricsNameBuilder.buildMetricName(prefix, MetricsConstant.QUERY_CACHE_COUNT)).getCount());
    //
    Snapshot queryScanSnapshot = metrics
            .getHistogram(MetricsNameBuilder.buildMetricName(prefix, MetricsConstant.QUERY_SCAN_ROWCOUNT))
            .getSnapshot();
    Assert.assertEquals(100.0, queryScanSnapshot.getMean(), 0);
    Assert.assertEquals(100.0, queryScanSnapshot.getMax(), 0);
    Assert.assertEquals(100.0, queryScanSnapshot.getMin(), 0);

    Snapshot queryResultSnapshot = metrics
            .getHistogram(MetricsNameBuilder.buildMetricName(prefix, MetricsConstant.QUERY_RESULT_ROWCOUNT))
            .getSnapshot();

    Assert.assertEquals(2.0, queryResultSnapshot.getMean(), 0);
    Assert.assertEquals(2.0, queryResultSnapshot.getMax(), 0);
    Assert.assertEquals(2.0, queryResultSnapshot.getMin(), 0);

    Snapshot queryLatencySnapshot = metrics
            .getTimer(MetricsNameBuilder.buildMetricName(prefix, MetricsConstant.QUERY_DURATION)).getSnapshot();
    Assert.assertEquals(TimeUnit.MILLISECONDS.toNanos(10), queryLatencySnapshot.getMean(), 0);
    Assert.assertEquals(TimeUnit.MILLISECONDS.toNanos(10), queryLatencySnapshot.getMax(), 0);
    Assert.assertEquals(TimeUnit.MILLISECONDS.toNanos(10), queryLatencySnapshot.getMin(), 0);

    SQLResponse sqlResponse2 = new SQLResponse();
    sqlResponse2.setDuration(10);
    sqlResponse2.setCube("test_cube");
    sqlResponse2.setIsException(true);

    QueryMetrics2Facade.updateMetrics(sqlRequest, sqlResponse2);
    prefix = buildCubeMetricPrefix(sqlRequest.getProject(), sqlResponse.getCube().replace("=", "->"));
    Assert.assertEquals(2L,
            metrics.getCounter(MetricsNameBuilder.buildMetricName(prefix, MetricsConstant.QUERY_COUNT)).getCount());
    Assert.assertEquals(1L,
            metrics.getCounter(MetricsNameBuilder.buildMetricName(prefix, MetricsConstant.QUERY_SUCCESS_COUNT))
                    .getCount());
    Assert.assertEquals(1L, metrics
            .getCounter(MetricsNameBuilder.buildMetricName(prefix, MetricsConstant.QUERY_FAIL_COUNT)).getCount());
}
 
开发者ID:apache,项目名称:kylin,代码行数:75,代码来源:QueryMetrics2Test.java


注:本文中的org.apache.kylin.rest.response.SQLResponse.setStorageCacheUsed方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。