phoenix-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] dbwong commented on a change in pull request #430: PHOENIX-5091 Add new features to UpdateStatisticsTool
Date Fri, 25 Jan 2019 21:54:45 GMT
dbwong commented on a change in pull request #430: PHOENIX-5091 Add new features to UpdateStatisticsTool
URL: https://github.com/apache/phoenix/pull/430#discussion_r251116538
 
 

 ##########
 File path: phoenix-core/src/it/java/org/apache/phoenix/schema/stats/BaseStatsCollectorIT.java
 ##########
 @@ -207,20 +206,42 @@ private void collectStatistics(Connection conn, String fullTableName,
     }
 
     private void collectStatsOnSnapshot(Connection conn, String fullTableName,
-                                        String guidePostWidth, String localPhysicalTableName)
throws Exception {
-        UpdateStatisticsTool tool = new UpdateStatisticsTool();
-        Configuration conf = utility.getConfiguration();
-        HBaseAdmin admin = conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin();
-        String snapshotName = "UpdateStatisticsTool_" + generateUniqueName();
-        admin.snapshot(snapshotName, localPhysicalTableName);
-        LOG.info("Successfully created snapshot " + snapshotName + " for " + localPhysicalTableName);
-        Path randomDir = getUtility().getRandomDir();
+                                        String guidePostWidth) throws Exception {
         if (guidePostWidth != null) {
             conn.createStatement().execute("ALTER TABLE " + fullTableName + " SET GUIDE_POSTS_WIDTH
= " + guidePostWidth);
         }
-        Job job = tool.configureJob(conf, fullTableName, snapshotName, randomDir);
-        assertEquals(job.getConfiguration().get(MAPREDUCE_JOB_TYPE), UPDATE_STATS.name());
-        tool.runJob(job, true);
+        runUpdateStatisticsTool(fullTableName);
+    }
+
+    // Run UpdateStatisticsTool in foreground with create and delete snapshot option
+    private void runUpdateStatisticsTool(String fullTableName) {
+        UpdateStatisticsTool tool = new UpdateStatisticsTool();
+        tool.setConf(utility.getConfiguration());
+        String randomDir = getUtility().getRandomDir().toString();
+        final String[] cmdArgs = getArgValues(fullTableName, randomDir);
+        try {
+            int status = tool.run(cmdArgs);
+            assertEquals(0, status);
+            HBaseAdmin hBaseAdmin = utility.getHBaseAdmin();
+            assertEquals(0, hBaseAdmin.listSnapshots(tool.getSnapshotName()).size());
+        } catch (Exception e) {
+            fail("Exception when running UpdateStatisticsTool for " + tableName + " Exception:
" + e);
+        } finally {
+            Job job = tool.getJob();
+            assertEquals(job.getConfiguration().get(MAPREDUCE_JOB_TYPE), UPDATE_STATS.name());
 
 Review comment:
   nit: Please add error message to this or alternatively throw more descriptive exception.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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

Mime
View raw message