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

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

commit 49ee3fc3ca3fbdd89a53906eb230ffc7f543c2c8
Author: Hao Hao <[email protected]>
AuthorDate: Mon May 20 23:32:46 2019 -0700

    hms: allow skip validation in Hive Metastore Kudu plugin
    
    This commit adds a system env 'KUDU_SKIP_HMS_PLUGIN_VALIDATION' to
    allow skip validation in the Hive Metastore Kudu plugin. This is useful
    for testing purpose when the Kudu plugin is used when HMS integration
    is actually disabled.
    
    Change-Id: I4fe686ce4b1d1fdb2dcdf0fcf1c177076465c01b
    Reviewed-on: http://gerrit.cloudera.org:8080/13387
    Reviewed-by: Andrew Wong <[email protected]>
    Tested-by: Hao Hao <[email protected]>
    Reviewed-by: Alexey Serbin <[email protected]>
---
 .../kudu/hive/metastore/KuduMetastorePlugin.java   | 35 ++++++++++++++++++++--
 1 file changed, 33 insertions(+), 2 deletions(-)

diff --git 
a/java/kudu-hive/src/main/java/org/apache/kudu/hive/metastore/KuduMetastorePlugin.java
 
b/java/kudu-hive/src/main/java/org/apache/kudu/hive/metastore/KuduMetastorePlugin.java
index d926a9f..b508c27 100644
--- 
a/java/kudu-hive/src/main/java/org/apache/kudu/hive/metastore/KuduMetastorePlugin.java
+++ 
b/java/kudu-hive/src/main/java/org/apache/kudu/hive/metastore/KuduMetastorePlugin.java
@@ -58,8 +58,11 @@ import org.apache.hadoop.hive.metastore.events.ListenerEvent;
  * environment containing a Kudu table ID, that event only applies
  * to the specified Kudu table. This provides some amount of concurrency
  * safety, so that the Kudu Master can ensure it is operating on the correct
- * table entry. Note that such validation does not apply to tables with
- * legacy Kudu storage handler.
+ * table entry.
+ *
+ * Note that such validation does not apply to tables with legacy Kudu
+ * storage handler and will be skipped if system env 
KUDU_SKIP_HMS_PLUGIN_VALIDATION
+ * is set to non-zero.
  */
 public class KuduMetastorePlugin extends MetaStoreEventListener {
 
@@ -76,6 +79,9 @@ public class KuduMetastorePlugin extends 
MetaStoreEventListener {
   @VisibleForTesting
   static final String KUDU_MASTER_EVENT = "kudu.master_event";
 
+  // System env to track if the HMS plugin validation should be skipped.
+  static final String SKIP_VALIDATION_ENV = "KUDU_SKIP_HMS_PLUGIN_VALIDATION";
+
   public KuduMetastorePlugin(Configuration config) {
     super(config);
   }
@@ -83,6 +89,11 @@ public class KuduMetastorePlugin extends 
MetaStoreEventListener {
   @Override
   public void onCreateTable(CreateTableEvent tableEvent) throws MetaException {
     super.onCreateTable(tableEvent);
+
+    if (skipsValidation()) {
+      return;
+    }
+
     Table table = tableEvent.getTable();
 
     // Only validate managed tables.
@@ -116,6 +127,10 @@ public class KuduMetastorePlugin extends 
MetaStoreEventListener {
       return;
     }
 
+    if (skipsValidation()) {
+      return;
+    }
+
     EnvironmentContext environmentContext = tableEvent.getEnvironmentContext();
     String targetTableId = environmentContext == null ? null :
         environmentContext.getProperties().get(KUDU_TABLE_ID_KEY);
@@ -143,6 +158,10 @@ public class KuduMetastorePlugin extends 
MetaStoreEventListener {
   public void onAlterTable(AlterTableEvent tableEvent) throws MetaException {
     super.onAlterTable(tableEvent);
 
+    if (skipsValidation()) {
+      return;
+    }
+
     Table oldTable = tableEvent.getOldTable();
     Table newTable = tableEvent.getNewTable();
 
@@ -295,4 +314,16 @@ public class KuduMetastorePlugin extends 
MetaStoreEventListener {
 
     return Boolean.parseBoolean(properties.get(KUDU_MASTER_EVENT));
   }
+
+  /**
+   * Returns true if the system env is set to skip validation.
+   */
+  private static boolean skipsValidation() {
+    String skipValidation = System.getenv(SKIP_VALIDATION_ENV);
+    if (skipValidation == null || skipValidation.isEmpty() ||
+        Integer.parseInt(skipValidation) == 0) {
+      return false;
+    }
+    return true;
+  }
 }

Reply via email to