hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cutt...@apache.org
Subject svn commit: r535993 - in /lucene/hadoop/trunk: CHANGES.txt src/java/org/apache/hadoop/dfs/DataNode.java
Date Mon, 07 May 2007 21:05:34 GMT
Author: cutting
Date: Mon May  7 14:05:30 2007
New Revision: 535993

URL: http://svn.apache.org/viewvc?view=rev&rev=535993
Log:
HADOOP-1200.  Restore disk checking lost in HADOOP-1170.  Contributed by Hairong.

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

Modified: lucene/hadoop/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/CHANGES.txt?view=diff&rev=535993&r1=535992&r2=535993
==============================================================================
--- lucene/hadoop/trunk/CHANGES.txt (original)
+++ lucene/hadoop/trunk/CHANGES.txt Mon May  7 14:05:30 2007
@@ -348,6 +348,9 @@
 103. HADOOP-1270.  Randomize the fetch of map outputs, speeding the
      shuffle.  (Arun C Murthy via cutting)
 
+104. HADOOP-1200.  Restore disk checking lost in HADOOP-1170.
+     (Hairong Kuang via cutting)
+
 
 Release 0.12.3 - 2007-04-06
 

Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/DataNode.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/DataNode.java?view=diff&rev=535993&r1=535992&r2=535993
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/DataNode.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/DataNode.java Mon May  7 14:05:30 2007
@@ -389,8 +389,29 @@
       }
     }
   }
-
-  void handleDiskError(String errMsgr) {
+  
+  
+  /* Check if there is no space in disk or the disk is read-only
+   *  when IOException occurs. 
+   * If so, handle the error */
+  private void checkDiskError( IOException e ) throws IOException {
+    if (e.getMessage().startsWith("No space left on device")) {
+      throw new DiskOutOfSpaceException("No space left on device");
+    } else {
+      checkDiskError();
+    }
+  }
+  
+  /* Check if there is no disk space and if so, handle the error*/
+  private void checkDiskError( ) throws IOException {
+    try {
+      data.checkDataDir();
+    } catch(DiskErrorException de) {
+      handleDiskError(de.getMessage());
+    }
+  }
+  
+  private void handleDiskError(String errMsgr) {
     LOG.warn("DataNode is shutting down.\n" + errMsgr);
     try {
       namenode.errorReport(
@@ -494,9 +515,6 @@
             }
           }
         } // synchronized
-      } catch(DiskErrorException e) {
-        handleDiskError(e.getLocalizedMessage());
-        return;
       } catch(RemoteException re) {
         String reClass = re.getClassName();
         if (UnregisteredDatanodeException.class.getName().equals(reClass) ||
@@ -536,7 +554,12 @@
       // safely garbage-collected.
       //
       Block toDelete[] = ((BlockCommand)cmd).getBlocks();
-      data.invalidate(toDelete);
+      try {
+        data.invalidate(toDelete);
+      } catch(IOException e) {
+        checkDiskError();
+        throw e;
+      }
       myMetrics.removedBlocks(toDelete.length);
       break;
     case DNA_SHUTDOWN:
@@ -804,7 +827,14 @@
         //
         // Open local disk out
         //
-        DataOutputStream out = new DataOutputStream(new BufferedOutputStream(data.writeToBlock(b)));
+        OutputStream o;
+        try {
+          o = data.writeToBlock(b);
+        } catch( IOException e ) {
+          checkDiskError( e );
+          throw e;
+        }
+        DataOutputStream out = new DataOutputStream(new BufferedOutputStream(o));
         InetSocketAddress mirrorTarget = null;
         String mirrorNode = null;
         try {
@@ -893,12 +923,8 @@
                   out.write(buf, 0, bytesRead);
                   myMetrics.wroteBytes(bytesRead);
                 } catch (IOException iex) {
-                  if (iex.getMessage().startsWith("No space left on device")) {
-                    throw new DiskOutOfSpaceException("No space left on device");
-                  } else {
-                    shutdown();
-                    throw iex;
-                  }
+                  checkDiskError(iex);
+                  throw iex;
                 }
                 len -= bytesRead;
               }
@@ -972,7 +998,7 @@
           try {
             out.close();
           } catch (IOException iex) {
-            shutdown();
+            checkDiskError(iex);
             throw iex;
           }
         }



Mime
View raw message