Search in sources :

Example 1 with DataSourceListBo

use of com.navercorp.pinpoint.common.server.bo.stat.DataSourceListBo in project pinpoint by naver.

the class DataSourceCodecV2 method decodeValue.

private DataSourceListBo decodeValue(Buffer valueBuffer, AgentStatDecodingContext decodingContext) {
    final String agentId = decodingContext.getAgentId();
    final long baseTimestamp = decodingContext.getBaseTimestamp();
    final long timestampDelta = decodingContext.getTimestampDelta();
    final long initialTimestamp = baseTimestamp + timestampDelta;
    int numValues = valueBuffer.readVInt();
    List<Long> startTimestamps = this.codec.decodeValues(valueBuffer, UnsignedLongEncodingStrategy.REPEAT_COUNT, numValues);
    List<Long> timestamps = this.codec.decodeTimestamps(initialTimestamp, valueBuffer, numValues);
    // decode headers
    final byte[] header = valueBuffer.readPrefixedBytes();
    AgentStatHeaderDecoder headerDecoder = new BitCountingHeaderDecoder(header);
    EncodingStrategy<Integer> idEncodingStrategy = UnsignedIntegerEncodingStrategy.getFromCode(headerDecoder.getCode());
    EncodingStrategy<Short> serviceTypeEncodingStrategy = UnsignedShortEncodingStrategy.getFromCode(headerDecoder.getCode());
    EncodingStrategy<String> databaseNameEncodingStrategy = StringEncodingStrategy.getFromCode(headerDecoder.getCode());
    EncodingStrategy<String> urlEncodingStrategy = StringEncodingStrategy.getFromCode(headerDecoder.getCode());
    EncodingStrategy<Integer> activeConnectionSizeStrategy = UnsignedIntegerEncodingStrategy.getFromCode(headerDecoder.getCode());
    EncodingStrategy<Integer> maxConnectionSizeStrategy = UnsignedIntegerEncodingStrategy.getFromCode(headerDecoder.getCode());
    List<Integer> ids = this.codec.decodeValues(valueBuffer, idEncodingStrategy, numValues);
    List<Short> serviceTypeCodes = this.codec.decodeValues(valueBuffer, serviceTypeEncodingStrategy, numValues);
    List<String> databaseNames = this.codec.decodeValues(valueBuffer, databaseNameEncodingStrategy, numValues);
    List<String> jdbcUrls = this.codec.decodeValues(valueBuffer, urlEncodingStrategy, numValues);
    List<Integer> activeConnectionSizes = this.codec.decodeValues(valueBuffer, activeConnectionSizeStrategy, numValues);
    List<Integer> maxConnectionSizes = this.codec.decodeValues(valueBuffer, maxConnectionSizeStrategy, numValues);
    DataSourceListBo dataSourceListBo = new DataSourceListBo();
    for (int i = 0; i < numValues; ++i) {
        if (i == 0) {
            dataSourceListBo.setAgentId(agentId);
            dataSourceListBo.setTimestamp(timestamps.get(i));
            dataSourceListBo.setStartTimestamp(startTimestamps.get(i));
        }
        DataSourceBo dataSourceBo = new DataSourceBo();
        dataSourceBo.setAgentId(agentId);
        dataSourceBo.setStartTimestamp(startTimestamps.get(i));
        dataSourceBo.setTimestamp(timestamps.get(i));
        dataSourceBo.setId(ids.get(i));
        dataSourceBo.setServiceTypeCode(serviceTypeCodes.get(i));
        dataSourceBo.setDatabaseName(databaseNames.get(i));
        dataSourceBo.setJdbcUrl(jdbcUrls.get(i));
        dataSourceBo.setActiveConnectionSize(activeConnectionSizes.get(i));
        dataSourceBo.setMaxConnectionSize(maxConnectionSizes.get(i));
        dataSourceListBo.add(dataSourceBo);
    }
    return dataSourceListBo;
}
Also used : BitCountingHeaderDecoder(com.navercorp.pinpoint.common.server.bo.codec.stat.header.BitCountingHeaderDecoder) DataSourceBo(com.navercorp.pinpoint.common.server.bo.stat.DataSourceBo) AgentStatHeaderDecoder(com.navercorp.pinpoint.common.server.bo.codec.stat.header.AgentStatHeaderDecoder) DataSourceListBo(com.navercorp.pinpoint.common.server.bo.stat.DataSourceListBo)

