This is an automated email from the ASF dual-hosted git repository.
nanda pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/hadoop.git
The following commit(s) were added to refs/heads/trunk by this push:
new 21de9af HDDS-1625 : ConcurrentModificationException when SCM has
containers of different owners. (#883)
21de9af is described below
commit 21de9af9038961e36e7335dc1f688f5f48056d1c
Author: avijayanhwx <[email protected]>
AuthorDate: Mon Jun 3 12:45:04 2019 -0700
HDDS-1625 : ConcurrentModificationException when SCM has containers of
different owners. (#883)
---
.../hdds/scm/container/SCMContainerManager.java | 9 +++++---
.../TestContainerStateManagerIntegration.java | 24 ++++++++++++++++++++++
2 files changed, 30 insertions(+), 3 deletions(-)
diff --git
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/SCMContainerManager.java
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/SCMContainerManager.java
index 359731c..1c1ffe1 100644
---
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/SCMContainerManager.java
+++
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/SCMContainerManager.java
@@ -43,6 +43,7 @@ import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.NavigableSet;
@@ -469,15 +470,17 @@ public class SCMContainerManager implements
ContainerManager {
*/
private NavigableSet<ContainerID> getContainersForOwner(
NavigableSet<ContainerID> containerIDs, String owner) {
- for (ContainerID cid : containerIDs) {
+ Iterator<ContainerID> containerIDIterator = containerIDs.iterator();
+ while (containerIDIterator.hasNext()) {
+ ContainerID cid = containerIDIterator.next();
try {
if (!getContainer(cid).getOwner().equals(owner)) {
- containerIDs.remove(cid);
+ containerIDIterator.remove();
}
} catch (ContainerNotFoundException e) {
LOG.error("Could not find container info for container id={} {}", cid,
e);
- containerIDs.remove(cid);
+ containerIDIterator.remove();
}
}
return containerIDs;
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/hdds/scm/container/TestContainerStateManagerIntegration.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/hdds/scm/container/TestContainerStateManagerIntegration.java
index 9f90a2d..e4f1a37 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/hdds/scm/container/TestContainerStateManagerIntegration.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/hdds/scm/container/TestContainerStateManagerIntegration.java
@@ -123,6 +123,30 @@ public class TestContainerStateManagerIntegration {
}
@Test
+ public void testAllocateContainerWithDifferentOwner() throws IOException {
+
+ // Allocate a container and verify the container info
+ ContainerWithPipeline container1 = scm.getClientProtocolServer()
+ .allocateContainer(xceiverClientManager.getType(),
+ xceiverClientManager.getFactor(), containerOwner);
+ ContainerInfo info = containerManager
+ .getMatchingContainer(OzoneConsts.GB * 3, containerOwner,
+ container1.getPipeline());
+ Assert.assertNotNull(info);
+
+ String newContainerOwner = "OZONE_NEW";
+ ContainerWithPipeline container2 = scm.getClientProtocolServer()
+ .allocateContainer(xceiverClientManager.getType(),
+ xceiverClientManager.getFactor(), newContainerOwner);
+ ContainerInfo info2 = containerManager
+ .getMatchingContainer(OzoneConsts.GB * 3, newContainerOwner,
+ container1.getPipeline());
+ Assert.assertNotNull(info2);
+
+ Assert.assertNotEquals(info.containerID(), info2.containerID());
+ }
+
+ @Test
public void testContainerStateManagerRestart() throws IOException,
TimeoutException, InterruptedException, AuthenticationException {
// Allocate 5 containers in ALLOCATED state and 5 in CREATING state
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]