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; }
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(); } }
.setStopRow(stopRow) .setMaxVersions(1) .addColumn(QueueEntryRow.COLUMN_FAMILY, stateColumnName) .setCaching(MAX_SCAN_ROWS) .build();