Search in sources :

Example 36 with FixedBuffer

use of com.navercorp.pinpoint.common.buffer.FixedBuffer in project pinpoint by naver.

the class AgentLifeCycleMapper method createAgentLifeCycleBo.

private AgentLifeCycleBo createAgentLifeCycleBo(Cell valueCell) {
    if (valueCell == null) {
        return null;
    }
    byte[] value = CellUtil.cloneValue(valueCell);
    final Buffer buffer = new FixedBuffer(value);
    final int version = buffer.readInt();
    if (version == 0) {
        final String agentId = buffer.readPrefixedString();
        final long startTimestamp = buffer.readLong();
        final long eventTimestamp = buffer.readLong();
        final long eventIdentifier = buffer.readLong();
        final AgentLifeCycleState agentLifeCycleState = AgentLifeCycleState.getStateByCode(buffer.readShort());
        final AgentLifeCycleBo agentLifeCycleBo = new AgentLifeCycleBo(agentId, startTimestamp, eventTimestamp, eventIdentifier, agentLifeCycleState);
        return agentLifeCycleBo;
    }
    return null;
}
Also used : FixedBuffer(com.navercorp.pinpoint.common.buffer.FixedBuffer) Buffer(com.navercorp.pinpoint.common.buffer.Buffer) FixedBuffer(com.navercorp.pinpoint.common.buffer.FixedBuffer) AgentLifeCycleBo(com.navercorp.pinpoint.common.server.bo.AgentLifeCycleBo) AgentLifeCycleState(com.navercorp.pinpoint.common.server.util.AgentLifeCycleState)

Example 37 with FixedBuffer

use of com.navercorp.pinpoint.common.buffer.FixedBuffer in project pinpoint by naver.

the class MapStatisticsCalleeMapper method mapRow.

@Override
public LinkDataMap mapRow(Result result, int rowNum) throws Exception {
    if (result.isEmpty()) {
        return new LinkDataMap();
    }
    logger.debug("mapRow:{}", rowNum);
    final byte[] rowKey = getOriginalKey(result.getRow());
    final Buffer row = new FixedBuffer(rowKey);
    final Application calleeApplication = readCalleeApplication(row);
    final long timestamp = TimeUtils.recoveryTimeMillis(row.readLong());
    final LinkDataMap linkDataMap = new LinkDataMap();
    for (Cell cell : result.rawCells()) {
        final byte[] qualifier = CellUtil.cloneQualifier(cell);
        final Application callerApplication = readCallerApplication(qualifier, calleeApplication.getServiceType());
        if (filter.filter(callerApplication)) {
            continue;
        }
        long requestCount = Bytes.toLong(cell.getValueArray(), cell.getValueOffset());
        short histogramSlot = ApplicationMapStatisticsUtils.getHistogramSlotFromColumnName(qualifier);
        String callerHost = ApplicationMapStatisticsUtils.getHost(qualifier);
        // nodes, they would not have reached here in the first place.
        if (calleeApplication.getServiceType().isQueue()) {
            callerHost = StringUtils.defaultString(callerHost);
        }
        boolean isError = histogramSlot == (short) -1;
        if (logger.isDebugEnabled()) {
            logger.debug("    Fetched Callee. {} callerHost:{} -> {} (slot:{}/{}),  ", callerApplication, callerHost, calleeApplication, histogramSlot, requestCount);
        }
        final short slotTime = (isError) ? (short) -1 : histogramSlot;
        linkDataMap.addLinkData(callerApplication, callerApplication.getName(), calleeApplication, callerHost, timestamp, slotTime, requestCount);
        if (logger.isDebugEnabled()) {
            logger.debug("    Fetched Callee. statistics:{}", linkDataMap);
        }
    }
    return linkDataMap;
}
Also used : FixedBuffer(com.navercorp.pinpoint.common.buffer.FixedBuffer) Buffer(com.navercorp.pinpoint.common.buffer.Buffer) FixedBuffer(com.navercorp.pinpoint.common.buffer.FixedBuffer) Application(com.navercorp.pinpoint.web.vo.Application) Cell(org.apache.hadoop.hbase.Cell) LinkDataMap(com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataMap)

Example 38 with FixedBuffer

use of com.navercorp.pinpoint.common.buffer.FixedBuffer in project pinpoint by naver.

the class MapStatisticsCallerMapper method mapRow.

