Search in sources :

Example 1 with AgentStatDataPoint

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

the class AgentStatHbaseOperationFactoryTest method create_should_create_one_put_if_dataPoints_fit_into_a_single_slot.

@Test
public void create_should_create_one_put_if_dataPoints_fit_into_a_single_slot() {
    // Given
    final int numDataPoints = 6;
    final long initialTimestamp = AGENT_STAT_STATISTICS.TIMESPAN_MS;
    final long expectedBaseTimestamp = AgentStatUtils.getBaseTimestamp(initialTimestamp);
    final List<AgentStatDataPoint> testDataPoints = createTestDataPoints(initialTimestamp, TEST_COLLECTION_INTERVAL, numDataPoints);
    // When
    List<Put> puts = this.agentStatHbaseOperationFactory.createPuts(TEST_AGENT_ID, TEST_AGENT_STAT_TYPE, testDataPoints, this.mockSerializer);
    // Then
    assertEquals(1, puts.size());
    Put put = puts.get(0);
    assertEquals(TEST_AGENT_ID, this.agentStatHbaseOperationFactory.getAgentId(put.getRow()));
    assertEquals(TEST_AGENT_STAT_TYPE, this.agentStatHbaseOperationFactory.getAgentStatType(put.getRow()));
    assertEquals(expectedBaseTimestamp, this.agentStatHbaseOperationFactory.getBaseTimestamp(put.getRow()));
}
Also used : AgentStatDataPoint(com.navercorp.pinpoint.common.server.bo.stat.AgentStatDataPoint) AgentStatDataPoint(com.navercorp.pinpoint.common.server.bo.stat.AgentStatDataPoint) Put(org.apache.hadoop.hbase.client.Put) Test(org.junit.Test)

Example 2 with AgentStatDataPoint

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

the class AgentStatHbaseOperationFactoryTest method test_using_current_timestamp.

@Test
public void test_using_current_timestamp() {
    // Given
    final int numDataPoints = 6;
    final long initialTimestamp = System.currentTimeMillis() - (TEST_COLLECTION_INTERVAL * numDataPoints);
    final List<AgentStatDataPoint> testDataPoints = createTestDataPoints(initialTimestamp, TEST_COLLECTION_INTERVAL, numDataPoints);
    final Set<Long> uniqueTimeslots = new TreeSet<>();
    for (AgentStatDataPoint testDataPoint : testDataPoints) {
        uniqueTimeslots.add(AgentStatUtils.getBaseTimestamp(testDataPoint.getTimestamp()));
    }
    // When
    List<Put> puts = this.agentStatHbaseOperationFactory.createPuts(TEST_AGENT_ID, TEST_AGENT_STAT_TYPE, testDataPoints, this.mockSerializer);
    // Then
    assertEquals(uniqueTimeslots.size(), puts.size());
    int i = 0;
    for (Long timeslot : uniqueTimeslots) {
        long expectedBaseTimestamp = timeslot;
        Put put = puts.get(i++);
        assertEquals(TEST_AGENT_ID, this.agentStatHbaseOperationFactory.getAgentId(put.getRow()));
        assertEquals(TEST_AGENT_STAT_TYPE, this.agentStatHbaseOperationFactory.getAgentStatType(put.getRow()));
        assertEquals(expectedBaseTimestamp, this.agentStatHbaseOperationFactory.getBaseTimestamp(put.getRow()));
    }
}
Also used : TreeSet(java.util.TreeSet) AgentStatDataPoint(com.navercorp.pinpoint.common.server.bo.stat.AgentStatDataPoint) AgentStatDataPoint(com.navercorp.pinpoint.common.server.bo.stat.AgentStatDataPoint) Put(org.apache.hadoop.hbase.client.Put) Test(org.junit.Test)

Example 3 with AgentStatDataPoint

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

the class AgentStatMapperV2 method filter.