Example 2 with DataSourceListBo

use of com.navercorp.pinpoint.common.server.bo.stat.DataSourceListBo in project pinpoint by naver.

the class AgentStatBatchMapper method map.

@Override
public AgentStatBo map(TAgentStatBatch tAgentStatBatch) {
    if (!tAgentStatBatch.isSetAgentStats()) {
        return null;
    }
    AgentStatBo agentStatBo = new AgentStatBo();
    final String agentId = tAgentStatBatch.getAgentId();
    final long startTimestamp = tAgentStatBatch.getStartTimestamp();
    agentStatBo.setAgentId(agentId);
    List<JvmGcBo> jvmGcBos = new ArrayList<>(tAgentStatBatch.getAgentStatsSize());
    List<JvmGcDetailedBo> jvmGcDetailedBos = new ArrayList<>(tAgentStatBatch.getAgentStatsSize());
    List<CpuLoadBo> cpuLoadBos = new ArrayList<>(tAgentStatBatch.getAgentStatsSize());
    List<TransactionBo> transactionBos = new ArrayList<>(tAgentStatBatch.getAgentStatsSize());
    List<ActiveTraceBo> activeTraceBos = new ArrayList<>(tAgentStatBatch.getAgentStatsSize());
    List<DataSourceListBo> dataSourceListBos = new ArrayList<DataSourceListBo>(tAgentStatBatch.getAgentStatsSize());
    for (TAgentStat tAgentStat : tAgentStatBatch.getAgentStats()) {
        final long timestamp = tAgentStat.getTimestamp();
        // jvmGc
        if (tAgentStat.isSetGc()) {
            JvmGcBo jvmGcBo = this.jvmGcBoMapper.map(tAgentStat.getGc());
            setBaseData(jvmGcBo, agentId, startTimestamp, timestamp);
            jvmGcBos.add(jvmGcBo);
        }
        // jvmGcDetailed
        if (tAgentStat.isSetGc()) {
            if (tAgentStat.getGc().isSetJvmGcDetailed()) {
                JvmGcDetailedBo jvmGcDetailedBo = this.jvmGcDetailedBoMapper.map(tAgentStat.getGc().getJvmGcDetailed());
                setBaseData(jvmGcDetailedBo, agentId, startTimestamp, timestamp);
                jvmGcDetailedBos.add(jvmGcDetailedBo);
            }
        }
        // cpuLoad
        if (tAgentStat.isSetCpuLoad()) {
            CpuLoadBo cpuLoadBo = this.cpuLoadBoMapper.map(tAgentStat.getCpuLoad());
            setBaseData(cpuLoadBo, agentId, startTimestamp, timestamp);
            cpuLoadBos.add(cpuLoadBo);
        }
        // transaction
        if (tAgentStat.isSetTransaction()) {
            TransactionBo transactionBo = this.transactionBoMapper.map(tAgentStat.getTransaction());
            setBaseData(transactionBo, agentId, startTimestamp, timestamp);
            transactionBo.setCollectInterval(tAgentStat.getCollectInterval());
            transactionBos.add(transactionBo);
        }
        // activeTrace
        if (tAgentStat.isSetActiveTrace() && tAgentStat.getActiveTrace().isSetHistogram()) {
            ActiveTraceBo activeTraceBo = this.activeTraceBoMapper.map(tAgentStat.getActiveTrace());
            setBaseData(activeTraceBo, agentId, startTimestamp, timestamp);
            activeTraceBos.add(activeTraceBo);
        }
        // datasource
        if (tAgentStat.isSetDataSourceList()) {
            DataSourceListBo dataSourceListBo = new DataSourceListBo();
            setBaseData(dataSourceListBo, agentId, startTimestamp, timestamp);
            TDataSourceList dataSourceList = tAgentStat.getDataSourceList();
            if (dataSourceList.getDataSourceListSize() > 0) {
                for (TDataSource dataSource : dataSourceList.getDataSourceList()) {
                    DataSourceBo dataSourceBo = dataSourceBoMapper.map(dataSource);
                    setBaseData(dataSourceBo, agentId, startTimestamp, timestamp);
                    dataSourceListBo.add(dataSourceBo);
                }
            }
            dataSourceListBos.add(dataSourceListBo);
        }
    }
    agentStatBo.setJvmGcBos(jvmGcBos);
    agentStatBo.setJvmGcDetailedBos(jvmGcDetailedBos);
    agentStatBo.setCpuLoadBos(cpuLoadBos);
    agentStatBo.setTransactionBos(transactionBos);
    agentStatBo.setActiveTraceBos(activeTraceBos);
    agentStatBo.setDataSourceListBos(dataSourceListBos);
    return agentStatBo;
}
Also used : JvmGcBo(com.navercorp.pinpoint.common.server.bo.stat.JvmGcBo) AgentStatBo(com.navercorp.pinpoint.common.server.bo.stat.AgentStatBo) TAgentStat(com.navercorp.pinpoint.thrift.dto.TAgentStat) CpuLoadBo(com.navercorp.pinpoint.common.server.bo.stat.CpuLoadBo) JvmGcDetailedBo(com.navercorp.pinpoint.common.server.bo.stat.JvmGcDetailedBo) ArrayList(java.util.ArrayList) DataSourceBo(com.navercorp.pinpoint.common.server.bo.stat.DataSourceBo) TDataSource(com.navercorp.pinpoint.thrift.dto.TDataSource) TDataSourceList(com.navercorp.pinpoint.thrift.dto.TDataSourceList) DataSourceListBo(com.navercorp.pinpoint.common.server.bo.stat.DataSourceListBo) TransactionBo(com.navercorp.pinpoint.common.server.bo.stat.TransactionBo) ActiveTraceBo(com.navercorp.pinpoint.common.server.bo.stat.ActiveTraceBo)

