Search in sources :

Example 1 with LimitedScanResult

use of com.navercorp.pinpoint.web.vo.LimitedScanResult in project pinpoint by naver.

the class HbaseApplicationTraceIndexDao method scanTraceIndex.

@Override
public LimitedScanResult<List<TransactionId>> scanTraceIndex(final String applicationName, SelectedScatterArea area, int limit) {
    if (applicationName == null) {
        throw new NullPointerException("applicationName must not be null");
    }
    if (area == null) {
        throw new NullPointerException("area must not be null");
    }
    if (limit < 0) {
        throw new IllegalArgumentException("negative limit:" + limit);
    }
    logger.debug("scanTraceIndex");
    Scan scan = createScan(applicationName, area.getTimeRange());
    final LimitedScanResult<List<TransactionId>> limitedScanResult = new LimitedScanResult<>();
    LastRowAccessor lastRowAccessor = new LastRowAccessor();
    List<List<TransactionId>> traceIndexList = hbaseOperations2.findParallel(HBaseTables.APPLICATION_TRACE_INDEX, scan, traceIdRowKeyDistributor, limit, traceIndexMapper, lastRowAccessor, APPLICATION_TRACE_INDEX_NUM_PARTITIONS);
    List<TransactionId> transactionIdSum = new ArrayList<>(128);
    for (List<TransactionId> transactionId : traceIndexList) {
        transactionIdSum.addAll(transactionId);
    }
    limitedScanResult.setScanData(transactionIdSum);
    if (transactionIdSum.size() >= limit) {
        Long lastRowTimestamp = lastRowAccessor.getLastRowTimestamp();
        limitedScanResult.setLimitedTime(lastRowTimestamp);
        if (logger.isDebugEnabled()) {
            logger.debug("lastRowTimestamp lastTime:{}", DateUtils.longToDateStr(lastRowTimestamp));
        }
    } else {
        if (logger.isDebugEnabled()) {
            logger.debug("scanner start lastTime:{}", DateUtils.longToDateStr(area.getTimeRange().getFrom()));
        }
        limitedScanResult.setLimitedTime(area.getTimeRange().getFrom());
    }
    return limitedScanResult;
}
Also used : ArrayList(java.util.ArrayList) Scan(org.apache.hadoop.hbase.client.Scan) FilterList(org.apache.hadoop.hbase.filter.FilterList) ArrayList(java.util.ArrayList) List(java.util.List) LimitedScanResult(com.navercorp.pinpoint.web.vo.LimitedScanResult) TransactionId(com.navercorp.pinpoint.common.util.TransactionId)

Example 2 with LimitedScanResult

use of com.navercorp.pinpoint.web.vo.LimitedScanResult in project pinpoint by naver.

the class HbaseApplicationTraceIndexDao method scanTraceIndex.

@Override
public LimitedScanResult<List<TransactionId>> scanTraceIndex(final String applicationName, Range range, int limit, boolean scanBackward) {
    if (applicationName == null) {
        throw new NullPointerException("applicationName must not be null");
    }
    if (range == null) {
        throw new NullPointerException("range must not be null");
    }
    if (limit < 0) {
        throw new IllegalArgumentException("negative limit:" + limit);
    }
    logger.debug("scanTraceIndex");
    Scan scan = createScan(applicationName, range, scanBackward);
    final LimitedScanResult<List<TransactionId>> limitedScanResult = new LimitedScanResult<>();
    LastRowAccessor lastRowAccessor = new LastRowAccessor();
    List<List<TransactionId>> traceIndexList = hbaseOperations2.findParallel(HBaseTables.APPLICATION_TRACE_INDEX, scan, traceIdRowKeyDistributor, limit, traceIndexMapper, lastRowAccessor, APPLICATION_TRACE_INDEX_NUM_PARTITIONS);
    List<TransactionId> transactionIdSum = new ArrayList<>(128);
    for (List<TransactionId> transactionId : traceIndexList) {
        transactionIdSum.addAll(transactionId);
    }
    limitedScanResult.setScanData(transactionIdSum);
    if (transactionIdSum.size() >= limit) {
        Long lastRowTimestamp = lastRowAccessor.getLastRowTimestamp();
        limitedScanResult.setLimitedTime(lastRowTimestamp);
        if (logger.isDebugEnabled()) {
            logger.debug("lastRowTimestamp lastTime:{}", DateUtils.longToDateStr(lastRowTimestamp));
        }
    } else {
        if (logger.isDebugEnabled()) {
            logger.debug("scanner start lastTime:{}", DateUtils.longToDateStr(range.getFrom()));
        }
        limitedScanResult.setLimitedTime(range.getFrom());
    }
    return limitedScanResult;
}
Also used : ArrayList(java.util.ArrayList) Scan(org.apache.hadoop.hbase.client.Scan) FilterList(org.apache.hadoop.hbase.filter.FilterList) ArrayList(java.util.ArrayList) List(java.util.List) LimitedScanResult(com.navercorp.pinpoint.web.vo.LimitedScanResult) TransactionId(com.navercorp.pinpoint.common.util.TransactionId)

Aggregations

TransactionId (com.navercorp.pinpoint.common.util.TransactionId)2 LimitedScanResult (com.navercorp.pinpoint.web.vo.LimitedScanResult)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Scan (org.apache.hadoop.hbase.client.Scan)2 FilterList (org.apache.hadoop.hbase.filter.FilterList)2