Github user vanzin commented on a diff in the pull request:
https://github.com/apache/spark/pull/9026#discussion_r42183714
--- Diff: yarn/src/main/scala/org/apache/spark/deploy/yarn/Client.scala ---
@@ -1272,11 +1272,24 @@ object Client extends Logging {
val mirror = universe.runtimeMirror(getClass.getClassLoader)
try {
- val hiveClass =
mirror.classLoader.loadClass("org.apache.hadoop.hive.ql.metadata.Hive")
- val hive = hiveClass.getMethod("get").invoke(null)
-
- val hiveConf = hiveClass.getMethod("getConf").invoke(hive)
val hiveConfClass =
mirror.classLoader.loadClass("org.apache.hadoop.hive.conf.HiveConf")
+ val hiveConf = hiveConfClass.newInstance()
+
+ // Set metastore to be a local temp directory to avoid conflict of
the `metaStore client`
+ // in `HiveContext` which will use the same derby dataBase by
default.
+ val hiveConfSet = (param: String, value: String) => hiveConfClass
+ .getMethod("set", classOf[Unit])
+ .invoke(hiveConf, param, value)
+ val tempDir = Utils.createTempDir()
+ val localMetastore = new File(tempDir, "metastore")
+ hiveConfSet("hive.metastore.warehouse.dir",
localMetastore.toURI.toString)
+ hiveConfSet("javax.jdo.option.ConnectionURL",
+
s"jdbc:derby:;databaseName=${localMetastore.getAbsolutePath};create=true")
+ hiveConfSet("datanucleus.rdbms.datastoreAdapterClassName",
+ "org.datanucleus.store.rdbms.adapter.DerbyAdapter")
+
+ val hiveClass =
mirror.classLoader.loadClass("org.apache.hadoop.hive.ql.metadata.Hive")
+ val hive = hiveClass.getMethod("get").invoke(null,
hiveConf.asInstanceOf[Object])
--- End diff --
So, the original problem is caused by this line, right?
Since the `hive` object is only used inside the condition on L1301, can't
you move the original line inside that `if` and fix the problem? You don't need
delegation tokens when using Derby (and `hive.metastore.uris` would be empty in
that case), so there's no point in even trying to call this class if Derby is
being used.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]