Example 3 with DataSourceListBo

use of com.navercorp.pinpoint.common.server.bo.stat.DataSourceListBo in project pinpoint by naver.

the class HbaseDataSourceListDao method reorderDataSourceListBos.

private List<DataSourceListBo> reorderDataSourceListBos(List<DataSourceListBo> dataSourceListBos) {
    // reorder dataSourceBo using id and timeSlot
    MultiKeyMap dataSourceListBoMap = new MultiKeyMap();
    for (DataSourceListBo dataSourceListBo : dataSourceListBos) {
        for (DataSourceBo dataSourceBo : dataSourceListBo.getList()) {
            int id = dataSourceBo.getId();
            long timestamp = dataSourceBo.getTimestamp();
            long timeSlot = AgentStatUtils.getBaseTimestamp(timestamp);
            DataSourceListBo mappedDataSourceListBo = (DataSourceListBo) dataSourceListBoMap.get(id, timeSlot);
            if (mappedDataSourceListBo == null) {
                mappedDataSourceListBo = new DataSourceListBo();
                mappedDataSourceListBo.setAgentId(dataSourceBo.getAgentId());
                mappedDataSourceListBo.setStartTimestamp(dataSourceBo.getStartTimestamp());
                mappedDataSourceListBo.setTimestamp(dataSourceBo.getTimestamp());
                dataSourceListBoMap.put(id, timeSlot, mappedDataSourceListBo);
            }
            // set fastest timestamp
            if (mappedDataSourceListBo.getTimestamp() > dataSourceBo.getTimestamp()) {
                mappedDataSourceListBo.setTimestamp(dataSourceBo.getTimestamp());
            }
            mappedDataSourceListBo.add(dataSourceBo);
        }
    }
    Collection values = dataSourceListBoMap.values();
    return new ArrayList<DataSourceListBo>(values);
}
Also used : MultiKeyMap(org.apache.commons.collections.map.MultiKeyMap) ArrayList(java.util.ArrayList) Collection(java.util.Collection) DataSourceListBo(com.navercorp.pinpoint.common.server.bo.stat.DataSourceListBo) DataSourceBo(com.navercorp.pinpoint.common.server.bo.stat.DataSourceBo)

Example 4 with DataSourceListBo

use of com.navercorp.pinpoint.common.server.bo.stat.DataSourceListBo in project pinpoint by naver.

the class TestAgentStatFactory method createDataSourceListBo.

