Repository: lens Updated Branches: refs/heads/master 99a242c76 -> d0d9adf35
LENS-1510 : Adding config for hive principal . Project: http://git-wip-us.apache.org/repos/asf/lens/repo Commit: http://git-wip-us.apache.org/repos/asf/lens/commit/d0d9adf3 Tree: http://git-wip-us.apache.org/repos/asf/lens/tree/d0d9adf3 Diff: http://git-wip-us.apache.org/repos/asf/lens/diff/d0d9adf3 Branch: refs/heads/master Commit: d0d9adf35ca476f28cb872285097309cdb6e55a6 Parents: 99a242c Author: Rajitha R <[email protected]> Authored: Fri Apr 20 15:11:48 2018 +0530 Committer: Rajitha.R <[email protected]> Committed: Fri Apr 20 15:11:48 2018 +0530 ---------------------------------------------------------------------- .../java/org/apache/lens/driver/hive/HiveDriver.java | 11 +++++++++++ .../src/main/resources/hivedriver-default.xml | 8 ++++++++ .../org/apache/lens/server/api/LensConfConstants.java | 7 +++++++ src/site/apt/admin/hivedriver-config.apt | 14 +++++++++----- .../server/drivers/hive/hive1/hivedriver-site.xml | 6 ++++++ 5 files changed, 41 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/lens/blob/d0d9adf3/lens-driver-hive/src/main/java/org/apache/lens/driver/hive/HiveDriver.java ---------------------------------------------------------------------- diff --git a/lens-driver-hive/src/main/java/org/apache/lens/driver/hive/HiveDriver.java b/lens-driver-hive/src/main/java/org/apache/lens/driver/hive/HiveDriver.java index 3fd5d2c..61fef15 100644 --- a/lens-driver-hive/src/main/java/org/apache/lens/driver/hive/HiveDriver.java +++ b/lens-driver-hive/src/main/java/org/apache/lens/driver/hive/HiveDriver.java @@ -327,11 +327,22 @@ public class HiveDriver extends AbstractLensDriver { */ @Override public void configure(Configuration conf, String driverType, String driverName) throws LensException { + super.configure(conf, driverType, driverName); this.hiveConf = new HiveConf(conf, HiveDriver.class); this.hiveConf.addResource(getConf()); + if (hiveConf.getVar(HiveConf.ConfVars.HIVE_SERVER2_AUTHENTICATION) + .equals(HiveAuthFactory.AuthTypes.KERBEROS.toString())) { + + log.info("set hive's server principal for hive driver as {}", + getConf().get(LensConfConstants.LENS_DRIVER_HIVE_PRINCIPAL)); + + hiveConf.setVar(HiveConf.ConfVars.HIVE_SERVER2_KERBEROS_PRINCIPAL, + getConf().get(LensConfConstants.LENS_DRIVER_HIVE_PRINCIPAL)); + } + connectionClass = getConf().getClass(HIVE_CONNECTION_CLASS, EmbeddedThriftConnection.class, ThriftConnection.class); isEmbedded = (connectionClass.getName().equals(EmbeddedThriftConnection.class.getName())); http://git-wip-us.apache.org/repos/asf/lens/blob/d0d9adf3/lens-driver-hive/src/main/resources/hivedriver-default.xml ---------------------------------------------------------------------- diff --git a/lens-driver-hive/src/main/resources/hivedriver-default.xml b/lens-driver-hive/src/main/resources/hivedriver-default.xml index 2b2dc0b..d41e36a 100644 --- a/lens-driver-hive/src/main/resources/hivedriver-default.xml +++ b/lens-driver-hive/src/main/resources/hivedriver-default.xml @@ -23,6 +23,14 @@ <configuration> + + <property> + <name>lens.driver.hive.kerberos.principal</name> + <value>hive/[email protected]</value> + <description>Set principal name to be used for hive server. + </description> + </property> + <property> <name>lens.driver.hive.connection.class</name> <value>org.apache.lens.driver.hive.EmbeddedThriftConnection</value> http://git-wip-us.apache.org/repos/asf/lens/blob/d0d9adf3/lens-server-api/src/main/java/org/apache/lens/server/api/LensConfConstants.java ---------------------------------------------------------------------- diff --git a/lens-server-api/src/main/java/org/apache/lens/server/api/LensConfConstants.java b/lens-server-api/src/main/java/org/apache/lens/server/api/LensConfConstants.java index 0e05d28..f14ae44 100644 --- a/lens-server-api/src/main/java/org/apache/lens/server/api/LensConfConstants.java +++ b/lens-server-api/src/main/java/org/apache/lens/server/api/LensConfConstants.java @@ -735,6 +735,13 @@ public final class LensConfConstants { public static final String LENS_PRINCIPAL = SERVER_PFX + "principal"; + + /** + * Hive principal for kerberos authentication + */ + public static final String LENS_DRIVER_HIVE_PRINCIPAL = DRIVER_PFX + + "hive.kerberos.principal"; + // Statistics Store configuration keys /** * The Constant STATS_STORE_CLASS. http://git-wip-us.apache.org/repos/asf/lens/blob/d0d9adf3/src/site/apt/admin/hivedriver-config.apt ---------------------------------------------------------------------- diff --git a/src/site/apt/admin/hivedriver-config.apt b/src/site/apt/admin/hivedriver-config.apt index b1a8431..221c166 100644 --- a/src/site/apt/admin/hivedriver-config.apt +++ b/src/site/apt/admin/hivedriver-config.apt @@ -52,9 +52,11 @@ Hive driver configuration *--+--+---+--+ |14|lens.driver.hive.cost.calculator.class|org.apache.lens.cube.query.cost.FactPartitionBasedQueryCostCalculator|Cost calculator class. By default calculating cost through fact partitions.| *--+--+---+--+ -|15|lens.driver.hive.hs2.connection.expiry.delay|600000|The idle time (in milliseconds) for expiring connection from hivedriver to HiveServer2| +|15|lens.driver.hive.driver.kerberos.principal|hive/[email protected]|Set principal name to be used for hive server.| *--+--+---+--+ -|16|lens.driver.hive.priority.ranges|VERY_HIGH,7.0,HIGH,30.0,NORMAL,90,LOW|Priority Ranges. The numbers are the costs of the query. \ | +|16|lens.driver.hive.hs2.connection.expiry.delay|600000|The idle time (in milliseconds) for expiring connection from hivedriver to HiveServer2| +*--+--+---+--+ +|17|lens.driver.hive.priority.ranges|VERY_HIGH,7.0,HIGH,30.0,NORMAL,90,LOW|Priority Ranges. The numbers are the costs of the query. \ | | | | |The cost is calculated based on partition weights and fact weights. The interpretation of the default config is: \ | | | | | \ | | | | |cost \<= 7\ \ \ \ \ \ \ \ \ \ \ :\ \ \ \ \ Priority = VERY_HIGH \ | @@ -70,10 +72,12 @@ Hive driver configuration | | | |One use case in range tuning can be that you never want queries to run with VERY_HIGH, assuming no other changes, you'll modify the value of this param in hivedriver-site.xml to be HIGH,30.0,NORMAL,90,LOW\ | | | | |via the configs, you can tune both the ranges and partition weights. this would give the end user more control. | *--+--+---+--+ -|17|lens.driver.hive.query.hook.classes| |The query hook classes for hive driver. By default there are no hooks. To add a hook, you should look at the default implementation and from there it'll be easy to derive what value can be added through a new hook. Multiple hooks can be provided by providing comma seperated name of classes.| +|18|lens.driver.hive.query.hook.classes| |The query hook classes for hive driver. By default there are no hooks. To add a hook, you should look at the default implementation and from there it'll be easy to derive what value can be added through a new hook. Multiple hooks can be provided by providing comma seperated name of classes.| +*--+--+---+--+ +|19|lens.driver.hive.query.launching.constraint.factories| |Factories used to instantiate constraints enforced on queries by driver. A query will be launched only if all constraints pass. Every Factory should be an implementation of org.apache.lens.server.api.common.ConfigBasedObjectCreationFactory and create an implementation of org.apache.lens.server.api.query.constraint.QueryLaunchingConstraint.| *--+--+---+--+ -|18|lens.driver.hive.query.launching.constraint.factories| |Factories used to instantiate constraints enforced on queries by driver. A query will be launched only if all constraints pass. Every Factory should be an implementation of org.apache.lens.server.api.common.ConfigBasedObjectCreationFactory and create an implementation of org.apache.lens.server.api.query.constraint.QueryLaunchingConstraint.| +|20|lens.driver.hive.waiting.queries.selection.policy.factories| |Factories used to instantiate driver specific waiting queries selection policies. Every factory should be an implementation of org.apache.lens.server.api.common.ConfigBasedObjectCreationFactory and create an implementation of org.apache.lens.server.api.query.collect.WaitingQueriesSelectionPolicy.| *--+--+---+--+ -|19|lens.driver.hive.waiting.queries.selection.policy.factories| |Factories used to instantiate driver specific waiting queries selection policies. Every factory should be an implementation of org.apache.lens.server.api.common.ConfigBasedObjectCreationFactory and create an implementation of org.apache.lens.server.api.query.collect.WaitingQueriesSelectionPolicy.| +|21|lens.driver.hive.kerberos.principal| |Set principal name to be used for hive server.| *--+--+---+--+ The configuration parameters and their default values http://git-wip-us.apache.org/repos/asf/lens/blob/d0d9adf3/tools/conf/server/drivers/hive/hive1/hivedriver-site.xml ---------------------------------------------------------------------- diff --git a/tools/conf/server/drivers/hive/hive1/hivedriver-site.xml b/tools/conf/server/drivers/hive/hive1/hivedriver-site.xml index 2e8e7fa..c0f2083 100644 --- a/tools/conf/server/drivers/hive/hive1/hivedriver-site.xml +++ b/tools/conf/server/drivers/hive/hive1/hivedriver-site.xml @@ -22,6 +22,12 @@ <?xml-stylesheet type="text/xsl" href="configuration.xsl"?> <configuration> + + <property> + <name>lens.driver.hive.kerberos.principal</name> + <value>hive/[email protected]</value> + </property> + <property> <name>hive.metastore.warehouse.dir</name> <value>/tmp/hive/warehouse</value>
