DFSAdmin (Apache Hadoop HDFS 3.5.0 API)
Description: declaration: package: org.apache.hadoop.hdfs.tools, class: DFSAdmin

Package org.apache.hadoop.hdfs.tools

# Class DFSAdmin

java.lang.Object
org.apache.hadoop.conf.Configured
org.apache.hadoop.fs.FsShell
org.apache.hadoop.hdfs.tools.DFSAdmin

All Implemented Interfaces:
  `org.apache.hadoop.conf.Configurable`, `org.apache.hadoop.util.Tool`

@Private public class DFSAdmin extends org.apache.hadoop.fs.FsShell
This class provides some DFS administrative access shell commands.

- ## Nested Class Summary

  ## Nested classes/interfaces inherited from class org.apache.hadoop.fs.FsShell

  `org.apache.hadoop.fs.FsShell.Help, org.apache.hadoop.fs.FsShell.Usage`

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final String[]`
  `DFS_REPORT_ARGS`

  ### Fields inherited from class org.apache.hadoop.fs.FsShell

  `commandFactory`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `DFSAdmin()`
  Construct a DFSAdmin object.
  `DFSAdmin(org.apache.hadoop.conf.Configuration conf)`
  Construct a DFSAdmin object.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `allowSnapshot(String[] argv)`
  Allow snapshot on a directory.
  `void`
  `disallowSnapshot(String[] argv)`
  Disallow snapshot on a directory.
  `int`
  `fetchImage(String[] argv, int idx)`
  Download the most recent fsimage from the name node, and save it to a local file in the given directory.
  `int`
  `finalizeUpgrade()`
  Command to ask the namenode to finalize previously performed upgrade.
  `int`
  `genericRefresh(String[] argv, int i)`
  `int`
  `getBalancerBandwidth(String[] argv, int idx)`
  Command to get balancer bandwidth for the given datanode.
  `protected org.apache.hadoop.hdfs.DistributedFileSystem`
  `getDFS()`
  `int`
  `getUpgradeStatus()`
  Command to get the upgrade status of each namenode in the nameservice.
  `int`
  `listOpenFiles(String[] argv)`
  Command to list all the open files currently managed by NameNode.
  `static void`
  `main(String[] argv)`
  main() has some simple utility methods.
  `int`
  `metaSave(String[] argv, int idx)`
  Dumps DFS data structures into specified file.
  `int`
  `printTopology()`
  Display each rack and the nodes assigned to that rack, as determined by the NameNode, in a hierarchical manner.
  `void`
  `provisionSnapshotTrash(String[] argv)`
  Provision trash root in a snapshottable directory.
  `int`
  `reconfig(String[] argv, int i)`
  `int`
  `refreshCallQueue()`
  `int`
  `refreshNodes()`
  Command to ask the namenode to reread the hosts and excluded hosts file.
  `int`
  `refreshServiceAcl()`
  Refresh the authorization policy on the `NameNode`.
  `int`
  `refreshSuperUserGroupsConfiguration()`
  refreshSuperUserGroupsConfiguration `NameNode`.
  `int`
  `refreshUserToGroupsMappings()`
  Refresh the user-to-groups mappings on the `NameNode`.
  `void`
  `report(String[] argv, int i)`
  Gives a report on how the FileSystem is doing.
  `int`
  `restoreFailedStorage(String arg)`
  Command to enable/disable/check restoring of failed storage replicas in the namenode.
  `int`
  `rollEdits()`
  `int`
  `run(String[] argv)`
  `int`
  `saveNamespace(String[] argv)`
  Command to ask the namenode to save the namespace.
  `int`
  `setBalancerBandwidth(String[] argv, int idx)`
  Command to ask the active namenode to set the balancer bandwidth.
  `void`
  `setSafeMode(String[] argv, int idx)`
  Safe mode maintenance command.
  `int`
  `triggerBlockReport(String[] argv)`
  `int`
  `upgrade(String arg)`
  Upgrade command to get the status of upgrade or ask NameNode to finalize the previously performed upgrade.

  ### Methods inherited from class org.apache.hadoop.fs.FsShell

  `close, getCurrentTrashDir, getCurrentTrashDir, getFS, getHelp, getTrash, getUsagePrefix, init, newShellInstance, registerCommands`

  ### Methods inherited from class org.apache.hadoop.conf.Configured

  `getConf, setConf`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

  ### Methods inherited from interface org.apache.hadoop.conf.Configurable

  `getConf, setConf`

- ## Field Details

  - ### DFS_REPORT_ARGS

    public static final String[] DFS_REPORT_ARGS

- ## Constructor Details

  - ### DFSAdmin

    public DFSAdmin()
    Construct a DFSAdmin object.

  - ### DFSAdmin

    public DFSAdmin(org.apache.hadoop.conf.Configuration conf)
    Construct a DFSAdmin object.

- ## Method Details

  - ### getDFS

    protected org.apache.hadoop.hdfs.DistributedFileSystem getDFS() throws IOException
    Throws:
      `IOException`

  - ### report

    public void report(String[] argv, int i) throws IOException
    Gives a report on how the FileSystem is doing.
    Throws:
      `IOException` - if the filesystem does not exist.

  - ### setSafeMode

    public void setSafeMode(String[] argv, int idx) throws IOException
    Safe mode maintenance command. Usage: hdfs dfsadmin -safemode [enter | leave | get | wait | forceExit]
    Parameters:
      `argv` - List of of command line parameters.
      `idx` - The index of the command that is being processed.
    Throws:
      `IOException` - if the filesystem does not exist.

  - ### triggerBlockReport

    public int triggerBlockReport(String[] argv) throws IOException
    Throws:
      `IOException`

  - ### allowSnapshot

    public void allowSnapshot(String[] argv) throws IOException
    Allow snapshot on a directory. Usage: hdfs dfsadmin -allowSnapshot snapshotDir
    Parameters:
      `argv` - List of of command line parameters.
    Throws:
      `IOException`

  - ### disallowSnapshot

    public void disallowSnapshot(String[] argv) throws IOException
    Disallow snapshot on a directory. Usage: hdfs dfsadmin -disallowSnapshot snapshotDir
    Parameters:
      `argv` - List of of command line parameters.
    Throws:
      `IOException`

  - ### provisionSnapshotTrash

    public void provisionSnapshotTrash(String[] argv) throws IOException
    Provision trash root in a snapshottable directory. Usage: hdfs dfsadmin -provisionSnapshotTrash snapshotDir hdfs dfsadmin -provisionSnapshotTrash -all
    Parameters:
      `argv` - List of of command line parameters.
    Throws:
      `IOException`

  - ### saveNamespace

    public int saveNamespace(String[] argv) throws IOException
    Command to ask the namenode to save the namespace. Usage: hdfs dfsadmin -saveNamespace
    Throws:
      `IOException`
    See Also:
      - `ClientProtocol.saveNamespace(long, long)`

  - ### rollEdits

    public int rollEdits() throws IOException
    Throws:
      `IOException`

  - ### restoreFailedStorage

    public int restoreFailedStorage(String arg) throws IOException
    Command to enable/disable/check restoring of failed storage replicas in the namenode. Usage: hdfs dfsadmin -restoreFailedStorage true|false|check
    Throws:
      `IOException`
    See Also:
      - `ClientProtocol.restoreFailedStorage(String arg)`

  - ### refreshNodes

    public int refreshNodes() throws IOException
    Command to ask the namenode to reread the hosts and excluded hosts file. Usage: hdfs dfsadmin -refreshNodes
    Throws:
      `IOException`

  - ### listOpenFiles

    public int listOpenFiles(String[] argv) throws IOException
    Command to list all the open files currently managed by NameNode. Usage: hdfs dfsadmin -listOpenFiles
    Parameters:
      `argv` -
    Throws:
      `IOException`

  - ### setBalancerBandwidth

    public int setBalancerBandwidth(String[] argv, int idx) throws IOException
    Command to ask the active namenode to set the balancer bandwidth. Usage: hdfs dfsadmin -setBalancerBandwidth bandwidth
    Parameters:
      `argv` - List of of command line parameters.
      `idx` - The index of the command that is being processed.
    Throws:
      `IOException`

  - ### getBalancerBandwidth

    public int getBalancerBandwidth(String[] argv, int idx) throws IOException
    Command to get balancer bandwidth for the given datanode. Usage: hdfs dfsadmin -getBalancerBandwidth <datanode_host:ipc_port>
    Parameters:
      `argv` - List of of command line parameters.
      `idx` - The index of the command that is being processed.
    Throws:
      `IOException`

  - ### fetchImage

    public int fetchImage(String[] argv, int idx) throws IOException
    Download the most recent fsimage from the name node, and save it to a local file in the given directory.
    Parameters:
      `argv` - List of of command line parameters.
      `idx` - The index of the command that is being processed.
    Returns:
      an exit code indicating success or failure.
    Throws:
      `IOException`

  - ### finalizeUpgrade

    public int finalizeUpgrade() throws IOException
    Command to ask the namenode to finalize previously performed upgrade. Usage: hdfs dfsadmin -finalizeUpgrade
    Throws:
      `IOException`

  - ### getUpgradeStatus

    public int getUpgradeStatus() throws IOException
    Command to get the upgrade status of each namenode in the nameservice. Usage: hdfs dfsadmin -upgrade query
    Throws:
      `IOException`

  - ### upgrade

    public int upgrade(String arg) throws IOException
    Upgrade command to get the status of upgrade or ask NameNode to finalize the previously performed upgrade. Usage: hdfs dfsadmin -upgrade [query | finalize]
    Throws:
      `IOException`

  - ### metaSave

    public int metaSave(String[] argv, int idx) throws IOException
    Dumps DFS data structures into specified file. Usage: hdfs dfsadmin -metasave filename
    Parameters:
      `argv` - List of of command line parameters.
      `idx` - The index of the command that is being processed.
    Throws:
      `IOException` - if an error occurred while accessing the file or path.

  - ### printTopology

    public int printTopology() throws IOException
    Display each rack and the nodes assigned to that rack, as determined by the NameNode, in a hierarchical manner. The nodes and racks are sorted alphabetically.
    Throws:
      `IOException` - If an error while getting datanode report

  - ### refreshServiceAcl

    public int refreshServiceAcl() throws IOException
    Refresh the authorization policy on the `NameNode`.
    Returns:
      exitcode 0 on success, non-zero on failure
    Throws:
      `IOException`

  - ### refreshUserToGroupsMappings

    public int refreshUserToGroupsMappings() throws IOException
    Refresh the user-to-groups mappings on the `NameNode`.
    Returns:
      exitcode 0 on success, non-zero on failure
    Throws:
      `IOException`

  - ### refreshSuperUserGroupsConfiguration

    public int refreshSuperUserGroupsConfiguration() throws IOException
    refreshSuperUserGroupsConfiguration `NameNode`.
    Returns:
      exitcode 0 on success, non-zero on failure
    Throws:
      `IOException`

  - ### refreshCallQueue

    public int refreshCallQueue() throws IOException
    Throws:
      `IOException`

  - ### reconfig

    public int reconfig(String[] argv, int i) throws IOException, InterruptedException
    Throws:
      `IOException`
      `InterruptedException`

  - ### genericRefresh

    public int genericRefresh(String[] argv, int i) throws IOException
    Throws:
      `IOException`

  - ### run

    public int run(String[] argv)
    Specified by:
      `run` in interface `org.apache.hadoop.util.Tool`
    Overrides:
      `run` in class `org.apache.hadoop.fs.FsShell`
    Parameters:
      `argv` - The parameters passed to this program.
    Returns:
      0 on success, non zero on error.

  - ### main

    public static void main(String[] argv) throws Exception
    main() has some simple utility methods.
    Parameters:
      `argv` - Command line parameters.
    Throws:
      `Exception` - if the filesystem does not exist.