This is an automated email from the ASF dual-hosted git repository.

gjacoby pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/phoenix.git


The following commit(s) were added to refs/heads/master by this push:
     new 579d492  PHOENIX-6073 - IndexTool IndexDisableLoggingType can't be set 
to NONE
579d492 is described below

commit 579d492398f038c2951c52e324a620ac7eb53b18
Author: Geoffrey Jacoby <[email protected]>
AuthorDate: Wed Aug 12 13:37:47 2020 -0700

    PHOENIX-6073 - IndexTool IndexDisableLoggingType can't be set to NONE
---
 .../phoenix/end2end/IndexToolForNonTxGlobalIndexIT.java | 12 ++++++++----
 .../it/java/org/apache/phoenix/end2end/IndexToolIT.java | 17 +++++++++++++----
 .../org/apache/phoenix/mapreduce/index/IndexTool.java   |  9 ++++-----
 3 files changed, 25 insertions(+), 13 deletions(-)

diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexToolForNonTxGlobalIndexIT.java
 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexToolForNonTxGlobalIndexIT.java
index f89bcb3..e32d310 100644
--- 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexToolForNonTxGlobalIndexIT.java
+++ 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexToolForNonTxGlobalIndexIT.java
@@ -270,7 +270,9 @@ public class IndexToolForNonTxGlobalIndexIT extends 
BaseUniqueNamesOwnClusterIT
             // Run the index MR job and verify that the index table is built 
correctly
             Configuration conf = new 
Configuration(getUtility().getConfiguration());
             conf.set(QueryServices.INDEX_REBUILD_PAGE_SIZE_IN_ROWS, 
Long.toString(2));
-            IndexTool indexTool = IndexToolIT.runIndexTool(conf, directApi, 
useSnapshot, schemaName, dataTableName, indexTableName, null, 0, 
IndexTool.IndexVerifyType.BEFORE, new String[0]);
+            IndexTool indexTool = IndexToolIT.runIndexTool(conf, directApi, 
useSnapshot,
+                schemaName, dataTableName, indexTableName, null, 0,
+                IndexTool.IndexVerifyType.BEFORE, 
IndexTool.IndexDisableLoggingType.NONE, new String[0]);
             assertEquals(NROWS, 
indexTool.getJob().getCounters().findCounter(INPUT_RECORDS).getValue());
             assertEquals(NROWS, 
indexTool.getJob().getCounters().findCounter(SCANNED_DATA_ROW_COUNT).getValue());
             assertEquals(NROWS, 
indexTool.getJob().getCounters().findCounter(REBUILT_INDEX_ROW_COUNT).getValue());
@@ -302,7 +304,7 @@ public class IndexToolForNonTxGlobalIndexIT extends 
BaseUniqueNamesOwnClusterIT
             IndexTool indexTool =
                     IndexToolIT.runIndexTool(conf, directApi, useSnapshot, 
schemaName,
                         dataTableName, indexTableName, null, 0, 
IndexTool.IndexVerifyType.BEFORE,
-                        new String[0]);
+                        IndexTool.IndexDisableLoggingType.NONE, new String[0]);
             assertEquals(3, 
indexTool.getJob().getCounters().findCounter(INPUT_RECORDS).getValue());
             assertEquals(3,
                 
indexTool.getJob().getCounters().findCounter(SCANNED_DATA_ROW_COUNT).getValue());
@@ -350,6 +352,7 @@ public class IndexToolForNonTxGlobalIndexIT extends 
BaseUniqueNamesOwnClusterIT
             IndexTool indexTool =
                     IndexToolIT.runIndexTool(conf, directApi, useSnapshot, 
schemaName,
                         dataTableName, indexTableName, null, 0, 
IndexTool.IndexVerifyType.AFTER,
+                        IndexTool.IndexDisableLoggingType.NONE,
                         "-st", String.valueOf(minTs), "-et",
                         
String.valueOf(EnvironmentEdgeManager.currentTimeMillis()));
             assertEquals(3, 
indexTool.getJob().getCounters().findCounter(INPUT_RECORDS).getValue());
@@ -1281,10 +1284,11 @@ public class IndexToolForNonTxGlobalIndexIT extends 
BaseUniqueNamesOwnClusterIT
                                       String schemaName, String dataTableName,
                                       String indexTableName, String 
indexTableFullName,
                                       int expectedStatus) throws Exception {
-        IndexTool tool = IndexToolIT.runIndexTool(true, false, schemaName, 
dataTableName,
+
+        IndexTool tool = 
IndexToolIT.runIndexTool(getUtility().getConfiguration(), true, false, 
schemaName, dataTableName,
             indexTableName,
             null,
-            expectedStatus, verifyType, "-dl", disableLoggingType.toString());
+            expectedStatus, verifyType, disableLoggingType,new String[0]);
         assertNotNull(tool);
         byte[] indexTableFullNameBytes = Bytes.toBytes(indexTableFullName);
 
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexToolIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexToolIT.java
index eef57e4..df21529 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexToolIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexToolIT.java
@@ -680,7 +680,7 @@ public class IndexToolIT extends 
BaseUniqueNamesOwnClusterIT {
             args.add(String.valueOf(endTime));
         }
 
-        if (disableLoggingType != IndexTool.IndexDisableLoggingType.NONE) {
+        if (verifyType != IndexTool.IndexVerifyType.NONE && disableLoggingType 
!= null) {
             args.add("-dl");
             args.add(disableLoggingType.getValue());
         }
@@ -701,6 +701,14 @@ public class IndexToolIT extends 
BaseUniqueNamesOwnClusterIT {
         return args.toArray(new String[0]);
     }
 
+    public static String[] getArgValues(boolean directApi, boolean 
useSnapshot, String schemaName,
+                                        String dataTable, String indexTable, 
String tenantId, IndexTool.IndexVerifyType verifyType,
+                                        IndexTool.IndexDisableLoggingType 
disableLoggingType) {
+        List<String> args = getArgList(directApi, useSnapshot, schemaName, 
dataTable, indexTable,
+                tenantId, verifyType, null, null, disableLoggingType, null);
+        return args.toArray(new String[0]);
+    }
+
     public static String [] getArgValues(boolean directApi, boolean 
useSnapshot, String schemaName,
             String dataTable, String indexTable, String tenantId,
             IndexTool.IndexVerifyType verifyType, Long startTime, Long 
endTime) {
@@ -772,18 +780,19 @@ public class IndexToolIT extends 
BaseUniqueNamesOwnClusterIT {
                                          String... additionalArgs) throws 
Exception {
         Configuration conf = new 
Configuration(getUtility().getConfiguration());
         return runIndexTool(conf, directApi, useSnapshot, schemaName, 
dataTableName, indexTableName,
-            tenantId, expectedStatus, verifyType, additionalArgs);
+            tenantId, expectedStatus, verifyType, 
IndexTool.IndexDisableLoggingType.NONE, additionalArgs);
     }
 
+
     public static IndexTool runIndexTool(Configuration conf, boolean 
directApi, boolean useSnapshot, String schemaName,
             String dataTableName, String indexTableName, String tenantId,
-            int expectedStatus, IndexTool.IndexVerifyType verifyType,
+            int expectedStatus, IndexTool.IndexVerifyType verifyType, 
IndexTool.IndexDisableLoggingType disableLoggingType,
             String... additionalArgs) throws Exception {
         IndexTool indexingTool = new IndexTool();
         conf.set(QueryServices.TRANSACTIONS_ENABLED, Boolean.TRUE.toString());
         indexingTool.setConf(conf);
         final String[] cmdArgs = getArgValues(directApi, useSnapshot, 
schemaName, dataTableName,
-                indexTableName, tenantId, verifyType);
+                indexTableName, tenantId, verifyType, disableLoggingType);
         List<String> cmdArgList = new ArrayList<>(Arrays.asList(cmdArgs));
         cmdArgList.addAll(Arrays.asList(additionalArgs));
         int status = indexingTool.run(cmdArgList.toArray(new 
String[cmdArgList.size()]));
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/IndexTool.java 
b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/IndexTool.java
index 0e3e5d8..ee7b17e 100644
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/IndexTool.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/IndexTool.java
@@ -399,11 +399,6 @@ public class IndexTool extends Configured implements Tool {
         String loggingDisableValue = 
cmdLine.getOptionValue(DISABLE_LOGGING_OPTION.getOpt());
         String verifyValue = cmdLine.getOptionValue(VERIFY_OPTION.getOpt());
         IndexDisableLoggingType loggingDisableType = 
IndexDisableLoggingType.fromValue(loggingDisableValue);
-        if (loggingDisableType != IndexDisableLoggingType.BEFORE &&
-            loggingDisableType != IndexDisableLoggingType.AFTER &&
-        loggingDisableType != IndexDisableLoggingType.BOTH) {
-            return true;
-        }
         IndexVerifyType verifyType = IndexVerifyType.fromValue(verifyValue);
         //error if we're trying to disable logging when we're not doing any 
verification
         if (verifyType.equals(IndexVerifyType.NONE)){
@@ -419,6 +414,10 @@ public class IndexTool extends Configured implements Tool {
             && loggingDisableType.equals(IndexDisableLoggingType.BEFORE)) {
             return true;
         }
+        if (loggingDisableType.equals(IndexDisableLoggingType.BOTH) &&
+            !verifyType.equals(IndexVerifyType.BOTH)){
+            return true;
+        }
         return false;
     }
 

Reply via email to