hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sze...@apache.org
Subject [04/44] hive git commit: HIVE-9823 - Load spark-defaults.conf from classpath [Spark Branch] (Brock via Xuefu)
Date Thu, 23 Apr 2015 02:34:13 GMT
HIVE-9823 - Load spark-defaults.conf from classpath [Spark Branch] (Brock via Xuefu)

git-svn-id: https://svn.apache.org/repos/asf/hive/branches/spark@1663147 13f79535-47bb-0310-9956-ffa450edef68


Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/347b8450
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/347b8450
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/347b8450

Branch: refs/heads/master
Commit: 347b8450ebb9efba76999c4b396193ff5af88c43
Parents: 320ec14
Author: Brock Noland <brock@apache.org>
Authored: Sun Mar 1 19:08:50 2015 +0000
Committer: Szehon Ho <szehon@cloudera.com>
Committed: Wed Apr 22 19:33:49 2015 -0700

----------------------------------------------------------------------
 .../apache/hive/spark/client/SparkClientImpl.java    | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/347b8450/spark-client/src/main/java/org/apache/hive/spark/client/SparkClientImpl.java
----------------------------------------------------------------------
diff --git a/spark-client/src/main/java/org/apache/hive/spark/client/SparkClientImpl.java
b/spark-client/src/main/java/org/apache/hive/spark/client/SparkClientImpl.java
index 727ad29..5de7c2e 100644
--- a/spark-client/src/main/java/org/apache/hive/spark/client/SparkClientImpl.java
+++ b/spark-client/src/main/java/org/apache/hive/spark/client/SparkClientImpl.java
@@ -24,12 +24,14 @@ import com.google.common.base.Preconditions;
 import com.google.common.base.Throwables;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
+import com.google.common.io.Resources;
 
 import io.netty.channel.ChannelHandlerContext;
 import io.netty.util.concurrent.GenericFutureListener;
 import io.netty.util.concurrent.Promise;
 
 import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
@@ -39,6 +41,7 @@ import java.io.OutputStreamWriter;
 import java.io.Serializable;
 import java.io.Writer;
 import java.net.URI;
+import java.net.URL;
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
@@ -249,6 +252,18 @@ class SparkClientImpl implements SparkClient {
       }
 
       Properties allProps = new Properties();
+      // first load the defaults from spark-defaults.conf if available
+      try {
+        URL sparkDefaultsUrl = Thread.currentThread().getContextClassLoader().getResource("spark-defaults.conf");
+        if (sparkDefaultsUrl != null) {
+          LOG.info("Loading spark defaults: " + sparkDefaultsUrl);
+          allProps.load(new ByteArrayInputStream(Resources.toByteArray(sparkDefaultsUrl)));
+        }
+      } catch (Exception e) {
+        String msg = "Exception trying to load spark-defaults.conf: " + e;
+        throw new IOException(msg, e);
+      }
+      // then load the SparkClientImpl config
       for (Map.Entry<String, String> e : conf.entrySet()) {
         allProps.put(e.getKey(), conf.get(e.getKey()));
       }


Mime
View raw message