swaroopak commented on a change in pull request #499: Phoenix-5272 ALTER INDEX
REBUILD ALL
URL: https://github.com/apache/phoenix/pull/499#discussion_r281736622
##########
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 see there are 60 maxRetries. This might end up using resources
unnecessarily. It's better to utilize an existing retry framework rather than
reinventing the wheel. RetryCounter gives an option to specify the policy of
the retry mechanism. What do you suggest @gjacoby126?
----------------------------------------------------------------
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