From 96ea464aaadeadc1ef149dab93813bcfd94fa21a Mon Sep 17 00:00:00 2001 From: Bharat Viswanadham Date: Wed, 16 Jan 2019 17:43:30 -0800 Subject: [PATCH] HDDS-971. ContainerDataConstructor throws exception on QUASI_CLOSED and UNHEALTHY container state. Contributed by Lokesh Jain. --- .../common/impl/ContainerDataYaml.java | 17 ++--------------- .../container/ozoneimpl/ContainerReader.java | 4 ++-- 2 files changed, 4 insertions(+), 17 deletions(-) diff --git a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/impl/ContainerDataYaml.java b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/impl/ContainerDataYaml.java index 2d09124a46..15719440f3 100644 --- a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/impl/ContainerDataYaml.java +++ b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/impl/ContainerDataYaml.java @@ -256,21 +256,8 @@ public Object construct(Node node) { kvData.setMetadata(meta); kvData.setChecksum((String) nodes.get(OzoneConsts.CHECKSUM)); String state = (String) nodes.get(OzoneConsts.STATE); - switch (state) { - case "OPEN": - kvData.setState(ContainerProtos.ContainerDataProto.State.OPEN); - break; - case "CLOSING": - kvData.setState(ContainerProtos.ContainerDataProto.State.CLOSING); - break; - case "CLOSED": - kvData.setState(ContainerProtos.ContainerDataProto.State.CLOSED); - break; - default: - throw new IllegalStateException("Unexpected " + - "ContainerLifeCycleState " + state + " for the containerId " + - nodes.get(OzoneConsts.CONTAINER_ID)); - } + kvData + .setState(ContainerProtos.ContainerDataProto.State.valueOf(state)); return kvData; } } diff --git a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/ozoneimpl/ContainerReader.java b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/ozoneimpl/ContainerReader.java index 43f78ed4eb..0192fd5dd1 100644 --- a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/ozoneimpl/ContainerReader.java +++ b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/ozoneimpl/ContainerReader.java @@ -96,8 +96,8 @@ public void run() { try { readVolume(hddsVolumeDir); } catch (RuntimeException ex) { - LOG.info("Caught an Run time exception during reading container files" + - " from Volume {}", hddsVolumeDir); + LOG.error("Caught a Run time exception during reading container files" + + " from Volume {} {}", hddsVolumeDir, ex); } }