Search in sources :

Example 11 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() {
    long currentTimeMillis = System.currentTimeMillis();
    TimeWindow timeWindow = new TimeWindow(Range.newRange(currentTimeMillis - 300000, currentTimeMillis));
    List<SampledDataSource> sampledDataSourceList = createSampledDataSourceList(timeWindow);
    StatChartGroup dataSourceChartGroup = DataSourceChart.newDataSourceChartGroup(timeWindow, sampledDataSourceList, serviceTypeRegistryService);
    assertEquals(sampledDataSourceList, dataSourceChartGroup);
}
Also used : StatChartGroup(com.navercorp.pinpoint.web.vo.stat.chart.StatChartGroup) SampledDataSource(com.navercorp.pinpoint.web.vo.stat.SampledDataSource) TimeWindow(com.navercorp.pinpoint.web.util.TimeWindow) Test(org.junit.Test)

Example 12 with SampledDataSource

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

the class DataSourceChartGroupTest method basicFunctionTest2.

@Test
public void basicFunctionTest2() {
    long currentTimeMillis = System.currentTimeMillis();
    TimeWindow timeWindow = new TimeWindow(Range.newRange(currentTimeMillis - 300000, currentTimeMillis));
    List<SampledDataSource> sampledDataSourceList = Collections.emptyList();
    DataSourceChart dataSourceChartGroup = new DataSourceChart(timeWindow, sampledDataSourceList, serviceTypeRegistryService);
    Assert.assertEquals(-1, dataSourceChartGroup.getId());
    Assert.assertEquals(null, dataSourceChartGroup.getJdbcUrl());
    Assert.assertEquals(null, dataSourceChartGroup.getDatabaseName());
    Assert.assertEquals(null, dataSourceChartGroup.getServiceType());
    Map<StatChartGroup.ChartType, Chart<? extends Point>> charts = dataSourceChartGroup.getCharts().getCharts();
    Assert.assertEquals(2, charts.size());
    for (Chart<? extends Point> chart : charts.values()) {
        Assert.assertTrue(CollectionUtils.isEmpty(chart.getPoints()));
    }
}
Also used : SampledDataSource(com.navercorp.pinpoint.web.vo.stat.SampledDataSource) Point(com.navercorp.pinpoint.web.vo.chart.Point) TimeWindow(com.navercorp.pinpoint.web.util.TimeWindow) Chart(com.navercorp.pinpoint.web.vo.chart.Chart) Test(org.junit.Test)

Example 13 with SampledDataSource

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

the class DataSourceChart method newDataSourceChartGroup.

@VisibleForTesting
static DataSourceChartGroup newDataSourceChartGroup(TimeWindow timeWindow, List<SampledDataSource> sampledDataSources, ServiceTypeRegistryService serviceTypeRegistryService) {
    Objects.requireNonNull(timeWindow, "timeWindow");
    Map<StatChartGroup.ChartType, Chart<? extends Point>> chartTypeChartMap = newDatasourceChart(timeWindow, sampledDataSources);
    if (CollectionUtils.isEmpty(sampledDataSources)) {
        final Integer uncollectedValue = SampledDataSource.UNCOLLECTED_VALUE;
        // TODO avoid null
        final String uncollectedString = SampledDataSource.UNCOLLECTED_STRING;
        return new DataSourceChartGroup(timeWindow, chartTypeChartMap, uncollectedValue, uncollectedString, uncollectedString, uncollectedString);
    } else {
        SampledDataSource latestSampledDataSource = CollectionUtils.lastElement(sampledDataSources);
        int id = latestSampledDataSource.getId();
        String serviceTypeName = serviceTypeRegistryService.findServiceType(latestSampledDataSource.getServiceTypeCode()).getName();
        String databaseName = latestSampledDataSource.getDatabaseName();
        String jdbcUrl = latestSampledDataSource.getJdbcUrl();
        return new DataSourceChartGroup(timeWindow, chartTypeChartMap, id, serviceTypeName, databaseName, jdbcUrl);
    }
}
Also used : SampledDataSource(com.navercorp.pinpoint.web.vo.stat.SampledDataSource) Point(com.navercorp.pinpoint.web.vo.chart.Point) StatChart(com.navercorp.pinpoint.web.vo.stat.chart.StatChart) Chart(com.navercorp.pinpoint.web.vo.chart.Chart) Point(com.navercorp.pinpoint.web.vo.chart.Point) VisibleForTesting(com.navercorp.pinpoint.common.annotations.VisibleForTesting)

Example 14 with SampledDataSource

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

the class DataSourceSamplerTest method sampleDataPointsTest1.

@Test
public void sampleDataPointsTest1() {
    int testObjectSize = RandomUtils.nextInt(1, CREATE_TEST_OBJECT_MAX_SIZE);
    int maxConnectionSize = RandomUtils.nextInt(MIN_VALUE_OF_MAX_CONNECTION_SIZE, MIN_VALUE_OF_MAX_CONNECTION_SIZE * 2);
    List<DataSourceBo> dataSourceBoList = DataSourceTestUtils.createDataSourceBoList(1, testObjectSize, maxConnectionSize);
    SampledDataSource sampledDataSource = sampler.sampleDataPoints(0, System.currentTimeMillis(), dataSourceBoList, null);
    assertEquals(sampledDataSource, dataSourceBoList);
}
Also used : SampledDataSource(com.navercorp.pinpoint.web.vo.stat.SampledDataSource) DataSourceBo(com.navercorp.pinpoint.common.server.bo.stat.DataSourceBo) Test(org.junit.Test)

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