gokceni commented on a change in pull request #499: Phoenix 4703 ALTER INDEX
REBUILD ALL
URL: https://github.com/apache/phoenix/pull/499#discussion_r281734633
##########
File path: phoenix-core/src/test/java/org/apache/phoenix/util/TestUtil.java
##########
@@ -934,7 +934,30 @@ public IndexStateCheck(PIndexState indexState, Long
indexDisableTimestamp, Boole
this.success = success;
}
}
-
+
+ public static void waitForIndexState(Connection conn, String
fullIndexName, PIndexState expectedIndexState) throws InterruptedException,
SQLException {
+ int maxTries = 60, nTries = 0;
+ do {
+ String schema =
SchemaUtil.getSchemaNameFromFullName(fullIndexName);
+ String index = SchemaUtil.getTableNameFromFullName(fullIndexName);
+ Thread.sleep(1000); // sleep 1 sec
+ String query = "SELECT " + PhoenixDatabaseMetaData.INDEX_STATE + "
FROM " +
+ PhoenixDatabaseMetaData.SYSTEM_CATALOG_NAME + " WHERE (" +
PhoenixDatabaseMetaData.TABLE_SCHEM + "," + PhoenixDatabaseMetaData.TABLE_NAME
+ + ") = (" + "'" + schema + "','" + index + "') "
+ + "AND " + PhoenixDatabaseMetaData.COLUMN_FAMILY + " IS
NULL AND " + PhoenixDatabaseMetaData.COLUMN_NAME + " IS NULL";
+ ResultSet rs = conn.createStatement().executeQuery(query);
+ PIndexState actualIndexState = null;
+ if (rs.next()) {
+ actualIndexState =
PIndexState.fromSerializedValue(rs.getString(1));
+ boolean matchesExpected = (actualIndexState ==
expectedIndexState);
+ if (matchesExpected) {
+ return;
+ }
+ }
+ } while (++nTries < maxTries);
Review comment:
I am not sure if exponential backoff is necessary here. It doesn't take a
lot of time to wait till indexes are build in the tests.
----------------------------------------------------------------
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]
With regards,
Apache Git Services