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;
}
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()));
}
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()));
}
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;
}
Aggregations