コード例 #1
0
ファイル: UserCompute.java プロジェクト: wisgood/mobile-core
 private String getPlat(String plat) {
   try {
     return String.valueOf(dmPlatyRuleDAO.getDMOjb(PlatTypeFormatUtil.getFormatPlatType(plat)));
   } catch (Exception e) {
     return null;
   }
 }
コード例 #2
0
    public void map(LongWritable key, Text value, Context context)
        throws IOException, InterruptedException {
      try {

        String line = value.toString();
        String sep = ",";
        if (filePath.toString().contains("offline")) {
          sep = "\t";
        }
        String[] fields = line.split(sep);
        // data
        String date = fields[BootStrap.TIMESTAMP.ordinal()];
        // mac
        String mac = null;
        // plat
        String plat = null;

        if (filePath.toString().contains("bootstrap")) {
          plat = fields[BootStrap.DEV.ordinal()];
          plat =
              String.valueOf(dmPlatyRuleDAO.getDMOjb(PlatTypeFormatUtil.getFormatPlatType(plat)));
          long versionId = IPFormatUtil.ip2long(fields[BootStrap.VER.ordinal()]);
          mac =
              FormatMobileUtil.getMac(
                  fields, Integer.parseInt(plat), versionId, BootStrap.class.getName());

        } else {
          plat = fields[Exit.DEV.ordinal()];
          plat =
              String.valueOf(dmPlatyRuleDAO.getDMOjb(PlatTypeFormatUtil.getFormatPlatType(plat)));
          long versionId = IPFormatUtil.ip2long(fields[Exit.VER.ordinal()]);
          mac =
              FormatMobileUtil.getMac(
                  fields, Integer.parseInt(plat), versionId, BootStrap.class.getName());
        }

        if ("0".equals(type)) {
          // 对于所有用户,只有iphone需要用到离线日志
          if (!"4".equals(plat)) {
            if (filePath.toString().contains("offline")) return;
          }

        } else if ("1".equals(type)) {
          // 计算在线用户
          if (filePath.toString().contains("bootstrap")) {
            if (!ntOK(fields[BootStrap.NT.ordinal()], "1")) return;
          } else {
            if (!ntOK(fields[Exit.NT.ordinal()], "1")) return;
          }
        } else if ("2".equals(type)) {

          // 对于所有用户,只有iphone需要用到离线日志
          if ("4".equals(plat)) {
            if (!filePath.toString().contains("offline")) return;
          } else {
            if (filePath.toString().contains("offline")) return;
          }

          // 计算离线用户
          if (filePath.toString().contains("bootstrap")) {
            if (!ntOK(fields[BootStrap.NT.ordinal()], "2")) return;
          } else {
            if (!ntOK(fields[Exit.NT.ordinal()], "2")) return;
          }
        }
        Map<ConstantEnum, String> formatTimesMap = TimestampFormatUtil.formatTimestamp(date);
        // dataId
        date = formatTimesMap.get(ConstantEnum.DATE_ID);
        context.write(new Text(date + "\t" + plat), new Text(mac));
      } catch (Exception e) {
        // TODO: handle exception
        e.printStackTrace();
        System.out.println(value.toString());
      }
    }