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());
}
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);
}
}
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;
}
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;
}
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"));
}
Aggregations