public static List<TargetInfo> parseOptTarget(CommandLine cmd, AlluxioConfiguration conf)
      throws IOException {
    String[] targets;
    if (cmd.hasOption(TARGET_OPTION_NAME)) {
      String argTarget = cmd.getOptionValue(TARGET_OPTION_NAME);
      if (StringUtils.isBlank(argTarget)) {
        throw new IOException("Option " + TARGET_OPTION_NAME + " can not be blank.");
      } else if (argTarget.contains(TARGET_SEPARATOR)) {
        targets = argTarget.split(TARGET_SEPARATOR);
      } else {
        targets = new String[]{argTarget};
      }
    } else {
      // By default we set on all targets (master/workers/job_master/job_workers)
      targets = new String[]{ROLE_MASTER, ROLE_JOB_MASTER, ROLE_WORKERS, ROLE_JOB_WORKERS};
    }
    return getTargetInfos(targets, conf);
  }
@Test
  public void parsetManualTargets() throws Exception {
    // Successfully guess all targets
    // One extra comma at the end
    // Some extra whitespace
    String allTargets = "masters-1:" + MASTER_WEB_PORT + " ,masters-2:" + JOB_MASTER_WEB_PORT
        + " ,\tworkers-1:" + WORKER_WEB_PORT + ",workers-2:" + WORKER_WEB_PORT
        + ",workers-3:" + JOB_WORKER_WEB_PORT + ",workers-4:" + JOB_WORKER_WEB_PORT + ", ";

    CommandLine mockCommandLine = mock(CommandLine.class);
    String[] mockArgs = new String[]{"--target", allTargets};
    when(mockCommandLine.getArgs()).thenReturn(mockArgs);
    when(mockCommandLine.hasOption(LogLevel.TARGET_OPTION_NAME)).thenReturn(true);
    when(mockCommandLine.getOptionValue(LogLevel.TARGET_OPTION_NAME)).thenReturn(mockArgs[1]);

    List<LogLevel.TargetInfo> targets = LogLevel.parseOptTarget(mockCommandLine, mConf);
    assertEquals(6, targets.size());
    assertEquals(new HashSet<>(Arrays.asList(
            new LogLevel.TargetInfo("masters-1", MASTER_WEB_PORT, "master"),
            new LogLevel.TargetInfo("masters-2", JOB_MASTER_WEB_PORT, "job_master"),
            new LogLevel.TargetInfo("workers-1", WORKER_WEB_PORT, "worker"),
            new LogLevel.TargetInfo("workers-2", WORKER_WEB_PORT, "worker"),
            new LogLevel.TargetInfo("workers-3", JOB_WORKER_WEB_PORT, "job_worker"),
            new LogLevel.TargetInfo("workers-4", JOB_WORKER_WEB_PORT, "job_worker"))),
        new HashSet<>(targets));
  }