private int processArgs(String[] argv) throws Exception {

    if (argv.length < 1) {
      printUsage("");
      return -1;
    }

    int exitCode = -1;
    int i = 0;
    String cmd = argv[i++];

    //
    // verify that we have enough command line parameters
    //
    if ("-geteditsize".equals(cmd)) {
      if (argv.length != 1) {
        printUsage(cmd);
        return exitCode;
      }
    } else if ("-checkpoint".equals(cmd)) {
      if (argv.length != 1 && argv.length != 2) {
        printUsage(cmd);
        return exitCode;
      }
      if (argv.length == 2 && !"force".equals(argv[i])) {
        printUsage(cmd);
        return exitCode;
      }
    }

    exitCode = 0;
    try {
      if ("-checkpoint".equals(cmd)) {
        long uncheckpointedTxns = countUncheckpointedTxns();
        if (countUncheckpointedTxns() >= checkpointTxnCount || 
            argv.length == 2 && "force".equals(argv[i])) {
          doCheckpoint();
        } else {
          LOG.info("EditLog uncheckpointed transactions " + uncheckpointedTxns
              + "smaller than configured checkpoint size of "
              + checkpointTxnCount + " transactions.");
          LOG.info("Skipping checkpoint based on transaction count.");

        }
      } else if ("-geteditsize".equals(cmd)) {
        long uncheckpointedTxns = countUncheckpointedTxns();
        System.out.println("EditLog size is " + uncheckpointedTxns + " transactions");
      } else {
        exitCode = -1;
        LOG.error(cmd.substring(1) + ": Unknown command");
        printUsage("");
      }
    } catch (RemoteException e) {
      //
      // This is a error returned by hadoop server. Print
      // out the first line of the error mesage, ignore the stack trace.
      exitCode = -1;
      try {
        String[] content;
        content = e.getLocalizedMessage().split("\n");
        LOG.error(cmd.substring(1) + ": "
                  + content[0]);
      } catch (Exception ex) {
        LOG.error(cmd.substring(1) + ": "
                  + ex.getLocalizedMessage());
      }
    } catch (IOException e) {
      //
      // IO exception encountered locally.
      //
      exitCode = -1;
      LOG.error(cmd.substring(1) + ": "
                + e.getLocalizedMessage());
    } finally {
      // Does the RPC connection need to be closed?
    }
    return exitCode;
  }
private int processArgs ( String [ ] argv ) throws Exception { if ( argv . length < 1 ) { printUsage ( "" ) ; return - 1 ; } int exitCode = - 1 ; int i = 0 ; String cmd = argv [ i ++ ] ; if ( "-geteditsize" . equals ( cmd ) ) { if ( argv . length != 1 ) { printUsage ( cmd ) ; return exitCode ; } } else if ( "-checkpoint" . equals ( cmd ) ) { if ( argv . length != 1 && argv . length != 2 ) { printUsage ( cmd ) ; return exitCode ; } if ( argv . length == 2 && ! "force" . equals ( argv [ i ] ) ) { printUsage ( cmd ) ; return exitCode ; } } exitCode = 0 ; try { if ( "-checkpoint" . equals ( cmd ) ) { long uncheckpointedTxns = countUncheckpointedTxns ( ) ; if ( countUncheckpointedTxns ( ) >= checkpointTxnCount || argv . length == 2 && "force" . equals ( argv [ i ] ) ) { doCheckpoint ( ) ; } else { LOG . info ( "EditLog uncheckpointed transactions " + uncheckpointedTxns + "smaller than configured checkpoint size of " + checkpointTxnCount + " transactions." ) ; LOG . info ( "Skipping checkpoint based on transaction count." ) ; } } else if ( "-geteditsize" . equals ( cmd ) ) { long uncheckpointedTxns = countUncheckpointedTxns ( ) ; System . out . println ( "EditLog size is " + uncheckpointedTxns + " transactions" ) ; } else { exitCode = - 1 ; LOG . error ( cmd . substring ( 1 ) + ": Unknown command" ) ; printUsage ( "" ) ; } } catch ( RemoteException e ) { exitCode = - 1 ; try { String [ ] content ; content = e . getLocalizedMessage ( ) . split ( "\n" ) ; LOG . error ( cmd . substring ( 1 ) + ": " + content [ 0 ] ) ; } catch ( Exception ex ) { LOG . error ( cmd . substring ( 1 ) + ": " + ex . getLocalizedMessage ( ) ) ; } } catch ( IOException e ) { exitCode = - 1 ; LOG . error ( cmd . substring ( 1 ) + ": " + e . getLocalizedMessage ( ) ) ; } finally { } return exitCode ; }
@param argv The parameters passed to this program.
@exception Exception if the filesystem does not exist.
@return 0 on success, non zero on error.