ivandika3 commented on code in PR #10946:
URL: https://github.com/apache/ozone/pull/10946#discussion_r3794018682


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/BlockManagerImpl.java:
##########
@@ -171,28 +172,48 @@ public AllocatedBlock allocateBlock(final long size,
     // configured, it will be of type StorageType.DISK and therefore belong
     // to a StorageTier.DISK tier, so for old clients the write process is
     // unchanged if the Datanode Volume configuration is not changed.
-    StorageTier storageTier = StorageTier.getDefaultTier();
-    ContainerInfo containerInfo = writableContainerFactory.getContainer(
-        size, replicationConfig, owner, excludeList, storageTier);
+    boolean isFallBack = false;
+    ContainerInfo containerInfo = null;
+    try {
+      containerInfo = writableContainerFactory.getContainer(
+          size, replicationConfig, owner, excludeList, 
storagePolicy.getCreationTier());
+    } catch (IOException e) {
+      if (allowFallbackStoragePolicy && 
storagePolicy.getCreationFallbackTier() != StorageTier.EMPTY) {
+        // TODO StoragePolicy should It should be distinguished in detail 
which exceptions can try to fallback
+        isFallBack = true;
+        containerInfo = writableContainerFactory.getContainer(size, 
replicationConfig, owner,
+            excludeList, storagePolicy.getCreationFallbackTier());
+      } else {
+        throw e;
+      }

Review Comment:
   We need to decide this in another patch. I raised 
[HDDS-16166](https://issues.apache.org/jira/browse/HDDS-16166) to consolidate 
the behavior and contract for allocateBlock. For now we can skip first and let 
OM handles this for compatibility reason.
   
   IMO I believe that throwing an exception is better, this 
`FAILED_TO_ALLOCATE_ENOUGH_BLOCKS` should be thrown in SCM and should not be 
handled in the client (i.e. OM). Remember that HDDS layer is supposed to be a 
separate layer.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to