Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
spark
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cs525-sp18-g07
spark
Commits
de028555
Commit
de028555
authored
11 years ago
by
Evan Chan
Browse files
Options
Downloads
Patches
Plain Diff
Add support for local:// URI scheme for addJars()
This indicates that a jar is available locally on each worker node.
parent
f0e23a02
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
core/src/main/scala/org/apache/spark/SparkContext.scala
+5
-1
5 additions, 1 deletion
core/src/main/scala/org/apache/spark/SparkContext.scala
core/src/test/scala/org/apache/spark/FileServerSuite.scala
+16
-0
16 additions, 0 deletions
core/src/test/scala/org/apache/spark/FileServerSuite.scala
with
21 additions
and
1 deletion
core/src/main/scala/org/apache/spark/SparkContext.scala
+
5
−
1
View file @
de028555
...
...
@@ -683,7 +683,7 @@ class SparkContext(
/**
* Adds a JAR dependency for all tasks to be executed on this SparkContext in the future.
* The `path` passed can be either a local file, a file in HDFS (or other Hadoop-supported
* filesystems),
or
an HTTP, HTTPS or FTP URI.
* filesystems), an HTTP, HTTPS or FTP URI
, or local:/path for a file on every worker node
.
*/
def
addJar
(
path
:
String
)
{
if
(
path
==
null
)
{
...
...
@@ -696,6 +696,7 @@ class SparkContext(
}
else
{
val
uri
=
new
URI
(
path
)
key
=
uri
.
getScheme
match
{
// A JAR file which exists only on the driver node
case
null
|
"file"
=>
if
(
env
.
hadoop
.
isYarnMode
())
{
// In order for this to work on yarn the user must specify the --addjars option to
...
...
@@ -713,6 +714,9 @@ class SparkContext(
}
else
{
env
.
httpFileServer
.
addJar
(
new
File
(
uri
.
getPath
))
}
// A JAR file which exists locally on every worker node
case
"local"
=>
"file:"
+
uri
.
getPath
case
_
=>
path
}
...
...
This diff is collapsed.
Click to expand it.
core/src/test/scala/org/apache/spark/FileServerSuite.scala
+
16
−
0
View file @
de028555
...
...
@@ -120,4 +120,20 @@ class FileServerSuite extends FunSuite with LocalSparkContext {
}.
collect
()
assert
(
result
.
toSet
===
Set
((
1
,
2
),
(
2
,
7
),
(
3
,
121
)))
}
test
(
"Dynamically adding JARS on a standalone cluster using local: URL"
)
{
sc
=
new
SparkContext
(
"local-cluster[1,1,512]"
,
"test"
)
val
sampleJarFile
=
getClass
.
getClassLoader
.
getResource
(
"uncommons-maths-1.2.2.jar"
).
getFile
()
sc
.
addJar
(
sampleJarFile
.
replace
(
"file"
,
"local"
))
val
testData
=
Array
((
1
,
1
),
(
1
,
1
),
(
2
,
1
),
(
3
,
5
),
(
2
,
3
),
(
3
,
0
))
val
result
=
sc
.
parallelize
(
testData
).
reduceByKey
{
(
x
,
y
)
=>
val
fac
=
Thread
.
currentThread
.
getContextClassLoader
()
.
loadClass
(
"org.uncommons.maths.Maths"
)
.
getDeclaredMethod
(
"factorial"
,
classOf
[
Int
])
val
a
=
fac
.
invoke
(
null
,
x
.
asInstanceOf
[
java.lang.Integer
]).
asInstanceOf
[
Long
].
toInt
val
b
=
fac
.
invoke
(
null
,
y
.
asInstanceOf
[
java.lang.Integer
]).
asInstanceOf
[
Long
].
toInt
a
+
b
}.
collect
()
assert
(
result
.
toSet
===
Set
((
1
,
2
),
(
2
,
7
),
(
3
,
121
)))
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment