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 47af1107ff..26b0ce1d78 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 @@ private ContainerReplicaProto.State getHddsState() 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 c7c08b07ea..1aa736158a 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 void testCloseContainer() throws Exception { 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);