Parcourir la source

HDFS-11369. Change exception message in StorageLocationChecker.

Arpit Agarwal il y a 8 ans
Parent
commit
7c1cc30b3c

+ 6 - 5
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/checker/StorageLocationChecker.java

@@ -213,14 +213,15 @@ public class StorageLocationChecker {
     }
     }
 
 
     if (failedLocations.size() > maxVolumeFailuresTolerated) {
     if (failedLocations.size() > maxVolumeFailuresTolerated) {
-      throw new IOException(
-          "Too many failed volumes: " + failedLocations.size() +
-          ". The configuration allows for a maximum of " +
-          maxVolumeFailuresTolerated + " failed volumes.");
+      throw new DiskErrorException("Too many failed volumes - "
+          + "current valid volumes: " + goodLocations.size()
+          + ", volumes configured: " + dataDirs.size()
+          + ", volumes failed: " + failedLocations.size()
+          + ", volume failures tolerated: " + maxVolumeFailuresTolerated);
     }
     }
 
 
     if (goodLocations.size() == 0) {
     if (goodLocations.size() == 0) {
-      throw new IOException("All directories in "
+      throw new DiskErrorException("All directories in "
           + DFS_DATANODE_DATA_DIR_KEY + " are invalid: "
           + DFS_DATANODE_DATA_DIR_KEY + " are invalid: "
           + failedLocations);
           + failedLocations);
     }
     }

+ 3 - 1
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/checker/TestStorageLocationChecker.java

@@ -109,7 +109,9 @@ public class TestStorageLocationChecker {
     conf.setInt(DFS_DATANODE_FAILED_VOLUMES_TOLERATED_KEY, 1);
     conf.setInt(DFS_DATANODE_FAILED_VOLUMES_TOLERATED_KEY, 1);
 
 
     thrown.expect(IOException.class);
     thrown.expect(IOException.class);
-    thrown.expectMessage("Too many failed volumes");
+    thrown.expectMessage("Too many failed volumes - current valid volumes: 1,"
+        + " volumes configured: 3, volumes failed: 2, volume failures"
+        + " tolerated: 1");
     StorageLocationChecker checker =
     StorageLocationChecker checker =
         new StorageLocationChecker(conf, new FakeTimer());
         new StorageLocationChecker(conf, new FakeTimer());
     checker.check(conf, locations);
     checker.check(conf, locations);