infraio commented on a change in pull request #1817:
URL: https://github.com/apache/hbase/pull/1817#discussion_r433667025
##########
File path:
hbase-server/src/main/java/org/apache/hadoop/hbase/tool/CanaryTool.java
##########
@@ -496,18 +497,75 @@ public ZookeeperTask(Connection connection, String host,
String znode, int timeo
@Override
public Void call() {
switch (taskType) {
- case READ:
- return read();
- case WRITE:
- return write();
- default:
- return read();
+ case READ:
+ return read();
+ case WRITE:
+ return write();
+ default:
+ return read();
}
}
+ private Void readColumnFamily(Table table, ColumnFamilyDescriptor column) {
+ byte[] startKey = null;
+ Get get = null;
+ Scan scan = null;
+ ResultScanner rs = null;
+ StopWatch stopWatch = new StopWatch();
+ startKey = region.getStartKey();
+ // Can't do a get on empty start row so do a Scan of first element if
any instead.
+ if (startKey.length > 0) {
+ get = new Get(startKey);
+ get.setCacheBlocks(false);
+ get.setFilter(new FirstKeyOnlyFilter());
+ get.addFamily(column.getName());
+ } else {
+ scan = new Scan();
+ LOG.debug("rawScan {} for {}", rawScanEnabled, region.getTable());
+ scan.setRaw(rawScanEnabled);
+ scan.setCaching(1);
+ scan.setCacheBlocks(false);
+ scan.setFilter(new FirstKeyOnlyFilter());
+ scan.addFamily(column.getName());
+ scan.setMaxResultSize(1L);
+ scan.setOneRowLimit();
+ }
+ LOG.debug("Reading from {} {} {} {}", region.getTable(),
region.getRegionNameAsString(),
+ column.getNameAsString(), Bytes.toStringBinary(startKey));
+ try {
+ stopWatch.start();
+ if (startKey.length > 0) {
+ table.get(get);
+ } else {
+ rs = table.getScanner(scan);
+ rs.next();
+ }
+ stopWatch.stop();
+ this.readWriteLatency.add(stopWatch.getTime());
+ sink.publishReadTiming(serverName, region, column,
stopWatch.getTime());
+ } catch (Exception e) {
+ sink.publishReadFailure(serverName, region, column, e);
+ sink.updateReadFailures(region.getRegionNameAsString(),
+ serverName == null ? "NULL" : serverName.getHostname());
+ } finally {
+ if (rs != null) {
+ rs.close();
+ }
+ }
+ return null;
+ }
+
+ private ColumnFamilyDescriptor
randomPickOneColumnFamily(ColumnFamilyDescriptor[] cfs) {
+ int size = cfs.length;
+ return cfs[ThreadLocalRandom.current().nextInt(size)];
+
+ }
+
public Void read() {
Table table = null;
TableDescriptor tableDesc = null;
+ boolean regionTaskReadAllCF =
Review comment:
Read conf every time? Can this be a global var and only read from conf
once?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]