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