From f6acbc9cafc9923069fb264540d7bf9a95c5b42e Mon Sep 17 00:00:00 2001 From: Sandeep Nemuri Date: Tue, 26 Mar 2019 15:44:18 +0530 Subject: [PATCH] HDDS-1310. In datanode once a container becomes unhealthy, datanode restart fails. Signed-off-by: Nanda kumar (cherry picked from commit 5c0a81ad3c3d28cc1dd8d91594298d3fc7ebcfa4) --- .../ozone/container/keyvalue/KeyValueContainer.java | 3 +++ .../container/keyvalue/TestKeyValueContainer.java | 13 +++++++++++++ 2 files changed, 16 insertions(+) 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 de1b109f39b..0d45d68319e 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 @@ -618,6 +618,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);