carbondata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gvram...@apache.org
Subject carbondata git commit: [CARBONDATA-1283] Carbon should continue with default value for wrong value in configured property
Date Wed, 12 Jul 2017 13:59:32 GMT
Repository: carbondata
Updated Branches:
  refs/heads/master cbe141976 -> 1a35cfb90


[CARBONDATA-1283] Carbon should continue with default value for wrong value in configured
property

This closes #1155


Project: http://git-wip-us.apache.org/repos/asf/carbondata/repo
Commit: http://git-wip-us.apache.org/repos/asf/carbondata/commit/1a35cfb9
Tree: http://git-wip-us.apache.org/repos/asf/carbondata/tree/1a35cfb9
Diff: http://git-wip-us.apache.org/repos/asf/carbondata/diff/1a35cfb9

Branch: refs/heads/master
Commit: 1a35cfb90d0f4a4da05ec80f7a5c192f6832b36d
Parents: cbe1419
Author: mohammadshahidkhan <mohdshahidkhan1987@gmail.com>
Authored: Mon Jul 10 17:47:16 2017 +0530
Committer: Venkata Ramana G <ramana.gollamudi@huawei.com>
Committed: Wed Jul 12 19:28:44 2017 +0530

----------------------------------------------------------------------
 .../core/constants/CarbonCommonConstants.java   |  14 ++
 .../core/datastore/impl/FileFactory.java        |   7 +-
 .../carbondata/core/locks/HdfsFileLock.java     |   5 +-
 .../carbondata/core/util/CarbonProperties.java  | 130 ++++++++++++++-
 .../apache/carbondata/core/util/CarbonUtil.java |  13 +-
 .../core/CarbonPropertiesValidationTest.java    | 164 +++++++++++++++++++
 6 files changed, 314 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/carbondata/blob/1a35cfb9/core/src/main/java/org/apache/carbondata/core/constants/CarbonCommonConstants.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/constants/CarbonCommonConstants.java
