use of com.navercorp.pinpoint.common.server.bo.stat.DataSourceBo in project pinpoint by naver.
the class DataSourceSamplerTest method assertEquals.
private void assertEquals(SampledDataSource sampledDataSource, List<DataSourceBo> dataSourceBoList) {
int minActiveConnectionSize = Integer.MAX_VALUE;
int maxActiveConnectionSize = Integer.MIN_VALUE;
int sumActiveConnectionSize = 0;
int minMaxConnectionSize = Integer.MAX_VALUE;
int maxMaxConnectionSize = Integer.MIN_VALUE;
int sumMaxConnectionSize = 0;
for (DataSourceBo dataSourceBo : dataSourceBoList) {
int activeConnectionSize = dataSourceBo.getActiveConnectionSize();
if (activeConnectionSize < minActiveConnectionSize) {
minActiveConnectionSize = activeConnectionSize;
}
if (activeConnectionSize > maxActiveConnectionSize) {
maxActiveConnectionSize = activeConnectionSize;
}
sumActiveConnectionSize += activeConnectionSize;
int maxConnectionSize = dataSourceBo.getMaxConnectionSize();
if (maxConnectionSize < minMaxConnectionSize) {
minMaxConnectionSize = maxConnectionSize;
}
if (maxConnectionSize > maxMaxConnectionSize) {
maxMaxConnectionSize = maxConnectionSize;
}
sumMaxConnectionSize += maxConnectionSize;
}
Assert.assertTrue(sampledDataSource.getActiveConnectionSize().getMinYVal().equals(minActiveConnectionSize));
Assert.assertTrue(sampledDataSource.getActiveConnectionSize().getMaxYVal().equals(maxActiveConnectionSize));
Assert.assertTrue(sampledDataSource.getActiveConnectionSize().getSumYVal().equals(sumActiveConnectionSize));
Assert.assertTrue(sampledDataSource.getMaxConnectionSize().getMinYVal().equals(minMaxConnectionSize));
Assert.assertTrue(sampledDataSource.getMaxConnectionSize().getMaxYVal().equals(maxMaxConnectionSize));
Assert.assertTrue(sampledDataSource.getMaxConnectionSize().getSumYVal().equals(sumMaxConnectionSize));
}
use of com.navercorp.pinpoint.common.server.bo.stat.DataSourceBo in project pinpoint by naver.
the class DataSourceChartGroupTest method createSampledDataSource.
private SampledDataSource createSampledDataSource(long timestamp, int maxConnectionSize) {
int testObjectSize = RANDOM.nextInt(CREATE_TEST_OBJECT_MAX_SIZE) + 1;
List<DataSourceBo> dataSourceBoList = DataSourceTestUtils.createDataSourceBoList(1, testObjectSize, maxConnectionSize);
return sampler.sampleDataPoints(0, timestamp, dataSourceBoList, null);
}
use of com.navercorp.pinpoint.common.server.bo.stat.DataSourceBo in project pinpoint by naver.
the class AgentStatMapper method map.
@Override
public AgentStatBo map(TAgentStat tAgentStat) {
if (tAgentStat == null) {
return null;
}
final String agentId = tAgentStat.getAgentId();
final long startTimestamp = tAgentStat.getStartTimestamp();
final long timestamp = tAgentStat.getTimestamp();
AgentStatBo agentStatBo = new AgentStatBo();
agentStatBo.setAgentId(agentId);
// jvmGc
if (tAgentStat.isSetGc()) {
JvmGcBo jvmGcBo = this.jvmGcBoMapper.map(tAgentStat.getGc());
setBaseData(jvmGcBo, agentId, startTimestamp, timestamp);
agentStatBo.setJvmGcBos(Arrays.asList(jvmGcBo));
}
// jvmGcDetailed
if (tAgentStat.isSetGc()) {
if (tAgentStat.getGc().isSetJvmGcDetailed()) {
JvmGcDetailedBo jvmGcDetailedBo = this.jvmGcDetailedBoMapper.map(tAgentStat.getGc().getJvmGcDetailed());
setBaseData(jvmGcDetailedBo, agentId, startTimestamp, timestamp);
agentStatBo.setJvmGcDetailedBos(Arrays.asList(jvmGcDetailedBo));
}
}
// cpuLoad
if (tAgentStat.isSetCpuLoad()) {
CpuLoadBo cpuLoadBo = this.cpuLoadBoMapper.map(tAgentStat.getCpuLoad());
setBaseData(cpuLoadBo, agentId, startTimestamp, timestamp);
agentStatBo.setCpuLoadBos(Arrays.asList(cpuLoadBo));
}
// transaction
if (tAgentStat.isSetTransaction()) {
TransactionBo transactionBo = this.transactionBoMapper.map(tAgentStat.getTransaction());
setBaseData(transactionBo, agentId, startTimestamp, timestamp);
transactionBo.setCollectInterval(tAgentStat.getCollectInterval());
agentStatBo.setTransactionBos(Arrays.asList(transactionBo));
}
// activeTrace
if (tAgentStat.isSetActiveTrace() && tAgentStat.getActiveTrace().isSetHistogram()) {
ActiveTraceBo activeTraceBo = this.activeTraceBoMapper.map(tAgentStat.getActiveTrace());
setBaseData(activeTraceBo, agentId, startTimestamp, timestamp);
agentStatBo.setActiveTraceBos(Arrays.asList(activeTraceBo));
}
// datasource
if (tAgentStat.isSetDataSourceList()) {
DataSourceListBo dataSourceListBo = new DataSourceListBo();
setBaseData(dataSourceListBo, agentId, startTimestamp, timestamp);
TDataSourceList dataSourceList = tAgentStat.getDataSourceList();
for (TDataSource dataSource : dataSourceList.getDataSourceList()) {
DataSourceBo dataSourceBo = dataSourceBoMapper.map(dataSource);
setBaseData(dataSourceBo, agentId, startTimestamp, timestamp);
dataSourceListBo.add(dataSourceBo);
}
agentStatBo.setDataSourceListBos(Arrays.asList(dataSourceListBo));
}
return agentStatBo;
}
use of com.navercorp.pinpoint.common.server.bo.stat.DataSourceBo in project pinpoint by naver.
the class DataSourceCodecV2 method encodeDataSourceListBo.
private void encodeDataSourceListBo(Buffer valueBuffer, DataSourceListBo dataSourceListBo) {
final int numValues = dataSourceListBo.size();
valueBuffer.putVInt(numValues);
if (numValues == 0) {
return;
}
// id // int
// serviceTypeCode // short
// name // string
// jdbcUrl // string
// activeConnectionSize //int
// maxConnectionSize // int
List<Long> startTimestamps = new ArrayList<Long>(numValues);
List<Long> timestamps = new ArrayList<Long>(numValues);
UnsignedIntegerEncodingStrategy.Analyzer.Builder idAnalyzerBuilder = new UnsignedIntegerEncodingStrategy.Analyzer.Builder();
UnsignedShortEncodingStrategy.Analyzer.Builder serviceTypeAnalyzerBuilder = new UnsignedShortEncodingStrategy.Analyzer.Builder();
StringEncodingStrategy.Analyzer.Builder databaseNameAnalyzerBuilder = new StringEncodingStrategy.Analyzer.Builder();
StringEncodingStrategy.Analyzer.Builder jdbcUrlAnalyzerBuilder = new StringEncodingStrategy.Analyzer.Builder();
UnsignedIntegerEncodingStrategy.Analyzer.Builder activeConnectionSizeAnalyzerBuilder = new UnsignedIntegerEncodingStrategy.Analyzer.Builder();
UnsignedIntegerEncodingStrategy.Analyzer.Builder maxConnectionSizeAnalyzerBuilder = new UnsignedIntegerEncodingStrategy.Analyzer.Builder();
for (DataSourceBo dataSourceBo : dataSourceListBo.getList()) {
startTimestamps.add(dataSourceBo.getStartTimestamp());
timestamps.add(dataSourceBo.getTimestamp());
idAnalyzerBuilder.addValue(dataSourceBo.getId());
serviceTypeAnalyzerBuilder.addValue(dataSourceBo.getServiceTypeCode());
databaseNameAnalyzerBuilder.addValue(dataSourceBo.getDatabaseName());
jdbcUrlAnalyzerBuilder.addValue(dataSourceBo.getJdbcUrl());
activeConnectionSizeAnalyzerBuilder.addValue(dataSourceBo.getActiveConnectionSize());
maxConnectionSizeAnalyzerBuilder.addValue(dataSourceBo.getMaxConnectionSize());
}
this.codec.encodeValues(valueBuffer, UnsignedLongEncodingStrategy.REPEAT_COUNT, startTimestamps);
this.codec.encodeTimestamps(valueBuffer, timestamps);
this.encodeDataPoints(valueBuffer, idAnalyzerBuilder.build(), serviceTypeAnalyzerBuilder.build(), databaseNameAnalyzerBuilder.build(), jdbcUrlAnalyzerBuilder.build(), activeConnectionSizeAnalyzerBuilder.build(), maxConnectionSizeAnalyzerBuilder.build());
}
use of com.navercorp.pinpoint.common.server.bo.stat.DataSourceBo in project pinpoint by naver.
the class SampledDataSourceResultExtractor method divideByDataSourceId.
private Map<Integer, List<DataSourceBo>> divideByDataSourceId(ResultScanner results) throws Exception {
int rowNum = 0;
Map<Integer, List<DataSourceBo>> dataSourceBoListMap = new HashMap<>();
for (Result result : results) {
for (DataSourceListBo dataPoint : this.rowMapper.mapRow(result, rowNum++)) {
if (dataPoint.size() == 0) {
continue;
}
DataSourceBo first = ListUtils.getFirst(dataPoint.getList(), null);
int id = first.getId();
List<DataSourceBo> dataSourceBoList = dataSourceBoListMap.get(id);
if (dataSourceBoList == null) {
dataSourceBoList = new ArrayList<>();
dataSourceBoListMap.put(id, dataSourceBoList);
}
dataSourceBoList.addAll(dataPoint.getList());
}
}
return dataSourceBoListMap;
}
Aggregations