/// <exception cref="System.IO.IOException"/>
            /// <exception cref="System.Exception"/>
            protected override void Map(object key, Text value, Mapper.Context context)
            {
                // Make one mapper slower for speculative execution
                TaskAttemptID taid               = context.GetTaskAttemptID();
                long          sleepTime          = 100;
                Configuration conf               = context.GetConfiguration();
                bool          test_speculate_map = conf.GetBoolean(MRJobConfig.MapSpeculative, 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
                {
                    Sharpen.Thread.Sleep(sleepTime);
                }
                catch (Exception)
                {
                }
                // Ignore
                context.Write(value, new IntWritable(1));
            }
Esempio n. 2
0
 /// <exception cref="System.IO.IOException"/>
 /// <exception cref="System.Exception"/>
 protected override void Map(Text key, Text value, Mapper.Context context)
 {
     // Just create a non-daemon thread which hangs forever. MR AM should not be
     // hung by this.
     new _Thread_36().Start();
     //
     if (context.GetTaskAttemptID().GetId() == 0)
     {
         System.Console.Out.WriteLine("Attempt:" + context.GetTaskAttemptID() + " Failing mapper throwing exception"
                                      );
         throw new IOException("Attempt:" + context.GetTaskAttemptID() + " Failing mapper throwing exception"
                               );
     }
     else
     {
         System.Console.Out.WriteLine("Attempt:" + context.GetTaskAttemptID() + " Exiting"
                                      );
         System.Environment.Exit(-1);
     }
 }