This is an automated email from the ASF dual-hosted git repository. tdsilva pushed a commit to branch 4.14-HBase-1.3 in repository https://gitbox.apache.org/repos/asf/phoenix.git
commit 0b93d2264f9489f37fc72ff39e966fe123911638 Author: Thomas D'Silva <tdsi...@apache.org> AuthorDate: Mon Feb 4 23:17:37 2019 -0800 PHOENIX-5124 PropertyPolicyProvider should not evaluate default hbase config properties --- .../it/java/org/apache/phoenix/end2end/AppendOnlySchemaIT.java | 2 +- .../src/it/java/org/apache/phoenix/rpc/UpdateCacheIT.java | 2 +- .../main/java/org/apache/phoenix/jdbc/PhoenixConnection.java | 7 +++++-- .../java/org/apache/phoenix/jdbc/PhoenixEmbeddedDriver.java | 7 ++----- .../phoenix/mapreduce/util/PhoenixConfigurationUtil.java | 6 ++++++ .../src/main/java/org/apache/phoenix/query/QueryServices.java | 2 ++ .../java/org/apache/phoenix/query/QueryServicesOptions.java | 2 ++ .../src/main/java/org/apache/phoenix/util/PropertiesUtil.java | 5 ++++- .../org/apache/phoenix/query/PropertyPolicyProviderTest.java | 10 ++++++++++ .../src/main/scala/org/apache/phoenix/spark/PhoenixRDD.scala | 1 + 10 files changed, 34 insertions(+), 10 deletions(-) diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AppendOnlySchemaIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AppendOnlySchemaIT.java index d601beb..771baed 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AppendOnlySchemaIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AppendOnlySchemaIT.java @@ -70,7 +70,7 @@ public class AppendOnlySchemaIT extends ParallelStatsDisabledIT { Mockito.spy(driver.getConnectionQueryServices(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))); Properties props = new Properties(); - props.putAll(PhoenixEmbeddedDriver.DEFFAULT_PROPS.asMap()); + props.putAll(PhoenixEmbeddedDriver.DEFAULT_PROPS.asMap()); try (Connection conn1 = connectionQueryServices.connect(getUrl(), props); Connection conn2 = sameClient ? conn1 : connectionQueryServices.connect(getUrl(), props)) { diff --git a/phoenix-core/src/it/java/org/apache/phoenix/rpc/UpdateCacheIT.java b/phoenix-core/src/it/java/org/apache/phoenix/rpc/UpdateCacheIT.java index e6a2f7d..dd4c549 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/rpc/UpdateCacheIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/rpc/UpdateCacheIT.java @@ -144,7 +144,7 @@ public class UpdateCacheIT extends ParallelStatsDisabledIT { // use a spyed ConnectionQueryServices so we can verify calls to getTable ConnectionQueryServices connectionQueryServices = Mockito.spy(driver.getConnectionQueryServices(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))); Properties props = new Properties(); - props.putAll(PhoenixEmbeddedDriver.DEFFAULT_PROPS.asMap()); + props.putAll(PhoenixEmbeddedDriver.DEFAULT_PROPS.asMap()); Connection conn = connectionQueryServices.connect(getUrl(), props); try { conn.setAutoCommit(false); 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 312d17b..43b7ca9 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 @@ -246,8 +246,11 @@ public class PhoenixConnection implements Connection, MetaDataMutated, SQLClosea this.isDescVarLengthRowKeyUpgrade = isDescVarLengthRowKeyUpgrade; // Filter user provided properties based on property policy, if - // provided. - PropertyPolicyProvider.getPropertyPolicy().evaluate(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/jdbc/PhoenixEmbeddedDriver.java b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixEmbeddedDriver.java index 00dfb5a..2669360 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixEmbeddedDriver.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixEmbeddedDriver.java @@ -19,7 +19,6 @@ package org.apache.phoenix.jdbc; import static org.apache.phoenix.util.PhoenixRuntime.PHOENIX_TEST_DRIVER_URL_PARAM; -import java.io.File; import java.io.IOException; import java.sql.Connection; import java.sql.Driver; @@ -37,7 +36,6 @@ import javax.annotation.concurrent.Immutable; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.hadoop.conf.Configuration; -import org.apache.hadoop.fs.Path; import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.security.User; import org.apache.hadoop.security.UserGroupInformation; @@ -50,7 +48,6 @@ import org.apache.phoenix.query.HBaseFactoryProvider; import org.apache.phoenix.query.QueryServices; import org.apache.phoenix.util.PhoenixRuntime; import org.apache.phoenix.util.PropertiesUtil; -import org.apache.phoenix.util.QueryUtil; import org.apache.phoenix.util.ReadOnlyProps; import org.apache.phoenix.util.SQLCloseable; import org.slf4j.LoggerFactory; @@ -85,7 +82,7 @@ public abstract class PhoenixEmbeddedDriver implements Driver, SQLCloseable { public final static String MINOR_VERSION_PROP = "DriverMinorVersion"; public final static String DRIVER_NAME_PROP = "DriverName"; - public static final ReadOnlyProps DEFFAULT_PROPS = new ReadOnlyProps( + public static final ReadOnlyProps DEFAULT_PROPS = new ReadOnlyProps( ImmutableMap.of( MAJOR_VERSION_PROP, Integer.toString(MetaDataProtocol.PHOENIX_MAJOR_VERSION), MINOR_VERSION_PROP, Integer.toString(MetaDataProtocol.PHOENIX_MINOR_VERSION), @@ -95,7 +92,7 @@ public abstract class PhoenixEmbeddedDriver implements Driver, SQLCloseable { } protected ReadOnlyProps getDefaultProps() { - return DEFFAULT_PROPS; + return DEFAULT_PROPS; } abstract public QueryServices getQueryServices() throws SQLException; diff --git a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/util/PhoenixConfigurationUtil.java b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/util/PhoenixConfigurationUtil.java index f3f0415..301f18b 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/util/PhoenixConfigurationUtil.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/util/PhoenixConfigurationUtil.java @@ -47,6 +47,7 @@ import org.apache.phoenix.mapreduce.ImportPreUpsertKeyValueProcessor; import org.apache.phoenix.mapreduce.PhoenixInputFormat; import org.apache.phoenix.mapreduce.index.IndexScrutinyTool.OutputFormat; import org.apache.phoenix.mapreduce.index.IndexScrutinyTool.SourceTable; +import org.apache.phoenix.query.QueryServices; import org.apache.phoenix.schema.PName; import org.apache.phoenix.schema.PTable; import org.apache.phoenix.schema.PTableKey; @@ -210,6 +211,11 @@ public final class PhoenixConfigurationUtil { Preconditions.checkNotNull(inputQuery); configuration.set(SELECT_STATEMENT, inputQuery); } + + public static void setPropertyPolicyProviderDisabled(final Configuration configuration) { + Preconditions.checkNotNull(configuration); + configuration.set(QueryServices.PROPERTY_POLICY_PROVIDER_ENABLED, "false"); + } public static void setSchemaType(Configuration configuration, final SchemaType schemaType) { Preconditions.checkNotNull(configuration); 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 9072d26..da81575 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 @@ -305,6 +305,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"; + //Update Cache Frequency default config attribute public static final String DEFAULT_UPDATE_CACHE_FREQUENCY_ATRRIB = "phoenix.default.update.cache.frequency"; 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 02a3d4b..551e0ff 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 @@ -339,6 +339,8 @@ public class QueryServicesOptions { public static final int DEFAULT_UPDATE_CACHE_FREQUENCY = 0; public static final int DEFAULT_SMALL_SCAN_THRESHOLD = 100; + 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 685b8cb..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 @@ -18,6 +18,7 @@ package org.apache.phoenix.util; import java.util.Collections; +import java.util.Enumeration; import java.util.Iterator; import java.util.Map; import java.util.Map.Entry; @@ -25,6 +26,8 @@ import java.util.Properties; import java.util.Set; import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.hbase.HBaseConfiguration; +import org.apache.phoenix.jdbc.PhoenixEmbeddedDriver; public class PropertiesUtil { @@ -55,7 +58,7 @@ public class PropertiesUtil { public static Properties combineProperties(Properties props, final Configuration conf) { return combineProperties(props, conf, Collections.<String>emptySet()); } - + public static Properties combineProperties(Properties props, final Configuration conf, Set<String> withoutTheseProps) { Iterator<Map.Entry<String, String>> iterator = conf.iterator(); Properties copy = deepCopy(props); 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) + ){} + } } diff --git a/phoenix-spark/src/main/scala/org/apache/phoenix/spark/PhoenixRDD.scala b/phoenix-spark/src/main/scala/org/apache/phoenix/spark/PhoenixRDD.scala index 2c2c6e1..280db38 100644 --- a/phoenix-spark/src/main/scala/org/apache/phoenix/spark/PhoenixRDD.scala +++ b/phoenix-spark/src/main/scala/org/apache/phoenix/spark/PhoenixRDD.scala @@ -83,6 +83,7 @@ class PhoenixRDD(sc: SparkContext, table: String, columns: Seq[String], PhoenixConfigurationUtil.setInputClass(config, classOf[PhoenixRecordWritable]) PhoenixConfigurationUtil.setInputTableName(config, table) + PhoenixConfigurationUtil.setPropertyPolicyProviderDisabled(config); if(!columns.isEmpty) { PhoenixConfigurationUtil.setSelectColumnNames(config, columns.toArray)