forked from apache/spark
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SPARK-1528 - spark on yarn, add support for accessing remote HDFS
Add a config (spark.yarn.access.namenodes) to allow applications running on yarn to access other secure HDFS cluster. User just specifies the namenodes of the other clusters and we get Tokens for those and ship them with the spark application. Author: Thomas Graves <[email protected]> Closes apache#1159 from tgravescs/spark-1528 and squashes the following commits: ddbcd16 [Thomas Graves] review comments 0ac8501 [Thomas Graves] SPARK-1528 - add support for accessing remote HDFS
- Loading branch information
Showing
3 changed files
with
101 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,14 +31,16 @@ import org.apache.hadoop.yarn.api.records.ContainerLaunchContext | |
import org.apache.hadoop.yarn.conf.YarnConfiguration | ||
import org.mockito.Matchers._ | ||
import org.mockito.Mockito._ | ||
|
||
|
||
import org.scalatest.FunSuite | ||
import org.scalatest.Matchers | ||
|
||
import scala.collection.JavaConversions._ | ||
import scala.collection.mutable.{ HashMap => MutableHashMap } | ||
import scala.util.Try | ||
|
||
import org.apache.spark.SparkConf | ||
import org.apache.spark.{SparkException, SparkConf} | ||
import org.apache.spark.util.Utils | ||
|
||
class ClientBaseSuite extends FunSuite with Matchers { | ||
|
@@ -138,6 +140,57 @@ class ClientBaseSuite extends FunSuite with Matchers { | |
} | ||
} | ||
|
||
test("check access nns empty") { | ||
val sparkConf = new SparkConf() | ||
sparkConf.set("spark.yarn.access.namenodes", "") | ||
val nns = ClientBase.getNameNodesToAccess(sparkConf) | ||
nns should be(Set()) | ||
} | ||
|
||
test("check access nns unset") { | ||
val sparkConf = new SparkConf() | ||
val nns = ClientBase.getNameNodesToAccess(sparkConf) | ||
nns should be(Set()) | ||
} | ||
|
||
test("check access nns") { | ||
val sparkConf = new SparkConf() | ||
sparkConf.set("spark.yarn.access.namenodes", "hdfs://nn1:8032") | ||
val nns = ClientBase.getNameNodesToAccess(sparkConf) | ||
nns should be(Set(new Path("hdfs://nn1:8032"))) | ||
} | ||
|
||
test("check access nns space") { | ||
val sparkConf = new SparkConf() | ||
sparkConf.set("spark.yarn.access.namenodes", "hdfs://nn1:8032, ") | ||
val nns = ClientBase.getNameNodesToAccess(sparkConf) | ||
nns should be(Set(new Path("hdfs://nn1:8032"))) | ||
} | ||
|
||
test("check access two nns") { | ||
val sparkConf = new SparkConf() | ||
sparkConf.set("spark.yarn.access.namenodes", "hdfs://nn1:8032,hdfs://nn2:8032") | ||
val nns = ClientBase.getNameNodesToAccess(sparkConf) | ||
nns should be(Set(new Path("hdfs://nn1:8032"), new Path("hdfs://nn2:8032"))) | ||
} | ||
|
||
test("check token renewer") { | ||
val hadoopConf = new Configuration() | ||
hadoopConf.set("yarn.resourcemanager.address", "myrm:8033") | ||
hadoopConf.set("yarn.resourcemanager.principal", "yarn/myrm:[email protected]") | ||
val renewer = ClientBase.getTokenRenewer(hadoopConf) | ||
renewer should be ("yarn/myrm:[email protected]") | ||
} | ||
|
||
test("check token renewer default") { | ||
val hadoopConf = new Configuration() | ||
val caught = | ||
intercept[SparkException] { | ||
ClientBase.getTokenRenewer(hadoopConf) | ||
} | ||
assert(caught.getMessage === "Can't get Master Kerberos principal for use as renewer") | ||
} | ||
|
||
object Fixtures { | ||
|
||
val knownDefYarnAppCP: Seq[String] = | ||
|