如何从java关闭hadoop推测执行

2skhul33  于 2021-06-03  发布在  Hadoop
关注(0)|答案(2)|浏览(393)

在阅读了hadoop推测性任务执行之后,我试图使用新的javaapi关闭推测性执行,但是没有效果。
这是我的主要课程:

public class Main {

  public static void main(String[] args) throws Exception {
    Configuration conf = new Configuration();

    //old api:
    //conf.setBoolean("mapred.map.tasks.speculative.execution", false);
    //new api:
    conf.setBoolean("mapreduce.map.speculative", false);

    int res = ToolRunner.run(conf, new LogParserMapReduce(), args);
    System.exit(res);
  }
}

我的Map缩小器是这样开始的:

@Override
public int run(String[] args) throws Exception {
    Configuration conf = super.getConf();

    /*
     * Instantiate a Job object for your job's configuration.  
     */
    Job job = Job.getInstance(conf);

但当我看日志时,我看到:

2014-04-24 10:06:21,418 INFO org.apache.hadoop.mapreduce.lib.input.FileInputFormat (main): Total input paths to process : 16
2014-04-24 10:06:21,574 INFO org.apache.hadoop.mapreduce.JobSubmitter (main): number of splits:26

如果我理解的话,这意味着推测执行仍然在进行,否则,如果我只有16个输入文件,为什么会有26个分割呢。我弄错了吗?
注意:我相信我使用了新的api,因为我在日志中看到了以下警告:

2014-04-24 10:06:21,590 INFO org.apache.hadoop.conf.Configuration.deprecation (main): mapred.job.classpath.files is deprecated. Instead, use mapreduce.job.classpath.files
6psbrbz9

6psbrbz91#

您的设置“无Map任务的推测性执行”很好。在运行时设置它的另一种方法(使实验/测试更容易)是在命令行中传递相应的参数(-s)。例如,下面的“推测执行”对于“贴图”设置为“关闭”,但是对于“异径管”设置为“打开”:

bin/hadoop jar -Dmapreduce.map.speculative=false \
               -Dmapreduce.reduce.speculative=true <jar>
polhcujo

polhcujo2#

“16个文件=16个Map器”这是一个错误的假设。
“16个文件=最少16个Map器”这是正确的。
如果16个文件中的某些文件大于块大小,它们将被拆分为多个Map器。因此,生成26个Map器的16个文件可能不是因为推测性执行。
在conf中设置值当然有效。您可以通过检查job.xml进行验证

相关问题