diff --git a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/KeyValueContainer.java b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/KeyValueContainer.java index 47af1107ffc..26b0ce1d788 100644 --- a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/KeyValueContainer.java +++ b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/KeyValueContainer.java @@ -623,6 +623,9 @@ public class KeyValueContainer implements Container { case CLOSED: state = ContainerReplicaProto.State.CLOSED; break; + case UNHEALTHY: + state = ContainerReplicaProto.State.UNHEALTHY; + break; default: throw new StorageContainerException("Invalid Container state found: " + containerData.getContainerID(), INVALID_CONTAINER_STATE); diff --git a/hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/keyvalue/TestKeyValueContainer.java b/hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/keyvalue/TestKeyValueContainer.java index c7c08b07eac..1aa736158a9 100644 --- a/hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/keyvalue/TestKeyValueContainer.java +++ b/hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/keyvalue/TestKeyValueContainer.java @@ -332,6 +332,19 @@ public class TestKeyValueContainer { keyValueContainerData.getState()); } + @Test + public void testReportOfUnhealthyContainer() throws Exception { + keyValueContainer.create(volumeSet, volumeChoosingPolicy, scmId); + Assert.assertNotNull(keyValueContainer.getContainerReport()); + keyValueContainer.markContainerUnhealthy(); + File containerFile = keyValueContainer.getContainerFile(); + keyValueContainerData = (KeyValueContainerData) ContainerDataYaml + .readContainerFile(containerFile); + assertEquals(ContainerProtos.ContainerDataProto.State.UNHEALTHY, + keyValueContainerData.getState()); + Assert.assertNotNull(keyValueContainer.getContainerReport()); + } + @Test public void testUpdateContainer() throws IOException { keyValueContainer.create(volumeSet, volumeChoosingPolicy, scmId);