@Override
public LinkDataMap mapRow(Result result, int rowNum) throws Exception {
    if (result.isEmpty()) {
        return new LinkDataMap();
    }
    logger.debug("mapRow:{}", rowNum);
    final byte[] rowKey = getOriginalKey(result.getRow());
    final Buffer row = new FixedBuffer(rowKey);
    final Application caller = readCallerApplication(row);
    final long timestamp = TimeUtils.recoveryTimeMillis(row.readLong());
    // key is destApplicationName.
    final LinkDataMap linkDataMap = new LinkDataMap();
    for (Cell cell : result.rawCells()) {
        final Buffer buffer = new OffsetFixedBuffer(cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength());
        final Application callee = readCalleeApplication(buffer);
        if (filter.filter(callee)) {
            continue;
        }
        String calleeHost = buffer.readPrefixedString();
        short histogramSlot = buffer.readShort();
        boolean isError = histogramSlot == (short) -1;
        String callerAgentId = buffer.readPrefixedString();
        long requestCount = getValueToLong(cell);
        if (logger.isDebugEnabled()) {
            logger.debug("    Fetched Caller.(New) {} {} -> {} (slot:{}/{}) calleeHost:{}", caller, callerAgentId, callee, histogramSlot, requestCount, calleeHost);
        }
        final short slotTime = (isError) ? (short) -1 : histogramSlot;
        if (StringUtils.isEmpty(calleeHost)) {
            calleeHost = callee.getName();
        }
        linkDataMap.addLinkData(caller, callerAgentId, callee, calleeHost, timestamp, slotTime, requestCount);
    }
    return linkDataMap;
}
Also used : FixedBuffer(com.navercorp.pinpoint.common.buffer.FixedBuffer) Buffer(com.navercorp.pinpoint.common.buffer.Buffer) OffsetFixedBuffer(com.navercorp.pinpoint.common.buffer.OffsetFixedBuffer) FixedBuffer(com.navercorp.pinpoint.common.buffer.FixedBuffer) OffsetFixedBuffer(com.navercorp.pinpoint.common.buffer.OffsetFixedBuffer) OffsetFixedBuffer(com.navercorp.pinpoint.common.buffer.OffsetFixedBuffer) Application(com.navercorp.pinpoint.web.vo.Application) Cell(org.apache.hadoop.hbase.Cell) LinkDataMap(com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataMap)

Example 39 with FixedBuffer

use of com.navercorp.pinpoint.common.buffer.FixedBuffer in project pinpoint by naver.

the class AgentEventMapper method mapRow.

@Override
public List<AgentEventBo> mapRow(Result result, int rowNum) throws Exception {
    if (result.isEmpty()) {
        return Collections.emptyList();
    }
    List<AgentEventBo> agentEvents = new ArrayList<>();
    for (Cell cell : result.rawCells()) {
        final int code = CellUtils.qualifierToInt(cell);
        final AgentEventType eventType = AgentEventType.getTypeByCode(code);
        if (eventType == null) {
            continue;
        }
        byte[] value = CellUtil.cloneValue(cell);
        final Buffer buffer = new FixedBuffer(value);
        final int version = buffer.readInt();
        switch(version) {
            case 0:
            case 1:
                final String agentId = buffer.readPrefixedString();
                final long startTimestamp = buffer.readLong();
                final long eventTimestamp = buffer.readLong();
                final byte[] eventMessage = buffer.readPrefixedBytes();
                final AgentEventBo agentEvent = new AgentEventBo(version, agentId, startTimestamp, eventTimestamp, eventType);
                agentEvent.setEventBody(eventMessage);
                agentEvents.add(agentEvent);
                break;
            default:
                break;
        }
    }
    return agentEvents;
}
Also used : FixedBuffer(com.navercorp.pinpoint.common.buffer.FixedBuffer) Buffer(com.navercorp.pinpoint.common.buffer.Buffer) AgentEventType(com.navercorp.pinpoint.common.server.util.AgentEventType) FixedBuffer(com.navercorp.pinpoint.common.buffer.FixedBuffer) AgentEventBo(com.navercorp.pinpoint.common.server.bo.event.AgentEventBo) ArrayList(java.util.ArrayList) Cell(org.apache.hadoop.hbase.Cell)

Aggregations

Buffer (com.navercorp.pinpoint.common.buffer.Buffer)39 FixedBuffer (com.navercorp.pinpoint.common.buffer.FixedBuffer)39 AutomaticBuffer (com.navercorp.pinpoint.common.buffer.AutomaticBuffer)23 Test (org.junit.Test)16 AgentStatDataPointCodec (com.navercorp.pinpoint.common.server.bo.codec.stat.AgentStatDataPointCodec)10 ApplicationStatDecodingContext (com.navercorp.pinpoint.common.server.bo.serializer.stat.ApplicationStatDecodingContext)10 JoinStatBo (com.navercorp.pinpoint.common.server.bo.stat.join.JoinStatBo)10 Date (java.util.Date)10 ByteBuffer (java.nio.ByteBuffer)5 Cell (org.apache.hadoop.hbase.Cell)4 ArrayList (java.util.ArrayList)3 AgentInfoBo (com.navercorp.pinpoint.common.server.bo.AgentInfoBo)2 AgentStatDecodingContext (com.navercorp.pinpoint.common.server.bo.serializer.stat.AgentStatDecodingContext)2 AgentStatDataPoint (com.navercorp.pinpoint.common.server.bo.stat.AgentStatDataPoint)2 IntStringStringValue (com.navercorp.pinpoint.common.util.IntStringStringValue)2 LinkDataMap (com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataMap)2 Application (com.navercorp.pinpoint.web.vo.Application)2 OffsetFixedBuffer (com.navercorp.pinpoint.common.buffer.OffsetFixedBuffer)1 AgentLifeCycleBo (com.navercorp.pinpoint.common.server.bo.AgentLifeCycleBo)1 ApiMetaDataBo (com.navercorp.pinpoint.common.server.bo.ApiMetaDataBo)1