Java Code Examples for org.apache.hadoop.mapreduce.TaskAttemptID#getTaskType()
The following examples show how to use
org.apache.hadoop.mapreduce.TaskAttemptID#getTaskType() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestSpeculativeExecution.java From hadoop with Apache License 2.0 | 6 votes |
public void map(Object key, Text value, Context context) throws IOException, InterruptedException { // Make one mapper slower for speculative execution TaskAttemptID taid = context.getTaskAttemptID(); long sleepTime = 100; Configuration conf = context.getConfiguration(); boolean test_speculate_map = conf.getBoolean(MRJobConfig.MAP_SPECULATIVE, false); // IF TESTING MAPPER SPECULATIVE EXECUTION: // Make the "*_m_000000_0" attempt take much longer than the others. // When speculative execution is enabled, this should cause the attempt // to be killed and restarted. At that point, the attempt ID will be // "*_m_000000_1", so sleepTime will still remain 100ms. if ( (taid.getTaskType() == TaskType.MAP) && test_speculate_map && (taid.getTaskID().getId() == 0) && (taid.getId() == 0)) { sleepTime = 10000; } try{ Thread.sleep(sleepTime); } catch(InterruptedException ie) { // Ignore } context.write(value, new IntWritable(1)); }
Example 2
Source File: TestSpeculativeExecution.java From hadoop with Apache License 2.0 | 6 votes |
public void reduce(Text key, Iterable<IntWritable> values, Context context) throws IOException, InterruptedException { // Make one reducer slower for speculative execution TaskAttemptID taid = context.getTaskAttemptID(); long sleepTime = 100; Configuration conf = context.getConfiguration(); boolean test_speculate_reduce = conf.getBoolean(MRJobConfig.REDUCE_SPECULATIVE, false); // IF TESTING REDUCE SPECULATIVE EXECUTION: // Make the "*_r_000000_0" attempt take much longer than the others. // When speculative execution is enabled, this should cause the attempt // to be killed and restarted. At that point, the attempt ID will be // "*_r_000000_1", so sleepTime will still remain 100ms. if ( (taid.getTaskType() == TaskType.REDUCE) && test_speculate_reduce && (taid.getTaskID().getId() == 0) && (taid.getId() == 0)) { sleepTime = 10000; } try{ Thread.sleep(sleepTime); } catch(InterruptedException ie) { // Ignore } context.write(key,new IntWritable(0)); }
Example 3
Source File: TestS3MultipartOutputCommitter.java From s3committer with Apache License 2.0 | 6 votes |
private static Path writeOutputFile(TaskAttemptID id, Path dest, String content, long copies) throws IOException { String fileName = ((id.getTaskType() == TaskType.REDUCE) ? "r_" : "m_") + id.getTaskID().getId() + "_" + id.getId() + "_" + UUID.randomUUID().toString(); Path outPath = new Path(dest, fileName); FileSystem fs = outPath.getFileSystem(getConfiguration()); try (OutputStream out = fs.create(outPath)) { byte[] bytes = content.getBytes(StandardCharsets.UTF_8); for (int i = 0; i < copies; i += 1) { out.write(bytes); } } return outPath; }
Example 4
Source File: TestSpeculativeExecution.java From big-c with Apache License 2.0 | 6 votes |
public void map(Object key, Text value, Context context) throws IOException, InterruptedException { // Make one mapper slower for speculative execution TaskAttemptID taid = context.getTaskAttemptID(); long sleepTime = 100; Configuration conf = context.getConfiguration(); boolean test_speculate_map = conf.getBoolean(MRJobConfig.MAP_SPECULATIVE, false); // IF TESTING MAPPER SPECULATIVE EXECUTION: // Make the "*_m_000000_0" attempt take much longer than the others. // When speculative execution is enabled, this should cause the attempt // to be killed and restarted. At that point, the attempt ID will be // "*_m_000000_1", so sleepTime will still remain 100ms. if ( (taid.getTaskType() == TaskType.MAP) && test_speculate_map && (taid.getTaskID().getId() == 0) && (taid.getId() == 0)) { sleepTime = 10000; } try{ Thread.sleep(sleepTime); } catch(InterruptedException ie) { // Ignore } context.write(value, new IntWritable(1)); }
Example 5
Source File: TestSpeculativeExecution.java From big-c with Apache License 2.0 | 6 votes |
public void reduce(Text key, Iterable<IntWritable> values, Context context) throws IOException, InterruptedException { // Make one reducer slower for speculative execution TaskAttemptID taid = context.getTaskAttemptID(); long sleepTime = 100; Configuration conf = context.getConfiguration(); boolean test_speculate_reduce = conf.getBoolean(MRJobConfig.REDUCE_SPECULATIVE, false); // IF TESTING REDUCE SPECULATIVE EXECUTION: // Make the "*_r_000000_0" attempt take much longer than the others. // When speculative execution is enabled, this should cause the attempt // to be killed and restarted. At that point, the attempt ID will be // "*_r_000000_1", so sleepTime will still remain 100ms. if ( (taid.getTaskType() == TaskType.REDUCE) && test_speculate_reduce && (taid.getTaskID().getId() == 0) && (taid.getId() == 0)) { sleepTime = 10000; } try{ Thread.sleep(sleepTime); } catch(InterruptedException ie) { // Ignore } context.write(key,new IntWritable(0)); }
Example 6
Source File: ZombieJob.java From hadoop with Apache License 2.0 | 5 votes |
/** * Mask the job ID part in a {@link TaskAttemptID}. * * @param attemptId * raw {@link TaskAttemptID} read from trace * @return masked {@link TaskAttemptID} with empty {@link JobID}. */ private TaskAttemptID maskAttemptID(TaskAttemptID attemptId) { JobID jobId = new JobID(); TaskType taskType = attemptId.getTaskType(); TaskID taskId = attemptId.getTaskID(); return new TaskAttemptID(jobId.getJtIdentifier(), jobId.getId(), taskType, taskId.getId(), attemptId.getId()); }
Example 7
Source File: ZombieJob.java From big-c with Apache License 2.0 | 5 votes |
/** * Mask the job ID part in a {@link TaskAttemptID}. * * @param attemptId * raw {@link TaskAttemptID} read from trace * @return masked {@link TaskAttemptID} with empty {@link JobID}. */ private TaskAttemptID maskAttemptID(TaskAttemptID attemptId) { JobID jobId = new JobID(); TaskType taskType = attemptId.getTaskType(); TaskID taskId = attemptId.getTaskID(); return new TaskAttemptID(jobId.getJtIdentifier(), jobId.getId(), taskType, taskId.getId(), attemptId.getId()); }
Example 8
Source File: HadoopShims.java From spork with Apache License 2.0 | 5 votes |
static public boolean isMap(TaskAttemptID taskAttemptID) { TaskType type = taskAttemptID.getTaskType(); if (type==TaskType.MAP) return true; return false; }