Пример #1
0
 private int runJob(Configuration conf, String[] argv) throws IOException, InterruptedException {
   if (argv.length < 2) {
     printUsage(System.err);
     return 1;
   }
   long genbytes = -1L;
   String traceIn = null;
   Path ioPath = null;
   URI userRsrc = null;
   userResolver =
       ReflectionUtils.newInstance(
           conf.getClass(GRIDMIX_USR_RSV, SubmitterUserResolver.class, UserResolver.class), conf);
   try {
     for (int i = 0; i < argv.length - 2; ++i) {
       if ("-generate".equals(argv[i])) {
         genbytes = StringUtils.TraditionalBinaryPrefix.string2long(argv[++i]);
       } else if ("-users".equals(argv[i])) {
         userRsrc = new URI(argv[++i]);
       } else {
         printUsage(System.err);
         return 1;
       }
     }
     if (!userResolver.setTargetUsers(userRsrc, conf)) {
       LOG.warn("Resource " + userRsrc + " ignored");
     }
     ioPath = new Path(argv[argv.length - 2]);
     traceIn = argv[argv.length - 1];
   } catch (Exception e) {
     e.printStackTrace();
     printUsage(System.err);
     return 1;
   }
   return start(conf, traceIn, ioPath, genbytes, userResolver);
 }
Пример #2
0
  private int runJob(Configuration conf, String[] argv) throws IOException, InterruptedException {
    if (argv.length < 2) {
      printUsage(System.err);
      return 1;
    }

    // Should gridmix generate distributed cache data ?
    boolean generate = false;
    long genbytes = -1L;
    String traceIn = null;
    Path ioPath = null;
    URI userRsrc = null;
    userResolver =
        ReflectionUtils.newInstance(
            conf.getClass(GRIDMIX_USR_RSV, SubmitterUserResolver.class, UserResolver.class), conf);
    try {
      for (int i = 0; i < argv.length - 2; ++i) {
        if ("-generate".equals(argv[i])) {
          genbytes = StringUtils.TraditionalBinaryPrefix.string2long(argv[++i]);
          generate = true;
        } else if ("-users".equals(argv[i])) {
          userRsrc = new URI(argv[++i]);
        } else {
          printUsage(System.err);
          return 1;
        }
      }

      if (userResolver.needsTargetUsersList()) {
        if (userRsrc != null) {
          if (!userResolver.setTargetUsers(userRsrc, conf)) {
            LOG.warn("Ignoring the user resource '" + userRsrc + "'.");
          }
        } else {
          System.err.println(
              "\n\n"
                  + userResolver.getClass()
                  + " needs target user list. Use -users option."
                  + "\n\n");
          printUsage(System.err);
          return 1;
        }
      } else if (userRsrc != null) {
        LOG.warn("Ignoring the user resource '" + userRsrc + "'.");
      }

      ioPath = new Path(argv[argv.length - 2]);
      traceIn = argv[argv.length - 1];
    } catch (Exception e) {
      e.printStackTrace();
      printUsage(System.err);
      return 1;
    }
    return start(conf, traceIn, ioPath, genbytes, userResolver, generate);
  }