You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@phoenix.apache.org by GitBox <gi...@apache.org> on 2019/05/16 05:40:49 UTC

[GitHub] [phoenix] twdsilva commented on a change in pull request #499: Phoenix-5272 ALTER INDEX REBUILD ALL

twdsilva commented on a change in pull request #499: Phoenix-5272 ALTER INDEX REBUILD ALL 
URL: https://github.com/apache/phoenix/pull/499#discussion_r284544490
 
 

 ##########
 File path: phoenix-core/src/test/java/org/apache/phoenix/util/TestUtil.java
 ##########
 @@ -934,7 +936,54 @@ 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;
+        RetryCounter retrier = new RetryCounter(maxTries,
+                1, TimeUnit.SECONDS);
+        while (retrier.shouldRetry()) {
+            String schema = SchemaUtil.getSchemaNameFromFullName(fullIndexName);
+            String index = SchemaUtil.getTableNameFromFullName(fullIndexName);
+
+            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;
+                }
+            }
+            retrier.sleepUntilNextRetry();
+        }
+        fail("Ran out of time waiting for index state to become " + expectedIndexState);
+
+        //        do {
 
 Review comment:
   remove commented code

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services