Java Code Examples for org.apache.hadoop.hbase.client.Scan#setId()

The following examples show how to use org.apache.hadoop.hbase.client.Scan#setId() .
Example 1
Project: pinpoint   File: HbaseMapStatisticsCallerDao.java    License: Apache License 2.0 6 votes vote down vote up
private Scan createScan(Application application, Range range, byte[]... familyArgs) {
    range = rangeFactory.createStatisticsRange(range);

    if (logger.isDebugEnabled()) {
        logger.debug("scan Time:{}", range.prettyToString());
    }

    // start key is replaced by end key because timestamp has been reversed
    byte[] startKey = ApplicationMapStatisticsUtils.makeRowKey(application.getName(), application.getServiceTypeCode(), range.getTo());
    byte[] endKey = ApplicationMapStatisticsUtils.makeRowKey(application.getName(), application.getServiceTypeCode(), range.getFrom());

    Scan scan = new Scan();
    scan.setCaching(SCAN_CACHE_SIZE);
    scan.setStartRow(startKey);
    scan.setStopRow(endKey);
    for(byte[] family : familyArgs) {
        scan.addFamily(family);
    }
    scan.setId("ApplicationStatisticsScan");

    return scan;
}
 
Example 2
Project: pinpoint   File: HbaseMapResponseTimeDao.java    License: Apache License 2.0 6 votes vote down vote up
private Scan createScan(Application application, Range range, byte[] family) {
    range = rangeFactory.createStatisticsRange(range);
    if (logger.isDebugEnabled()) {
        logger.debug("scan time:{} ", range.prettyToString());
    }

    // start key is replaced by end key because timestamp has been reversed
    byte[] startKey = ApplicationMapStatisticsUtils.makeRowKey(application.getName(), application.getServiceTypeCode(), range.getTo());
    byte[] endKey = ApplicationMapStatisticsUtils.makeRowKey(application.getName(), application.getServiceTypeCode(), range.getFrom());

    final Scan scan = new Scan();
    scan.setCaching(this.scanCacheSize);
    scan.setStartRow(startKey);
    scan.setStopRow(endKey);
    scan.addFamily(family);
    scan.setId("ApplicationSelfScan");

    return scan;
}
 
Example 3
Project: pinpoint   File: HbaseApplicationTraceIndexDao.java    License: Apache License 2.0 6 votes vote down vote up
private Scan createScan(String applicationName, Range range, boolean scanBackward) {
    Scan scan = new Scan();
    scan.setCaching(this.scanCacheSize);

    byte[] bApplicationName = Bytes.toBytes(applicationName);
    byte[] traceIndexStartKey = SpanUtils.getApplicationTraceIndexRowKey(bApplicationName, range.getFrom());
    byte[] traceIndexEndKey = SpanUtils.getApplicationTraceIndexRowKey(bApplicationName, range.getTo());

    if (scanBackward) {
        // start key is replaced by end key because key has been reversed
        scan.setStartRow(traceIndexEndKey);
        scan.setStopRow(traceIndexStartKey);
    } else {
        scan.setReversed(true);
        scan.setStartRow(traceIndexStartKey);
        scan.setStopRow(traceIndexEndKey);
    }

    scan.addFamily(descriptor.getColumnFamilyName());
    scan.setId("ApplicationTraceIndexScan");

    // toString() method of Scan converts a message to json format so it is slow for the first time.
    logger.trace("create scan:{}", scan);
    return scan;
}
 
