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

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


The following commit(s) were added to refs/heads/4.x-HBase-1.4 by this push:
     new 1872a60  PHOENIX-5124 Add config to enable PropertyPolicyProvider
1872a60 is described below

commit 1872a605cf71656c45764951b8157c49ae4c2086
Author: Thomas D'Silva <tdsi...@apache.org>
AuthorDate: Thu Feb 14 16:14:18 2019 -0800

    PHOENIX-5124 Add config to enable PropertyPolicyProvider
---
 .../phoenix/end2end/PropertyPolicyProviderIT.java  | 26 ----------------------
 .../org/apache/phoenix/jdbc/PhoenixConnection.java |  7 ++++--
 .../org/apache/phoenix/query/QueryServices.java    |  2 ++
 .../apache/phoenix/query/QueryServicesOptions.java |  2 ++
 .../org/apache/phoenix/util/PropertiesUtil.java    | 26 ----------------------
 .../phoenix/query/PropertyPolicyProviderTest.java  | 10 +++++++++
 6 files changed, 19 insertions(+), 54 deletions(-)

diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/PropertyPolicyProviderIT.java
 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/PropertyPolicyProviderIT.java
deleted file mode 100644
index 48508a9..0000000
--- 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/PropertyPolicyProviderIT.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package org.apache.phoenix.end2end;
-
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseConfiguration;
-import org.apache.hadoop.hbase.HConstants;
-import org.apache.phoenix.mapreduce.util.ConnectionUtil;
-import org.junit.Test;
-
-import java.sql.Connection;
-import java.sql.SQLException;
-import java.util.Properties;
-
-public class PropertyPolicyProviderIT  extends ParallelStatsDisabledIT {
-
-    @Test
-    public void testUsingDefaultHBaseConfigs() throws SQLException {
-        Configuration config = HBaseConfiguration.create();
-        config.set(HConstants.ZOOKEEPER_QUORUM, getUrl());
-        Properties properties=new Properties();
-        properties.put("allowedProperty","value");
-        try(
-                Connection conn = ConnectionUtil.getInputConnection(config, 
properties)
-        ){}
-    }
-
-}
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixConnection.java 
b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixConnection.java
index d74ffff..d668758 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixConnection.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixConnection.java
@@ -244,8 +244,11 @@ public class PhoenixConnection implements Connection, 
MetaDataMutated, SQLClosea
         this.isDescVarLengthRowKeyUpgrade = isDescVarLengthRowKeyUpgrade;
 
         // Filter user provided properties based on property policy, if
-        // provided.
-        
PropertyPolicyProvider.getPropertyPolicy().evaluate(PropertiesUtil.removeStandardHBasePhoenixConfig(info));
+        // provided and QueryServices.PROPERTY_POLICY_PROVIDER_ENABLED is true
+        if 
(Boolean.valueOf(info.getProperty(QueryServices.PROPERTY_POLICY_PROVIDER_ENABLED,
+                
String.valueOf(QueryServicesOptions.DEFAULT_PROPERTY_POLICY_PROVIDER_ENABLED))))
 {
+            PropertyPolicyProvider.getPropertyPolicy().evaluate(info);
+        }
 
         // Copy so client cannot change
         this.info = info == null ? new Properties() : PropertiesUtil
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServices.java 
b/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServices.java
index fc11539..c21a785 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServices.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServices.java
@@ -309,6 +309,8 @@ public interface QueryServices extends SQLCloseable {
     // whether to enable server side RS -> RS calls for upsert select 
statements
     public static final String ENABLE_SERVER_UPSERT_SELECT 
="phoenix.client.enable.server.upsert.select";
 
+    public static final String PROPERTY_POLICY_PROVIDER_ENABLED = 
"phoenix.property.policy.provider.enabled";
+
     // whether to trigger mutations on the server at all (UPSERT/DELETE or 
DELETE FROM)
     public static final String ENABLE_SERVER_SIDE_MUTATIONS 
="phoenix.client.enable.server.mutations";
 
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServicesOptions.java 
b/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServicesOptions.java
index fcf57c7..684e955 100644
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServicesOptions.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServicesOptions.java
@@ -351,6 +351,8 @@ public class QueryServicesOptions {
 
     public static final boolean 
DEFAULT_ALLOW_SPLITTABLE_SYSTEM_CATALOG_ROLLBACK = false;
 
+    public static final boolean DEFAULT_PROPERTY_POLICY_PROVIDER_ENABLED = 
true;
+
     @SuppressWarnings("serial")
     public static final Set<String> DEFAULT_QUERY_SERVER_SKIP_WORDS = new 
HashSet<String>() {
       {
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/util/PropertiesUtil.java 
b/phoenix-core/src/main/java/org/apache/phoenix/util/PropertiesUtil.java
index a52d979..f415f0b 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/util/PropertiesUtil.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/util/PropertiesUtil.java
@@ -74,32 +74,6 @@ public class PropertiesUtil {
         return copy;
     }
 
-    /**
-     * Removes properties present that are present in standard HBase 
configuration and standard Phoenix properties
-     * These are then evaluated by the PropertyPolicyProvider.
-     */
-    public static Properties removeStandardHBasePhoenixConfig(Properties 
props) {
-        Configuration config = HBaseConfiguration.create();
-        Properties normalizedProps  = new Properties();
-        for(Entry entry: props.entrySet()) {
-            if ( entry.getKey() instanceof String) {
-                String propName = (String) entry.getKey();
-                // add the property to the normalized list if its not a 
standard Phoenix property and
-                // if the property is not defined in hbase-site.xml or if it 
is defined and its value is different
-                if ( PhoenixEmbeddedDriver.DEFAULT_PROPS.get(propName) == null
-                        && !propName.equals(PhoenixRuntime.CURRENT_SCN_ATTRIB)
-                        && !propName.equals(PhoenixRuntime.TENANT_ID_ATTRIB)
-                        && (config.get(propName) == null || 
!config.get(propName).equals(entry.getValue()) )) {
-                    normalizedProps.put(propName, props.getProperty(propName));
-                }
-            }
-            else {
-                normalizedProps.put(entry.getKey(), entry.getValue());
-            }
-        }
-        return normalizedProps;
-    }
-
    /**
      * Utility to work around the limitation of the copy constructor
      * {@link Configuration#Configuration(Configuration)} provided by the 
{@link Configuration}
diff --git 
a/phoenix-core/src/test/java/org/apache/phoenix/query/PropertyPolicyProviderTest.java
 
b/phoenix-core/src/test/java/org/apache/phoenix/query/PropertyPolicyProviderTest.java
index 053448e..a8e7fd7 100644
--- 
a/phoenix-core/src/test/java/org/apache/phoenix/query/PropertyPolicyProviderTest.java
+++ 
b/phoenix-core/src/test/java/org/apache/phoenix/query/PropertyPolicyProviderTest.java
@@ -49,4 +49,14 @@ public class PropertyPolicyProviderTest extends 
BaseConnectionlessQueryTest{
         Connection conn = DriverManager.getConnection(getUrl(),properties);
         ){}
     }
+
+    @Test
+    public void testDisablePropertyPolicyProvider() throws SQLException {
+        Properties properties=new Properties();
+        properties.put("DisallowedProperty","value");
+        properties.put(QueryServices.PROPERTY_POLICY_PROVIDER_ENABLED, 
"false");
+        try(
+                Connection conn = DriverManager.getConnection(getUrl(), 
properties)
+        ){}
+    }
 }

Reply via email to