Search in sources :

Example 11 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_STATISTICS.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 12 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_STATISTICS.TIMESPAN_MS - TEST_COLLECTION_INTERVAL;
    final long expectedBaseTimestamp1 = AgentStatUtils.getBaseTimestamp(initialTimestamp);
    final long expectedBaseTimestamp2 = AgentStatUtils.getBaseTimestamp(expectedBaseTimestamp1 + AGENT_STAT_STATISTICS.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)

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