You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by cu...@apache.org on 2007/04/16 23:44:46 UTC
svn commit: r529410 [3/27] - in /lucene/hadoop/trunk: ./
src/contrib/abacus/src/examples/org/apache/hadoop/abacus/examples/
src/contrib/abacus/src/java/org/apache/hadoop/abacus/
src/contrib/data_join/src/java/org/apache/hadoop/contrib/utils/join/ src/c...
Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/ClientProtocol.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/ClientProtocol.java?view=diff&rev=529410&r1=529409&r2=529410
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/ClientProtocol.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/ClientProtocol.java Mon Apr 16 14:44:35 2007
@@ -29,329 +29,329 @@
**********************************************************************/
interface ClientProtocol extends VersionedProtocol {
- /*
- * 11: metasave() added and reportWrittenBlock() removed.
- */
- public static final long versionID = 11L;
+ /*
+ * 11: metasave() added and reportWrittenBlock() removed.
+ */
+ public static final long versionID = 11L;
- ///////////////////////////////////////
- // File contents
- ///////////////////////////////////////
- /**
- * Open an existing file, at the given name. Returns block
- * and DataNode info. DataNodes for each block are sorted by
- * the distance to the client's address.
- * The client will then have to contact
- * each indicated DataNode to obtain the actual data. There
- * is no need to call close() or any other function after
- * calling open().
- */
- public LocatedBlock[] open(String src) throws IOException;
-
- /**
- * Create a new file. Get back block and datanode info,
- * which describes where the first block should be written.
- *
- * Successfully calling this method prevents any other
- * client from creating a file under the given name, but
- * the caller must invoke complete() for the file to be
- * added to the filesystem.
- *
- * Blocks have a maximum size. Clients that intend to
- * create multi-block files must also use reportWrittenBlock()
- * and addBlock().
- */
- public LocatedBlock create( String src,
- String clientName,
- boolean overwrite,
- short replication,
- long blockSize
+ ///////////////////////////////////////
+ // File contents
+ ///////////////////////////////////////
+ /**
+ * Open an existing file, at the given name. Returns block
+ * and DataNode info. DataNodes for each block are sorted by
+ * the distance to the client's address.
+ * The client will then have to contact
+ * each indicated DataNode to obtain the actual data. There
+ * is no need to call close() or any other function after
+ * calling open().
+ */
+ public LocatedBlock[] open(String src) throws IOException;
+
+ /**
+ * Create a new file. Get back block and datanode info,
+ * which describes where the first block should be written.
+ *
+ * Successfully calling this method prevents any other
+ * client from creating a file under the given name, but
+ * the caller must invoke complete() for the file to be
+ * added to the filesystem.
+ *
+ * Blocks have a maximum size. Clients that intend to
+ * create multi-block files must also use reportWrittenBlock()
+ * and addBlock().
+ */
+ public LocatedBlock create( String src,
+ String clientName,
+ boolean overwrite,
+ short replication,
+ long blockSize
) throws IOException;
- /**
- * Set replication for an existing file.
- *
- * The NameNode sets replication to the new value and returns.
- * The actual block replication is not expected to be performed during
- * this method call. The blocks will be populated or removed in the
- * background as the result of the routine block maintenance procedures.
- *
- * @param src file name
- * @param replication new replication
- * @throws IOException
- * @return true if successful;
- * false if file does not exist or is a directory
- * @author shv
- */
- public boolean setReplication( String src,
- short replication
- ) throws IOException;
-
- /**
- * If the client has not yet called reportWrittenBlock(), it can
- * give up on it by calling abandonBlock(). The client can then
- * either obtain a new block, or complete or abandon the file.
- *
- * Any partial writes to the block will be garbage-collected.
- */
- public void abandonBlock(Block b, String src) throws IOException;
-
- /**
- * A client that wants to write an additional block to the
- * indicated filename (which must currently be open for writing)
- * should call addBlock().
- *
- * addBlock() returns block and datanode info, just like the initial
- * call to create().
- *
- * A null response means the NameNode could not allocate a block,
- * and that the caller should try again.
- */
- public LocatedBlock addBlock(String src, String clientName) throws IOException;
-
- /**
- * A client that wants to abandon writing to the current file
- * should call abandonFileInProgress(). After this call, any
- * client can call create() to obtain the filename.
- *
- * Any blocks that have been written for the file will be
- * garbage-collected.
- * @param src The filename
- * @param holder The datanode holding the lease
- */
- public void abandonFileInProgress(String src,
- String holder) throws IOException;
-
- /**
- * The client is done writing data to the given filename, and would
- * like to complete it.
- *
- * The function returns whether the file has been closed successfully.
- * If the function returns false, the caller should try again.
- *
- * A call to complete() will not return true until all the file's
- * blocks have been replicated the minimum number of times. Thus,
- * DataNode failures may cause a client to call complete() several
- * times before succeeding.
- */
- public boolean complete(String src, String clientName) throws IOException;
-
- /**
- * The client wants to report corrupted blocks (blocks with specified
- * locations on datanodes).
- * @param blocks Array of located blocks to report
- */
- public void reportBadBlocks(LocatedBlock[] blocks) throws IOException;
-
- ///////////////////////////////////////
- // Namespace management
- ///////////////////////////////////////
- /**
- * Rename an item in the fs namespace
- */
- public boolean rename(String src, String dst) throws IOException;
-
- /**
- * Remove the given filename from the filesystem
- */
- public boolean delete(String src) throws IOException;
-
- /**
- * Check whether the given file exists
- */
- public boolean exists(String src) throws IOException;
-
- /**
- * Check whether the given filename is a directory or not.
- */
- public boolean isDir(String src) throws IOException;
-
- /**
- * Create a directory (or hierarchy of directories) with the given
- * name.
- */
- public boolean mkdirs(String src) throws IOException;
-
- /**
- * Get a listing of the indicated directory
- */
- public DFSFileInfo[] getListing(String src) throws IOException;
-
- ///////////////////////////////////////
- // System issues and management
- ///////////////////////////////////////
- /**
- * getHints() returns a list of hostnames that store data for
- * a specific file region. It returns a set of hostnames for
- * every block within the indicated region.
- *
- * This function is very useful when writing code that considers
- * data-placement when performing operations. For example, the
- * MapReduce system tries to schedule tasks on the same machines
- * as the data-block the task processes.
- */
- public String[][] getHints(String src, long start, long len) throws IOException;
- /**
- * obtainLock() is used for lock managemnet. It returns true if
- * the lock has been seized correctly. It returns false if the
- * lock could not be obtained, and the client should try again.
- *
- * Locking is a part of most filesystems and is useful for a
- * number of inter-process synchronization tasks.
- */
- /** @deprecated */ @Deprecated
+ /**
+ * Set replication for an existing file.
+ *
+ * The NameNode sets replication to the new value and returns.
+ * The actual block replication is not expected to be performed during
+ * this method call. The blocks will be populated or removed in the
+ * background as the result of the routine block maintenance procedures.
+ *
+ * @param src file name
+ * @param replication new replication
+ * @throws IOException
+ * @return true if successful;
+ * false if file does not exist or is a directory
+ * @author shv
+ */
+ public boolean setReplication( String src,
+ short replication
+ ) throws IOException;
+
+ /**
+ * If the client has not yet called reportWrittenBlock(), it can
+ * give up on it by calling abandonBlock(). The client can then
+ * either obtain a new block, or complete or abandon the file.
+ *
+ * Any partial writes to the block will be garbage-collected.
+ */
+ public void abandonBlock(Block b, String src) throws IOException;
+
+ /**
+ * A client that wants to write an additional block to the
+ * indicated filename (which must currently be open for writing)
+ * should call addBlock().
+ *
+ * addBlock() returns block and datanode info, just like the initial
+ * call to create().
+ *
+ * A null response means the NameNode could not allocate a block,
+ * and that the caller should try again.
+ */
+ public LocatedBlock addBlock(String src, String clientName) throws IOException;
+
+ /**
+ * A client that wants to abandon writing to the current file
+ * should call abandonFileInProgress(). After this call, any
+ * client can call create() to obtain the filename.
+ *
+ * Any blocks that have been written for the file will be
+ * garbage-collected.
+ * @param src The filename
+ * @param holder The datanode holding the lease
+ */
+ public void abandonFileInProgress(String src,
+ String holder) throws IOException;
+
+ /**
+ * The client is done writing data to the given filename, and would
+ * like to complete it.
+ *
+ * The function returns whether the file has been closed successfully.
+ * If the function returns false, the caller should try again.
+ *
+ * A call to complete() will not return true until all the file's
+ * blocks have been replicated the minimum number of times. Thus,
+ * DataNode failures may cause a client to call complete() several
+ * times before succeeding.
+ */
+ public boolean complete(String src, String clientName) throws IOException;
+
+ /**
+ * The client wants to report corrupted blocks (blocks with specified
+ * locations on datanodes).
+ * @param blocks Array of located blocks to report
+ */
+ public void reportBadBlocks(LocatedBlock[] blocks) throws IOException;
+
+ ///////////////////////////////////////
+ // Namespace management
+ ///////////////////////////////////////
+ /**
+ * Rename an item in the fs namespace
+ */
+ public boolean rename(String src, String dst) throws IOException;
+
+ /**
+ * Remove the given filename from the filesystem
+ */
+ public boolean delete(String src) throws IOException;
+
+ /**
+ * Check whether the given file exists
+ */
+ public boolean exists(String src) throws IOException;
+
+ /**
+ * Check whether the given filename is a directory or not.
+ */
+ public boolean isDir(String src) throws IOException;
+
+ /**
+ * Create a directory (or hierarchy of directories) with the given
+ * name.
+ */
+ public boolean mkdirs(String src) throws IOException;
+
+ /**
+ * Get a listing of the indicated directory
+ */
+ public DFSFileInfo[] getListing(String src) throws IOException;
+
+ ///////////////////////////////////////
+ // System issues and management
+ ///////////////////////////////////////
+ /**
+ * getHints() returns a list of hostnames that store data for
+ * a specific file region. It returns a set of hostnames for
+ * every block within the indicated region.
+ *
+ * This function is very useful when writing code that considers
+ * data-placement when performing operations. For example, the
+ * MapReduce system tries to schedule tasks on the same machines
+ * as the data-block the task processes.
+ */
+ public String[][] getHints(String src, long start, long len) throws IOException;
+ /**
+ * obtainLock() is used for lock managemnet. It returns true if
+ * the lock has been seized correctly. It returns false if the
+ * lock could not be obtained, and the client should try again.
+ *
+ * Locking is a part of most filesystems and is useful for a
+ * number of inter-process synchronization tasks.
+ */
+ /** @deprecated */ @Deprecated
public boolean obtainLock(String src, String clientName, boolean exclusive) throws IOException;
- /**
- * releaseLock() is called if the client would like to release
- * a held lock. It returns true if the lock is correctly released.
- * It returns false if the client should wait and try again.
- */
- /** @deprecated */ @Deprecated
+ /**
+ * releaseLock() is called if the client would like to release
+ * a held lock. It returns true if the lock is correctly released.
+ * It returns false if the client should wait and try again.
+ */
+ /** @deprecated */ @Deprecated
public boolean releaseLock(String src, String clientName) throws IOException;
- /**
- * Client programs can cause stateful changes in the NameNode
- * that affect other clients. A client may obtain a file and
- * neither abandon nor complete it. A client might hold a series
- * of locks that prevent other clients from proceeding.
- * Clearly, it would be bad if a client held a bunch of locks
- * that it never gave up. This can happen easily if the client
- * dies unexpectedly.
- *
- * So, the NameNode will revoke the locks and live file-creates
- * for clients that it thinks have died. A client tells the
- * NameNode that it is still alive by periodically calling
- * renewLease(). If a certain amount of time passes since
- * the last call to renewLease(), the NameNode assumes the
- * client has died.
- */
- public void renewLease(String clientName) throws IOException;
-
- /**
- * Get a set of statistics about the filesystem.
- * Right now, only two values are returned.
- * [0] contains the total storage capacity of the system,
- * in bytes.
- * [1] contains the available storage of the system, in bytes.
- */
- public long[] getStats() throws IOException;
-
- /**
- * Get a full report on the system's current datanodes.
- * One DatanodeInfo object is returned for each DataNode.
- */
- public DatanodeInfo[] getDatanodeReport() throws IOException;
-
- /**
- * Get the block size for the given file.
- * @param filename The name of the file
- * @return The number of bytes in each block
- * @throws IOException
- */
- public long getBlockSize(String filename) throws IOException;
-
- /**
- * Enter, leave or get safe mode.
- * <p>
- * Safe mode is a name node state when it
- * <ol><li>does not accept changes to name space (read-only), and</li>
- * <li>does not replicate or delete blocks.</li></ol>
- *
- * <p>
- * Safe mode is entered automatically at name node startup.
- * Safe mode can also be entered manually using
- * {@link #setSafeMode(FSConstants.SafeModeAction) setSafeMode( SafeModeAction.SAFEMODE_GET )}.
- * <p>
- * At startup the name node accepts data node reports collecting
- * information about block locations.
- * In order to leave safe mode it needs to collect a configurable
- * percentage called threshold of blocks, which satisfy the minimal
- * replication condition.
- * The minimal replication condition is that each block must have at least
- * <tt>dfs.replication.min</tt> replicas.
- * When the threshold is reached the name node extends safe mode
- * for a configurable amount of time
- * to let the remaining data nodes to check in before it
- * will start replicating missing blocks.
- * Then the name node leaves safe mode.
- * <p>
- * If safe mode is turned on manually using
- * {@link #setSafeMode(FSConstants.SafeModeAction) setSafeMode( SafeModeAction.SAFEMODE_ENTER )}
- * then the name node stays in safe mode until it is manually turned off
- * using {@link #setSafeMode(FSConstants.SafeModeAction) setSafeMode( SafeModeAction.SAFEMODE_LEAVE )}.
- * Current state of the name node can be verified using
- * {@link #setSafeMode(FSConstants.SafeModeAction) setSafeMode( SafeModeAction.SAFEMODE_GET )}
- * <h4>Configuration parameters:</h4>
- * <tt>dfs.safemode.threshold.pct</tt> is the threshold parameter.<br>
- * <tt>dfs.safemode.extension</tt> is the safe mode extension parameter.<br>
- * <tt>dfs.replication.min</tt> is the minimal replication parameter.
- *
- * <h4>Special cases:</h4>
- * The name node does not enter safe mode at startup if the threshold is
- * set to 0 or if the name space is empty.<br>
- * If the threshold is set to 1 then all blocks need to have at least
- * minimal replication.<br>
- * If the threshold value is greater than 1 then the name node will not be
- * able to turn off safe mode automatically.<br>
- * Safe mode can always be turned off manually.
- *
- * @param action <ul> <li>0 leave safe mode;</li>
- * <li>1 enter safe mode;</li>
- * <li>2 get safe mode state.</li></ul>
- * @return <ul><li>0 if the safe mode is OFF or</li>
- * <li>1 if the safe mode is ON.</li></ul>
- * @throws IOException
- * @author Konstantin Shvachko
- */
- public boolean setSafeMode( FSConstants.SafeModeAction action ) throws IOException;
-
- /**
- * Tells the namenode to reread the hosts and exclude files.
- * @return True if the call was successful, false otherwise.
- * @throws IOException
- */
- public void refreshNodes() throws IOException;
-
-
- /**
- * Get the size of the current edit log (in bytes).
- * @return The number of bytes in the current edit log.
- * @throws IOException
- */
- public long getEditLogSize() throws IOException;
-
- /**
- * Closes the current edit log and opens a new one. The
- * call fails if there are already two or more edits log files or
- * if the file system is in SafeMode.
- * @return True if the call was successful, false otherwise.
- * @throws IOException
- */
- public void rollEditLog() throws IOException;
-
- /**
- * Rolls the fsImage log. It removes the old fsImage, copies the
- * new image to fsImage, removes the old edits and renames edits.new
- * to edits. The call fails if any of the four files are missing.
- * @return True if the call was successful, false otherwise.
- * @throws IOException
- */
- public void rollFsImage() throws IOException;
-
- /**
- * Finalize previous upgrade.
- * Remove file system state saved during the upgrade.
- * The upgrade will become irreversible.
- *
- * @throws IOException
- */
- public void finalizeUpgrade() throws IOException;
-
- /**
- * Dumps namenode data structures into specified file. If file
- * already exists, then append.
- * @throws IOException
- */
- public void metaSave(String filename) throws IOException;
+ /**
+ * Client programs can cause stateful changes in the NameNode
+ * that affect other clients. A client may obtain a file and
+ * neither abandon nor complete it. A client might hold a series
+ * of locks that prevent other clients from proceeding.
+ * Clearly, it would be bad if a client held a bunch of locks
+ * that it never gave up. This can happen easily if the client
+ * dies unexpectedly.
+ *
+ * So, the NameNode will revoke the locks and live file-creates
+ * for clients that it thinks have died. A client tells the
+ * NameNode that it is still alive by periodically calling
+ * renewLease(). If a certain amount of time passes since
+ * the last call to renewLease(), the NameNode assumes the
+ * client has died.
+ */
+ public void renewLease(String clientName) throws IOException;
+
+ /**
+ * Get a set of statistics about the filesystem.
+ * Right now, only two values are returned.
+ * [0] contains the total storage capacity of the system,
+ * in bytes.
+ * [1] contains the available storage of the system, in bytes.
+ */
+ public long[] getStats() throws IOException;
+
+ /**
+ * Get a full report on the system's current datanodes.
+ * One DatanodeInfo object is returned for each DataNode.
+ */
+ public DatanodeInfo[] getDatanodeReport() throws IOException;
+
+ /**
+ * Get the block size for the given file.
+ * @param filename The name of the file
+ * @return The number of bytes in each block
+ * @throws IOException
+ */
+ public long getBlockSize(String filename) throws IOException;
+
+ /**
+ * Enter, leave or get safe mode.
+ * <p>
+ * Safe mode is a name node state when it
+ * <ol><li>does not accept changes to name space (read-only), and</li>
+ * <li>does not replicate or delete blocks.</li></ol>
+ *
+ * <p>
+ * Safe mode is entered automatically at name node startup.
+ * Safe mode can also be entered manually using
+ * {@link #setSafeMode(FSConstants.SafeModeAction) setSafeMode( SafeModeAction.SAFEMODE_GET )}.
+ * <p>
+ * At startup the name node accepts data node reports collecting
+ * information about block locations.
+ * In order to leave safe mode it needs to collect a configurable
+ * percentage called threshold of blocks, which satisfy the minimal
+ * replication condition.
+ * The minimal replication condition is that each block must have at least
+ * <tt>dfs.replication.min</tt> replicas.
+ * When the threshold is reached the name node extends safe mode
+ * for a configurable amount of time
+ * to let the remaining data nodes to check in before it
+ * will start replicating missing blocks.
+ * Then the name node leaves safe mode.
+ * <p>
+ * If safe mode is turned on manually using
+ * {@link #setSafeMode(FSConstants.SafeModeAction) setSafeMode( SafeModeAction.SAFEMODE_ENTER )}
+ * then the name node stays in safe mode until it is manually turned off
+ * using {@link #setSafeMode(FSConstants.SafeModeAction) setSafeMode( SafeModeAction.SAFEMODE_LEAVE )}.
+ * Current state of the name node can be verified using
+ * {@link #setSafeMode(FSConstants.SafeModeAction) setSafeMode( SafeModeAction.SAFEMODE_GET )}
+ * <h4>Configuration parameters:</h4>
+ * <tt>dfs.safemode.threshold.pct</tt> is the threshold parameter.<br>
+ * <tt>dfs.safemode.extension</tt> is the safe mode extension parameter.<br>
+ * <tt>dfs.replication.min</tt> is the minimal replication parameter.
+ *
+ * <h4>Special cases:</h4>
+ * The name node does not enter safe mode at startup if the threshold is
+ * set to 0 or if the name space is empty.<br>
+ * If the threshold is set to 1 then all blocks need to have at least
+ * minimal replication.<br>
+ * If the threshold value is greater than 1 then the name node will not be
+ * able to turn off safe mode automatically.<br>
+ * Safe mode can always be turned off manually.
+ *
+ * @param action <ul> <li>0 leave safe mode;</li>
+ * <li>1 enter safe mode;</li>
+ * <li>2 get safe mode state.</li></ul>
+ * @return <ul><li>0 if the safe mode is OFF or</li>
+ * <li>1 if the safe mode is ON.</li></ul>
+ * @throws IOException
+ * @author Konstantin Shvachko
+ */
+ public boolean setSafeMode( FSConstants.SafeModeAction action ) throws IOException;
+
+ /**
+ * Tells the namenode to reread the hosts and exclude files.
+ * @return True if the call was successful, false otherwise.
+ * @throws IOException
+ */
+ public void refreshNodes() throws IOException;
+
+
+ /**
+ * Get the size of the current edit log (in bytes).
+ * @return The number of bytes in the current edit log.
+ * @throws IOException
+ */
+ public long getEditLogSize() throws IOException;
+
+ /**
+ * Closes the current edit log and opens a new one. The
+ * call fails if there are already two or more edits log files or
+ * if the file system is in SafeMode.
+ * @return True if the call was successful, false otherwise.
+ * @throws IOException
+ */
+ public void rollEditLog() throws IOException;
+
+ /**
+ * Rolls the fsImage log. It removes the old fsImage, copies the
+ * new image to fsImage, removes the old edits and renames edits.new
+ * to edits. The call fails if any of the four files are missing.
+ * @return True if the call was successful, false otherwise.
+ * @throws IOException
+ */
+ public void rollFsImage() throws IOException;
+
+ /**
+ * Finalize previous upgrade.
+ * Remove file system state saved during the upgrade.
+ * The upgrade will become irreversible.
+ *
+ * @throws IOException
+ */
+ public void finalizeUpgrade() throws IOException;
+
+ /**
+ * Dumps namenode data structures into specified file. If file
+ * already exists, then append.
+ * @throws IOException
+ */
+ public void metaSave(String filename) throws IOException;
}
Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/DFSAdmin.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/DFSAdmin.java?view=diff&rev=529410&r1=529409&r2=529410
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/DFSAdmin.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/DFSAdmin.java Mon Apr 16 14:44:35 2007
@@ -31,355 +31,355 @@
*/
public class DFSAdmin extends FsShell {
- /**
- * Construct a DFSAdmin object.
- */
- public DFSAdmin() {
- super();
- }
-
- /**
- * Gives a report on how the FileSystem is doing.
- * @exception IOException if the filesystem does not exist.
- */
- public void report() throws IOException {
- if (fs instanceof DistributedFileSystem) {
- DistributedFileSystem dfs = (DistributedFileSystem) fs;
- long raw = dfs.getRawCapacity();
- long rawUsed = dfs.getRawUsed();
- long used = dfs.getUsed();
- boolean mode = dfs.setSafeMode(
- FSConstants.SafeModeAction.SAFEMODE_GET);
+ /**
+ * Construct a DFSAdmin object.
+ */
+ public DFSAdmin() {
+ super();
+ }
+
+ /**
+ * Gives a report on how the FileSystem is doing.
+ * @exception IOException if the filesystem does not exist.
+ */
+ public void report() throws IOException {
+ if (fs instanceof DistributedFileSystem) {
+ DistributedFileSystem dfs = (DistributedFileSystem) fs;
+ long raw = dfs.getRawCapacity();
+ long rawUsed = dfs.getRawUsed();
+ long used = dfs.getUsed();
+ boolean mode = dfs.setSafeMode(
+ FSConstants.SafeModeAction.SAFEMODE_GET);
- if (mode) {
- System.out.println("Safe mode is ON");
- }
- System.out.println("Total raw bytes: " + raw
- + " (" + byteDesc(raw) + ")");
- System.out.println("Used raw bytes: " + rawUsed
- + " (" + byteDesc(rawUsed) + ")");
- System.out.println("% used: "
- + limitDecimal(((1.0 * rawUsed) / raw) * 100, 2)
- + "%");
- System.out.println();
- System.out.println("Total effective bytes: " + used
- + " (" + byteDesc(used) + ")");
- System.out.println("Effective replication multiplier: "
- + (1.0 * rawUsed / used));
-
- System.out.println("-------------------------------------------------");
- DatanodeInfo[] info = dfs.getDataNodeStats();
- System.out.println("Datanodes available: " + info.length);
+ if (mode) {
+ System.out.println("Safe mode is ON");
+ }
+ System.out.println("Total raw bytes: " + raw
+ + " (" + byteDesc(raw) + ")");
+ System.out.println("Used raw bytes: " + rawUsed
+ + " (" + byteDesc(rawUsed) + ")");
+ System.out.println("% used: "
+ + limitDecimal(((1.0 * rawUsed) / raw) * 100, 2)
+ + "%");
+ System.out.println();
+ System.out.println("Total effective bytes: " + used
+ + " (" + byteDesc(used) + ")");
+ System.out.println("Effective replication multiplier: "
+ + (1.0 * rawUsed / used));
+
+ System.out.println("-------------------------------------------------");
+ DatanodeInfo[] info = dfs.getDataNodeStats();
+ System.out.println("Datanodes available: " + info.length);
+ System.out.println();
+ for (int i = 0; i < info.length; i++) {
+ System.out.println(info[i].getDatanodeReport());
System.out.println();
- for (int i = 0; i < info.length; i++) {
- System.out.println(info[i].getDatanodeReport());
- System.out.println();
- }
}
}
+ }
- /**
- * Safe mode maintenance command.
- * Usage: java DFSAdmin -safemode [enter | leave | get]
- * @param argv List of of command line parameters.
- * @param idx The index of the command that is being processed.
- * @exception IOException if the filesystem does not exist.
- */
- public void setSafeMode(String[] argv, int idx) throws IOException {
- if (!(fs instanceof DistributedFileSystem)) {
- System.err.println("FileSystem is " + fs.getName());
- return;
- }
- if (idx != argv.length - 1) {
- printUsage("-safemode");
- return;
- }
- FSConstants.SafeModeAction action;
- Boolean waitExitSafe = false;
+ /**
+ * Safe mode maintenance command.
+ * Usage: java DFSAdmin -safemode [enter | leave | get]
+ * @param argv List of of command line parameters.
+ * @param idx The index of the command that is being processed.
+ * @exception IOException if the filesystem does not exist.
+ */
+ public void setSafeMode(String[] argv, int idx) throws IOException {
+ if (!(fs instanceof DistributedFileSystem)) {
+ System.err.println("FileSystem is " + fs.getName());
+ return;
+ }
+ if (idx != argv.length - 1) {
+ printUsage("-safemode");
+ return;
+ }
+ FSConstants.SafeModeAction action;
+ Boolean waitExitSafe = false;
- if ("leave".equalsIgnoreCase(argv[idx])) {
- action = FSConstants.SafeModeAction.SAFEMODE_LEAVE;
- } else if ("enter".equalsIgnoreCase(argv[idx])) {
- action = FSConstants.SafeModeAction.SAFEMODE_ENTER;
- } else if ("get".equalsIgnoreCase(argv[idx])) {
- action = FSConstants.SafeModeAction.SAFEMODE_GET;
- } else if ("wait".equalsIgnoreCase(argv[idx])) {
- action = FSConstants.SafeModeAction.SAFEMODE_GET;
- waitExitSafe = true;
- } else {
- printUsage("-safemode");
- return;
- }
- DistributedFileSystem dfs = (DistributedFileSystem) fs;
- boolean inSafeMode = dfs.setSafeMode(action);
+ if ("leave".equalsIgnoreCase(argv[idx])) {
+ action = FSConstants.SafeModeAction.SAFEMODE_LEAVE;
+ } else if ("enter".equalsIgnoreCase(argv[idx])) {
+ action = FSConstants.SafeModeAction.SAFEMODE_ENTER;
+ } else if ("get".equalsIgnoreCase(argv[idx])) {
+ action = FSConstants.SafeModeAction.SAFEMODE_GET;
+ } else if ("wait".equalsIgnoreCase(argv[idx])) {
+ action = FSConstants.SafeModeAction.SAFEMODE_GET;
+ waitExitSafe = true;
+ } else {
+ printUsage("-safemode");
+ return;
+ }
+ DistributedFileSystem dfs = (DistributedFileSystem) fs;
+ boolean inSafeMode = dfs.setSafeMode(action);
- //
- // If we are waiting for safemode to exit, then poll and
- // sleep till we are out of safemode.
- //
- if (waitExitSafe) {
- while (inSafeMode) {
- try {
- Thread.sleep(5000);
- } catch (java.lang.InterruptedException e) {
- throw new IOException("Wait Interrupted");
- }
- inSafeMode = dfs.setSafeMode(action);
+ //
+ // If we are waiting for safemode to exit, then poll and
+ // sleep till we are out of safemode.
+ //
+ if (waitExitSafe) {
+ while (inSafeMode) {
+ try {
+ Thread.sleep(5000);
+ } catch (java.lang.InterruptedException e) {
+ throw new IOException("Wait Interrupted");
}
+ inSafeMode = dfs.setSafeMode(action);
}
-
- System.out.println("Safe mode is " + (inSafeMode ? "ON" : "OFF"));
}
- /**
- * Command to ask the namenode to reread the hosts and excluded hosts
- * file.
- * Usage: java DFSAdmin -refreshNodes
- * @exception IOException
- */
- public int refreshNodes() throws IOException {
- int exitCode = -1;
+ System.out.println("Safe mode is " + (inSafeMode ? "ON" : "OFF"));
+ }
- if (!(fs instanceof DistributedFileSystem)) {
- System.err.println("FileSystem is " + fs.getName());
- return exitCode;
- }
+ /**
+ * Command to ask the namenode to reread the hosts and excluded hosts
+ * file.
+ * Usage: java DFSAdmin -refreshNodes
+ * @exception IOException
+ */
+ public int refreshNodes() throws IOException {
+ int exitCode = -1;
- DistributedFileSystem dfs = (DistributedFileSystem) fs;
- dfs.refreshNodes();
- exitCode = 0;
-
+ if (!(fs instanceof DistributedFileSystem)) {
+ System.err.println("FileSystem is " + fs.getName());
return exitCode;
}
- private void printHelp(String cmd) {
- String summary = "hadoop dfsadmin is the command to execute dfs administrative commands.\n" +
- "The full syntax is: \n\n" +
- "hadoop dfsadmin [-report] [-safemode <enter | leave | get | wait>]\n" +
- "\t[-refreshNodes] [-help [cmd]]\n";
+ DistributedFileSystem dfs = (DistributedFileSystem) fs;
+ dfs.refreshNodes();
+ exitCode = 0;
+
+ return exitCode;
+ }
- String report ="-report: \tReports basic filesystem information and statistics.\n";
-
- String safemode = "-safemode <enter|leave|get|wait>: Safemode maintenance command.\n" +
- "\t\tSafe mode is a name node state when it\n" +
- "\t\t\t1. does not accept changes to name space (read-only)\n" +
- "\t\t\t2. does not replicate or delete blocks.\n" +
- "\t\tSafe mode is entered automatically at name node startup, and\n" +
- "\t\tleaves safe mode automatically when the configured minimum\n" +
- "\t\tpercentage of blocks satisfies the minimal replication\n" +
- "\t\tcondition. Safe mode can also be entered manually, but then\n" +
- "\t\tcan only be turned off manually as well.\n";
-
- String refreshNodes = "-refreshNodes: \tReread the hosts and exclude files to update the set\n" +
- "\t\tof datanodes that are allowed to connect to the namenode\n" +
- "\t\tand those that should be decommissioned/recommissioned.\n";
-
- String help = "-help [cmd]: \tDisplays help for given command or all commands if none\n" +
- "\t\tis specified.\n";
-
- if ("report".equals(cmd)) {
- System.out.println(report);
- } else if ("safemode".equals(cmd)) {
- System.out.println(safemode);
- } else if ("refreshNodes".equals(cmd)) {
- System.out.println(refreshNodes);
- } else if ("help".equals(cmd)) {
- System.out.println(help);
- } else {
- System.out.println(summary);
- System.out.println(report);
- System.out.println(safemode);
- System.out.println(refreshNodes);
- System.out.println(help);
- }
+ private void printHelp(String cmd) {
+ String summary = "hadoop dfsadmin is the command to execute dfs administrative commands.\n" +
+ "The full syntax is: \n\n" +
+ "hadoop dfsadmin [-report] [-safemode <enter | leave | get | wait>]\n" +
+ "\t[-refreshNodes] [-help [cmd]]\n";
+ String report ="-report: \tReports basic filesystem information and statistics.\n";
+
+ String safemode = "-safemode <enter|leave|get|wait>: Safemode maintenance command.\n" +
+ "\t\tSafe mode is a name node state when it\n" +
+ "\t\t\t1. does not accept changes to name space (read-only)\n" +
+ "\t\t\t2. does not replicate or delete blocks.\n" +
+ "\t\tSafe mode is entered automatically at name node startup, and\n" +
+ "\t\tleaves safe mode automatically when the configured minimum\n" +
+ "\t\tpercentage of blocks satisfies the minimal replication\n" +
+ "\t\tcondition. Safe mode can also be entered manually, but then\n" +
+ "\t\tcan only be turned off manually as well.\n";
+
+ String refreshNodes = "-refreshNodes: \tReread the hosts and exclude files to update the set\n" +
+ "\t\tof datanodes that are allowed to connect to the namenode\n" +
+ "\t\tand those that should be decommissioned/recommissioned.\n";
+
+ String help = "-help [cmd]: \tDisplays help for given command or all commands if none\n" +
+ "\t\tis specified.\n";
+
+ if ("report".equals(cmd)) {
+ System.out.println(report);
+ } else if ("safemode".equals(cmd)) {
+ System.out.println(safemode);
+ } else if ("refreshNodes".equals(cmd)) {
+ System.out.println(refreshNodes);
+ } else if ("help".equals(cmd)) {
+ System.out.println(help);
+ } else {
+ System.out.println(summary);
+ System.out.println(report);
+ System.out.println(safemode);
+ System.out.println(refreshNodes);
+ System.out.println(help);
}
+ }
- /**
- * Command to ask the namenode to finalize previously performed upgrade.
- * Usage: java DFSAdmin -finalizeUpgrade
- * @exception IOException
- */
- public int finalizeUpgrade() throws IOException {
- int exitCode = -1;
- if (!(fs instanceof DistributedFileSystem)) {
- System.out.println("FileSystem is " + fs.getUri());
- return exitCode;
- }
+ /**
+ * Command to ask the namenode to finalize previously performed upgrade.
+ * Usage: java DFSAdmin -finalizeUpgrade
+ * @exception IOException
+ */
+ public int finalizeUpgrade() throws IOException {
+ int exitCode = -1;
- DistributedFileSystem dfs = (DistributedFileSystem) fs;
- dfs.finalizeUpgrade();
- exitCode = 0;
-
+ if (!(fs instanceof DistributedFileSystem)) {
+ System.out.println("FileSystem is " + fs.getUri());
return exitCode;
}
- /**
- * Dumps DFS data structures into specified file.
- * Usage: java DFSAdmin -metasave filename
- * @param argv List of of command line parameters.
- * @param idx The index of the command that is being processed.
- * @exception IOException if an error accoured wile accessing
- * the file or path.
- */
- public int metaSave(String[] argv, int idx) throws IOException {
- String pathname = argv[idx];
- DistributedFileSystem dfs = (DistributedFileSystem) fs;
- dfs.metaSave(pathname);
- System.out.println("Created file " + pathname + " on server " +
- dfs.getUri());
- return 0;
- }
-
- /**
- * Displays format of commands.
- * @param cmd The command that is being executed.
- */
- public void printUsage(String cmd) {
- if ("-report".equals(cmd)) {
- System.err.println("Usage: java DFSAdmin"
- + " [-report]");
- } else if ("-safemode".equals(cmd)) {
- System.err.println("Usage: java DFSAdmin"
- + " [-safemode enter | leave | get | wait]");
- } else if ("-refreshNodes".equals(cmd)) {
- System.err.println("Usage: java DFSAdmin"
- + " [-refreshNodes]");
- } else if ("-finalizeUpgrade".equals(cmd)) {
- System.err.println("Usage: java DFSAdmin"
- + " [-finalizeUpgrade]");
- } else if ("-metasave".equals(cmd)) {
- System.err.println("Usage: java DFSAdmin"
- + " [-metasave filename]");
- } else {
- System.err.println("Usage: java DFSAdmin");
- System.err.println(" [-report]");
- System.err.println(" [-safemode enter | leave | get | wait]");
- System.err.println(" [-refreshNodes]");
- System.err.println(" [-finalizeUpgrade]");
- System.err.println(" [-metasave filename]");
- System.err.println(" [-help [cmd]]");
- }
- }
-
- /**
- * @param argv The parameters passed to this program.
- * @exception Exception if the filesystem does not exist.
- * @return 0 on success, non zero on error.
- */
- public int run(String[] argv) throws Exception {
-
- if (argv.length < 1) {
- printUsage("");
- return -1;
- }
-
- int exitCode = -1;
- int i = 0;
- String cmd = argv[i++];
-
- //
- // verify that we have enough command line parameters
- //
- if ("-safemode".equals(cmd)) {
- if (argv.length != 2) {
- printUsage(cmd);
- return exitCode;
- }
- } else if ("-report".equals(cmd)) {
- if (argv.length != 1) {
- printUsage(cmd);
- return exitCode;
- }
- } else if ("-refreshNodes".equals(cmd)) {
- if (argv.length != 1) {
- printUsage(cmd);
- return exitCode;
- }
- } else if ("-finalizeUpgrade".equals(cmd)) {
- if (argv.length != 1) {
- printUsage(cmd);
- return exitCode;
- }
- } else if ("-metasave".equals(cmd)) {
- if (argv.length != 2) {
- printUsage(cmd);
- return exitCode;
- }
- }
+ DistributedFileSystem dfs = (DistributedFileSystem) fs;
+ dfs.finalizeUpgrade();
+ exitCode = 0;
+
+ return exitCode;
+ }
+ /**
+ * Dumps DFS data structures into specified file.
+ * Usage: java DFSAdmin -metasave filename
+ * @param argv List of of command line parameters.
+ * @param idx The index of the command that is being processed.
+ * @exception IOException if an error accoured wile accessing
+ * the file or path.
+ */
+ public int metaSave(String[] argv, int idx) throws IOException {
+ String pathname = argv[idx];
+ DistributedFileSystem dfs = (DistributedFileSystem) fs;
+ dfs.metaSave(pathname);
+ System.out.println("Created file " + pathname + " on server " +
+ dfs.getUri());
+ return 0;
+ }
+
+ /**
+ * Displays format of commands.
+ * @param cmd The command that is being executed.
+ */
+ public void printUsage(String cmd) {
+ if ("-report".equals(cmd)) {
+ System.err.println("Usage: java DFSAdmin"
+ + " [-report]");
+ } else if ("-safemode".equals(cmd)) {
+ System.err.println("Usage: java DFSAdmin"
+ + " [-safemode enter | leave | get | wait]");
+ } else if ("-refreshNodes".equals(cmd)) {
+ System.err.println("Usage: java DFSAdmin"
+ + " [-refreshNodes]");
+ } else if ("-finalizeUpgrade".equals(cmd)) {
+ System.err.println("Usage: java DFSAdmin"
+ + " [-finalizeUpgrade]");
+ } else if ("-metasave".equals(cmd)) {
+ System.err.println("Usage: java DFSAdmin"
+ + " [-metasave filename]");
+ } else {
+ System.err.println("Usage: java DFSAdmin");
+ System.err.println(" [-report]");
+ System.err.println(" [-safemode enter | leave | get | wait]");
+ System.err.println(" [-refreshNodes]");
+ System.err.println(" [-finalizeUpgrade]");
+ System.err.println(" [-metasave filename]");
+ System.err.println(" [-help [cmd]]");
+ }
+ }
- // initialize DFSAdmin
- try {
- init();
- } catch (RPC.VersionMismatch v) {
- System.err.println("Version Mismatch between client and server"
- + "... command aborted.");
- return exitCode;
- } catch (IOException e) {
- System.err.println("Bad connection to DFS... command aborted.");
- return exitCode;
- }
+ /**
+ * @param argv The parameters passed to this program.
+ * @exception Exception if the filesystem does not exist.
+ * @return 0 on success, non zero on error.
+ */
+ public int run(String[] argv) throws Exception {
+
+ if (argv.length < 1) {
+ printUsage("");
+ return -1;
+ }
- exitCode = 0;
- try {
- if ("-report".equals(cmd)) {
- report();
- } else if ("-safemode".equals(cmd)) {
- setSafeMode(argv, i);
- } else if ("-refreshNodes".equals(cmd)) {
- exitCode = refreshNodes();
- } else if ("-finalizeUpgrade".equals(cmd)) {
- exitCode = finalizeUpgrade();
- } else if ("-metasave".equals(cmd)) {
- exitCode = metaSave(argv, i);
- } else if ("-help".equals(cmd)) {
- if (i < argv.length) {
- printHelp(argv[i]);
- } else {
- printHelp("");
- }
- } else {
- exitCode = -1;
- System.err.println(cmd.substring(1) + ": Unknown command");
- printUsage("");
- }
- } 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");
- System.err.println(cmd.substring(1) + ": "
- + content[0]);
- } catch (Exception ex) {
- System.err.println(cmd.substring(1) + ": "
- + ex.getLocalizedMessage());
- }
- } catch (IOException e) {
- //
- // IO exception encountered locally.
- //
- exitCode = -1;
- System.err.println(cmd.substring(1) + ": "
- + e.getLocalizedMessage());
- } finally {
- fs.close();
- }
+ int exitCode = -1;
+ int i = 0;
+ String cmd = argv[i++];
+
+ //
+ // verify that we have enough command line parameters
+ //
+ if ("-safemode".equals(cmd)) {
+ if (argv.length != 2) {
+ printUsage(cmd);
+ return exitCode;
+ }
+ } else if ("-report".equals(cmd)) {
+ if (argv.length != 1) {
+ printUsage(cmd);
+ return exitCode;
+ }
+ } else if ("-refreshNodes".equals(cmd)) {
+ if (argv.length != 1) {
+ printUsage(cmd);
+ return exitCode;
+ }
+ } else if ("-finalizeUpgrade".equals(cmd)) {
+ if (argv.length != 1) {
+ printUsage(cmd);
+ return exitCode;
+ }
+ } else if ("-metasave".equals(cmd)) {
+ if (argv.length != 2) {
+ printUsage(cmd);
return exitCode;
+ }
+ }
+
+
+ // initialize DFSAdmin
+ try {
+ init();
+ } catch (RPC.VersionMismatch v) {
+ System.err.println("Version Mismatch between client and server"
+ + "... command aborted.");
+ return exitCode;
+ } catch (IOException e) {
+ System.err.println("Bad connection to DFS... command aborted.");
+ return exitCode;
}
- /**
- * main() has some simple utility methods.
- * @param argv Command line parameters.
- * @exception Exception if the filesystem does not exist.
- */
- public static void main(String[] argv) throws Exception {
- int res = new DFSAdmin().doMain(new Configuration(), argv);
- System.exit(res);
+ exitCode = 0;
+ try {
+ if ("-report".equals(cmd)) {
+ report();
+ } else if ("-safemode".equals(cmd)) {
+ setSafeMode(argv, i);
+ } else if ("-refreshNodes".equals(cmd)) {
+ exitCode = refreshNodes();
+ } else if ("-finalizeUpgrade".equals(cmd)) {
+ exitCode = finalizeUpgrade();
+ } else if ("-metasave".equals(cmd)) {
+ exitCode = metaSave(argv, i);
+ } else if ("-help".equals(cmd)) {
+ if (i < argv.length) {
+ printHelp(argv[i]);
+ } else {
+ printHelp("");
+ }
+ } else {
+ exitCode = -1;
+ System.err.println(cmd.substring(1) + ": Unknown command");
+ printUsage("");
+ }
+ } 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");
+ System.err.println(cmd.substring(1) + ": "
+ + content[0]);
+ } catch (Exception ex) {
+ System.err.println(cmd.substring(1) + ": "
+ + ex.getLocalizedMessage());
+ }
+ } catch (IOException e) {
+ //
+ // IO exception encountered locally.
+ //
+ exitCode = -1;
+ System.err.println(cmd.substring(1) + ": "
+ + e.getLocalizedMessage());
+ } finally {
+ fs.close();
}
+ return exitCode;
+ }
+
+ /**
+ * main() has some simple utility methods.
+ * @param argv Command line parameters.
+ * @exception Exception if the filesystem does not exist.
+ */
+ public static void main(String[] argv) throws Exception {
+ int res = new DFSAdmin().doMain(new Configuration(), argv);
+ System.exit(res);
+ }
}