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 @@ -27,9 +27,12 @@
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import org.apache.hadoop.hbase.DoNotRetryIOException;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.regionserver.HRegion;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.phoenix.compile.ExplainPlan;
import org.apache.phoenix.compile.ExplainPlanAttributes;
Expand Down Expand Up @@ -102,6 +105,23 @@ public void getTable(RpcController controller, MetaDataProtos.GetTableRequest re

}

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;
});
}

@Test
public void testUcfWithNoGetTableCalls() throws Throwable {
final String tableName = generateUniqueName();
Expand All @@ -118,7 +138,7 @@ public void testUcfWithNoGetTableCalls() throws Throwable {

stmt.execute("CREATE TABLE " + tableName
+ " (COL1 CHAR(10) NOT NULL, COL2 CHAR(5) NOT NULL, COL3 VARCHAR,"
+ " COL4 VARCHAR CONSTRAINT pk PRIMARY KEY(COL1, COL2))" + " UPDATE_CACHE_FREQUENCY=20000");
+ " COL4 VARCHAR CONSTRAINT pk PRIMARY KEY(COL1, COL2))" + " UPDATE_CACHE_FREQUENCY=NEVER");
stmt.execute("CREATE INDEX " + indexName + " ON " + tableName + " (COL3) INCLUDE (COL4)");
stmt.execute("CREATE VIEW " + view01 + " (VCOL1 CHAR(8), COL5 VARCHAR) AS SELECT * FROM "
+ tableName + " WHERE COL1 = 'col1'");
Expand Down Expand Up @@ -203,6 +223,7 @@ public void testUcfWithDisabledIndex1() throws Throwable {
updateIndexToRebuild(conn, tableName, indexName);
TestUtil.removeCoprocessor(conn, "SYSTEM.CATALOG", TestMetaDataEndpointImpl.class);
TestUtil.addCoprocessor(conn, "SYSTEM.CATALOG", MetaDataEndpointImpl.class);
waitForCoprocessorOnSystemCatalog(MetaDataEndpointImpl.class);
verifyTableAndIndexRows(conn, tableName, indexName, false);
conn.close();
}
Expand Down Expand Up @@ -266,6 +287,7 @@ private static void updateIndexToRebuild(Connection conn, String tableName, Stri
// re-attach original coproc
TestUtil.removeCoprocessor(conn, "SYSTEM.CATALOG", TestMetaDataEndpointImpl.class);
TestUtil.addCoprocessor(conn, "SYSTEM.CATALOG", MetaDataEndpointImpl.class);
waitForCoprocessorOnSystemCatalog(MetaDataEndpointImpl.class);

final Statement stmt = conn.createStatement();
stmt.execute("UPSERT INTO " + tableName + " (col1, col2, col3, col4) values ('c011', "
Expand Down Expand Up @@ -334,6 +356,7 @@ private static Statement createIndexAndUpdateCoproc(Connection conn, String tabl
// attach coproc that does not allow getTable RPC call
TestUtil.removeCoprocessor(conn, "SYSTEM.CATALOG", MetaDataEndpointImpl.class);
TestUtil.addCoprocessor(conn, "SYSTEM.CATALOG", TestMetaDataEndpointImpl.class);
waitForCoprocessorOnSystemCatalog(TestMetaDataEndpointImpl.class);
return stmt;
}

Expand All @@ -356,6 +379,7 @@ public void testUcfWithDisabledIndex2() throws Throwable {
updateIndexToRebuild(conn, tableName, indexName);
TestUtil.removeCoprocessor(conn, "SYSTEM.CATALOG", TestMetaDataEndpointImpl.class);
TestUtil.addCoprocessor(conn, "SYSTEM.CATALOG", MetaDataEndpointImpl.class);
waitForCoprocessorOnSystemCatalog(MetaDataEndpointImpl.class);
verifyTableAndIndexRows(conn, tableName, indexName, false);
conn.close();
}
Expand Down Expand Up @@ -385,6 +409,7 @@ public void testUcfWithDisabledIndex3() throws Throwable {
updateIndexToRebuild(conn, tableName, indexName);
TestUtil.removeCoprocessor(conn, "SYSTEM.CATALOG", TestMetaDataEndpointImpl.class);
TestUtil.addCoprocessor(conn, "SYSTEM.CATALOG", MetaDataEndpointImpl.class);
waitForCoprocessorOnSystemCatalog(MetaDataEndpointImpl.class);
verifyTableAndIndexRows(conn, tableName, indexName, true);
conn.close();
}
Expand Down