@@ -59,7 +59,7 @@ private[hive] object IsolatedClientLoader extends Logging {
5959 } else {
6060 val (downloadedFiles, actualHadoopVersion) =
6161 try {
62- (downloadVersion(resolvedVersion, hadoopVersion, ivyPath), hadoopVersion)
62+ (downloadVersion(resolvedVersion, hadoopVersion, sparkConf, ivyPath), hadoopVersion)
6363 } catch {
6464 case e : RuntimeException if e.getMessage.contains(" hadoop" ) =>
6565 // If the error message contains hadoop, it is probably because the hadoop
@@ -73,7 +73,7 @@ private[hive] object IsolatedClientLoader extends Logging {
7373 " It is recommended to set jars used by Hive metastore client through " +
7474 " spark.sql.hive.metastore.jars in the production environment." )
7575 sharesHadoopClasses = false
76- (downloadVersion(resolvedVersion, " 2.4.0" , ivyPath), " 2.4.0" )
76+ (downloadVersion(resolvedVersion, " 2.4.0" , sparkConf, ivyPath), " 2.4.0" )
7777 }
7878 resolvedVersions.put((resolvedVersion, actualHadoopVersion), downloadedFiles)
7979 resolvedVersions((resolvedVersion, actualHadoopVersion))
@@ -102,28 +102,36 @@ private[hive] object IsolatedClientLoader extends Logging {
102102 private def downloadVersion (
103103 version : HiveVersion ,
104104 hadoopVersion : String ,
105+ sparkConf : SparkConf ,
105106 ivyPath : Option [String ]): Seq [URL ] = {
106107 val hiveArtifacts = version.extraDeps ++
107108 Seq (" hive-metastore" , " hive-exec" , " hive-common" , " hive-serde" )
108109 .map(a => s " org.apache.hive: $a: ${version.fullVersion}" ) ++
109110 Seq (" com.google.guava:guava:14.0.1" ,
110111 s " org.apache.hadoop:hadoop-client: $hadoopVersion" )
111112
113+ // if repositories contain a local repo, it will not download jars from remote repo
114+ val repos : Option [String ] = Option (sparkConf.get(" spark.jars.repositories" )).map {
115+ repo =>
116+ Seq (repo, " http://www.datanucleus.org/downloads/maven2" ).mkString(" ," )
117+ }.orElse(Some (" http://www.datanucleus.org/downloads/maven2" ))
118+
119+ val ivyRepoPath = Option (sparkConf.get(" spark.jars.ivy" ))
120+ val ivySettings = Option (sparkConf.get(" spark.jars.ivySettings" )).map { ivySettingsFile =>
121+ SparkSubmitUtils .loadIvySettings(ivySettingsFile, repos, ivyRepoPath)
122+ }.getOrElse {
123+ SparkSubmitUtils .buildIvySettings(repos, ivyRepoPath)
124+ }
125+
112126 val classpath = quietly {
113127 SparkSubmitUtils .resolveMavenCoordinates(
114128 hiveArtifacts.mkString(" ," ),
115- SparkSubmitUtils .buildIvySettings(
116- Some (" http://www.datanucleus.org/downloads/maven2" ),
117- ivyPath),
129+ ivySettings,
118130 exclusions = version.exclusions)
119131 }
120- val allFiles = classpath.split(" ," ).map(new File (_)).toSet
121132
122- // TODO: Remove copy logic.
123- val tempDir = Utils .createTempDir(namePrefix = s " hive- ${version}" )
124- allFiles.foreach(f => FileUtils .copyFileToDirectory(f, tempDir))
125- logInfo(s " Downloaded metastore jars to ${tempDir.getCanonicalPath}" )
126- tempDir.listFiles().map(_.toURI.toURL)
133+ logInfo(s " Downloaded metastore jars location: $classpath" )
134+ classpath.split(" ," ).map(new File (_).toURI.toURL)
127135 }
128136
129137 // A map from a given pair of HiveVersion and Hadoop version to jar files.
0 commit comments