Example 4
Project: pinpoint   File: HbaseHostApplicationMapDao.java    License: Apache License 2.0 6 votes vote down vote up
private Scan createScan(Application parentApplication, Range range) {
    Objects.requireNonNull(parentApplication, "parentApplication");

    if (logger.isDebugEnabled()) {
        logger.debug("scan parentApplication:{}, range:{}", parentApplication, range);
    }

    // TODO need common logic for creating scanner
    final long startTime = TimeUtils.reverseTimeMillis(timeSlot.getTimeSlot(range.getFrom()));
    final long endTime = TimeUtils.reverseTimeMillis(timeSlot.getTimeSlot(range.getTo()) + 1);
    // start key is replaced by end key because timestamp has been reversed
    final byte[] startKey = createKey(parentApplication, endTime);
    final byte[] endKey = createKey(parentApplication, startTime);

    Scan scan = new Scan();
    scan.setCaching(this.scanCacheSize);
    scan.setStartRow(startKey);
    scan.setStopRow(endKey);
    scan.setId("HostApplicationScan_Ver2");

    return scan;
}
 
Example 5
Project: pinpoint   File: HbaseMapStatisticsCalleeDao.java    License: Apache License 2.0 6 votes vote down vote up
private Scan createScan(Application application, Range range, byte[] family) {
    range = rangeFactory.createStatisticsRange(range);

    if (logger.isDebugEnabled()) {
        logger.debug("scan time:{} ", range.prettyToString());
    }

    // start key is replaced by end key because timestamp has been reversed
    byte[] startKey = ApplicationMapStatisticsUtils.makeRowKey(application.getName(), application.getServiceTypeCode(), range.getTo());
    byte[] endKey = ApplicationMapStatisticsUtils.makeRowKey(application.getName(), application.getServiceTypeCode(), range.getFrom());

    Scan scan = new Scan();
    scan.setCaching(SCAN_CACHE_SIZE);
    scan.setStartRow(startKey);
    scan.setStopRow(endKey);
    scan.addFamily(family);
    scan.setId("ApplicationStatisticsScan");

    return scan;
}
 
Example 6
Project: pinpoint   File: HbaseTemplate2.java    License: Apache License 2.0 6 votes vote down vote up
private ResultScanner[] splitScan(Table table, Scan originalScan, AbstractRowKeyDistributor rowKeyDistributor) throws IOException {
    Scan[] scans = rowKeyDistributor.getDistributedScans(originalScan);
    final int length = scans.length;
    for (int i = 0; i < length; i++) {
        Scan scan = scans[i];
        // other properties are already set upon construction
        scan.setId(scan.getId() + "-" + i);
    }

    ResultScanner[] scanners = new ResultScanner[length];
    boolean success = false;
    try {
        for (int i = 0; i < length; i++) {
            scanners[i] = table.getScanner(scans[i]);
        }
        success = true;
    } finally {
        if (!success) {
            closeScanner(scanners);
        }
    }
    return scanners;
}
 
Example 7
Project: pinpoint   File: HbaseApplicationStatDaoOperations.java    License: Apache License 2.0 5 votes vote down vote up
private Scan createScan(StatType statType, String applicationId, Range range, int scanCacheSize) {
    Scan scan = this.operationFactory.createScan(applicationId, statType, range.getFrom(), range.getTo());
    scan.setCaching(scanCacheSize);
    scan.setId("ApplicationStat_" + statType);
    scan.addFamily(descriptor.getColumnFamilyName());
    return scan;
}
 
Example 8
Project: pinpoint   File: HbaseAgentStatDaoOperationsV2.java    License: Apache License 2.0 5 votes vote down vote up
private Scan createScan(AgentStatType agentStatType, String agentId, Range range, int scanCacheSize) {
    Scan scan = this.operationFactory.createScan(agentId, agentStatType, range.getFrom(), range.getTo());
    scan.setCaching(scanCacheSize);
    scan.setId("AgentStat_" + agentStatType);
    scan.addFamily(descriptor.getColumnFamilyName());
    return scan;
}
 
Example 9
Project: pinpoint   File: ParallelResultScanner.java    License: Apache License 2.0 5 votes vote down vote up
private Scan[] splitScans(Scan originalScan) throws IOException {
    Scan[] scans = this.keyDistributor.getDistributedScans(originalScan);
    for (int i = 0; i < scans.length; i++) {
        Scan scan = scans[i];
        scan.setId(originalScan.getId() + "-" + i);
    }
    return scans;
}