Search in sources :

Example 1 with DataSourceChart

use of com.navercorp.pinpoint.web.vo.stat.chart.agent.DataSourceChart in project pinpoint by naver.

the class DataSourceChartService method selectAgentChartList.

@Override
public List<StatChart> selectAgentChartList(String agentId, TimeWindow timeWindow) {
    Objects.requireNonNull(agentId, "agentId");
    Objects.requireNonNull(timeWindow, "timeWindow");
    List<SampledDataSourceList> sampledAgentStatList = this.sampledDataSourceDao.getSampledAgentStatList(agentId, timeWindow);
    if (CollectionUtils.isEmpty(sampledAgentStatList)) {
        List<StatChart> result = new ArrayList<>(1);
        result.add(new DataSourceChart(timeWindow, Collections.emptyList(), serviceTypeRegistryService));
        return result;
    } else {
        List<StatChart> result = new ArrayList<>(sampledAgentStatList.size());
        for (SampledDataSourceList sampledDataSourceList : sampledAgentStatList) {
            result.add(new DataSourceChart(timeWindow, sampledDataSourceList.getSampledDataSourceList(), serviceTypeRegistryService));
        }
        return result;
    }
}
Also used : SampledDataSourceList(com.navercorp.pinpoint.web.vo.stat.SampledDataSourceList) DataSourceChart(com.navercorp.pinpoint.web.vo.stat.chart.agent.DataSourceChart) ArrayList(java.util.ArrayList) StatChart(com.navercorp.pinpoint.web.vo.stat.chart.StatChart)

Example 2 with DataSourceChart

use of com.navercorp.pinpoint.web.vo.stat.chart.agent.DataSourceChart 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

DataSourceChart (com.navercorp.pinpoint.web.vo.stat.chart.agent.DataSourceChart)2 TimeWindow (com.navercorp.pinpoint.web.util.TimeWindow)1 SampledDataSource (com.navercorp.pinpoint.web.vo.stat.SampledDataSource)1 SampledDataSourceList (com.navercorp.pinpoint.web.vo.stat.SampledDataSourceList)1 StatChart (com.navercorp.pinpoint.web.vo.stat.chart.StatChart)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1