Hey guys

Is there a way to dynamically change the input dir and outputdir

I have the following CONSTANT directories in HDFS

  *   /path/to/input/9999-99-99 (empty directory )
  *   /path/to/output/9999-99-99 (empty directory)

A new directory with yesterdays date like /path/to/input/2013-05-23 gets 
created every day

I set the job params
mapreduce.input.fileinputformat.inputdir=/path/to/input/9999-99-99
mapreduce.output.fileoutputformat.outputdir=/path/to/output/9999-99-99

But in my Mapper I thought I can sneak in this code….But it does not work ?


    protected void setup(Context context)

            throws IOException,

                   InterruptedException{

     org.apache.hadoop.conf.Configuration hadoopConf = 
((JobContext)context).getConfiguration();

    String inputDir = 
hadoopConf.get("mapreduce.input.fileinputformat.inputdir");

    String outputDir = 
hadoopConf.get("mapreduce.output.fileoutputformat.outputdir");

    String yesterdaysDate =DateUtils.getDayYYYYMMDD("-", -1);

    String inputDirUseThis = inputDir.replaceAll("9999-99-99", yesterdaysDate);

    String outputDirUseThis = inputDir.replaceAll("9999-99-99", yesterdaysDate);

    hadoopConf.set("mapreduce.input.fileinputformat.inputdir",inputDirUseThis);

    
hadoopConf.set("mapreduce.output.fileoutputformat.outputdir",outputDirUseThis);

    }

Thanks

sanjay


CONFIDENTIALITY NOTICE
======================
This email message and any attachments are for the exclusive use of the 
intended recipient(s) and may contain confidential and privileged information. 
Any unauthorized review, use, disclosure or distribution is prohibited. If you 
are not the intended recipient, please contact the sender by reply email and 
destroy all copies of the original message along with any attachments, from 
your computer system. If you are the intended recipient, please be advised that 
the content of this message is subject to access, review and disclosure by the 
sender's Email System Administrator.

Reply via email to