Search in sources :

Example 6 with SampledDataSource

use of com.navercorp.pinpoint.web.vo.stat.SampledDataSource in project pinpoint by naver.

the class DataSourceChartGroupSerializerTest method serializeTest.

@Test
public void serializeTest() throws Exception {
    long currentTimeMillis = System.currentTimeMillis();
    TimeWindow timeWindow = new TimeWindow(new Range(currentTimeMillis - 300000, currentTimeMillis));
    List<SampledDataSource> sampledDataSourceList = createSampledDataSourceList(timeWindow);
    DataSourceChartGroup dataSourceChartGroup = new DataSourceChartGroup(timeWindow, sampledDataSourceList, serviceTypeRegistryService);
    String jsonValue = mapper.writeValueAsString(dataSourceChartGroup);
    Map map = mapper.readValue(jsonValue, Map.class);
    Assert.assertTrue(map.containsKey("id"));
    Assert.assertTrue(map.containsKey("jdbcUrl"));
    Assert.assertTrue(map.containsKey("databaseName"));
    Assert.assertTrue(map.containsKey("serviceType"));
    Assert.assertTrue(map.containsKey("charts"));
}
Also used : DataSourceChartGroup(com.navercorp.pinpoint.web.vo.stat.chart.DataSourceChartGroup) SampledDataSource(com.navercorp.pinpoint.web.vo.stat.SampledDataSource) Range(com.navercorp.pinpoint.web.vo.Range) TimeWindow(com.navercorp.pinpoint.web.util.TimeWindow) Map(java.util.Map) Test(org.junit.Test)

Example 7 with SampledDataSource

use of com.navercorp.pinpoint.web.vo.stat.SampledDataSource in project pinpoint by naver.

the class DataSourceChartGroupTest method basicFunctionTest1.

@Test
public void basicFunctionTest1() throws Exception {
    long currentTimeMillis = System.currentTimeMillis();
    TimeWindow timeWindow = new TimeWindow(new Range(currentTimeMillis - 300000, currentTimeMillis));
    List<SampledDataSource> sampledDataSourceList = createSampledDataSourceList(timeWindow);
    DataSourceChartGroup dataSourceChartGroup = new DataSourceChartGroup(timeWindow, sampledDataSourceList, serviceTypeRegistryService);
    assertEquals(sampledDataSourceList, dataSourceChartGroup);
}
Also used : SampledDataSource(com.navercorp.pinpoint.web.vo.stat.SampledDataSource) Range(com.navercorp.pinpoint.web.vo.Range) TimeWindow(com.navercorp.pinpoint.web.util.TimeWindow) Test(org.junit.Test)

Example 8 with SampledDataSource

use of com.navercorp.pinpoint.web.vo.stat.SampledDataSource in project pinpoint by naver.

the class DataSourceChartGroupTest method createSampledDataSourceList.

private List<SampledDataSource> createSampledDataSourceList(TimeWindow timeWindow) {
    List<SampledDataSource> sampledDataSourceList = new ArrayList<>();
    int maxConnectionSize = RANDOM.nextInt(MIN_VALUE_OF_MAX_CONNECTION_SIZE) + MIN_VALUE_OF_MAX_CONNECTION_SIZE;
    long from = timeWindow.getWindowRange().getFrom();
    long to = timeWindow.getWindowRange().getTo();
    for (long i = from; i < to; i += timeWindow.getWindowSlotSize()) {
        sampledDataSourceList.add(createSampledDataSource(i, maxConnectionSize));
    }
    return sampledDataSourceList;
}
Also used : SampledDataSource(com.navercorp.pinpoint.web.vo.stat.SampledDataSource) ArrayList(java.util.ArrayList) Point(com.navercorp.pinpoint.web.vo.chart.Point)

Example 9 with SampledDataSource

use of com.navercorp.pinpoint.web.vo.stat.SampledDataSource in project pinpoint by naver.

the class DataSourceChartGroupTest method assertEquals.

