public abstract class Command extends org.apache.hadoop.conf.Configured implements Closeable
| Constructor and Description | 
|---|
| Command(org.apache.hadoop.conf.Configuration conf)Constructs a command. | 
| Command(org.apache.hadoop.conf.Configuration conf,
       PrintStream ps)Constructs a command. | 
| Modifier and Type | Method and Description | 
|---|---|
| protected void | addValidCommandParameters(String key,
                         String desc)Adds valid params to the valid args table. | 
| void | close()Cleans any resources held by this command. | 
| protected org.apache.hadoop.fs.FSDataOutputStream | create(String fileName)Returns a file created in the cluster. | 
| abstract void | execute(org.apache.commons.cli.CommandLine cmd)Executes the Client Calls. | 
| URI | getClusterURI()Gets cluster URL. | 
| org.apache.hadoop.hdfs.protocol.ClientDatanodeProtocol | getDataNodeProxy(String datanode)Copied from DFSAdmin.java. | 
| protected int | getDefaultTop()returns default top number of nodes. | 
| protected Set<String> | getNodeList(String listArg)Gets the node set from a file or a string. | 
| protected List<DiskBalancerDataNode> | getNodes(String listArg)Returns a DiskBalancer Node list from the Cluster or null if not found. | 
| protected org.apache.hadoop.fs.Path | getOutputPath()Returns the output path where the plan and snapshot gets written. | 
| int | getTopNodes()Get top number of nodes to be processed. | 
| protected org.apache.hadoop.fs.FSDataInputStream | open(String fileName)Returns a InputStream to read data. | 
| protected int | parseTopNodes(org.apache.commons.cli.CommandLine cmd,
             org.apache.commons.text.TextStringBuilder result)Parse top number of nodes to be processed. | 
| protected void | populatePathNames(DiskBalancerDataNode node)Reads the Physical path of the disks we are balancing. | 
| abstract void | printHelp()Gets extended help for this command. | 
| protected DiskBalancerCluster | readClusterInfo(org.apache.commons.cli.CommandLine cmd)Process the URI and return the cluster with nodes setup. | 
| protected void | recordOutput(org.apache.commons.text.TextStringBuilder result,
            String outputLine)Put output line to log and string buffer. | 
| void | setCluster(DiskBalancerCluster newCluster)Set DiskBalancer cluster | 
| void | setClusterURI(URI clusterURI)Set cluster URL. | 
| protected void | setNodesToProcess(DiskBalancerDataNode node)Sets the nodes to process. | 
| protected void | setNodesToProcess(List<DiskBalancerDataNode> nodes)Sets the list of Nodes to process. | 
| protected void | setOutputPath(String path)Setup the outpath. | 
| void | setTopNodes(int topNodes)Set top number of nodes to be processed. | 
| protected void | verifyCommandOptions(String commandName,
                    org.apache.commons.cli.CommandLine cmd)Verifies if the command line options are sane. | 
public Command(org.apache.hadoop.conf.Configuration conf)
public Command(org.apache.hadoop.conf.Configuration conf,
               PrintStream ps)
public void close()
           throws IOException
 The main goal is to delete id file created in
 .NameNodeConnector#checkAndMarkRunning
 , otherwise, it's not allowed to run multiple commands in a row.
 
close in interface Closeableclose in interface AutoCloseableIOExceptionpublic abstract void execute(org.apache.commons.cli.CommandLine cmd)
                      throws Exception
cmd - - CommandLineExceptionpublic abstract void printHelp()
protected DiskBalancerCluster readClusterInfo(org.apache.commons.cli.CommandLine cmd) throws Exception
cmd - - CommandLineExceptionprotected void setOutputPath(String path) throws IOException
path - - Path or null to use default path.IOExceptionprotected void setNodesToProcess(DiskBalancerDataNode node)
node - - Nodeprotected void setNodesToProcess(List<DiskBalancerDataNode> nodes)
nodes - Nodes.protected Set<String> getNodeList(String listArg) throws IOException
listArg - - String File URL or a comma separated list of node names.IOExceptionprotected List<DiskBalancerDataNode> getNodes(String listArg) throws IOException
listArg - String File URL or a comma separated list of node names.IOExceptionprotected void verifyCommandOptions(String commandName, org.apache.commons.cli.CommandLine cmd)
commandName - - Name of the commandcmd - - Parsed Command Linepublic URI getClusterURI()
public void setClusterURI(URI clusterURI)
clusterURI - - URLpublic org.apache.hadoop.hdfs.protocol.ClientDatanodeProtocol getDataNodeProxy(String datanode) throws IOException
datanode - - dataNode.IOExceptionprotected org.apache.hadoop.fs.FSDataOutputStream create(String fileName) throws IOException
fileName - - fileName to open.IOExceptionprotected org.apache.hadoop.fs.FSDataInputStream open(String fileName) throws IOException
IOExceptionprotected org.apache.hadoop.fs.Path getOutputPath()
protected void addValidCommandParameters(String key, String desc)
key - desc - protected int getDefaultTop()
protected void recordOutput(org.apache.commons.text.TextStringBuilder result,
                            String outputLine)
protected int parseTopNodes(org.apache.commons.cli.CommandLine cmd,
                            org.apache.commons.text.TextStringBuilder result)
                     throws IllegalArgumentException
IllegalArgumentExceptionprotected void populatePathNames(DiskBalancerDataNode node) throws IOException
node - - Disk Balancer Node.IOExceptionpublic void setTopNodes(int topNodes)
public int getTopNodes()
public void setCluster(DiskBalancerCluster newCluster)
Copyright © 2008–2023 Apache Software Foundation. All rights reserved.