@Override public List<Dot> scanTraceScatter(String applicationName, Range range, final int limit) { 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("scanTraceScatter"); Scan scan = createScan(applicationName, range); List<List<Dot>> dotListList = hbaseOperations2.find( HBaseTables.APPLICATION_TRACE_INDEX, scan, traceIdRowKeyDistributor, limit, traceIndexScatterMapper); List<Dot> mergeList = new ArrayList<Dot>(limit + 10); for (List<Dot> dotList : dotListList) { mergeList.addAll(dotList); } return mergeList; }
@Override public List<SpanBo> selectSpan(TransactionId transactionId) { if (transactionId == null) { throw new NullPointerException("transactionId must not be null"); } byte[] transactionIdRowKey = rowKeyDecoder.encodeRowKey(transactionId); return template2.get( HBaseTables.TRACES, transactionIdRowKey, HBaseTables.TRACES_CF_SPAN, spanMapper); }
@Override public List<SpanBo> selectSpans(TransactionId transactionId) { if (transactionId == null) { throw new NullPointerException("transactionId must not be null"); } byte[] transactionIdRowKey = rowKeyDecoder.encodeRowKey(transactionId); Get get = new Get(transactionIdRowKey); get.addFamily(HBaseTables.TRACES_CF_SPAN); get.addFamily(HBaseTables.TRACES_CF_TERMINALSPAN); return template2.get(HBaseTables.TRACES, get, spanMapper); }
@Override public List<SqlMetaDataBo> getSqlMetaData(String agentId, long time, int hashCode) { if (agentId == null) { throw new NullPointerException("agentId must not be null"); } SqlMetaDataBo sqlMetaData = new SqlMetaDataBo(agentId, time, hashCode); byte[] sqlId = getDistributedKey(sqlMetaData.toRowKey()); Get get = new Get(sqlId); get.addFamily(HBaseTables.SQL_METADATA_CF_SQL); return hbaseOperations2.get(HBaseTables.SQL_METADATA, get, sqlMetaDataMapper); }
@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; }
@Override public List<Dot> scanTraceScatter( String applicationName, SelectedScatterArea area, TransactionId offsetTransactionId, int offsetTransactionElapsed, int limit) { if (applicationName == null) { throw new NullPointerException("applicationName must not be null"); } if (area == null) { throw new NullPointerException("range must not be null"); } if (limit < 0) { throw new IllegalArgumentException("negative limit:" + limit); } logger.debug("scanTraceScatter"); Scan scan = createScan(applicationName, area.getTimeRange()); // method 1 // not used yet. instead, use another row mapper (testing) // scan.setFilter(makeResponseTimeFilter(area, offsetTransactionId, offsetTransactionElapsed)); // method 2 ResponseTimeRange responseTimeRange = area.getResponseTimeRange(); TraceIndexScatterMapper2 mapper = new TraceIndexScatterMapper2(responseTimeRange.getFrom(), responseTimeRange.getTo()); List<List<Dot>> dotListList = hbaseOperations2.findParallel( HBaseTables.APPLICATION_TRACE_INDEX, scan, traceIdRowKeyDistributor, limit, mapper, APPLICATION_TRACE_INDEX_NUM_PARTITIONS); List<Dot> result = new ArrayList<>(); for (List<Dot> dotList : dotListList) { result.addAll(dotList); } return result; }
@Override public ScatterData scanTraceScatterData( String applicationName, Range range, int xGroupUnit, int yGroupUnit, 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("scanTraceScatterDataMadeOfDotGroup"); Scan scan = createScan(applicationName, range, scanBackward); TraceIndexScatterMapper3 mapper = new TraceIndexScatterMapper3(range.getFrom(), range.getTo(), xGroupUnit, yGroupUnit); List<ScatterData> dotGroupList = hbaseOperations2.findParallel( HBaseTables.APPLICATION_TRACE_INDEX, scan, traceIdRowKeyDistributor, limit, mapper, APPLICATION_TRACE_INDEX_NUM_PARTITIONS); if (ListUtils.isEmpty(dotGroupList)) { return new ScatterData(range.getFrom(), range.getTo(), xGroupUnit, yGroupUnit); } else { ScatterData firstScatterData = dotGroupList.get(0); for (int i = 1; i < dotGroupList.size(); i++) { firstScatterData.merge(dotGroupList.get(i)); } return firstScatterData; } }
private List<List<SpanBo>> getSpans0( List<TransactionId> transactionIdList, List<byte[]> hBaseFamiliyList) { if (transactionIdList == null || transactionIdList.isEmpty()) { return Collections.emptyList(); } if (hBaseFamiliyList == null) { throw new NullPointerException("hBaseFamiliyList may not be null."); } final List<Get> getList = new ArrayList<>(transactionIdList.size()); for (TransactionId transactionId : transactionIdList) { byte[] transactionIdRowKey = rowKeyDecoder.encodeRowKey(transactionId); final Get get = new Get(transactionIdRowKey); for (byte[] hbaseFamily : hBaseFamiliyList) { get.addFamily(hbaseFamily); } getList.add(get); } return template2.get(HBaseTables.TRACES, getList, spanMapper); }