private void verifyParity(String[] args, int startIndex) {
    boolean restoreReplication = false;
    int repl = -1;
    Path root = null;
    for (int i = startIndex; i < args.length; i++) {
      String arg = args[i];
      if (arg.equals("-restore")) {
        restoreReplication = true;
      } else if (arg.equals("-repl")){
        i++;
        if (i >= args.length) {
          throw new IllegalArgumentException("Missing repl after -r option");
        }
        repl = Integer.parseInt(args[i]);
      } else {
        root = new Path(arg);
      }
    }
    if (root == null) {
      throw new IllegalArgumentException("Too few arguments");
    }
    if (repl == -1) {
      throw new IllegalArgumentException("Need to specify -r option");
    }
    if (repl < 1 || repl > 3) {
      throw new IllegalArgumentException("repl could only in the range [1, 3]");
    }
    Codec matched = null;
    String rootPath = root.toUri().getPath();
    if (!rootPath.endsWith(Path.SEPARATOR)) {
      rootPath += Path.SEPARATOR;
    }
    for (Codec code : Codec.getCodecs()) {
      if (rootPath.startsWith(code.getParityPrefix())) {
        matched = code;
        break;
      }
    }
    if (matched == null) {
      throw new IllegalArgumentException(
          "root needs to starts with parity dirs");
    }
    try {
      FileSystem fs = root.getFileSystem(conf);
      // Make sure default uri is the same as root  
      conf.set(FileSystem.FS_DEFAULT_NAME_KEY, fs.getUri().toString());
      ParityVerifier pv = new ParityVerifier(conf, restoreReplication, 
          repl, matched);
      pv.verifyParities(root, System.out);
    } catch (IOException ex) {
      System.err.println("findMissingParityFiles: " + ex);
    }
  }
private void verifyParity ( String [ ] args , int startIndex ) { boolean restoreReplication = false ; int repl = - 1 ; Path root = null ; for ( int i = startIndex ; i < args . length ; i ++ ) { String arg = args [ i ] ; if ( arg . equals ( "-restore" ) ) { restoreReplication = true ; } else if ( arg . equals ( "-repl" ) ) { i ++ ; if ( i >= args . length ) { throw new IllegalArgumentException ( "Missing repl after -r option" ) ; } repl = Integer . parseInt ( args [ i ] ) ; } else { root = new Path ( arg ) ; } } if ( root == null ) { throw new IllegalArgumentException ( "Too few arguments" ) ; } if ( repl == - 1 ) { throw new IllegalArgumentException ( "Need to specify -r option" ) ; } if ( repl < 1 || repl > 3 ) { throw new IllegalArgumentException ( "repl could only in the range [1, 3]" ) ; } Codec matched = null ; String rootPath = root . toUri ( ) . getPath ( ) ; if ( ! rootPath . endsWith ( Path . SEPARATOR ) ) { rootPath += Path . SEPARATOR ; } for ( Codec code : Codec . getCodecs ( ) ) { if ( rootPath . startsWith ( code . getParityPrefix ( ) ) ) { matched = code ; break ; } } if ( matched == null ) { throw new IllegalArgumentException ( "root needs to starts with parity dirs" ) ; } try { FileSystem fs = root . getFileSystem ( conf ) ; conf . set ( FileSystem . FS_DEFAULT_NAME_KEY , fs . getUri ( ) . toString ( ) ) ; ParityVerifier pv = new ParityVerifier ( conf , restoreReplication , repl , matched ) ; pv . verifyParities ( root , System . out ) ; } catch ( IOException ex ) { System . err . println ( "findMissingParityFiles: " + ex ) ; } }
search each parity and verify the source files have
the expected replication