protected String[] getInputPath(String[] args) {
    // String[] input = new String[]{HadoopTable.atpanel(args[0])};

    String[] input =
        new String[] {"/group/tbdev/xiaodu/suoni/user_view_muli_host_setp_two/" + args[0]};
    if (args.length > 1 && "false".equals(args[1])) {
      input =
          new String[] {"/group/tbdev/xiaodu/suoni/user_view_muli_host_setp_two_all/" + args[0]};
    }
    System.out.println("input path => " + Utils.asString(input));
    return input;
  }
  public int run(String[] args) throws Exception {
    if (args.length < 1) {
      args = new String[] {DateStringUtils.now()};
      System.out.println(
          "ERROR: Please Enter Date , eg. 20101010 ! now use default => " + DateStringUtils.now());
    }

    JobConf config = new JobConf(getConf(), getClass());
    config.set("user.args", Utils.asString(args));

    config.setJobName(getClass() + "-" + System.currentTimeMillis());
    config.setNumReduceTasks(100);
    config.setMapperClass(getClass());
    config.setReducerClass(getClass());
    config.setInputFormat(getInputFormat());
    config.setMapOutputKeyClass(Text.class);
    config.setMapOutputValueClass(Text.class);

    // add input paths
    for (String path : getInputPath(args)) {
      if (TextInputFormat.class.equals(getInputFormat())) {
        TextInputFormat.addInputPath(config, new Path(path));
      } else if (SequenceFileInputFormat.class.equals(getInputFormat())) {
        SequenceFileInputFormat.addInputPath(config, new Path(path));
      }
    }

    config.setOutputKeyClass(Text.class);
    config.setOutputValueClass(Text.class);

    // if output path exists then return
    FileSystem fs = FileSystem.get(config);
    Path outputPath = new Path(getOutputPath(args));
    FileOutputFormat.setOutputPath(config, outputPath);

    if (!fs.exists(outputPath)) {
      JobClient.runJob(config);
    } else {
      System.out.println("You has finished this job today ! " + outputPath);
    }

    return JobClient.SUCCESS;
  }
Example #3
0
 @Override
 protected String[] getInputPath(String[] args) {
   String[] input = HadoopTable.orderDelta(args[0]).getInputPath();
   System.out.println("input path => " + Utils.asString(input));
   return input;
 }