private boolean filter(T candidate) {
    if (candidate instanceof AgentStatDataPointList) {
        AgentStatDataPointList<AgentStatDataPoint> agentStatDataPointList = (AgentStatDataPointList) candidate;
        List<AgentStatDataPoint> list = agentStatDataPointList.getList();
        for (AgentStatDataPoint agentStatDataPoint : list) {
            long timestamp = agentStatDataPoint.getTimestamp();
            if (!this.filter.filter(timestamp)) {
                return false;
            }
        }
        return true;
    } else {
        long timestamp = candidate.getTimestamp();
        return this.filter.filter(timestamp);
    }
}
Also used : AgentStatDataPointList(com.navercorp.pinpoint.common.server.bo.stat.AgentStatDataPointList) AgentStatDataPoint(com.navercorp.pinpoint.common.server.bo.stat.AgentStatDataPoint)

Example 4 with AgentStatDataPoint

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

the class HbaseAgentStatDaoOperationsV2 method getAgentStatList.

<T extends AgentStatDataPoint> List<T> getAgentStatList(AgentStatType agentStatType, AgentStatMapperV2<T> mapper, String agentId, Range range) {
    Objects.requireNonNull(agentId, "agentId");
    Objects.requireNonNull(range, "range");
    Scan scan = this.createScan(agentStatType, agentId, range);
    TableName agentStatTableName = tableNameProvider.getTableName(DESCRIPTOR.getTable());
    List<List<T>> intermediate = hbaseOperations2.findParallel(agentStatTableName, scan, this.operationFactory.getRowKeyDistributor(), mapper, AGENT_STAT_VER2_NUM_PARTITIONS);
    int expectedSize = (int) (range.getRange() / DESCRIPTOR.TIMESPAN_MS);
    return ListListUtils.toList(intermediate, expectedSize);
}
Also used : TableName(org.apache.hadoop.hbase.TableName) Scan(org.apache.hadoop.hbase.client.Scan) List(java.util.List) AgentStatDataPoint(com.navercorp.pinpoint.common.server.bo.stat.AgentStatDataPoint) SampledAgentStatDataPoint(com.navercorp.pinpoint.web.vo.stat.SampledAgentStatDataPoint)

Example 5 with AgentStatDataPoint

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

the class HbaseAgentStatDaoOperationsV2 method agentStatExists.

<T extends AgentStatDataPoint> boolean agentStatExists(AgentStatType agentStatType, AgentStatMapperV2<T> mapper, String agentId, Range range) {
    Objects.requireNonNull(agentId, "agentId");
    Objects.requireNonNull(range, "range");
    if (logger.isDebugEnabled()) {
        logger.debug("checking for stat data existence : agentId={}, {}", agentId, range);
    }
    int resultLimit = 20;
    Scan scan = this.createScan(agentStatType, agentId, range, resultLimit);
    TableName agentStatTableName = tableNameProvider.getTableName(DESCRIPTOR.getTable());
    List<List<T>> result = hbaseOperations2.findParallel(agentStatTableName, scan, this.operationFactory.getRowKeyDistributor(), resultLimit, mapper, AGENT_STAT_VER2_NUM_PARTITIONS);
    if (result.isEmpty()) {
        return false;
    } else {
        return true;
    }
}
Also used : TableName(org.apache.hadoop.hbase.TableName) Scan(org.apache.hadoop.hbase.client.Scan) List(java.util.List) AgentStatDataPoint(com.navercorp.pinpoint.common.server.bo.stat.AgentStatDataPoint) SampledAgentStatDataPoint(com.navercorp.pinpoint.web.vo.stat.SampledAgentStatDataPoint)

Aggregations

AgentStatDataPoint (com.navercorp.pinpoint.common.server.bo.stat.AgentStatDataPoint)12 SampledAgentStatDataPoint (com.navercorp.pinpoint.web.vo.stat.SampledAgentStatDataPoint)5 List (java.util.List)5 Put (org.apache.hadoop.hbase.client.Put)5 Scan (org.apache.hadoop.hbase.client.Scan)5 Test (org.junit.Test)5 TableName (org.apache.hadoop.hbase.TableName)4 ArrayList (java.util.ArrayList)2 AgentStatDataPointList (com.navercorp.pinpoint.common.server.bo.stat.AgentStatDataPointList)1 TreeSet (java.util.TreeSet)1