Class Command
java.lang.Object
org.apache.hadoop.conf.Configured
org.apache.hadoop.hdfs.server.diskbalancer.command.Command
- All Implemented Interfaces:
Closeable,AutoCloseable,org.apache.hadoop.conf.Configurable
- Direct Known Subclasses:
CancelCommand,ExecuteCommand,HelpCommand,PlanCommand,QueryCommand,ReportCommand
Common interface for command handling.
-
Constructor Summary
ConstructorsConstructorDescriptionCommand(org.apache.hadoop.conf.Configuration conf) Constructs a command.Command(org.apache.hadoop.conf.Configuration conf, PrintStream ps) Constructs a command. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddValidCommandParameters(String key, String desc) Adds valid params to the valid args table.voidclose()Cleans any resources held by this command.protected org.apache.hadoop.fs.FSDataOutputStreamReturns a file created in the cluster.abstract voidexecute(org.apache.commons.cli.CommandLine cmd) Executes the Client Calls.Gets cluster URL.org.apache.hadoop.hdfs.protocol.ClientDatanodeProtocolgetDataNodeProxy(String datanode) Copied from DFSAdmin.java. -- Creates a connection to dataNode.protected intreturns default top number of nodes.getNodeList(String listArg) Gets the node set from a file or a string.protected List<DiskBalancerDataNode>Returns a DiskBalancer Node list from the Cluster or null if not found.protected org.apache.hadoop.fs.PathReturns the output path where the plan and snapshot gets written.intGet top number of nodes to be processed.protected org.apache.hadoop.fs.FSDataInputStreamReturns a InputStream to read data.protected intparseTopNodes(org.apache.commons.cli.CommandLine cmd, org.apache.commons.text.TextStringBuilder result) Parse top number of nodes to be processed.protected voidReads the Physical path of the disks we are balancing.abstract voidGets extended help for this command.protected DiskBalancerClusterreadClusterInfo(org.apache.commons.cli.CommandLine cmd) Process the URI and return the cluster with nodes setup.protected voidrecordOutput(org.apache.commons.text.TextStringBuilder result, String outputLine) Put output line to log and string buffer.voidsetCluster(DiskBalancerCluster newCluster) Set DiskBalancer clustervoidsetClusterURI(URI clusterURI) Set cluster URL.protected voidSets the list of Nodes to process.protected voidSets the nodes to process.protected voidsetOutputPath(String path) Setup the outpath.voidsetTopNodes(int topNodes) Set top number of nodes to be processed.protected voidverifyCommandOptions(String commandName, org.apache.commons.cli.CommandLine cmd) Verifies if the command line options are sane.Methods inherited from class org.apache.hadoop.conf.Configured
getConf, setConf
-
Constructor Details
-
Command
public Command(org.apache.hadoop.conf.Configuration conf) Constructs a command. -
Command
Constructs a command.
-
-
Method Details
-
close
Cleans any resources held by this command.The main goal is to delete id file created in
.NameNodeConnector#checkAndMarkRunning, otherwise, it's not allowed to run multiple commands in a row.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
execute
Executes the Client Calls.- Parameters:
cmd- - CommandLine- Throws:
Exception
-
printHelp
public abstract void printHelp()Gets extended help for this command. -
readClusterInfo
protected DiskBalancerCluster readClusterInfo(org.apache.commons.cli.CommandLine cmd) throws Exception Process the URI and return the cluster with nodes setup. This is used in all commands.- Parameters:
cmd- - CommandLine- Returns:
- DiskBalancerCluster
- Throws:
Exception
-
setOutputPath
Setup the outpath.- Parameters:
path- - Path or null to use default path.- Throws:
IOException
-
setNodesToProcess
Sets the nodes to process.- Parameters:
node- - Node
-
setNodesToProcess
Sets the list of Nodes to process.- Parameters:
nodes- Nodes.
-
getNodeList
Gets the node set from a file or a string.- Parameters:
listArg- - String File URL or a comma separated list of node names.- Returns:
- Set of node names
- Throws:
IOException
-
getNodes
Returns a DiskBalancer Node list from the Cluster or null if not found.- Parameters:
listArg- String File URL or a comma separated list of node names.- Returns:
- List of DiskBalancer Node
- Throws:
IOException
-
verifyCommandOptions
Verifies if the command line options are sane.- Parameters:
commandName- - Name of the commandcmd- - Parsed Command Line
-
getClusterURI
Gets cluster URL.- Returns:
- - URL
-
setClusterURI
Set cluster URL.- Parameters:
clusterURI- - URL
-
getDataNodeProxy
public org.apache.hadoop.hdfs.protocol.ClientDatanodeProtocol getDataNodeProxy(String datanode) throws IOException Copied from DFSAdmin.java. -- Creates a connection to dataNode.- Parameters:
datanode- - dataNode.- Returns:
- ClientDataNodeProtocol
- Throws:
IOException
-
create
Returns a file created in the cluster.- Parameters:
fileName- - fileName to open.- Returns:
- OutputStream.
- Throws:
IOException
-
open
Returns a InputStream to read data.- Throws:
IOException
-
getOutputPath
protected org.apache.hadoop.fs.Path getOutputPath()Returns the output path where the plan and snapshot gets written.- Returns:
- Path
-
addValidCommandParameters
Adds valid params to the valid args table.- Parameters:
key-desc-
-
getDefaultTop
protected int getDefaultTop()returns default top number of nodes.- Returns:
- default top number of nodes.
-
recordOutput
Put output line to log and string buffer. -
parseTopNodes
protected int parseTopNodes(org.apache.commons.cli.CommandLine cmd, org.apache.commons.text.TextStringBuilder result) throws IllegalArgumentException Parse top number of nodes to be processed.- Returns:
- top number of nodes to be processed.
- Throws:
IllegalArgumentException
-
populatePathNames
Reads the Physical path of the disks we are balancing. This is needed to make the disk balancer human friendly and not used in balancing.- Parameters:
node- - Disk Balancer Node.- Throws:
IOException
-
setTopNodes
public void setTopNodes(int topNodes) Set top number of nodes to be processed. -
getTopNodes
public int getTopNodes()Get top number of nodes to be processed.- Returns:
- top number of nodes to be processed.
-
setCluster
Set DiskBalancer cluster
-