chihsuan commented on code in PR #11235:
URL: https://github.com/apache/ozone/pull/11235#discussion_r4577105498
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/key/OMKeyRequest.java:
##########
@@ -214,32 +215,22 @@ protected List<OmKeyLocationInfo> allocateBlock(
final int numBlocks = (int)
Math.min(ozoneManager.getPreallocateBlocksMax(),
(requestedSize - 1) / (scmBlockSize * dataGroupSize) + 1);
- final String scmClientMachine;
- final String omClientMachine;
- // Sorted order cached by datanode set so blocks whose pipelines share the
- // same datanodes are sorted once (mirrors the read path's caching). Keyed
by
- // the UUID set so it is order-insensitive and dedups across pipelines.
- final Map<Set<String>, List<? extends DatanodeDetails>> sortedByNodes;
final String remoteAddress = userInfo.getRemoteAddress();
final NetworkTopology clusterMap = shouldSortDatanodes
&& keyManager.isSortDatanodesForWriteEnabled()
? ozoneManager.getClusterMapAllowNull() : null;
- if (!shouldSortDatanodes) {
- scmClientMachine = "";
- omClientMachine = "";
- sortedByNodes = null;
- } else if (clusterMap != null && !remoteAddress.isEmpty()) {
- // Sort in OM: SCM skips sorting (empty machine), OM sorts by
remoteAddress.
- scmClientMachine = "";
- omClientMachine = remoteAddress;
- sortedByNodes = new HashMap<>();
- } else {
- // Sort in SCM (or keep order when remoteAddress is empty, since SCM
skips
- // sorting for an empty client machine).
- scmClientMachine = remoteAddress;
- omClientMachine = "";
- sortedByNodes = null;
- }
+ // Resolve the client once per request, before the block loop, so the
+ // DNS-to-switch mapping is consulted at most once.
+ final Node omClient = clusterMap != null && !remoteAddress.isEmpty()
Review Comment:
Thanks for the review! 🙏
> We probably need shouldSortDatanodes == true? BTW, the previous
if-then-else is easier to understand.
Good call. I've restored the if-then-else in 8c5835d8dd, so
`shouldSortDatanodes` is an explicit branch again. Also added the
`requestedSize > 0` check from your patch.
> We could use a MemoizedSupplier to do lazy initialization
I kept the lookup eager, since OM tells SCM whether to sort in the
`allocateBlock` call. It should also be cheap, as the default mappings cache it
per host. But happy to switch if you're fine dropping the SCM fallback.
--
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]