Search in sources :

Example 6 with AgentStatDataPoint

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

the class AgentStatHbaseOperationFactoryTest method createTestDataPoints.

private List<AgentStatDataPoint> createTestDataPoints(long initialTimestamp, long interval, int count) {
    List<AgentStatDataPoint> dataPoints = new ArrayList<AgentStatDataPoint>(count);
    long timestamp = initialTimestamp;
    for (int i = 0; i < count; ++i) {
        AgentStatDataPoint dataPoint = createTestDataPoint(timestamp);
        dataPoints.add(dataPoint);
        timestamp += interval;
    }
    return dataPoints;
}
Also used : ArrayList(java.util.ArrayList) AgentStatDataPoint(com.navercorp.pinpoint.common.server.bo.stat.AgentStatDataPoint) AgentStatDataPoint(com.navercorp.pinpoint.common.server.bo.stat.AgentStatDataPoint)

Example 7 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_there_is_only_one_dataPoint.

@Test
public void create_should_create_one_put_if_there_is_only_one_dataPoint() {
    // Given
    final int numDataPoints = 1;
    final long initialTimestamp = AGENT_STAT_TIMESPAN_MS + 1L;
    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 8 with AgentStatDataPoint

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

the class AgentStatHbaseOperationFactoryTest method create_should_create_two_puts_if_dataPoints_span_over_a_timespan.

@Test
public void create_should_create_two_puts_if_dataPoints_span_over_a_timespan() {
    // Given
    final int numDataPoints = 6;
    final long initialTimestamp = AGENT_STAT_TIMESPAN_MS - TEST_COLLECTION_INTERVAL;
    final long expectedBaseTimestamp1 = AgentStatUtils.getBaseTimestamp(initialTimestamp);
    final long expectedBaseTimestamp2 = AgentStatUtils.getBaseTimestamp(expectedBaseTimestamp1 + AGENT_STAT_TIMESPAN_MS);
    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(2, puts.size());
    Put firstPut = puts.get(0);
    assertEquals(TEST_AGENT_ID, this.agentStatHbaseOperationFactory.getAgentId(firstPut.getRow()));
    assertEquals(TEST_AGENT_STAT_TYPE, this.agentStatHbaseOperationFactory.getAgentStatType(firstPut.getRow()));
    assertEquals(expectedBaseTimestamp1, this.agentStatHbaseOperationFactory.getBaseTimestamp(firstPut.getRow()));
    Put secondPut = puts.get(1);
    assertEquals(TEST_AGENT_ID, this.agentStatHbaseOperationFactory.getAgentId(secondPut.getRow()));
    assertEquals(TEST_AGENT_STAT_TYPE, this.agentStatHbaseOperationFactory.getAgentStatType(secondPut.getRow()));
    assertEquals(expectedBaseTimestamp2, this.agentStatHbaseOperationFactory.getBaseTimestamp(secondPut.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 9 with AgentStatDataPoint

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

the class HbaseAgentStatDaoOperations method getAgentStatListFromRaw.

private <T extends AgentStatDataPoint> List<T> getAgentStatListFromRaw(AgentStatMapperV1<T> mapper, String agentId, Range range) {
    Scan scan = createScan(agentId, range);
    List<List<T>> intermediate = hbaseOperations2.find(HBaseTables.AGENT_STAT, scan, rowKeyDistributor, mapper);
    // data for 5 seconds
    int expectedSize = (int) (range.getRange() / 5000);
    List<T> merged = new ArrayList<>(expectedSize);
    for (List<T> each : intermediate) {
        merged.addAll(each);
    }
    return merged;
}
Also used : ArrayList(java.util.ArrayList) Scan(org.apache.hadoop.hbase.client.Scan) ArrayList(java.util.ArrayList) 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)9 Put (org.apache.hadoop.hbase.client.Put)5 Test (org.junit.Test)5 ArrayList (java.util.ArrayList)4 SampledAgentStatDataPoint (com.navercorp.pinpoint.web.vo.stat.SampledAgentStatDataPoint)3 List (java.util.List)3 Scan (org.apache.hadoop.hbase.client.Scan)3 TreeSet (java.util.TreeSet)1