Exemple #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);
 }
 /** Constructor */
 SetSpaceQuotaCommand(String[] args, int pos, FileSystem fs) {
   super(fs);
   CommandFormat c = new CommandFormat(NAME, 2, Integer.MAX_VALUE);
   List<String> parameters = c.parse(args, pos);
   String str = parameters.remove(0).trim();
   quota = StringUtils.TraditionalBinaryPrefix.string2long(str);
   this.args = parameters.toArray(new String[parameters.size()]);
 }
Exemple #3
0
 private long parseLong(String[] args, int offset) {
   if (offset == args.length) {
     throw new IllegalArgumentException("<n> not specified in " + cmd);
   }
   long n = StringUtils.TraditionalBinaryPrefix.string2long(args[offset]);
   if (n <= 0) {
     throw new IllegalArgumentException("n = " + n + " <= 0 in " + cmd);
   }
   return n;
 }
Exemple #4
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);
  }