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