b/core/src/main/java/org/apache/carbondata/core/constants/CarbonCommonConstants.java
index 8110abb..ccb6344 100644
--- a/core/src/main/java/org/apache/carbondata/core/constants/CarbonCommonConstants.java
+++ b/core/src/main/java/org/apache/carbondata/core/constants/CarbonCommonConstants.java
@@ -143,6 +143,11 @@ public final class CarbonCommonConstants {
    * VIEWFSURL_PREFIX
    */
   public static final String VIEWFSURL_PREFIX = "viewfs://";
+
+  /**
+   * ALLUXIO_PREFIX
+   */
+  public static final String ALLUXIOURL_PREFIX = "alluxio://";
   /**
    * FS_DEFAULT_FS
    */
@@ -329,6 +334,15 @@ public final class CarbonCommonConstants {
    */
   public static final String CSV_READ_BUFFER_SIZE_DEFAULT = "50000";
   /**
+   * min value for csv read buffer size
+   */
+  public static final int CSV_READ_BUFFER_SIZE_MIN = 10240; //10 kb
+  /**
+   * max value for csv read buffer size
+   */
+  public static final int CSV_READ_BUFFER_SIZE_MAX = 10485760; // 10 mb
+
+  /**
    * CSV_READ_COPIES
    */
   public static final String DEFAULT_NUMBER_CORES = "2";

http://git-wip-us.apache.org/repos/asf/carbondata/blob/1a35cfb9/core/src/main/java/org/apache/carbondata/core/datastore/impl/FileFactory.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/datastore/impl/FileFactory.java
b/core/src/main/java/org/apache/carbondata/core/datastore/impl/FileFactory.java
index 2a35ab3..2794470 100644
--- a/core/src/main/java/org/apache/carbondata/core/datastore/impl/FileFactory.java
+++ b/core/src/main/java/org/apache/carbondata/core/datastore/impl/FileFactory.java
@@ -28,6 +28,7 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.util.zip.GZIPInputStream;
 
+import org.apache.carbondata.core.constants.CarbonCommonConstants;
 import org.apache.carbondata.core.datastore.FileHolder;
 import org.apache.carbondata.core.datastore.filesystem.*;
 import org.apache.carbondata.core.util.CarbonUtil;
@@ -74,13 +75,13 @@ public final class FileFactory {
   }
 
   public static FileType getFileType(String path) {
-    if (path.startsWith(CarbonUtil.HDFS_PREFIX)) {
+    if (path.startsWith(CarbonCommonConstants.HDFSURL_PREFIX)) {
       return FileType.HDFS;
     }
-    else if (path.startsWith(CarbonUtil.ALLUXIO_PREFIX)) {
+    else if (path.startsWith(CarbonCommonConstants.ALLUXIOURL_PREFIX)) {
       return FileType.ALLUXIO;
     }
-    else if (path.startsWith(CarbonUtil.VIEWFS_PREFIX)) {
+    else if (path.startsWith(CarbonCommonConstants.VIEWFSURL_PREFIX)) {
       return FileType.VIEWFS;
     }
     return FileType.LOCAL;

http://git-wip-us.apache.org/repos/asf/carbondata/blob/1a35cfb9/core/src/main/java/org/apache/carbondata/core/locks/HdfsFileLock.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/locks/HdfsFileLock.java b/core/src/main/java/org/apache/carbondata/core/locks/HdfsFileLock.java
index 94e7307..326f8ae 100644
--- a/core/src/main/java/org/apache/carbondata/core/locks/HdfsFileLock.java
+++ b/core/src/main/java/org/apache/carbondata/core/locks/HdfsFileLock.java
@@ -54,8 +54,9 @@ public class HdfsFileLock extends AbstractCarbonLock {
     // If can not get the STORE_LOCATION, then use hadoop.tmp.dir .
     tmpPath = CarbonProperties.getInstance().getProperty(CarbonCommonConstants.STORE_LOCATION,
                System.getProperty(CarbonCommonConstants.HDFS_TEMP_LOCATION));
-    if (!tmpPath.startsWith(CarbonCommonConstants.HDFSURL_PREFIX)
-          && !tmpPath.startsWith(CarbonCommonConstants.VIEWFSURL_PREFIX)) {
+    if (!tmpPath.startsWith(CarbonCommonConstants.HDFSURL_PREFIX) && !tmpPath
+        .startsWith(CarbonCommonConstants.VIEWFSURL_PREFIX) && !tmpPath
+        .startsWith(CarbonCommonConstants.ALLUXIOURL_PREFIX)) {
       tmpPath = hdfsPath + tmpPath;
     }
   }

http://git-wip-us.apache.org/repos/asf/carbondata/blob/1a35cfb9/core/src/main/java/org/apache/carbondata/core/util/CarbonProperties.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/util/CarbonProperties.java b/core/src/main/java/org/apache/carbondata/core/util/CarbonProperties.java
index c1e70ff..c9dd1ec 100644
--- a/core/src/main/java/org/apache/carbondata/core/util/CarbonProperties.java
+++ b/core/src/main/java/org/apache/carbondata/core/util/CarbonProperties.java
@@ -33,6 +33,8 @@ import org.apache.carbondata.core.constants.CarbonLoadOptionConstants;
 import org.apache.carbondata.core.constants.CarbonV3DataFormatConstants;
 import org.apache.carbondata.core.metadata.ColumnarFormatVersion;
 
+import org.apache.hadoop.conf.Configuration;
+
 public final class CarbonProperties {
   /**
    * Attribute for Carbon LOGGER.
@@ -98,6 +100,124 @@ public final class CarbonProperties {
     validateBlockletGroupSizeInMB();
     validateNumberOfColumnPerIORead();
     validateNumberOfRowsPerBlockletColumnPage();
+    validateEnableUnsafeSort();
+    validateCustomBlockDistribution();
+    validateEnableVectorReader();
+    validateLockType();
+    validateCarbonCSVReadBufferSizeByte();
+  }
+
+  private void validateCarbonCSVReadBufferSizeByte() {
+    String csvReadBufferSizeStr =
+        carbonProperties.getProperty(CarbonCommonConstants.CSV_READ_BUFFER_SIZE);
+    if (null != csvReadBufferSizeStr) {
+      try {
+        int bufferSize = Integer.parseInt(csvReadBufferSizeStr);
+        if (bufferSize < CarbonCommonConstants.CSV_READ_BUFFER_SIZE_MIN
+            || bufferSize > CarbonCommonConstants.CSV_READ_BUFFER_SIZE_MAX) {
+          LOGGER.warn("The value \"" + csvReadBufferSizeStr + "\" configured for key "
+              + CarbonCommonConstants.CSV_READ_BUFFER_SIZE
+              + "\" is not in range. Valid range is (byte) \""
+              + CarbonCommonConstants.CSV_READ_BUFFER_SIZE_MIN + " to \""
+              + CarbonCommonConstants.CSV_READ_BUFFER_SIZE_MAX + ". Using the default value
\""
+              + CarbonCommonConstants.CSV_READ_BUFFER_SIZE_DEFAULT);
+          carbonProperties.setProperty(CarbonCommonConstants.CSV_READ_BUFFER_SIZE,
+              CarbonCommonConstants.CSV_READ_BUFFER_SIZE_DEFAULT);
+        }
+      } catch (NumberFormatException nfe) {
+        LOGGER.warn("The value \"" + csvReadBufferSizeStr + "\" configured for key "
+            + CarbonCommonConstants.CSV_READ_BUFFER_SIZE
+            + "\" is invalid. Using the default value \""
+            + CarbonCommonConstants.CSV_READ_BUFFER_SIZE_DEFAULT);
+        carbonProperties.setProperty(CarbonCommonConstants.CSV_READ_BUFFER_SIZE,
+            CarbonCommonConstants.CSV_READ_BUFFER_SIZE_DEFAULT);
+      }
+    }
+  }
+
+  private void validateLockType() {
+    String lockTypeConfigured = carbonProperties.getProperty(CarbonCommonConstants.LOCK_TYPE);
+    if (null != lockTypeConfigured) {
+      switch (lockTypeConfigured.toUpperCase()) {
+        // if user is setting the lock type as CARBON_LOCK_TYPE_ZOOKEEPER then no need to
validate
+        // else validate based on the file system type for LOCAL file system lock will be
+        // CARBON_LOCK_TYPE_LOCAL and for the distributed one CARBON_LOCK_TYPE_HDFS
+        case CarbonCommonConstants.CARBON_LOCK_TYPE_ZOOKEEPER:
+          break;
+        case CarbonCommonConstants.CARBON_LOCK_TYPE_LOCAL:
+        case CarbonCommonConstants.CARBON_LOCK_TYPE_HDFS:
+        default:
+          validateAndConfigureLockType(lockTypeConfigured);
+      }
+    } else {
+      validateAndConfigureLockType(lockTypeConfigured);
+    }
+  }
+
+  /**
+   * the method decide and set the lock type based on the configured system type
+   *
+   * @param lockTypeConfigured
+   */
+  private void validateAndConfigureLockType(String lockTypeConfigured) {
+    Configuration configuration = new Configuration(true);
+    String defaultFs = configuration.get("fs.defaultFS");
+    if (null != defaultFs && (defaultFs.startsWith(CarbonCommonConstants.HDFSURL_PREFIX)
+        || defaultFs.startsWith(CarbonCommonConstants.VIEWFSURL_PREFIX) || defaultFs
+        .startsWith(CarbonCommonConstants.ALLUXIOURL_PREFIX))
+        && !CarbonCommonConstants.CARBON_LOCK_TYPE_HDFS.equalsIgnoreCase(lockTypeConfigured))
{
+      LOGGER.warn("The value \"" + lockTypeConfigured + "\" configured for key "
+          + CarbonCommonConstants.LOCK_TYPE + "\" is invalid. Using the default value \""
+          + CarbonCommonConstants.CARBON_LOCK_TYPE_HDFS);
+      carbonProperties.setProperty(CarbonCommonConstants.LOCK_TYPE,
+          CarbonCommonConstants.CARBON_LOCK_TYPE_HDFS);
+    } else if (null != defaultFs && defaultFs.startsWith(CarbonCommonConstants.LOCAL_FILE_PREFIX)
+        && !CarbonCommonConstants.CARBON_LOCK_TYPE_LOCAL.equalsIgnoreCase(lockTypeConfigured))
{
+      carbonProperties.setProperty(CarbonCommonConstants.LOCK_TYPE,
+          CarbonCommonConstants.CARBON_LOCK_TYPE_LOCAL);
+      LOGGER.warn("The value \"" + lockTypeConfigured + "\" configured for key "
+          + CarbonCommonConstants.LOCK_TYPE
+          + "\" is invalid. Using the default value \""
+          + CarbonCommonConstants.CARBON_LOCK_TYPE_LOCAL);
+    }
+  }
+
+  private void validateEnableVectorReader() {
+    String vectorReaderStr =
+        carbonProperties.getProperty(CarbonCommonConstants.ENABLE_VECTOR_READER);
+    boolean isValidBooleanValue = CarbonUtil.validateBoolean(vectorReaderStr);
+    if (!isValidBooleanValue) {
+      LOGGER.warn("The enable vector reader value \"" + vectorReaderStr
+          + "\" is invalid. Using the default value \""
+          + CarbonCommonConstants.ENABLE_VECTOR_READER_DEFAULT);
+      carbonProperties.setProperty(CarbonCommonConstants.ENABLE_VECTOR_READER,
+          CarbonCommonConstants.ENABLE_VECTOR_READER_DEFAULT);
+    }
+  }
+
+  private void validateCustomBlockDistribution() {
+    String customBlockDistributionStr =
+        carbonProperties.getProperty(CarbonCommonConstants.CARBON_CUSTOM_BLOCK_DISTRIBUTION);
+    boolean isValidBooleanValue = CarbonUtil.validateBoolean(customBlockDistributionStr);
+    if (!isValidBooleanValue) {
+      LOGGER.warn("The custom block distribution value \"" + customBlockDistributionStr
+          + "\" is invalid. Using the default value \""
+          + CarbonCommonConstants.CARBON_CUSTOM_BLOCK_DISTRIBUTION_DEFAULT);
+      carbonProperties.setProperty(CarbonCommonConstants.CARBON_CUSTOM_BLOCK_DISTRIBUTION,
+          CarbonCommonConstants.CARBON_CUSTOM_BLOCK_DISTRIBUTION_DEFAULT);
+    }
+  }
+
+  private void validateEnableUnsafeSort() {
+    String unSafeSortStr = carbonProperties.getProperty(CarbonCommonConstants.ENABLE_UNSAFE_SORT);
+    boolean isValidBooleanValue = CarbonUtil.validateBoolean(unSafeSortStr);
+    if (!isValidBooleanValue) {
+      LOGGER.warn("The enable unsafe sort value \"" + unSafeSortStr
+          + "\" is invalid. Using the default value \""
+          + CarbonCommonConstants.ENABLE_UNSAFE_SORT_DEFAULT);
+      carbonProperties.setProperty(CarbonCommonConstants.ENABLE_UNSAFE_SORT,
+          CarbonCommonConstants.ENABLE_UNSAFE_SORT_DEFAULT);
+    }
   }
 
   private void initPropertySet() throws IllegalAccessException {
@@ -330,12 +450,10 @@ public final class CarbonProperties {
   }
 
   private void validateHighCardinalityIdentify() {
-    String highcardIdentifyStr = carbonProperties
-        .getProperty(CarbonCommonConstants.HIGH_CARDINALITY_IDENTIFY_ENABLE,
-            CarbonCommonConstants.HIGH_CARDINALITY_IDENTIFY_ENABLE_DEFAULT);
-    try {
-      Boolean.parseBoolean(highcardIdentifyStr);
-    } catch (NumberFormatException e) {
+    String highcardIdentifyStr =
+        carbonProperties.getProperty(CarbonCommonConstants.HIGH_CARDINALITY_IDENTIFY_ENABLE);
+    boolean validateBoolean = CarbonUtil.validateBoolean(highcardIdentifyStr);
+    if (!validateBoolean) {
       LOGGER.info("The high cardinality identify value \"" + highcardIdentifyStr
           + "\" is invalid. Using the default value \""
           + CarbonCommonConstants.HIGH_CARDINALITY_IDENTIFY_ENABLE_DEFAULT);

http://git-wip-us.apache.org/repos/asf/carbondata/blob/1a35cfb9/core/src/main/java/org/apache/carbondata/core/util/CarbonUtil.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/util/CarbonUtil.java b/core/src/main/java/org/apache/carbondata/core/util/CarbonUtil.java
index 06b2a61..1b08263 100644
--- a/core/src/main/java/org/apache/carbondata/core/util/CarbonUtil.java
+++ b/core/src/main/java/org/apache/carbondata/core/util/CarbonUtil.java
@@ -84,11 +84,6 @@ import org.apache.thrift.transport.TIOStreamTransport;
 
 public final class CarbonUtil {
 
-  public static final String HDFS_PREFIX = "hdfs://";
-  public static final String VIEWFS_PREFIX = "viewfs://";
-  public static final String ALLUXIO_PREFIX = "alluxio://";
-  private static final String FS_DEFAULT_FS = "fs.defaultFS";
-
   /**
    * Attribute for Carbon LOGGER
    */
@@ -697,7 +692,7 @@ public final class CarbonUtil {
    */
   public static String checkAndAppendHDFSUrl(String filePath) {
     String currentPath = filePath;
-    String defaultFsUrl = conf.get(FS_DEFAULT_FS);
+    String defaultFsUrl = conf.get(CarbonCommonConstants.FS_DEFAULT_FS);
     String baseDFSUrl = CarbonProperties.getInstance()
         .getProperty(CarbonCommonConstants.CARBON_DDL_BASE_HDFS_URL, "");
     if (checkIfPrefixExists(filePath)) {
@@ -721,8 +716,10 @@ public final class CarbonUtil {
 
   private static boolean checkIfPrefixExists(String path) {
     final String lowerPath = path.toLowerCase();
-    return lowerPath.startsWith(HDFS_PREFIX) || lowerPath.startsWith(VIEWFS_PREFIX) || lowerPath
-        .startsWith("file://") || lowerPath.startsWith(ALLUXIO_PREFIX);
+    return lowerPath.startsWith(CarbonCommonConstants.HDFSURL_PREFIX) || lowerPath
+        .startsWith(CarbonCommonConstants.VIEWFSURL_PREFIX) || lowerPath
+        .startsWith(CarbonCommonConstants.LOCAL_FILE_PREFIX) || lowerPath
+        .startsWith(CarbonCommonConstants.ALLUXIOURL_PREFIX);
   }
 
   public static String getCarbonStorePath() {

http://git-wip-us.apache.org/repos/asf/carbondata/blob/1a35cfb9/core/src/test/java/org/apache/carbondata/core/CarbonPropertiesValidationTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/carbondata/core/CarbonPropertiesValidationTest.java
b/core/src/test/java/org/apache/carbondata/core/CarbonPropertiesValidationTest.java
new file mode 100644
index 0000000..e0262dc
--- /dev/null
+++ b/core/src/test/java/org/apache/carbondata/core/CarbonPropertiesValidationTest.java
@@ -0,0 +1,164 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.carbondata.core;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import org.apache.carbondata.core.constants.CarbonCommonConstants;
+import org.apache.carbondata.core.util.CarbonProperties;
+import org.apache.carbondata.core.util.CarbonProperty;
+
+import junit.framework.TestCase;
+import org.junit.Test;
+
+/**
+ * Method to test the carbon common constant configurations.
+ */
+public class CarbonPropertiesValidationTest extends TestCase {
+
+  CarbonProperties carbonProperties;
+
+  @Override public void setUp() throws Exception {
+    carbonProperties = CarbonProperties.getInstance();
+  }
+
+  @Test public void testvalidateLockType()
+      throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
+    Method validateMethodType = carbonProperties.getClass().getDeclaredMethod("validateLockType");
+    validateMethodType.setAccessible(true);
+    carbonProperties.addProperty(CarbonCommonConstants.LOCK_TYPE, "xyz");
+    String valueBeforeValidation = carbonProperties.getProperty(CarbonCommonConstants.LOCK_TYPE);
+    validateMethodType.invoke(carbonProperties);
+    String valueAfterValidation = carbonProperties.getProperty(CarbonCommonConstants.LOCK_TYPE);
+    assertTrue(!valueBeforeValidation.equals(valueAfterValidation));
+    assertTrue(CarbonCommonConstants.CARBON_LOCK_TYPE_LOCAL.equalsIgnoreCase(valueAfterValidation));
+  }
+
+  @Test public void testValidateEnableUnsafeSort()
+      throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
+    Method validateMethodType =
+        carbonProperties.getClass().getDeclaredMethod("validateEnableUnsafeSort");
+    validateMethodType.setAccessible(true);
+    carbonProperties.addProperty(CarbonCommonConstants.ENABLE_UNSAFE_SORT, "xyz");
+    String valueBeforeValidation =
+        carbonProperties.getProperty(CarbonCommonConstants.ENABLE_UNSAFE_SORT);
+    validateMethodType.invoke(carbonProperties);
+    String valueAfterValidation =
+        carbonProperties.getProperty(CarbonCommonConstants.ENABLE_UNSAFE_SORT);
+    assertTrue(!valueBeforeValidation.equals(valueAfterValidation));
+    assertTrue(
+        CarbonCommonConstants.ENABLE_UNSAFE_SORT_DEFAULT.equalsIgnoreCase(valueAfterValidation));
+  }
+
+  @Test public void testValidateCustomBlockDistribution()
+      throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
+    Method validateMethodType =
+        carbonProperties.getClass().getDeclaredMethod("validateCustomBlockDistribution");
+    validateMethodType.setAccessible(true);
+    carbonProperties.addProperty(CarbonCommonConstants.CARBON_CUSTOM_BLOCK_DISTRIBUTION,
"xyz");
+    String valueBeforeValidation =
+        carbonProperties.getProperty(CarbonCommonConstants.CARBON_CUSTOM_BLOCK_DISTRIBUTION);
+    validateMethodType.invoke(carbonProperties);
+    String valueAfterValidation =
+        carbonProperties.getProperty(CarbonCommonConstants.CARBON_CUSTOM_BLOCK_DISTRIBUTION);
+    assertTrue(!valueBeforeValidation.equals(valueAfterValidation));
+    assertTrue(CarbonCommonConstants.CARBON_CUSTOM_BLOCK_DISTRIBUTION_DEFAULT
+        .equalsIgnoreCase(valueAfterValidation));
+  }
+
+  @Test public void testValidateEnableVectorReader()
+      throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
+    Method validateMethodType =
+        carbonProperties.getClass().getDeclaredMethod("validateEnableVectorReader");
+    validateMethodType.setAccessible(true);
+    carbonProperties.addProperty(CarbonCommonConstants.ENABLE_VECTOR_READER, "xyz");
+    String valueBeforeValidation =
+        carbonProperties.getProperty(CarbonCommonConstants.ENABLE_VECTOR_READER);
+    validateMethodType.invoke(carbonProperties);
+    String valueAfterValidation =
+        carbonProperties.getProperty(CarbonCommonConstants.ENABLE_VECTOR_READER);
+    assertTrue(!valueBeforeValidation.equals(valueAfterValidation));
+    assertTrue(
+        CarbonCommonConstants.ENABLE_VECTOR_READER_DEFAULT.equalsIgnoreCase(valueAfterValidation));
+  }
+
+  @Test public void testValidateCarbonCSVReadBufferSizeByte()
+      throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
+    Method validateMethodType =
+        carbonProperties.getClass().getDeclaredMethod("validateCarbonCSVReadBufferSizeByte");
+    validateMethodType.setAccessible(true);
+    carbonProperties.addProperty(CarbonCommonConstants.CSV_READ_BUFFER_SIZE, "xyz");
+    String valueBeforeValidation =
+        carbonProperties.getProperty(CarbonCommonConstants.CSV_READ_BUFFER_SIZE);
+    validateMethodType.invoke(carbonProperties);
+    String valueAfterValidation =
+        carbonProperties.getProperty(CarbonCommonConstants.CSV_READ_BUFFER_SIZE);
+    assertTrue(!valueBeforeValidation.equals(valueAfterValidation));
+    assertTrue(
+        CarbonCommonConstants.CSV_READ_BUFFER_SIZE_DEFAULT.equalsIgnoreCase(valueAfterValidation));
+  }
+
+  @Test public void testValidateCarbonCSVReadBufferSizeByteRange()
+      throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
+    Method validateMethodType =
+        carbonProperties.getClass().getDeclaredMethod("validateCarbonCSVReadBufferSizeByte");
+    validateMethodType.setAccessible(true);
+    carbonProperties.addProperty(CarbonCommonConstants.CSV_READ_BUFFER_SIZE, "10485761");
+    String valueBeforeValidation =
+        carbonProperties.getProperty(CarbonCommonConstants.CSV_READ_BUFFER_SIZE);
+    validateMethodType.invoke(carbonProperties);
+    String valueAfterValidation =
+        carbonProperties.getProperty(CarbonCommonConstants.CSV_READ_BUFFER_SIZE);
+    assertTrue(!valueBeforeValidation.equals(valueAfterValidation));
+    assertTrue(
+        CarbonCommonConstants.CSV_READ_BUFFER_SIZE_DEFAULT.equalsIgnoreCase(valueAfterValidation));
+    carbonProperties.addProperty(CarbonCommonConstants.CSV_READ_BUFFER_SIZE, "10240");
+    valueBeforeValidation =
+        carbonProperties.getProperty(CarbonCommonConstants.CSV_READ_BUFFER_SIZE);
+    validateMethodType.invoke(carbonProperties);
+    valueAfterValidation =
+        carbonProperties.getProperty(CarbonCommonConstants.CSV_READ_BUFFER_SIZE);
+    assertTrue(valueBeforeValidation.equals(valueAfterValidation));
+    carbonProperties.addProperty(CarbonCommonConstants.CSV_READ_BUFFER_SIZE, "10239");
+    valueBeforeValidation =
+        carbonProperties.getProperty(CarbonCommonConstants.CSV_READ_BUFFER_SIZE);
+    validateMethodType.invoke(carbonProperties);
+    valueAfterValidation =
+        carbonProperties.getProperty(CarbonCommonConstants.CSV_READ_BUFFER_SIZE);
+    assertTrue(!valueBeforeValidation.equals(valueAfterValidation));
+    assertTrue(
+        CarbonCommonConstants.CSV_READ_BUFFER_SIZE_DEFAULT.equalsIgnoreCase(valueAfterValidation));
+  }
+
+  @Test public void testValidateHighCardinalityIdentify()
+      throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
+    Method validateMethodType =
+        carbonProperties.getClass().getDeclaredMethod("validateHighCardinalityIdentify");
+    validateMethodType.setAccessible(true);
+    carbonProperties.addProperty(CarbonCommonConstants.HIGH_CARDINALITY_IDENTIFY_ENABLE,
"xyz");
+    String valueBeforeValidation =
+        carbonProperties.getProperty(CarbonCommonConstants.HIGH_CARDINALITY_IDENTIFY_ENABLE);
+    validateMethodType.invoke(carbonProperties);
+    String valueAfterValidation =
+        carbonProperties.getProperty(CarbonCommonConstants.HIGH_CARDINALITY_IDENTIFY_ENABLE);
+    assertTrue(!valueBeforeValidation.equals(valueAfterValidation));
+    assertTrue(CarbonCommonConstants.HIGH_CARDINALITY_IDENTIFY_ENABLE_DEFAULT
+        .equalsIgnoreCase(valueAfterValidation));
+  }
+}


Mime
View raw message