diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/conf/ReconfigurableBase.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/conf/ReconfigurableBase.java index 3248b9a133f..3664549e2ff 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/conf/ReconfigurableBase.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/conf/ReconfigurableBase.java @@ -128,7 +128,7 @@ public abstract class ReconfigurableBase try { this.parent.reconfigurePropertyImpl(change.prop, change.newVal); } catch (ReconfigurationException e) { - errorMessage = e.toString(); + errorMessage = e.getCause().getMessage(); } results.put(change, Optional.fromNullable(errorMessage)); } diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/conf/TestReconfiguration.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/conf/TestReconfiguration.java index 07b26eb2b82..238ebda3cdc 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/conf/TestReconfiguration.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/conf/TestReconfiguration.java @@ -389,7 +389,8 @@ public class TestReconfiguration { .reconfigurePropertyImpl(eq("name1"), anyString()); doNothing().when(dummy) .reconfigurePropertyImpl(eq("name2"), anyString()); - doThrow(new ReconfigurationException("NAME3", "NEW3", "OLD3")) + doThrow(new ReconfigurationException("NAME3", "NEW3", "OLD3", + new IOException("io exception"))) .when(dummy).reconfigurePropertyImpl(eq("name3"), anyString()); dummy.startReconfigurationTask(); @@ -406,7 +407,7 @@ public class TestReconfiguration { assertThat(result.getValue().get(), containsString("Property name2 is not reconfigurable")); } else if (change.prop.equals("name3")) { - assertThat(result.getValue().get(), containsString("NAME3")); + assertThat(result.getValue().get(), containsString("io exception")); } else { fail("Unknown property: " + change.prop); } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataNode.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataNode.java index 2ff6870a40f..13c32d530ad 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataNode.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataNode.java @@ -446,7 +446,7 @@ public class DataNode extends ReconfigurableBase try { LOG.info("Reconfiguring " + property + " to " + newVal); this.refreshVolumes(newVal); - } catch (Exception e) { + } catch (IOException e) { throw new ReconfigurationException(property, newVal, getConf().get(property), e); } @@ -581,14 +581,15 @@ public class DataNode extends ReconfigurableBase IOException ioe = ioExceptionFuture.get(); if (ioe != null) { errorMessageBuilder.append(String.format("FAILED TO ADD: %s: %s\n", - volume.toString(), ioe.getMessage())); + volume, ioe.getMessage())); + LOG.error("Failed to add volume: " + volume, ioe); } else { effectiveVolumes.add(volume.toString()); + LOG.info("Successfully added volume: " + volume); } - LOG.info("Storage directory is loaded: " + volume.toString()); } catch (Exception e) { errorMessageBuilder.append(String.format("FAILED to ADD: %s: %s\n", - volume.toString(), e.getMessage())); + volume, e.getMessage())); } } }