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
8f979ede
Commit
8f979ede
authored
11 years ago
by
Jey Kottalam
Browse files
Options
Downloads
Patches
Plain Diff
Fix newTaskAttemptID to work under YARN
parent
14b6bcdf
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
core/src/main/scala/org/apache/hadoop/mapreduce/SparkHadoopMapReduceUtil.scala
+19
-1
19 additions, 1 deletion
...rg/apache/hadoop/mapreduce/SparkHadoopMapReduceUtil.scala
with
19 additions
and
1 deletion
core/src/main/scala/org/apache/hadoop/mapreduce/SparkHadoopMapReduceUtil.scala
+
19
−
1
View file @
8f979ede
...
...
@@ -18,6 +18,7 @@
package
org.apache.hadoop.mapreduce
import
org.apache.hadoop.conf.Configuration
import
java.lang.
{
Integer
=>
JInteger
,
Boolean
=>
JBoolean
}
trait
SparkHadoopMapReduceUtil
{
def
newJobContext
(
conf
:
Configuration
,
jobId
:
JobID
)
:
JobContext
=
{
...
...
@@ -37,7 +38,24 @@ trait SparkHadoopMapReduceUtil {
}
def
newTaskAttemptID
(
jtIdentifier
:
String
,
jobId
:
Int
,
isMap
:
Boolean
,
taskId
:
Int
,
attemptId
:
Int
)
=
{
new
TaskAttemptID
(
jtIdentifier
,
jobId
,
isMap
,
taskId
,
attemptId
)
val
klass
=
Class
.
forName
(
"org.apache.hadoop.mapreduce.TaskAttemptID"
);
try
{
// first, attempt to use the old-style constructor that takes a boolean isMap (not available in YARN)
val
ctor
=
klass
.
getDeclaredConstructor
(
classOf
[
String
],
classOf
[
Int
],
classOf
[
Boolean
],
classOf
[
Int
],
classOf
[
Int
])
ctor
.
newInstance
(
jtIdentifier
,
new
JInteger
(
jobId
),
new
JBoolean
(
isMap
),
new
JInteger
(
taskId
),
new
JInteger
(
attemptId
)).
asInstanceOf
[
TaskAttemptID
]
}
catch
{
case
exc
:
NoSuchMethodException
=>
{
// failed, look for the new ctor that takes a TaskType (not available in 1.x)
val
taskTypeClass
=
Class
.
forName
(
"org.apache.hadoop.mapreduce.TaskType"
).
asInstanceOf
[
Class
[
Enum
[
_
]]]
val
taskType
=
taskTypeClass
.
getMethod
(
"valueOf"
,
classOf
[
String
]).
invoke
(
taskTypeClass
,
if
(
isMap
)
"MAP"
else
"REDUCE"
)
val
ctor
=
klass
.
getDeclaredConstructor
(
classOf
[
String
],
classOf
[
Int
],
taskTypeClass
,
classOf
[
Int
],
classOf
[
Int
])
ctor
.
newInstance
(
jtIdentifier
,
new
JInteger
(
jobId
),
taskType
,
new
JInteger
(
taskId
),
new
JInteger
(
attemptId
)).
asInstanceOf
[
TaskAttemptID
]
}
}
}
private
def
firstAvailableClass
(
first
:
String
,
second
:
String
)
:
Class
[
_
]
=
{
...
...
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