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

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


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

commit 1922895dfe5960dc025709b04acfaf974d3959dc
Author: Geoffrey Jacoby <gjac...@salesforce.com>
AuthorDate: Wed Aug 12 13:37:47 2020 -0700

    PHOENIX-6073 - IndexTool IndexDisableLoggingType can't be set to NONE
---
 .../phoenix/end2end/IndexToolForNonTxGlobalIndexIT.java | 10 +++++-----
 .../it/java/org/apache/phoenix/end2end/IndexToolIT.java | 17 +++++++++++++----
 .../org/apache/phoenix/mapreduce/index/IndexTool.java   |  9 ++++-----
 3 files changed, 22 insertions(+), 14 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 a2e5da0..a32bd9c 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
@@ -1116,7 +1116,7 @@ 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(directApi, 
useSnapshot, schemaName, dataTableName, indexTableName, null, 0, 
IndexTool.IndexVerifyType.BEFORE, 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());
@@ -1148,7 +1148,7 @@ public class IndexToolForNonTxGlobalIndexIT extends 
BaseUniqueNamesOwnClusterIT
             Configuration conf = new 
Configuration(getUtility().getConfiguration());
             conf.set(QueryServices.INDEX_REBUILD_PAGE_SIZE_IN_ROWS, 
Long.toString(1));
             IndexTool indexTool =
-                    IndexToolIT.runIndexTool(conf, directApi, useSnapshot, 
schemaName,
+                    IndexToolIT.runIndexTool(directApi, useSnapshot, 
schemaName,
                         dataTableName, indexTableName, null, 0, 
IndexTool.IndexVerifyType.BEFORE,
                         new String[0]);
             assertEquals(3, 
indexTool.getJob().getCounters().findCounter(INPUT_RECORDS).getValue());
@@ -1201,7 +1201,7 @@ public class IndexToolForNonTxGlobalIndexIT extends 
BaseUniqueNamesOwnClusterIT
             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,
+                    IndexToolIT.runIndexTool(directApi, useSnapshot, 
schemaName,
                         dataTableName, indexTableName, null, 0, 
IndexTool.IndexVerifyType.AFTER,
                         "-st", String.valueOf(minTs), "-et",
                         
String.valueOf(EnvironmentEdgeManager.currentTimeMillis()));
@@ -1456,10 +1456,10 @@ public class IndexToolForNonTxGlobalIndexIT extends 
BaseUniqueNamesOwnClusterIT
                                       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 63258b8..c56e01f 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
@@ -683,7 +683,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());
         }
@@ -704,6 +704,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) {
@@ -775,18 +783,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 3477049..aac189e 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
@@ -400,11 +400,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)){
@@ -420,6 +415,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