hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cutt...@apache.org
Subject svn commit: r483654 - in /lucene/hadoop/trunk: CHANGES.txt src/java/org/apache/hadoop/dfs/DFSAdmin.java
Date Thu, 07 Dec 2006 20:50:47 GMT
Author: cutting
Date: Thu Dec  7 12:50:46 2006
New Revision: 483654

URL: http://svn.apache.org/viewvc?view=rev&rev=483654
Log:
HADOOP-756.  Add new dfsadmin option to wait for filesystem to be operational.  Contributed
by Dhruba.

Modified:
    lucene/hadoop/trunk/CHANGES.txt
    lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/DFSAdmin.java

Modified: lucene/hadoop/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/CHANGES.txt?view=diff&rev=483654&r1=483653&r2=483654
==============================================================================
--- lucene/hadoop/trunk/CHANGES.txt (original)
+++ lucene/hadoop/trunk/CHANGES.txt Thu Dec  7 12:50:46 2006
@@ -33,6 +33,9 @@
  9. HADOOP-639. Restructure InterTrackerProtocol to make task
     accounting more reliable.  (Arun C Murthy via cutting)
 
+10. HADOOP-756. Add new dfsadmin option to wait for filesystem to be
+    operational.  (Dhruba Borthakur via cutting)
+
 
 Release 0.9.1 - 2006-12-06
 

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=483654&r1=483653&r2=483654
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/DFSAdmin.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/DFSAdmin.java Thu Dec  7 12:50:46 2006
@@ -96,6 +96,7 @@
         return;
       }
       FSConstants.SafeModeAction action;
+      Boolean waitExitSafe = false;
 
       if ("leave".equalsIgnoreCase(argv[idx])) {
         action = FSConstants.SafeModeAction.SAFEMODE_LEAVE;
@@ -103,13 +104,32 @@
         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 mode = dfs.setSafeMode(action);
-      System.out.println("Safe mode is " + (mode ? "ON" : "OFF"));
+      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);
+        }
+      }
+
+      System.out.println("Safe mode is " + (inSafeMode ? "ON" : "OFF"));
     }
 
     /**
@@ -122,11 +142,11 @@
                 + " [report]");
           } else if ("-safemode".equals(cmd)) {
             System.err.println("Usage: java DFSAdmin"
-                + " [-safemode enter | leave | get]");
+                + " [-safemode enter | leave | get | wait]");
           } else {
             System.err.println("Usage: java DFSAdmin");
             System.err.println("           [-report]");
-            System.err.println("           [-safemode enter | leave | get]");
+            System.err.println("           [-safemode enter | leave | get | wait]");
           }
     }
 



Mime
View raw message