use of com.navercorp.pinpoint.common.server.bo.stat.join.JoinDataSourceBo in project pinpoint by naver.
the class JoinDataSourceSampler method getJoinDataSourceBoList.
public List<JoinDataSourceBo> getJoinDataSourceBoList(long timestamp, List<JoinDataSourceBo> joinDataSourceBoList) {
List<JoinDataSourceBo> aggreJoinDataSourceBoList = new ArrayList<>(joinDataSourceBoList.size());
for (JoinDataSourceBo ds : joinDataSourceBoList) {
AggreJoinDataSourceBo dataSourceBo = new AggreJoinDataSourceBo(ds.getServiceTypeCode(), ds.getUrl(), ds.getActiveConnectionSizeJoinValue(), timestamp);
aggreJoinDataSourceBoList.add(dataSourceBo);
}
return aggreJoinDataSourceBoList;
}
use of com.navercorp.pinpoint.common.server.bo.stat.join.JoinDataSourceBo in project pinpoint by naver.
the class JoinDataSourceListBoMapper method map.
@Override
public JoinDataSourceListBo map(TFAgentStat tFAgentStat) {
if (!tFAgentStat.isSetDataSourceList()) {
return JoinDataSourceListBo.EMPTY_JOIN_DATA_SOURCE_LIST_BO;
}
TFDataSourceList dataSourceList = tFAgentStat.getDataSourceList();
if (!dataSourceList.isSetDataSourceList()) {
return JoinDataSourceListBo.EMPTY_JOIN_DATA_SOURCE_LIST_BO;
}
List<TFDataSource> tFDataSourceList = dataSourceList.getDataSourceList();
if (tFDataSourceList.isEmpty()) {
return JoinDataSourceListBo.EMPTY_JOIN_DATA_SOURCE_LIST_BO;
}
final String agentId = tFAgentStat.getAgentId();
JoinDataSourceListBo joinDataSourceListBo = new JoinDataSourceListBo();
joinDataSourceListBo.setId(agentId);
joinDataSourceListBo.setTimestamp(tFAgentStat.getTimestamp());
List<JoinDataSourceBo> joinDataSourceBoList = new ArrayList<>();
for (TFDataSource tFDataSource : tFDataSourceList) {
JoinDataSourceBo joinDataSourceBo = new JoinDataSourceBo();
joinDataSourceBo.setServiceTypeCode(tFDataSource.getServiceTypeCode());
joinDataSourceBo.setUrl(tFDataSource.getUrl());
final int activeConnectionSize = tFDataSource.getActiveConnectionSize();
joinDataSourceBo.setActiveConnectionSizeJoinValue(new JoinIntFieldBo(activeConnectionSize, activeConnectionSize, agentId, activeConnectionSize, agentId));
joinDataSourceBoList.add(joinDataSourceBo);
}
joinDataSourceListBo.setJoinDataSourceBoList(joinDataSourceBoList);
return joinDataSourceListBo;
}
use of com.navercorp.pinpoint.common.server.bo.stat.join.JoinDataSourceBo in project pinpoint by naver.
the class JoinDataSourceListBoMapperTest method mapTest.
@Test
public void mapTest() {
JoinDataSourceListBoMapper mapper = new JoinDataSourceListBoMapper();
TFAgentStat tFAgentStat = new TFAgentStat();
tFAgentStat.setAgentId("testAgent");
tFAgentStat.setTimestamp(1491274138454L);
TFDataSourceList tFDataSourceList = new TFDataSourceList();
List<TFDataSource> dataSourceList = new ArrayList<>();
TFDataSource tFDataSource1 = new TFDataSource();
tFDataSource1.setUrl("jdbc:mysql");
tFDataSource1.setMaxConnectionSize(30);
tFDataSource1.setActiveConnectionSize(13);
tFDataSource1.setDatabaseName("pinpoint");
tFDataSource1.setServiceTypeCode((short) 1000);
TFDataSource tFDataSource2 = new TFDataSource();
tFDataSource2.setUrl("jdbc:mssql");
tFDataSource2.setMaxConnectionSize(31);
tFDataSource2.setActiveConnectionSize(23);
tFDataSource2.setDatabaseName("pinpoint");
tFDataSource2.setServiceTypeCode((short) 2000);
dataSourceList.add(tFDataSource1);
dataSourceList.add(tFDataSource2);
tFDataSourceList.setDataSourceList(dataSourceList);
tFAgentStat.setDataSourceList(tFDataSourceList);
JoinDataSourceListBo joinDataSourceListBo = mapper.map(tFAgentStat);
assertEquals(joinDataSourceListBo.getId(), "testAgent");
assertEquals(joinDataSourceListBo.getTimestamp(), 1491274138454L);
assertEquals(joinDataSourceListBo.getJoinDataSourceBoList().size(), 2);
List<JoinDataSourceBo> joinDataSourceBoList = joinDataSourceListBo.getJoinDataSourceBoList();
JoinDataSourceBo joinDataSourceBo1 = joinDataSourceBoList.get(0);
assertEquals(joinDataSourceBo1.getServiceTypeCode(), 1000);
assertEquals(joinDataSourceBo1.getUrl(), "jdbc:mysql");
assertEquals(joinDataSourceBo1.getActiveConnectionSizeJoinValue(), new JoinIntFieldBo(13, 13, "testAgent", 13, "testAgent"));
JoinDataSourceBo joinDataSourceBo2 = joinDataSourceBoList.get(1);
assertEquals(joinDataSourceBo2.getServiceTypeCode(), 2000);
assertEquals(joinDataSourceBo2.getUrl(), "jdbc:mssql");
assertEquals(joinDataSourceBo2.getActiveConnectionSizeJoinValue(), new JoinIntFieldBo(23, 23, "testAgent", 23, "testAgent"));
}
use of com.navercorp.pinpoint.common.server.bo.stat.join.JoinDataSourceBo in project pinpoint by naver.
the class DataSourceCodec method encodeJoinDataSourceBo.
private void encodeJoinDataSourceBo(Buffer valueBuffer, List<JoinDataSourceBo> joinDataSourceBoList) {
final int numValues = joinDataSourceBoList.size();
valueBuffer.putVInt(numValues);
UnsignedShortEncodingStrategy.Analyzer.Builder serviceTypeAnalyzerBuilder = new UnsignedShortEncodingStrategy.Analyzer.Builder();
StringEncodingStrategy.Analyzer.Builder jdbcUrlAnalyzerBuilder = new StringEncodingStrategy.Analyzer.Builder();
JoinIntFieldStrategyAnalyzer.Builder activeConnectionSizeAnalyzerBuilder = new JoinIntFieldStrategyAnalyzer.Builder();
for (JoinDataSourceBo joinDataSourceBo : joinDataSourceBoList) {
serviceTypeAnalyzerBuilder.addValue(joinDataSourceBo.getServiceTypeCode());
jdbcUrlAnalyzerBuilder.addValue(joinDataSourceBo.getUrl());
activeConnectionSizeAnalyzerBuilder.addValue(joinDataSourceBo.getActiveConnectionSizeJoinValue());
}
StrategyAnalyzer<Short> serviceTypeAnalyzer = serviceTypeAnalyzerBuilder.build();
StrategyAnalyzer<String> jdbcUrlAnalyzer = jdbcUrlAnalyzerBuilder.build();
JoinIntFieldStrategyAnalyzer activeConnectionSizeAnalyzer = activeConnectionSizeAnalyzerBuilder.build();
AgentStatHeaderEncoder headerEncoder = new BitCountingHeaderEncoder();
headerEncoder.addCode(serviceTypeAnalyzer.getBestStrategy().getCode());
headerEncoder.addCode(jdbcUrlAnalyzer.getBestStrategy().getCode());
final byte[] codes = activeConnectionSizeAnalyzer.getBestStrategy().getCodes();
for (byte code : codes) {
headerEncoder.addCode(code);
}
final byte[] header = headerEncoder.getHeader();
valueBuffer.putPrefixedBytes(header);
this.codec.encodeValues(valueBuffer, serviceTypeAnalyzer.getBestStrategy(), serviceTypeAnalyzer.getValues());
this.codec.encodeValues(valueBuffer, jdbcUrlAnalyzer.getBestStrategy(), jdbcUrlAnalyzer.getValues());
this.codec.encodeValues(valueBuffer, activeConnectionSizeAnalyzer.getBestStrategy(), activeConnectionSizeAnalyzer.getValues());
}
use of com.navercorp.pinpoint.common.server.bo.stat.join.JoinDataSourceBo in project pinpoint by naver.
the class DataSourceCodec method decodeJoinDataSourceBoList.
private List<JoinDataSourceBo> decodeJoinDataSourceBoList(Buffer valueBuffer) {
int numValues = valueBuffer.readVInt();
final byte[] header = valueBuffer.readPrefixedBytes();
AgentStatHeaderDecoder headerDecoder = new BitCountingHeaderDecoder(header);
EncodingStrategy<Short> serviceTypeEncodingStrategy = UnsignedShortEncodingStrategy.getFromCode(headerDecoder.getCode());
EncodingStrategy<String> urlEncodingStrategy = StringEncodingStrategy.getFromCode(headerDecoder.getCode());
JoinIntFieldEncodingStrategy activeConnectionSizeEncodingStrategy = JoinIntFieldEncodingStrategy.getFromCode(headerDecoder.getCode(), headerDecoder.getCode(), headerDecoder.getCode(), headerDecoder.getCode(), headerDecoder.getCode());
List<Short> serviceTypeCodeList = this.codec.decodeValues(valueBuffer, serviceTypeEncodingStrategy, numValues);
List<String> jdbcUrlList = this.codec.decodeValues(valueBuffer, urlEncodingStrategy, numValues);
final List<JoinIntFieldBo> activeConnectionSizeValueList = this.codec.decodeValues(valueBuffer, activeConnectionSizeEncodingStrategy, numValues);
List<JoinDataSourceBo> joinDataSourceBoList = new ArrayList<JoinDataSourceBo>(numValues);
for (int i = 0; i < numValues; ++i) {
JoinDataSourceBo joinDataSourceBo = new JoinDataSourceBo();
joinDataSourceBo.setServiceTypeCode(serviceTypeCodeList.get(i));
joinDataSourceBo.setUrl(jdbcUrlList.get(i));
joinDataSourceBo.setActiveConnectionSizeJoinValue(activeConnectionSizeValueList.get(i));
joinDataSourceBoList.add(joinDataSourceBo);
}
return joinDataSourceBoList;
}
Aggregations