use of org.apache.hadoop.hbase.client.ResultScanner in project hbase by apache.
the class ReplicationTableBase method getQueuesBelongingToServer.
/**
* Get the queue id's and meta data (Owner and History) for the queues belonging to the named
* server
*
* @param server name of the server
* @return a ResultScanner over the QueueIds belonging to the server
* @throws IOException
*/
protected ResultScanner getQueuesBelongingToServer(String server) throws IOException {
Scan scan = new Scan();
SingleColumnValueFilter filterMyQueues = new SingleColumnValueFilter(CF_QUEUE, COL_QUEUE_OWNER, CompareFilter.CompareOp.EQUAL, Bytes.toBytes(server));
scan.setFilter(filterMyQueues);
scan.addColumn(CF_QUEUE, COL_QUEUE_OWNER);
scan.addColumn(CF_QUEUE, COL_QUEUE_OWNER_HISTORY);
try (Table replicationTable = getOrBlockOnReplicationTable()) {
ResultScanner results = replicationTable.getScanner(scan);
return results;
}
}
use of org.apache.hadoop.hbase.client.ResultScanner in project hbase by apache.
the class TableBasedReplicationQueuesImpl method getResultIfOwner.
/**
* Attempts to run a Get on some queue. Will only return a non-null result if we currently own
* the queue.
*
* @param get The Get that we want to query
* @return The result of the Get if this server is the owner of the queue. Else it returns null.
* @throws IOException
*/
private Result getResultIfOwner(Get get) throws IOException {
Scan scan = new Scan(get);
// Check if the Get currently contains all columns or only specific columns
if (scan.getFamilyMap().size() > 0) {
// Add the OWNER column if the scan is already only over specific columns
scan.addColumn(CF_QUEUE, COL_QUEUE_OWNER);
}
scan.setMaxResultSize(1);
SingleColumnValueFilter checkOwner = new SingleColumnValueFilter(CF_QUEUE, COL_QUEUE_OWNER, CompareFilter.CompareOp.EQUAL, serverNameBytes);
scan.setFilter(checkOwner);
ResultScanner scanner = null;
try (Table replicationTable = getOrBlockOnReplicationTable()) {
scanner = replicationTable.getScanner(scan);
Result result = scanner.next();
return (result == null || result.isEmpty()) ? null : result;
} finally {
if (scanner != null) {
scanner.close();
}
}
}
use of org.apache.hadoop.hbase.client.ResultScanner in project hbase by apache.
the class BackupSystemTable method hasBackupSessions.
/**
* Checks if we have at least one backup session in backup system table This API is used by
* BackupLogCleaner
* @return true, if - at least one session exists in backup system table table
* @throws IOException exception
*/
public boolean hasBackupSessions() throws IOException {
if (LOG.isTraceEnabled()) {
LOG.trace("Has backup sessions from backup system table");
}
boolean result = false;
Scan scan = createScanForBackupHistory();
scan.setCaching(1);
try (Table table = connection.getTable(tableName);
ResultScanner scanner = table.getScanner(scan)) {
if (scanner.next() != null) {
result = true;
}
return result;
}
}
use of org.apache.hadoop.hbase.client.ResultScanner in project hbase by apache.
the class BackupSystemTable method readRegionServerLastLogRollResult.
/**
* Get the Region Servers log information after the last log roll from backup system table.
* @param backupRoot root directory path to backup
* @return RS log info
* @throws IOException exception
*/
public HashMap<String, Long> readRegionServerLastLogRollResult(String backupRoot) throws IOException {
if (LOG.isTraceEnabled()) {
LOG.trace("read region server last roll log result to backup system table");
}
Scan scan = createScanForReadRegionServerLastLogRollResult(backupRoot);
try (Table table = connection.getTable(tableName);
ResultScanner scanner = table.getScanner(scan)) {
Result res = null;
HashMap<String, Long> rsTimestampMap = new HashMap<String, Long>();
while ((res = scanner.next()) != null) {
res.advance();
Cell cell = res.current();
byte[] row = CellUtil.cloneRow(cell);
String server = getServerNameForReadRegionServerLastLogRollResult(row);
byte[] data = CellUtil.cloneValue(cell);
rsTimestampMap.put(server, Bytes.toLong(data));
}
return rsTimestampMap;
}
}
use of org.apache.hadoop.hbase.client.ResultScanner in project hbase by apache.
the class BackupSystemTable method listBackupSets.
/**
* BACKUP SETS
*/
/**
* Get backup set list
* @return backup set list
* @throws IOException
*/
public List<String> listBackupSets() throws IOException {
if (LOG.isTraceEnabled()) {
LOG.trace(" Backup set list");
}
List<String> list = new ArrayList<String>();
Table table = null;
ResultScanner scanner = null;
try {
table = connection.getTable(tableName);
Scan scan = createScanForBackupSetList();
scan.setMaxVersions(1);
scanner = table.getScanner(scan);
Result res = null;
while ((res = scanner.next()) != null) {
res.advance();
list.add(cellKeyToBackupSetName(res.current()));
}
return list;
} finally {
if (scanner != null) {
scanner.close();
}
if (table != null) {
table.close();
}
}
}
Aggregations