private static DataSourceListBo createDataSourceListBo(String agentId, long startTimestamp, long initialTimestamp, int id, int maxConnectionSize, int numValues) {
    DataSourceListBo dataSourceListBo = new DataSourceListBo();
    dataSourceListBo.setAgentId(agentId);
    dataSourceListBo.setStartTimestamp(startTimestamp);
    dataSourceListBo.setTimestamp(initialTimestamp);
    List<Long> startTimestamps = createStartTimestamps(startTimestamp, numValues);
    List<Long> timestamps = createTimestamps(initialTimestamp, numValues);
    for (int i = 0; i < numValues; i++) {
        DataSourceBo dataSourceBo = new DataSourceBo();
        dataSourceBo.setAgentId(agentId);
        dataSourceBo.setStartTimestamp(startTimestamps.get(i));
        dataSourceBo.setTimestamp(timestamps.get(i));
        dataSourceBo.setId(id);
        dataSourceBo.setServiceTypeCode(ServiceType.UNKNOWN.getCode());
        dataSourceBo.setDatabaseName("name-" + id);
        dataSourceBo.setJdbcUrl("jdbcurl-" + id);
        dataSourceBo.setActiveConnectionSize(RANDOM.nextInt(maxConnectionSize));
        dataSourceBo.setMaxConnectionSize(maxConnectionSize);
        dataSourceListBo.add(dataSourceBo);
    }
    return dataSourceListBo;
}
Also used : DataSourceListBo(com.navercorp.pinpoint.common.server.bo.stat.DataSourceListBo) DataSourceBo(com.navercorp.pinpoint.common.server.bo.stat.DataSourceBo)

Example 5 with DataSourceListBo

use of com.navercorp.pinpoint.common.server.bo.stat.DataSourceListBo 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;
}
Also used : JvmGcBo(com.navercorp.pinpoint.common.server.bo.stat.JvmGcBo) AgentStatBo(com.navercorp.pinpoint.common.server.bo.stat.AgentStatBo) CpuLoadBo(com.navercorp.pinpoint.common.server.bo.stat.CpuLoadBo) TDataSourceList(com.navercorp.pinpoint.thrift.dto.TDataSourceList) JvmGcDetailedBo(com.navercorp.pinpoint.common.server.bo.stat.JvmGcDetailedBo) DataSourceListBo(com.navercorp.pinpoint.common.server.bo.stat.DataSourceListBo) DataSourceBo(com.navercorp.pinpoint.common.server.bo.stat.DataSourceBo) TransactionBo(com.navercorp.pinpoint.common.server.bo.stat.TransactionBo) TDataSource(com.navercorp.pinpoint.thrift.dto.TDataSource) ActiveTraceBo(com.navercorp.pinpoint.common.server.bo.stat.ActiveTraceBo)

Aggregations

DataSourceListBo (com.navercorp.pinpoint.common.server.bo.stat.DataSourceListBo)10 DataSourceBo (com.navercorp.pinpoint.common.server.bo.stat.DataSourceBo)6 ArrayList (java.util.ArrayList)5 ActiveTraceBo (com.navercorp.pinpoint.common.server.bo.stat.ActiveTraceBo)2 AgentStatBo (com.navercorp.pinpoint.common.server.bo.stat.AgentStatBo)2 CpuLoadBo (com.navercorp.pinpoint.common.server.bo.stat.CpuLoadBo)2 JvmGcBo (com.navercorp.pinpoint.common.server.bo.stat.JvmGcBo)2 JvmGcDetailedBo (com.navercorp.pinpoint.common.server.bo.stat.JvmGcDetailedBo)2 TransactionBo (com.navercorp.pinpoint.common.server.bo.stat.TransactionBo)2 TDataSource (com.navercorp.pinpoint.thrift.dto.TDataSource)2 TDataSourceList (com.navercorp.pinpoint.thrift.dto.TDataSourceList)2 AgentStatHeaderDecoder (com.navercorp.pinpoint.common.server.bo.codec.stat.header.AgentStatHeaderDecoder)1 BitCountingHeaderDecoder (com.navercorp.pinpoint.common.server.bo.codec.stat.header.BitCountingHeaderDecoder)1 TAgentStat (com.navercorp.pinpoint.thrift.dto.TAgentStat)1 SampledDataSourceResultExtractor (com.navercorp.pinpoint.web.mapper.stat.SampledDataSourceResultExtractor)1 Range (com.navercorp.pinpoint.web.vo.Range)1 SampledDataSourceList (com.navercorp.pinpoint.web.vo.stat.SampledDataSourceList)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 List (java.util.List)1