How to overwrite/reuse the existing output path for Hadoop jobs again and agian

后端 未结 10 874
既然无缘
既然无缘 2021-02-12 10:29

I want to overwrite/reuse the existing output directory when I run my Hadoop job daily. Actually the output directory will store summarized output of each day\'s job run results

10条回答
  •  情歌与酒
    2021-02-12 11:19

    You can create an output subdirectory for each execution by time. For example lets say you are expecting output directory from user and then set it as follows:

    FileOutputFormat.setOutputPath(job, new Path(args[1]);
    

    Change this by the following lines:

    String timeStamp = new SimpleDateFormat("yyyy.MM.dd.HH.mm.ss", Locale.US).format(new Timestamp(System.currentTimeMillis()));
    FileOutputFormat.setOutputPath(job, new Path(args[1] + "/" + timeStamp));
    

提交回复
热议问题