@Override
    public int run(String[] args) throws Exception {
        
        // Create the job specification object
        Job job = new Job(getConf());
        job.setJarByClass(MostVisitedSite.class);
        job.setJobName(this.getClass().getName());
        outRootPath = job.getWorkingDirectory().toString();
 
        String year = null, month = null, day = null;

        if (dev)
        {
            year = "2013";
            month = "11";
            day = "05";
        }
        else
        {
            if (args.length == 3 || args.length == 4)
            {
                year = args[0];
                month = args[1];
                day = args[2];
                if ( args.length == 4)
                {
                    outRootPath = args[3];
                }
            }
            else
            {
                throw new Exception("Bad arguments");
            }
        }

        // Setup input and output paths
        String p = resPath(year + month + day);
        FileInputFormat.setInputPaths(job, p);

        Path outFilesPath = new Path(outRootPath + "/mes_vista_" + year + "-" + month + "-" + day);

        // Delete and create if exist
        FileSystem.get(new Configuration()).delete(outFilesPath, true);
        FileOutputFormat.setOutputPath(job, outFilesPath);

        // Set the Mapper and Reducer classes
        job.setMapperClass(MyMap.class);
        job.setReducerClass(MyRed.class);

        job.setMapOutputKeyClass(Text.class);
        job.setMapOutputValueClass(IntWritable.class);

        // Specify the type of output keys and values
        job.setOutputKeyClass(Text.class);
        job.setOutputValueClass(IntWritable.class);

        boolean success = job.waitForCompletion(true);
        return success ? 0 : 1;
    }