This is an automated email from the ASF dual-hosted git repository.

sodonnell pushed a commit to branch HDDS-3816-ec
in repository https://gitbox.apache.org/repos/asf/ozone.git


The following commit(s) were added to refs/heads/HDDS-3816-ec by this push:
     new 9cda6a1  HDDS-6460. EC: Adjust requested size by EC DataNum in 
WritableECContainerProvider (#3203)
9cda6a1 is described below

commit 9cda6a1a069bc025c16153b3db617c736317d08e
Author: Stephen O'Donnell <[email protected]>
AuthorDate: Tue Mar 22 12:49:10 2022 +0000

    HDDS-6460. EC: Adjust requested size by EC DataNum in 
WritableECContainerProvider (#3203)
---
 .../scm/pipeline/WritableECContainerProvider.java  | 16 ++++++++++------
 .../pipeline/TestWritableECContainerProvider.java  | 22 +++++++++++++++++-----
 2 files changed, 27 insertions(+), 11 deletions(-)

diff --git 
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipeline/WritableECContainerProvider.java
 
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipeline/WritableECContainerProvider.java
index 554a72a..117d957 100644
--- 
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipeline/WritableECContainerProvider.java
+++ 
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipeline/WritableECContainerProvider.java
@@ -92,12 +92,16 @@ public class WritableECContainerProvider
   public ContainerInfo getContainer(final long size,
       ECReplicationConfig repConfig, String owner, ExcludeList excludeList)
       throws IOException {
+    // Bound this at a minimum of 1 byte in case a request is made for a very
+    // small size, which when divided by EC DataNum is zero.
+    long requiredSpace = Math.max(1, size / repConfig.getData());
     synchronized (this) {
       int openPipelineCount = pipelineManager.getPipelineCount(repConfig,
           Pipeline.PipelineState.OPEN);
       if (openPipelineCount < providerConfig.getMinimumPipelines()) {
         try {
-          return allocateContainer(repConfig, size, owner, excludeList);
+          return allocateContainer(
+              repConfig, requiredSpace, owner, excludeList);
         } catch (IOException e) {
           LOG.warn("Unable to allocate a container for {} with {} existing "
               + "containers", repConfig, openPipelineCount, e);
@@ -109,7 +113,9 @@ public class WritableECContainerProvider
         excludeList.getDatanodes(), excludeList.getPipelineIds());
 
     PipelineRequestInformation pri =
-        PipelineRequestInformation.Builder.getBuilder().setSize(size).build();
+        PipelineRequestInformation.Builder.getBuilder()
+            .setSize(requiredSpace)
+            .build();
     while (existingPipelines.size() > 0) {
       Pipeline pipeline =
           pipelineChoosePolicy.choosePipeline(existingPipelines, pri);
@@ -121,10 +127,8 @@ public class WritableECContainerProvider
       synchronized (pipeline.getId()) {
         try {
           ContainerInfo containerInfo = getContainerFromPipeline(pipeline);
-          // TODO - For EC, what is the block size? If the client says 128MB,
-          //        is that 128MB / 6 (for EC-6-3?)
           if (containerInfo == null
-              || !containerHasSpace(containerInfo, size)) {
+              || !containerHasSpace(containerInfo, requiredSpace)) {
             // This is O(n), which isn't great if there are a lot of pipelines
             // and we keep finding pipelines without enough space.
             existingPipelines.remove(pipeline);
@@ -148,7 +152,7 @@ public class WritableECContainerProvider
     // allocate a new one and usePipelineManagerV2Impl.java it.
     try {
       synchronized (this) {
-        return allocateContainer(repConfig, size, owner, excludeList);
+        return allocateContainer(repConfig, requiredSpace, owner, excludeList);
       }
     } catch (IOException e) {
       LOG.error("Unable to allocate a container for {} after trying all "
diff --git 
a/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/pipeline/TestWritableECContainerProvider.java
 
b/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/pipeline/TestWritableECContainerProvider.java
index 269927a..b3ce216 100644
--- 
a/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/pipeline/TestWritableECContainerProvider.java
+++ 
b/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/pipeline/TestWritableECContainerProvider.java
@@ -280,16 +280,28 @@ public class TestWritableECContainerProvider {
       assertFalse(allocatedContainers.contains(container));
       allocatedContainers.add(container);
     }
-    // Update all the containers to make them full
+    // Update all the containers to make them nearly full, but with enough 
space
+    // for an EC block to be striped across them.
     for (ContainerInfo c : allocatedContainers) {
-      c.setUsedBytes(getMaxContainerSize());
+      c.setUsedBytes(getMaxContainerSize() - 30 * 1024 * 1024);
     }
-    // Get a new container and ensure it is not one of the original set
+
+    // Get a new container of size 50 and ensure it is one of the original set.
+    // We ask for a space of 50, but as it is stripped across the EC group it
+    // will actually need 50 / dataNum space
     ContainerInfo newContainer =
-        provider.getContainer(1, repConfig, OWNER, new ExcludeList());
+        provider.getContainer(50 * 1024 * 1024, repConfig, OWNER,
+            new ExcludeList());
+    assertNotNull(newContainer);
+    assertTrue(allocatedContainers.contains(newContainer));
+    // Now get a new container where there is not enough space in the existing
+    // and ensure a new container gets created.
+    newContainer = provider.getContainer(
+        128 * 1024 * 1024, repConfig, OWNER, new ExcludeList());
     assertNotNull(newContainer);
     assertFalse(allocatedContainers.contains(newContainer));
-    // The original pipelines should all be closed
+    // The original pipelines should all be closed, triggered by the lack of
+    // space.
     for (ContainerInfo c : allocatedContainers) {
       Pipeline pipeline = pipelineManager.getPipeline(c.getPipelineID());
       assertEquals(CLOSED, pipeline.getPipelineState());

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to