sodonnel commented on code in PR #7550:
URL: https://github.com/apache/ozone/pull/7550#discussion_r1889139508


##########
hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/scm/client/OMBlockPrefetchClient.java:
##########
@@ -0,0 +1,298 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hdds.scm.client;
+
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
+import org.apache.hadoop.hdds.DFSConfigKeysLegacy;
+import org.apache.hadoop.hdds.client.ECReplicationConfig;
+import org.apache.hadoop.hdds.client.ReplicationConfig;
+import org.apache.hadoop.hdds.conf.OzoneConfiguration;
+import org.apache.hadoop.hdds.conf.ConfigurationSource;
+import org.apache.hadoop.hdds.protocol.DatanodeDetails;
+import org.apache.hadoop.hdds.protocol.proto.HddsProtos;
+import org.apache.hadoop.hdds.scm.container.common.helpers.ExcludeList;
+import org.apache.hadoop.hdds.scm.net.InnerNode;
+import org.apache.hadoop.hdds.scm.net.NetworkTopology;
+import org.apache.hadoop.hdds.scm.net.Node;
+import org.apache.hadoop.hdds.scm.net.NodeImpl;
+import org.apache.hadoop.net.CachedDNSToSwitchMapping;
+import org.apache.hadoop.net.DNSToSwitchMapping;
+import org.apache.hadoop.net.TableMapping;
+import org.apache.hadoop.hdds.scm.protocol.ScmBlockLocationProtocol;
+import org.apache.hadoop.hdds.scm.container.common.helpers.AllocatedBlock;
+import org.apache.hadoop.util.ReflectionUtils;
+import org.apache.hadoop.util.Time;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeoutException;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentLinkedDeque;
+
+import static org.apache.hadoop.hdds.scm.net.NetConstants.NODE_COST_DEFAULT;
+import static 
org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_OM_PREFETCH_MAX_BLOCKS;
+import static 
org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_OM_PREFETCH_MAX_BLOCKS_DEFAULT;
+import static 
org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_OM_PREFETCHED_BLOCKS_EXPIRY_INTERVAL;
+import static 
org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_OM_PREFETCHED_BLOCKS_EXPIRY_INTERVAL_DEFAULT;
+
+/**
+ * OMBlockPrefetchClient manages block prefetching for efficient write 
operations.
+ * It maintains a queue of allocated blocks per replication configuration and 
periodically removes expired blocks.
+ * The client refills the queue in the background to handle high-throughput 
scenarios efficiently.
+ */
+public class OMBlockPrefetchClient {
+  private static final Logger LOG = 
LoggerFactory.getLogger(OMBlockPrefetchClient.class);
+  private final ScmBlockLocationProtocol scmBlockLocationProtocol;
+  private int maxBlocks;
+  private boolean useHostname;
+  private DNSToSwitchMapping dnsToSwitchMapping;
+  private ScheduledExecutorService prefetchExecutor;
+  private final Map<ReplicationConfig, 
ConcurrentLinkedDeque<ExpiringAllocatedBlock>> blockQueueMap =
+      new ConcurrentHashMap<>();
+  private long expiryDuration;
+  private OMBlockPrefetchMetrics metrics;
+
+  private static final ReplicationConfig RATIS_THREE =
+      
ReplicationConfig.fromProtoTypeAndFactor(HddsProtos.ReplicationType.RATIS,
+          HddsProtos.ReplicationFactor.THREE);
+  private static final ReplicationConfig RATIS_ONE =
+      
ReplicationConfig.fromProtoTypeAndFactor(HddsProtos.ReplicationType.RATIS,
+          HddsProtos.ReplicationFactor.ONE);
+  private static final ReplicationConfig RS_3_2_1024 =
+      ReplicationConfig.fromProto(HddsProtos.ReplicationType.EC, null,
+          toProto(3, 2, ECReplicationConfig.EcCodec.RS, 1024));
+  private static final ReplicationConfig RS_6_3_1024 =
+      ReplicationConfig.fromProto(HddsProtos.ReplicationType.EC, null,
+          toProto(6, 3, ECReplicationConfig.EcCodec.RS, 1024));
+  private static final ReplicationConfig XOR_10_4_4096 =

Review Comment:
   > Can the other parameters within the EC replication configuration vary 
alongside the chunk size?
   
   We have only really tested 3-2, 6-3 and 10-4, but any combination of data 
and parity within reason is theoretically possible. Therefore we should not 
impose limits in other parts of the code that may break things in the future.
   
   >  Can we impose specific limitations over the chunk size variations, or are 
they indefinite?
   
   In theory, they are indefinite, but out of the box, there is a config that 
limits the EC schemes to the few we have tested, ie 3-2, 6-3, 10-4 with 1024k 
chunksize, but by overriding the config a user can do whatever they want.
     
   > Will replication configurations with different chunk sizes require 
separate pipelines, or can they share the same pipeline internally?
   
   Yea, each EC scheme has a different pool of pipelines. Also an EC pipeline 
is only ever used for a single container. The pipelines are not long lived.
   



-- 
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