Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import java.util.List;
import java.util.Map;
import java.util.concurrent.CountDownLatch;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.regionserver.HRegion;
import org.apache.hadoop.hbase.regionserver.Region;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.phoenix.coprocessor.MetaDataEndpointImpl;
Expand Down Expand Up @@ -72,6 +74,7 @@ public void testBlockedReadDoesNotBlockAnotherRead() throws Exception {
BlockingMetaDataEndpointImpl.setSleepSignal(sleepSignal);
BlockingMetaDataEndpointImpl.setSleepDuration(SLEEP_DURATION);
TestUtil.addCoprocessor(conn, "SYSTEM.CATALOG", BlockingMetaDataEndpointImpl.class);
waitForCoprocessorOnSystemCatalog(BlockingMetaDataEndpointImpl.class);

// start thread-1 and wait for signal before it starts sleeping
Thread t1 = getQueryThread(tableName);
Expand All @@ -94,6 +97,23 @@ public void testBlockedReadDoesNotBlockAnotherRead() throws Exception {
}
}

private static void waitForCoprocessorOnSystemCatalog(Class<?> coprocessorClass) throws Exception {
final TableName sysCatalog = TableName.valueOf("SYSTEM.CATALOG");
utility.waitFor(10000, 100, () -> {
List<HRegion> regions = utility.getHBaseCluster().getRegions(sysCatalog);
if (regions.isEmpty()) {
return false;
}
for (HRegion region : regions) {
if (region.getCoprocessorHost()
.findCoprocessor(coprocessorClass.getName()) == null) {
return false;
}
}
return true;
});
}

private static Thread getQueryThread(String tableName) {
Runnable runnable = () -> {
try (Connection conn1 = DriverManager.getConnection(getUrl())) {
Expand Down