priyankporwal commented on a change in pull request #660: PHOENIX-5644: 
IndexUpgradeTool should sleep only once if there is at …
URL: https://github.com/apache/phoenix/pull/660#discussion_r363506217
 
 

 ##########
 File path: 
phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/IndexUpgradeTool.java
 ##########
 @@ -318,53 +323,155 @@ public int executeTool() {
         return -1;
     }
 
-    private int executeTool(Connection conn, ConnectionQueryServices 
queryServices,
+    private int executeTool(Connection conn,
+            ConnectionQueryServices queryServices,
             Configuration conf) {
-        LOGGER.info("Executing " + operation);
+        ArrayList<String> immutableList = new ArrayList<>();
+        ArrayList<String> mutableList = new ArrayList<>();
         for (Map.Entry<String, HashSet<String>> entry 
:tablesAndIndexes.entrySet()) {
             String dataTableFullName = entry.getKey();
-            HashSet<String> indexes = entry.getValue();
-
-            try (Admin admin = queryServices.getAdmin()) {
+            try {
                 PTable dataTable = PhoenixRuntime.getTableNoCache(conn, 
dataTableFullName);
-                LOGGER.info("Executing " + operation + " of " + 
dataTableFullName);
+                if (dataTable.isImmutableRows()) {
+                    //add to list where immutable tables are processed in a 
different function
+                    immutableList.add(dataTableFullName);
+                } else {
+                    mutableList.add(dataTableFullName);
+                }
+            } catch (SQLException e) {
+                LOGGER.severe("Something went wrong while getting the PTable "
+                        + dataTableFullName + " "+e);
+                return -1;
+            }
+        }
+        long startWaitTime = executeToolForImmutableTables(queryServices, 
immutableList);
+        executeToolForMutableTables(conn, queryServices, conf, mutableList);
+        enableImmutableTables(queryServices, immutableList, startWaitTime);
+        rebuildIndexes(conn, conf, immutableList);
+        return 0;
+    }
 
+    private long executeToolForImmutableTables(ConnectionQueryServices 
queryServices,
+            ArrayList<String> immutableList) {
+        LOGGER.info("Started " + operation + " for immutable tables");
+        try (Admin admin = queryServices.getAdmin()) {
 
 Review comment:
   Do you want to put try/catch to be inside the for loop? It seems like 
handleFailure() is called for just the the table that hit an exception, and the 
rest of tables in the list are not handled (upgraded/rolledback). 

----------------------------------------------------------------
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

Reply via email to