Example usage for org.apache.hadoop.fs.shell Command run

List of usage examples for org.apache.hadoop.fs.shell Command run

Introduction

In this page you can find the example usage for org.apache.hadoop.fs.shell Command run.

Prototype

public int run(String... argv) 

Source Link

Document

Invokes the command handler.

Usage

From source file:com.ruizhan.hadoop.hdfs.FsShell.java

License:Apache License

/**
 * run//from   www  . ja v  a2 s  . co  m
 */
public int run(String argv[]) throws Exception {
    // initialize FsShell
    init();

    int exitCode = -1;
    if (argv.length < 1) {
        printUsage(System.err);
    } else {
        String cmd = argv[0];
        Command instance = null;
        try {
            instance = commandFactory.getInstance(cmd);
            if (instance == null) {
                throw new UnknownCommandException();
            }
            exitCode = instance.run(Arrays.copyOfRange(argv, 1, argv.length));
        } catch (IllegalArgumentException e) {
            displayError(cmd, e.getLocalizedMessage());
            if (instance != null) {
                printInstanceUsage(System.err, instance);
            }
        } catch (Exception e) {
            // instance.run catches IOE, so something is REALLY wrong if here
            LOG.debug("Error", e);
            displayError(cmd, "Fatal internal error");
            e.printStackTrace(System.err);
        }
    }
    return exitCode;
}