File tree Expand file tree Collapse file tree 3 files changed +22
-18
lines changed
mr/src/main/java/org/elasticsearch/hadoop/mr Expand file tree Collapse file tree 3 files changed +22
-18
lines changed Original file line number Diff line number Diff line change @@ -179,7 +179,7 @@ protected void init() throws IOException {
179
179
}
180
180
181
181
private int detectCurrentInstance (Configuration conf ) {
182
- TaskID taskID = TaskID . forName ( HadoopCfgUtils .getTaskId (conf ) );
182
+ TaskID taskID = HadoopCfgUtils .getTaskID (conf );
183
183
184
184
if (taskID == null ) {
185
185
log .warn (String .format ("Cannot determine task id - redirecting writes in a random fashion" ));
Original file line number Diff line number Diff line change 23
23
24
24
import org .apache .hadoop .conf .Configuration ;
25
25
import org .apache .hadoop .mapred .JobConf ;
26
+ import org .apache .hadoop .mapred .TaskAttemptID ;
27
+ import org .apache .hadoop .mapred .TaskID ;
28
+ import org .elasticsearch .hadoop .util .StringUtils ;
26
29
import org .elasticsearch .hadoop .util .unit .TimeValue ;
27
30
28
31
/**
@@ -137,4 +140,20 @@ public static JobConf asJobConf(Configuration cfg) {
137
140
public static String getMapValueClass (Configuration cfg ) {
138
141
return get (cfg , "mapred.mapoutput.value.class" , "mapreduce.map.output.value.class" );
139
142
}
143
+
144
+ public static TaskID getTaskID (Configuration cfg ) {
145
+ // first try with the attempt since some Hadoop versions mix the two
146
+ String taskAttemptId = HadoopCfgUtils .getTaskAttemptId (cfg );
147
+ if (StringUtils .hasText (taskAttemptId )) {
148
+ return TaskAttemptID .forName (taskAttemptId ).getTaskID ();
149
+ }
150
+ else {
151
+ String taskIdProp = HadoopCfgUtils .getTaskId (cfg );
152
+ // double-check task id bug in Hadoop 2.5.x
153
+ if (StringUtils .hasText (taskIdProp ) && !taskIdProp .contains ("attempt" )) {
154
+ return TaskID .forName (taskIdProp );
155
+ }
156
+ }
157
+ return null ;
158
+ }
140
159
}
Original file line number Diff line number Diff line change 24
24
25
25
import org .apache .commons .logging .Log ;
26
26
import org .apache .hadoop .conf .Configuration ;
27
- import org .apache .hadoop .mapred .TaskAttemptID ;
28
27
import org .apache .hadoop .mapred .TaskID ;
29
28
import org .apache .hadoop .util .Progressable ;
30
29
import org .elasticsearch .hadoop .util .Assert ;
31
- import org .elasticsearch .hadoop .util .StringUtils ;
32
30
import org .elasticsearch .hadoop .util .unit .TimeValue ;
33
31
34
32
/**
@@ -51,22 +49,9 @@ class HeartBeat {
51
49
this .rate = new TimeValue (tv .getMillis () - delay .getMillis (), TimeUnit .MILLISECONDS );
52
50
this .log = log ;
53
51
54
- TaskID taskID = null ;
55
- // first try with the attempt since some Hadoop versions mix the two
56
-
57
- String taskAttemptId = HadoopCfgUtils .getTaskAttemptId (cfg );
58
- if (StringUtils .hasText (taskAttemptId )) {
59
- taskID = TaskAttemptID .forName (taskAttemptId ).getTaskID ();
60
- }
61
- else {
62
- String taskIdProp = HadoopCfgUtils .getTaskId (cfg );
63
- // double-check task id bug in Hadoop 2.5.x
64
- if (StringUtils .hasText (taskIdProp ) && !taskIdProp .contains ("attempt" )) {
65
- taskID = TaskID .forName (taskIdProp );
66
- }
67
- }
68
-
69
52
String taskId ;
53
+ TaskID taskID = HadoopCfgUtils .getTaskID (cfg );
54
+
70
55
if (taskID == null ) {
71
56
log .warn ("Cannot determine task id..." );
72
57
taskId = "<unknown>" ;
You can’t perform that action at this time.
0 commit comments