Search in sources :

Example 1 with AgentEventBo

use of com.navercorp.pinpoint.common.server.bo.event.AgentEventBo in project pinpoint by naver.

the class ThriftAgentEventMapperTest method simpleTest2.

@Test
public void simpleTest2() {
    final String agentId = "agentId";
    final long startTimestamp = Long.MAX_VALUE;
    final long eventTimestamp = startTimestamp;
    final TAgentStat agentStat = createAgentStat(agentId, startTimestamp, eventTimestamp, 0);
    DeadlockBo deadlockBo = new DeadlockBo();
    DeadlockEventBo expectedEventBo = new DeadlockEventBo(agentId, startTimestamp, eventTimestamp, AgentEventType.AGENT_DEADLOCK_DETECTED, deadlockBo);
    when(this.deadlockEventBoMapper.map(any(String.class), any(Long.class), any(Long.class), any(TDeadlock.class))).thenReturn(expectedEventBo);
    AgentEventBo actualEventBo = agentEventMapper.map(agentStat);
    Assert.assertNull(actualEventBo);
}
Also used : TDeadlock(com.navercorp.pinpoint.thrift.dto.TDeadlock) TAgentStat(com.navercorp.pinpoint.thrift.dto.TAgentStat) DeadlockBo(com.navercorp.pinpoint.common.server.bo.event.DeadlockBo) AgentEventBo(com.navercorp.pinpoint.common.server.bo.event.AgentEventBo) DeadlockEventBo(com.navercorp.pinpoint.common.server.bo.event.DeadlockEventBo) Test(org.junit.Test)

Example 2 with AgentEventBo

use of com.navercorp.pinpoint.common.server.bo.event.AgentEventBo in project pinpoint by naver.

the class HbaseAgentEventDao method getAgentEvent.

@Override
public AgentEventBo getAgentEvent(String agentId, long eventTimestamp, AgentEventType eventType) {
    Objects.requireNonNull(agentId, "agentId");
    if (eventTimestamp < 0) {
        throw new IllegalArgumentException("eventTimestamp must not be less than 0");
    }
    Objects.requireNonNull(eventType, "eventType");
    final byte[] rowKey = createRowKey(agentId, eventTimestamp);
    byte[] qualifier = Bytes.toBytes(eventType.getCode());
    TableName agentEventTableName = tableNameProvider.getTableName(DESCRIPTOR.getTable());
    List<AgentEventBo> events = this.hbaseOperations2.get(agentEventTableName, rowKey, DESCRIPTOR.getName(), qualifier, this.agentEventMapper);
    if (CollectionUtils.isEmpty(events)) {
        return null;
    }
    return events.get(0);
}
Also used : TableName(org.apache.hadoop.hbase.TableName) AgentEventBo(com.navercorp.pinpoint.common.server.bo.event.AgentEventBo)

Example 3 with AgentEventBo

use of com.navercorp.pinpoint.common.server.bo.event.AgentEventBo in project pinpoint by naver.

the class HbaseAgentEventDao method getAgentEvents.

@Override
public List<AgentEventBo> getAgentEvents(String agentId, Range range, Set<AgentEventType> excludeEventTypes) {
    Objects.requireNonNull(agentId, "agentId");
    Objects.requireNonNull(range, "range");
    Scan scan = new Scan();
    scan.setMaxVersions(1);
    scan.setCaching(SCANNER_CACHE_SIZE);
    scan.withStartRow(createRowKey(agentId, range.getTo()));
    scan.withStopRow(createRowKey(agentId, range.getFrom()));
    scan.addFamily(DESCRIPTOR.getName());
    if (CollectionUtils.hasLength(excludeEventTypes)) {
        FilterList filterList = new FilterList(FilterList.Operator.MUST_PASS_ALL);
        for (AgentEventType excludeEventType : excludeEventTypes) {
            byte[] excludeQualifier = Bytes.toBytes(excludeEventType.getCode());
            filterList.addFilter(new QualifierFilter(CompareFilter.CompareOp.NOT_EQUAL, new BinaryComparator(excludeQualifier)));
        }
        scan.setFilter(filterList);
    }
    TableName agentEventTableName = tableNameProvider.getTableName(DESCRIPTOR.getTable());
    List<AgentEventBo> agentEvents = this.hbaseOperations2.find(agentEventTableName, scan, agentEventResultsExtractor);
    logger.debug("agentEvents found. {}", agentEvents);
    return agentEvents;
}
Also used : TableName(org.apache.hadoop.hbase.TableName) AgentEventType(com.navercorp.pinpoint.common.server.util.AgentEventType) AgentEventBo(com.navercorp.pinpoint.common.server.bo.event.AgentEventBo) Scan(org.apache.hadoop.hbase.client.Scan) FilterList(org.apache.hadoop.hbase.filter.FilterList) BinaryComparator(org.apache.hadoop.hbase.filter.BinaryComparator) QualifierFilter(org.apache.hadoop.hbase.filter.QualifierFilter)

