ivandika3 commented on code in PR #10598:
URL: https://github.com/apache/ozone/pull/10598#discussion_r3519942689
##########
hadoop-ozone/integration-test/dev-support/findbugsExcludeFile.xml:
##########
@@ -16,4 +16,16 @@
limitations under the License.
-->
<FindBugsFilter>
+ <Match>
+ <Class
name="org.apache.hadoop.hdds.scm.TestRackAwarePlacement$WithRacksAndHosts"/>
+ <Bug pattern="SIC_INNER_SHOULD_BE_STATIC"/>
+ </Match>
+ <Match>
+ <Class
name="org.apache.hadoop.hdds.scm.TestRackAwarePlacement$WithRacksOnly"/>
+ <Bug pattern="SIC_INNER_SHOULD_BE_STATIC"/>
+ </Match>
+ <Match>
+ <Class
name="org.apache.hadoop.hdds.scm.TestRackAwarePlacement$WithHostsOnly"/>
+ <Bug pattern="SIC_INNER_SHOULD_BE_STATIC"/>
+ </Match>
Review Comment:
Any way to prevent this?
##########
hadoop-ozone/mini-cluster/src/main/java/org/apache/hadoop/ozone/FixedHostMapping.java:
##########
@@ -0,0 +1,153 @@
+/*
+ * 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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.ozone;
+
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.stream.Collectors;
+import org.apache.hadoop.net.CachedDNSToSwitchMapping;
+import org.apache.hadoop.net.DNSToSwitchMapping;
+import org.apache.hadoop.net.NetworkTopology;
+
+/**
+ * A {@link CachedDNSToSwitchMapping} implementation that resolves hostnames
+ * to rack locations using a statically configured map, bypassing DNS lookups.
+ *
+ * <p>This is intended for use in test environments (e.g. {@code
MiniOzoneCluster})
+ * where DataNode hostnames may be synthetic or unresolvable via DNS. The
standard
+ * {@link CachedDNSToSwitchMapping} performs DNS normalization before rack
resolution,
+ * which can cause synthetic hostnames to be incorrectly resolved to a real IP
address,
+ * leading to rack mapping failures. This class avoids that by resolving
directly
+ * against the registered hostname.
+ *
+ * <p>The mapping is stored in a JVM-wide static map. Callers must invoke
+ * {@link #addNode(String, String)} before cluster startup to register
hostname-to-rack
+ * entries, and should call {@link #clear()} after each test to avoid
cross-test pollution.
+ *
+ * <p>Usage:
+ * <pre>{@code
+ * FixedHostMapping.addNode("dn-0.test", "/rack1");
+ * FixedHostMapping.addNode("dn-1.test", "/rack1");
+ * FixedHostMapping.addNode("dn-2.test", "/rack2");
+ *
+ * conf.setClass(
+ * CommonConfigurationKeysPublic.NET_TOPOLOGY_NODE_SWITCH_MAPPING_IMPL_KEY,
+ * FixedHostMapping.class,
+ * DNSToSwitchMapping.class);
+ * }</pre>
+ */
+public class FixedHostMapping extends CachedDNSToSwitchMapping {
Review Comment:
Can I check what is the difference between this and the Hadoop
`StaticMapping` used in Hadoop?
##########
hadoop-ozone/mini-cluster/src/main/java/org/apache/hadoop/ozone/MiniOzoneClusterImpl.java:
##########
@@ -527,6 +533,12 @@ public MiniOzoneCluster build() throws IOException {
cluster.startHddsDatanodes();
}
+ // Recreate the Ratis pipeline to prevent imbalanced node placement
across racks
+ // caused by asynchronous DN registration.
+ if (racks != null && startDataNodes) {
+ resetPipelinesForRackAwareness(cluster);
+ }
Review Comment:
Hm, I don't get this logic. Rack awareness should not leak logic to a
generic MiniOzoneCluster?
--
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]