HBASE-17930 Avoid using Canary.sniff in HBaseTestingUtility
This commit is contained in:
parent
a26de9b51e
commit
c8c2e07aa1
|
@ -68,6 +68,7 @@ import org.apache.hadoop.hbase.ServerName;
|
||||||
import org.apache.hadoop.hbase.TableName;
|
import org.apache.hadoop.hbase.TableName;
|
||||||
import org.apache.hadoop.hbase.TableNotEnabledException;
|
import org.apache.hadoop.hbase.TableNotEnabledException;
|
||||||
import org.apache.hadoop.hbase.TableNotFoundException;
|
import org.apache.hadoop.hbase.TableNotFoundException;
|
||||||
|
import org.apache.hadoop.hbase.classification.InterfaceAudience;
|
||||||
import org.apache.hadoop.hbase.client.Admin;
|
import org.apache.hadoop.hbase.client.Admin;
|
||||||
import org.apache.hadoop.hbase.client.Connection;
|
import org.apache.hadoop.hbase.client.Connection;
|
||||||
import org.apache.hadoop.hbase.client.ConnectionFactory;
|
import org.apache.hadoop.hbase.client.ConnectionFactory;
|
||||||
|
@ -77,7 +78,6 @@ import org.apache.hadoop.hbase.client.RegionLocator;
|
||||||
import org.apache.hadoop.hbase.client.ResultScanner;
|
import org.apache.hadoop.hbase.client.ResultScanner;
|
||||||
import org.apache.hadoop.hbase.client.Scan;
|
import org.apache.hadoop.hbase.client.Scan;
|
||||||
import org.apache.hadoop.hbase.client.Table;
|
import org.apache.hadoop.hbase.client.Table;
|
||||||
import org.apache.hadoop.hbase.client.Scan.ReadType;
|
|
||||||
import org.apache.hadoop.hbase.filter.FirstKeyOnlyFilter;
|
import org.apache.hadoop.hbase.filter.FirstKeyOnlyFilter;
|
||||||
import org.apache.hadoop.hbase.tool.Canary.RegionTask.TaskType;
|
import org.apache.hadoop.hbase.tool.Canary.RegionTask.TaskType;
|
||||||
import org.apache.hadoop.hbase.util.Bytes;
|
import org.apache.hadoop.hbase.util.Bytes;
|
||||||
|
@ -108,6 +108,7 @@ import org.apache.zookeeper.data.Stat;
|
||||||
* 3. zookeeper mode - for each zookeeper instance, selects a zNode and
|
* 3. zookeeper mode - for each zookeeper instance, selects a zNode and
|
||||||
* outputs some information about failure or latency.
|
* outputs some information about failure or latency.
|
||||||
*/
|
*/
|
||||||
|
@InterfaceAudience.Private
|
||||||
public final class Canary implements Tool {
|
public final class Canary implements Tool {
|
||||||
// Sink interface used by the canary to outputs information
|
// Sink interface used by the canary to outputs information
|
||||||
public interface Sink {
|
public interface Sink {
|
||||||
|
@ -1109,49 +1110,6 @@ public final class Canary implements Tool {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Canary entry point for specified table.
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
|
||||||
public static void sniff(final Admin admin, TableName tableName, boolean rawScanEnabled)
|
|
||||||
throws Exception {
|
|
||||||
sniff(admin, tableName, TaskType.READ, rawScanEnabled);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Canary entry point for specified table.
|
|
||||||
* Keeping this method backward compatibility
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
|
||||||
public static void sniff(final Admin admin, TableName tableName)
|
|
||||||
throws Exception {
|
|
||||||
sniff(admin, tableName, TaskType.READ, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Canary entry point for specified table with task type(read/write)
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
|
||||||
public static void sniff(final Admin admin, TableName tableName, TaskType taskType,
|
|
||||||
boolean rawScanEnabled) throws Exception {
|
|
||||||
List<Future<Void>> taskFutures =
|
|
||||||
Canary.sniff(admin, new StdOutSink(), tableName.getNameAsString(),
|
|
||||||
new ScheduledThreadPoolExecutor(1), taskType, rawScanEnabled);
|
|
||||||
for (Future<Void> future : taskFutures) {
|
|
||||||
future.get();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Canary entry point for specified table with task type(read/write)
|
|
||||||
* Keeping this method backward compatible
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
|
||||||
public static void sniff(final Admin admin, TableName tableName, TaskType taskType)
|
|
||||||
throws Exception {
|
|
||||||
Canary.sniff(admin, tableName, taskType, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Canary entry point for specified table.
|
* Canary entry point for specified table.
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
|
|
|
@ -17,6 +17,10 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.hadoop.hbase;
|
package org.apache.hadoop.hbase;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
|
@ -82,8 +86,8 @@ import org.apache.hadoop.hbase.io.hfile.HFile;
|
||||||
import org.apache.hadoop.hbase.ipc.RpcServerInterface;
|
import org.apache.hadoop.hbase.ipc.RpcServerInterface;
|
||||||
import org.apache.hadoop.hbase.ipc.ServerNotRunningYetException;
|
import org.apache.hadoop.hbase.ipc.ServerNotRunningYetException;
|
||||||
import org.apache.hadoop.hbase.mapreduce.MapreduceTestingShim;
|
import org.apache.hadoop.hbase.mapreduce.MapreduceTestingShim;
|
||||||
import org.apache.hadoop.hbase.master.HMaster;
|
|
||||||
import org.apache.hadoop.hbase.master.AssignmentManager;
|
import org.apache.hadoop.hbase.master.AssignmentManager;
|
||||||
|
import org.apache.hadoop.hbase.master.HMaster;
|
||||||
import org.apache.hadoop.hbase.master.RegionStates;
|
import org.apache.hadoop.hbase.master.RegionStates;
|
||||||
import org.apache.hadoop.hbase.master.ServerManager;
|
import org.apache.hadoop.hbase.master.ServerManager;
|
||||||
import org.apache.hadoop.hbase.protobuf.ProtobufUtil;
|
import org.apache.hadoop.hbase.protobuf.ProtobufUtil;
|
||||||
|
@ -100,7 +104,6 @@ import org.apache.hadoop.hbase.regionserver.wal.WALActionsListener;
|
||||||
import org.apache.hadoop.hbase.security.HBaseKerberosUtils;
|
import org.apache.hadoop.hbase.security.HBaseKerberosUtils;
|
||||||
import org.apache.hadoop.hbase.security.User;
|
import org.apache.hadoop.hbase.security.User;
|
||||||
import org.apache.hadoop.hbase.security.visibility.VisibilityLabelsCache;
|
import org.apache.hadoop.hbase.security.visibility.VisibilityLabelsCache;
|
||||||
import org.apache.hadoop.hbase.tool.Canary;
|
|
||||||
import org.apache.hadoop.hbase.util.Bytes;
|
import org.apache.hadoop.hbase.util.Bytes;
|
||||||
import org.apache.hadoop.hbase.util.FSTableDescriptors;
|
import org.apache.hadoop.hbase.util.FSTableDescriptors;
|
||||||
import org.apache.hadoop.hbase.util.FSUtils;
|
import org.apache.hadoop.hbase.util.FSUtils;
|
||||||
|
@ -132,10 +135,6 @@ import org.apache.zookeeper.WatchedEvent;
|
||||||
import org.apache.zookeeper.ZooKeeper;
|
import org.apache.zookeeper.ZooKeeper;
|
||||||
import org.apache.zookeeper.ZooKeeper.States;
|
import org.apache.zookeeper.ZooKeeper.States;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
import static org.junit.Assert.fail;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Facility for testing HBase. Replacement for
|
* Facility for testing HBase. Replacement for
|
||||||
* old HBaseTestCase and HBaseClusterTestCase functionality.
|
* old HBaseTestCase and HBaseClusterTestCase functionality.
|
||||||
|
@ -4181,10 +4180,20 @@ public class HBaseTestingUtility extends HBaseCommonTestingUtility {
|
||||||
public boolean evaluate() throws IOException {
|
public boolean evaluate() throws IOException {
|
||||||
boolean tableAvailable = getHBaseAdmin().isTableAvailable(tableName);
|
boolean tableAvailable = getHBaseAdmin().isTableAvailable(tableName);
|
||||||
if (tableAvailable) {
|
if (tableAvailable) {
|
||||||
try {
|
try (Table table = getConnection().getTable(tableName)) {
|
||||||
Canary.sniff(getHBaseAdmin(), tableName);
|
HTableDescriptor htd = table.getTableDescriptor();
|
||||||
} catch (Exception e) {
|
for (HRegionLocation loc : getConnection().getRegionLocator(tableName)
|
||||||
throw new IOException("Canary sniff failed for table " + tableName, e);
|
.getAllRegionLocations()) {
|
||||||
|
Scan scan = new Scan().withStartRow(loc.getRegionInfo().getStartKey())
|
||||||
|
.withStopRow(loc.getRegionInfo().getEndKey()).setOneRowLimit()
|
||||||
|
.setMaxResultsPerColumnFamily(1).setCacheBlocks(false);
|
||||||
|
for (byte[] family : htd.getFamiliesKeys()) {
|
||||||
|
scan.addFamily(family);
|
||||||
|
}
|
||||||
|
try (ResultScanner scanner = table.getScanner(scan)) {
|
||||||
|
scanner.next();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return tableAvailable;
|
return tableAvailable;
|
||||||
|
|
Loading…
Reference in New Issue