Ejemplo n.º 1
0
  @Override
  public int run(String[] args) throws Exception {
    // TODO Auto-generated method stub
    Configuration conf = getConf();
    Job job = new Job(conf, "2_coredate_onoffline_user");
    job.setJarByClass(OnoffLineUserCompute.class);
    job.getConfiguration()
        .set(ConstantEnum.DM_MOBILE_PLATY_FILEPATH.name(), "conf/dm_mobile_platy");

    job.getConfiguration()
        .set(ConstantEnum.DM_MOBILE_QUDAO_FILEPATH.name(), "conf/dm_mobile_qudao");
    job.getConfiguration().set("type", args[2]);
    for (String path : args[0].split(",")) {
      FileInputFormat.addInputPath(job, new Path(path));
    }
    HdfsUtil.deleteDir(args[1]);

    FileOutputFormat.setOutputPath(job, new Path(args[1]));
    job.setMapperClass(UserComputeMapper.class);
    job.setReducerClass(UserComputeReducer.class);
    job.setNumReduceTasks(10);
    job.setOutputKeyClass(Text.class);
    job.setOutputValueClass(Text.class);
    System.exit(job.waitForCompletion(true) ? 0 : 1);
    return 0;
  }
Ejemplo n.º 2
0
 @Override
 protected void setup(Context context) throws IOException, InterruptedException {
   type = context.getConfiguration().get("type");
   FileSplit fileSplit = (FileSplit) context.getInputSplit();
   filePath = fileSplit.getPath();
   dmPlatyRuleDAO = new DMPlatyRuleDAOImpl<String, Integer>();
   dmQuDaoRuleDAO = new DMQuDaoRuleDAOImpl<Integer, Integer>();
   if (isLocalRunMode(context)) {
     String dmMobilePlayFilePath =
         context.getConfiguration().get(ConstantEnum.DM_MOBILE_PLATY_FILEPATH.name());
     dmPlatyRuleDAO.parseDMObj(new File(dmMobilePlayFilePath));
     String dmQuodaoFilePath =
         context.getConfiguration().get(ConstantEnum.DM_MOBILE_QUDAO_FILEPATH.name());
     dmQuDaoRuleDAO.parseDMObj(new File(dmQuodaoFilePath));
   } else {
     File dmMobilePlayFile = new File(ConstantEnum.DM_MOBILE_PLATY.name().toLowerCase());
     dmPlatyRuleDAO.parseDMObj(dmMobilePlayFile);
     dmQuDaoRuleDAO.parseDMObj(new File(ConstantEnum.DM_MOBILE_QUDAO.name().toLowerCase()));
   }
 }