Search in sources :

Example 1 with JoinDataSourceBo

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;
}
Also used : JoinDataSourceBo(com.navercorp.pinpoint.common.server.bo.stat.join.JoinDataSourceBo) AggreJoinDataSourceBo(com.navercorp.pinpoint.web.vo.stat.AggreJoinDataSourceBo) ArrayList(java.util.ArrayList) AggreJoinDataSourceBo(com.navercorp.pinpoint.web.vo.stat.AggreJoinDataSourceBo)

Example 2 with JoinDataSourceBo

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;
}
Also used : JoinDataSourceBo(com.navercorp.pinpoint.common.server.bo.stat.join.JoinDataSourceBo) JoinIntFieldBo(com.navercorp.pinpoint.common.server.bo.stat.join.JoinIntFieldBo) TFDataSourceList(com.navercorp.pinpoint.thrift.dto.flink.TFDataSourceList) ArrayList(java.util.ArrayList) TFDataSource(com.navercorp.pinpoint.thrift.dto.flink.TFDataSource) JoinDataSourceListBo(com.navercorp.pinpoint.common.server.bo.stat.join.JoinDataSourceListBo)

Example 3 with JoinDataSourceBo

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"));
}
Also used : JoinDataSourceBo(com.navercorp.pinpoint.common.server.bo.stat.join.JoinDataSourceBo) JoinIntFieldBo(com.navercorp.pinpoint.common.server.bo.stat.join.JoinIntFieldBo) TFDataSourceList(com.navercorp.pinpoint.thrift.dto.flink.TFDataSourceList) ArrayList(java.util.ArrayList) TFAgentStat(com.navercorp.pinpoint.thrift.dto.flink.TFAgentStat) TFDataSource(com.navercorp.pinpoint.thrift.dto.flink.TFDataSource) JoinDataSourceListBo(com.navercorp.pinpoint.common.server.bo.stat.join.JoinDataSourceListBo) Test(org.junit.Test)

Example 4 with JoinDataSourceBo

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());
}
Also used : JoinIntFieldStrategyAnalyzer(com.navercorp.pinpoint.common.server.bo.codec.stat.strategy.JoinIntFieldStrategyAnalyzer) JoinIntFieldStrategyAnalyzer(com.navercorp.pinpoint.common.server.bo.codec.stat.strategy.JoinIntFieldStrategyAnalyzer) StrategyAnalyzer(com.navercorp.pinpoint.common.server.bo.codec.stat.strategy.StrategyAnalyzer) BitCountingHeaderEncoder(com.navercorp.pinpoint.common.server.bo.codec.stat.header.BitCountingHeaderEncoder) StringEncodingStrategy(com.navercorp.pinpoint.common.server.bo.codec.stat.strategy.StringEncodingStrategy) JoinDataSourceBo(com.navercorp.pinpoint.common.server.bo.stat.join.JoinDataSourceBo) UnsignedShortEncodingStrategy(com.navercorp.pinpoint.common.server.bo.codec.stat.strategy.UnsignedShortEncodingStrategy) AgentStatHeaderEncoder(com.navercorp.pinpoint.common.server.bo.codec.stat.header.AgentStatHeaderEncoder)

Example 5 with JoinDataSourceBo

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;
}
Also used : BitCountingHeaderDecoder(com.navercorp.pinpoint.common.server.bo.codec.stat.header.BitCountingHeaderDecoder) ArrayList(java.util.ArrayList) AgentStatHeaderDecoder(com.navercorp.pinpoint.common.server.bo.codec.stat.header.AgentStatHeaderDecoder) JoinIntFieldBo(com.navercorp.pinpoint.common.server.bo.stat.join.JoinIntFieldBo) JoinDataSourceBo(com.navercorp.pinpoint.common.server.bo.stat.join.JoinDataSourceBo) JoinIntFieldEncodingStrategy(com.navercorp.pinpoint.common.server.bo.codec.stat.strategy.JoinIntFieldEncodingStrategy)

Aggregations

JoinDataSourceBo (com.navercorp.pinpoint.common.server.bo.stat.join.JoinDataSourceBo)9 ArrayList (java.util.ArrayList)6 AggreJoinDataSourceBo (com.navercorp.pinpoint.web.vo.stat.AggreJoinDataSourceBo)4 JoinDataSourceListBo (com.navercorp.pinpoint.common.server.bo.stat.join.JoinDataSourceListBo)3 JoinIntFieldBo (com.navercorp.pinpoint.common.server.bo.stat.join.JoinIntFieldBo)3 TFDataSource (com.navercorp.pinpoint.thrift.dto.flink.TFDataSource)2 TFDataSourceList (com.navercorp.pinpoint.thrift.dto.flink.TFDataSourceList)2 AgentStatHeaderDecoder (com.navercorp.pinpoint.common.server.bo.codec.stat.header.AgentStatHeaderDecoder)1 AgentStatHeaderEncoder (com.navercorp.pinpoint.common.server.bo.codec.stat.header.AgentStatHeaderEncoder)1 BitCountingHeaderDecoder (com.navercorp.pinpoint.common.server.bo.codec.stat.header.BitCountingHeaderDecoder)1 BitCountingHeaderEncoder (com.navercorp.pinpoint.common.server.bo.codec.stat.header.BitCountingHeaderEncoder)1 JoinIntFieldEncodingStrategy (com.navercorp.pinpoint.common.server.bo.codec.stat.strategy.JoinIntFieldEncodingStrategy)1 JoinIntFieldStrategyAnalyzer (com.navercorp.pinpoint.common.server.bo.codec.stat.strategy.JoinIntFieldStrategyAnalyzer)1 StrategyAnalyzer (com.navercorp.pinpoint.common.server.bo.codec.stat.strategy.StrategyAnalyzer)1 StringEncodingStrategy (com.navercorp.pinpoint.common.server.bo.codec.stat.strategy.StringEncodingStrategy)1 UnsignedShortEncodingStrategy (com.navercorp.pinpoint.common.server.bo.codec.stat.strategy.UnsignedShortEncodingStrategy)1 TFAgentStat (com.navercorp.pinpoint.thrift.dto.flink.TFAgentStat)1 AggreJoinDataSourceListBo (com.navercorp.pinpoint.web.vo.stat.AggreJoinDataSourceListBo)1 Test (org.junit.Test)1