use of co.cask.cdap.data2.util.hbase.ScanBuilder in project cdap by caskdata.
the class ReplicationStatusTool method getScanBuilder.
private static ScanBuilder getScanBuilder(HBaseTableUtil tableUtil, String rowType) {
ScanBuilder scan = tableUtil.buildScan();
// FIX: get scan based on start row and stop row
// ReplicationStatusKey startKey = new ReplicationStatusKey(Bytes.toBytes(prefix));
// scan.setStartRow(startKey.getKey());
// scan.setStopRow(Bytes.stopKeyForPrefix(startKey.getKey()));
scan.addColumn(Bytes.toBytes(ReplicationConstants.ReplicationStatusTool.TIME_FAMILY), Bytes.toBytes(rowType));
scan.setMaxVersions(1);
return scan;
}
use of co.cask.cdap.data2.util.hbase.ScanBuilder in project cdap by caskdata.
the class ReplicationStatusTool method dumpReplicationStateTable.
private static void dumpReplicationStateTable() throws Exception {
System.out.println("\nThis is all the HBase regions on the Cluster:");
HBaseTableUtil tableUtil = new HBaseTableUtilFactory(cConf).get();
HTable hTable = tableUtil.createHTable(hConf, getReplicationStateTableId(tableUtil));
ScanBuilder scan = tableUtil.buildScan();
scan.addColumn(Bytes.toBytes(ReplicationConstants.ReplicationStatusTool.TIME_FAMILY), Bytes.toBytes(ReplicationConstants.ReplicationStatusTool.WRITE_TIME_ROW_TYPE));
scan.addColumn(Bytes.toBytes(ReplicationConstants.ReplicationStatusTool.TIME_FAMILY), Bytes.toBytes(ReplicationConstants.ReplicationStatusTool.REPLICATE_TIME_ROW_TYPE));
Result result;
try (ResultScanner resultScanner = hTable.getScanner(scan.build())) {
while ((result = resultScanner.next()) != null) {
ReplicationStatusKey key = new ReplicationStatusKey(result.getRow());
String rowType = key.getRowType();
String region = key.getRegionName();
UUID rsID = key.getRsID();
Long writeTime = getTimeFromResult(result, ReplicationConstants.ReplicationStatusTool.WRITE_TIME_ROW_TYPE);
Long replicateTime = getTimeFromResult(result, ReplicationConstants.ReplicationStatusTool.REPLICATE_TIME_ROW_TYPE);
System.out.println("Key=>rowType:" + rowType + ":region:" + region + ":RSID:" + rsID + " writeTime:" + writeTime + ":replicateTime:" + replicateTime);
}
} finally {
hTable.close();
}
}
use of co.cask.cdap.data2.util.hbase.ScanBuilder in project cdap by caskdata.
the class HBaseMetadataTable method listTopics.
@Override
public List<TopicId> listTopics(NamespaceId namespaceId) throws IOException {
byte[] startRow = MessagingUtils.topicScanKey(namespaceId);
ScanBuilder scanBuilder = tableUtil.buildScan().setStartRow(startRow).setStopRow(Bytes.stopKeyForPrefix(startRow));
return scanTopics(scanBuilder);
}
use of co.cask.cdap.data2.util.hbase.ScanBuilder in project cdap by caskdata.
the class HBaseTable method scanPersisted.
@ReadOnly
@Override
protected Scanner scanPersisted(co.cask.cdap.api.dataset.table.Scan scan) throws Exception {
ScanBuilder hScan = tableUtil.buildScan();
hScan.addFamily(columnFamily);
// todo: should be configurable
// NOTE: by default we assume scanner is used in mapreduce job, hence no cache blocks
hScan.setCacheBlocks(false);
hScan.setCaching(1000);
byte[] startRow = scan.getStartRow();
byte[] stopRow = scan.getStopRow();
if (startRow != null) {
hScan.setStartRow(startRow);
}
if (stopRow != null) {
hScan.setStopRow(stopRow);
}
setFilterIfNeeded(hScan, scan.getFilter());
hScan.setAttribute(TxConstants.TX_OPERATION_ATTRIBUTE_KEY, txCodec.encode(tx));
ResultScanner resultScanner = wrapResultScanner(hTable.getScanner(hScan.build()));
return new HBaseScanner(resultScanner, columnFamily);
}
use of co.cask.cdap.data2.util.hbase.ScanBuilder in project cdap by caskdata.
the class HBaseMetricsTable method scan.
@Override
public Scanner scan(@Nullable byte[] startRow, @Nullable byte[] stopRow, @Nullable FuzzyRowFilter filter) {
ScanBuilder scanBuilder = tableUtil.buildScan();
configureRangeScan(scanBuilder, startRow, stopRow, filter);
try {
ResultScanner resultScanner = hTable.getScanner(scanBuilder.build());
return new HBaseScanner(resultScanner, columnFamily);
} catch (IOException e) {
throw new DataSetException("Scan failed on table " + tableId, e);
}
}
Aggregations