Example 4 with AgentEventBo

use of com.navercorp.pinpoint.common.server.bo.event.AgentEventBo in project pinpoint by naver.

the class AgentEventDataCollector method collect.

@Override
public void collect() {
    if (init.get()) {
        return;
    }
    Range range = Range.newUncheckedRange(timeSlotEndTime - slotInterval, timeSlotEndTime);
    List<String> agentIds = applicationIndexDao.selectAgentIds(application.getName());
    for (String agentId : agentIds) {
        List<AgentEventBo> agentEventBoList = agentEventDao.getAgentEvents(agentId, range, Collections.emptySet());
        if (hasDeadlockEvent(agentEventBoList)) {
            agentDeadlockEventDetected.put(agentId, true);
        }
    }
    init.set(true);
}
Also used : AgentEventBo(com.navercorp.pinpoint.common.server.bo.event.AgentEventBo) Range(com.navercorp.pinpoint.web.vo.Range)

Example 5 with AgentEventBo

use of com.navercorp.pinpoint.common.server.bo.event.AgentEventBo in project pinpoint by naver.

the class AgentEventHandlingFilter method insertResponseEvent.

private void insertResponseEvent(ResponseEvent responseEvent, long eventTimestamp) {
    final TCommandTransfer command = responseEvent.getDeliveryCommand();
    final String agentId = command.getAgentId();
    final long startTimestamp = command.getStartTime();
    final TCommandTransferResponse response = responseEvent.getRouteResult();
    final byte[] payload = response.getPayload();
    final Class<?> payloadType = readPayload(payload);
    if (payload == null) {
        return;
    }
    for (AgentEventType eventType : RESPONSE_EVENT_TYPES) {
        if (eventType.getMessageType() == payloadType) {
            final AgentEventBo agentEventBo = new AgentEventBo(agentId, startTimestamp, eventTimestamp, eventType);
            agentEventBo.setEventBody(payload);
            this.agentEventService.insert(agentEventBo);
        }
    }
}
Also used : TCommandTransfer(com.navercorp.pinpoint.thrift.dto.command.TCommandTransfer) AgentEventType(com.navercorp.pinpoint.common.server.util.AgentEventType) TCommandTransferResponse(com.navercorp.pinpoint.thrift.dto.command.TCommandTransferResponse) AgentEventBo(com.navercorp.pinpoint.common.server.bo.event.AgentEventBo)

Aggregations

AgentEventBo (com.navercorp.pinpoint.common.server.bo.event.AgentEventBo)20 AgentEventType (com.navercorp.pinpoint.common.server.util.AgentEventType)5 ArrayList (java.util.ArrayList)5 Test (org.junit.Test)5 TAgentStat (com.navercorp.pinpoint.thrift.dto.TAgentStat)3 TCommandTransfer (com.navercorp.pinpoint.thrift.dto.command.TCommandTransfer)3 TCommandTransferResponse (com.navercorp.pinpoint.thrift.dto.command.TCommandTransferResponse)3 ResponseEvent (com.navercorp.pinpoint.collector.cluster.route.ResponseEvent)2 DeadlockBo (com.navercorp.pinpoint.common.server.bo.event.DeadlockBo)2 DeadlockEventBo (com.navercorp.pinpoint.common.server.bo.event.DeadlockEventBo)2 Header (com.navercorp.pinpoint.grpc.Header)2 HeaderV1 (com.navercorp.pinpoint.io.header.v1.HeaderV1)2 DefaultMessage (com.navercorp.pinpoint.io.request.DefaultMessage)2 TDeadlock (com.navercorp.pinpoint.thrift.dto.TDeadlock)2 HeaderTBaseDeserializer (com.navercorp.pinpoint.thrift.io.HeaderTBaseDeserializer)2 AgentEvent (com.navercorp.pinpoint.web.vo.AgentEvent)2 TableName (org.apache.hadoop.hbase.TableName)2 TBase (org.apache.thrift.TBase)2 AgentProperty (com.navercorp.pinpoint.collector.service.async.AgentProperty)1 AgentPropertyChannelAdaptor (com.navercorp.pinpoint.collector.service.async.AgentPropertyChannelAdaptor)1