private void assertEquals(List<SampledDataSource> sampledDataSourceList, StatChartGroup dataSourceChartGroup) {
    Map<StatChartGroup.ChartType, Chart<? extends Point>> charts = dataSourceChartGroup.getCharts();
    Chart<? extends Point> activeConnectionSizeChart = charts.get(DataSourceChart.DataSourceChartGroup.DataSourceChartType.ACTIVE_CONNECTION_SIZE);
    List<? extends Point> activeConnectionSizeChartPointList = activeConnectionSizeChart.getPoints();
    for (int i = 0; i < sampledDataSourceList.size(); i++) {
        SampledDataSource sampledDataSource = sampledDataSourceList.get(i);
        Point point = sampledDataSource.getActiveConnectionSize();
        Assert.assertEquals(activeConnectionSizeChartPointList.get(i), point);
    }
    Chart maxConnectionSizeChart = charts.get(DataSourceChart.DataSourceChartGroup.DataSourceChartType.MAX_CONNECTION_SIZE);
    List<Point> maxConnectionSizeChartPointList = maxConnectionSizeChart.getPoints();
    for (int i = 0; i < sampledDataSourceList.size(); i++) {
        SampledDataSource sampledDataSource = sampledDataSourceList.get(i);
        Point point = sampledDataSource.getMaxConnectionSize();
        Assert.assertEquals(maxConnectionSizeChartPointList.get(i), point);
    }
}
Also used : SampledDataSource(com.navercorp.pinpoint.web.vo.stat.SampledDataSource) Point(com.navercorp.pinpoint.web.vo.chart.Point) Chart(com.navercorp.pinpoint.web.vo.chart.Chart) Point(com.navercorp.pinpoint.web.vo.chart.Point)

Example 10 with SampledDataSource

use of com.navercorp.pinpoint.web.vo.stat.SampledDataSource in project pinpoint by naver.

the class DataSourceChartGroupTest method createSampledDataSourceList.

private List<SampledDataSource> createSampledDataSourceList(TimeWindow timeWindow) {
    List<SampledDataSource> sampledDataSourceList = new ArrayList<>();
    int maxConnectionSize = ThreadLocalRandom.current().nextInt(MIN_VALUE_OF_MAX_CONNECTION_SIZE) + MIN_VALUE_OF_MAX_CONNECTION_SIZE;
    long from = timeWindow.getWindowRange().getFrom();
    long to = timeWindow.getWindowRange().getTo();
    for (long i = from; i < to; i += timeWindow.getWindowSlotSize()) {
        sampledDataSourceList.add(createSampledDataSource(i, maxConnectionSize));
    }
    return sampledDataSourceList;
}
Also used : SampledDataSource(com.navercorp.pinpoint.web.vo.stat.SampledDataSource) ArrayList(java.util.ArrayList) Point(com.navercorp.pinpoint.web.vo.chart.Point)

Aggregations

SampledDataSource (com.navercorp.pinpoint.web.vo.stat.SampledDataSource)14 Test (org.junit.Test)7 TimeWindow (com.navercorp.pinpoint.web.util.TimeWindow)6 Point (com.navercorp.pinpoint.web.vo.chart.Point)6 Chart (com.navercorp.pinpoint.web.vo.chart.Chart)4 DataSourceBo (com.navercorp.pinpoint.common.server.bo.stat.DataSourceBo)3 Range (com.navercorp.pinpoint.web.vo.Range)3 ArrayList (java.util.ArrayList)3 VisibleForTesting (com.navercorp.pinpoint.common.annotations.VisibleForTesting)1 EagerSamplingHandler (com.navercorp.pinpoint.web.mapper.stat.sampling.EagerSamplingHandler)1 SampledDataSourceList (com.navercorp.pinpoint.web.vo.stat.SampledDataSourceList)1 DataSourceChartGroup (com.navercorp.pinpoint.web.vo.stat.chart.DataSourceChartGroup)1 StatChart (com.navercorp.pinpoint.web.vo.stat.chart.StatChart)1 StatChartGroup (com.navercorp.pinpoint.web.vo.stat.chart.StatChartGroup)1 AgentStatPoint (com.navercorp.pinpoint.web.vo.stat.chart.agent.AgentStatPoint)1 DataSourceChart (com.navercorp.pinpoint.web.vo.stat.chart.agent.DataSourceChart)1 Map (java.util.Map)1