@Override
  public int run(String argv[]) throws Exception {
    if (argv.length < 1) {
      printUsage(null);
      return -1;
    }

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

    // verify that we have enough command line parameters
    if ("-create".equals(cmd)) {
      boolean error = true;
      if (argv.length == 2) {
        error = false;
      } else if (argv.length == 3) {
        if ("-ignoreleases".equals(argv[2])) {
          error = false;
        }
      }

      if (error) { 
        printUsage(cmd);
        return exitCode;
      }
    }
    else if ("-list".equals(cmd)) {
      if (argv.length != 1) {
        printUsage(cmd);
        return exitCode;
      }
    }
    else if ("-delete".equals(cmd)) {
      if (argv.length != 2) {
        printUsage(cmd);
        return exitCode;
      }
    }
    else {
      LOG.error(cmd.substring(1) + ": Unknown command");
      printUsage(null);
      return exitCode;
    }

    try {
      if ("-create".equals(cmd)) {
        exitCode = createSnapshot(argv[1], argv.length == 3);
      } else if ("-list".equals(cmd)) {
        exitCode = listSnapshots();
      } else if ("-delete".equals(cmd)) {
        exitCode = deleteSnapshot(argv[1]);
      }
    } 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());
    } catch (Exception e) {
      exitCode = -1;
      LOG.error(cmd.substring(1) + ": " + e.getLocalizedMessage());
    } finally {
      // Does the RPC connection need to be closed?
    }

    return exitCode;
  }
@ Override public int run ( String argv [ ] ) throws Exception { if ( argv . length < 1 ) { printUsage ( null ) ; return - 1 ; } int exitCode = - 1 ; int i = 0 ; String cmd = argv [ i ++ ] ; if ( "-create" . equals ( cmd ) ) { boolean error = true ; if ( argv . length == 2 ) { error = false ; } else if ( argv . length == 3 ) { if ( "-ignoreleases" . equals ( argv [ 2 ] ) ) { error = false ; } } if ( error ) { printUsage ( cmd ) ; return exitCode ; } } else if ( "-list" . equals ( cmd ) ) { if ( argv . length != 1 ) { printUsage ( cmd ) ; return exitCode ; } } else if ( "-delete" . equals ( cmd ) ) { if ( argv . length != 2 ) { printUsage ( cmd ) ; return exitCode ; } } else { LOG . error ( cmd . substring ( 1 ) + ": Unknown command" ) ; printUsage ( null ) ; return exitCode ; } try { if ( "-create" . equals ( cmd ) ) { exitCode = createSnapshot ( argv [ 1 ] , argv . length == 3 ) ; } else if ( "-list" . equals ( cmd ) ) { exitCode = listSnapshots ( ) ; } else if ( "-delete" . equals ( cmd ) ) { exitCode = deleteSnapshot ( argv [ 1 ] ) ; } } 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 ( ) ) ; } catch ( Exception e ) { exitCode = - 1 ; LOG . error ( cmd . substring ( 1 ) + ": " + e . getLocalizedMessage ( ) ) ; } finally { } return exitCode ; }
run