Search in sources :

Example 1 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() throws Exception {
    long currentTimeMillis = System.currentTimeMillis();
    TimeWindow timeWindow = new TimeWindow(new Range(currentTimeMillis - 300000, currentTimeMillis));
    List<SampledDataSource> sampledDataSourceList = Collections.emptyList();
    DataSourceChartGroup dataSourceChartGroup = new DataSourceChartGroup(timeWindow, sampledDataSourceList, serviceTypeRegistryService);
    Assert.assertEquals(-1, dataSourceChartGroup.getId());
    Assert.assertEquals(null, dataSourceChartGroup.getJdbcUrl());
    Assert.assertEquals(null, dataSourceChartGroup.getDatabaseName());
    Assert.assertEquals(null, dataSourceChartGroup.getServiceTypeName());
}
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 2 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, DataSourceChartGroup dataSourceChartGroup) {
    Map<AgentStatChartGroup.ChartType, Chart> charts = dataSourceChartGroup.getCharts();
    Chart activeConnectionSizeChart = charts.get(DataSourceChartGroup.DataSourceChartType.ACTIVE_CONNECTION_SIZE);
    List<Point> activeConnectionSizeChartPointList = activeConnectionSizeChart.getPoints();
    for (int i = 0; i < sampledDataSourceList.size(); i++) {
        SampledDataSource sampledDataSource = sampledDataSourceList.get(i);
        Point<Long, Integer> point = sampledDataSource.getActiveConnectionSize();
        Assert.assertEquals(activeConnectionSizeChartPointList.get(i), point);
    }
    Chart maxConnectionSizeChart = charts.get(DataSourceChartGroup.DataSourceChartType.MAX_CONNECTION_SIZE);
    List<Point> maxConnectionSizeChartPointList = maxConnectionSizeChart.getPoints();
    for (int i = 0; i < sampledDataSourceList.size(); i++) {
        SampledDataSource sampledDataSource = sampledDataSourceList.get(i);
        Point<Long, Integer> 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 3 with SampledDataSource

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

the class SampledDataSourceResultExtractor method getSampleData.

private SampledDataSourceList getSampleData(List<DataSourceBo> dataSourceBoList) {
    dataSourceBoList.sort(Comparator.comparingLong(DataSourceBo::getTimestamp).reversed());
    AgentStatSamplingHandler<DataSourceBo, SampledDataSource> samplingHandler = new EagerSamplingHandler<>(timeWindow, sampler);
    for (DataSourceBo dataSourceBo : dataSourceBoList) {
        samplingHandler.addDataPoint(dataSourceBo);
    }
    List<SampledDataSource> sampledDataSources = samplingHandler.getSampledDataPoints();
    SampledDataSourceList sampledDataSourceList = new SampledDataSourceList();
    for (SampledDataSource sampledDataSource : sampledDataSources) {
        sampledDataSourceList.addSampledDataSource(sampledDataSource);
    }
    return sampledDataSourceList;
}
Also used : SampledDataSourceList(com.navercorp.pinpoint.web.vo.stat.SampledDataSourceList) SampledDataSource(com.navercorp.pinpoint.web.vo.stat.SampledDataSource) DataSourceBo(com.navercorp.pinpoint.common.server.bo.stat.DataSourceBo) EagerSamplingHandler(com.navercorp.pinpoint.web.mapper.stat.sampling.EagerSamplingHandler)

Example 4 with SampledDataSource

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

the class DataSourceSampler method sampleDataPoints.

@Override
public SampledDataSource sampleDataPoints(int timeWindowIndex, long timestamp, List<DataSourceBo> dataSourceBoList, DataSourceBo previousDataSourceBo) {
    if (CollectionUtils.isEmpty(dataSourceBoList)) {
        return null;
    }
    final List<Integer> activeConnectionSizes = new ArrayList<>(dataSourceBoList.size());
    final List<Integer> maxConnectionSizes = new ArrayList<>(dataSourceBoList.size());
    final DataSourceBo defaultDataSourceBo = dataSourceBoList.get(0);
    final int id = defaultDataSourceBo.getId();
    final short serviceTypeCode = defaultDataSourceBo.getServiceTypeCode();
    String databaseName = defaultDataSourceBo.getDatabaseName();
    String jdbcUrl = defaultDataSourceBo.getJdbcUrl();
    for (DataSourceBo dataSourceBo : dataSourceBoList) {
        final int activeConnectionSize = dataSourceBo.getActiveConnectionSize();
        if (activeConnectionSize >= 0) {
            activeConnectionSizes.add(activeConnectionSize);
        }
        final int maxConnectionSize = dataSourceBo.getMaxConnectionSize();
        if (maxConnectionSize >= 0) {
            maxConnectionSizes.add(maxConnectionSize);
        }
        if (dataSourceBo.getId() != id) {
            throw new IllegalArgumentException("id must be same");
        }
        if (dataSourceBo.getServiceTypeCode() != serviceTypeCode) {
            throw new IllegalArgumentException("serviceTypeCode must be same");
        }
        if (databaseName == null && dataSourceBo.getDatabaseName() != null) {
            databaseName = dataSourceBo.getDatabaseName();
        }
        if (jdbcUrl == null && dataSourceBo.getJdbcUrl() != null) {
            jdbcUrl = dataSourceBo.getJdbcUrl();
        }
    }
    SampledDataSource sampledDataSource = new SampledDataSource();
    sampledDataSource.setId(id);
    sampledDataSource.setServiceTypeCode(serviceTypeCode);
    sampledDataSource.setDatabaseName(databaseName);
    sampledDataSource.setJdbcUrl(jdbcUrl);
    sampledDataSource.setActiveConnectionSize(createPoint(timestamp, activeConnectionSizes));
    sampledDataSource.setMaxConnectionSize(createPoint(timestamp, maxConnectionSizes));
    return sampledDataSource;
}
Also used : SampledDataSource(com.navercorp.pinpoint.web.vo.stat.SampledDataSource) ArrayList(java.util.ArrayList) DataSourceBo(com.navercorp.pinpoint.common.server.bo.stat.DataSourceBo) AgentStatPoint(com.navercorp.pinpoint.web.vo.stat.chart.agent.AgentStatPoint)

Example 5 with SampledDataSource

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

the class DataSourceChartSerializerTest method serializeTest.

@Test
public void serializeTest() throws Exception {
    long currentTimeMillis = System.currentTimeMillis();
    TimeWindow timeWindow = new TimeWindow(Range.newRange(currentTimeMillis - 300000, currentTimeMillis));
    List<SampledDataSource> sampledDataSourceList = createSampledDataSourceList(timeWindow);
    DataSourceChart dataSourceChartGroup = new DataSourceChart(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 : SampledDataSource(com.navercorp.pinpoint.web.vo.stat.SampledDataSource) DataSourceChart(com.navercorp.pinpoint.web.vo.stat.chart.agent.DataSourceChart) TimeWindow(com.navercorp.pinpoint.web.util.TimeWindow) 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