squito commented on a change in pull request #23951: [SPARK-27038][CORE][YARN] Re-implement RackResolver to reduce resolving time URL: https://github.com/apache/spark/pull/23951#discussion_r263442029
########## File path: resource-managers/yarn/src/main/scala/org/apache/spark/scheduler/cluster/YarnRackResolver.scala ########## @@ -0,0 +1,94 @@ +/* + * 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.spark.scheduler.cluster + +import scala.collection.JavaConverters._ +import scala.collection.mutable.ArrayBuffer + +import com.google.common.base.Strings +import org.apache.hadoop.conf.Configuration +import org.apache.hadoop.fs.CommonConfigurationKeysPublic +import org.apache.hadoop.net._ +import org.apache.hadoop.util.ReflectionUtils + +import org.apache.spark.internal.Logging + +/** + * Added in SPARK-27038. Before using the higher Hadoop version which applied YARN-9332, + * we construct [[YarnRackResolver]] instead of [[org.apache.hadoop.yarn.util.RackResolver]] + * to revolve the rack info. + */ +object YarnRackResolver extends Logging { + private var dnsToSwitchMapping: DNSToSwitchMapping = _ + private var initCalled = false + // advisory count of arguments for rack script + private val ADVISORY_MINIMUM_NUMBER_SCRIPT_ARGS = 10000 + + def init(conf: Configuration): Unit = { + if (!initCalled) { + initCalled = true + val dnsToSwitchMappingClass = + conf.getClass(CommonConfigurationKeysPublic.NET_TOPOLOGY_NODE_SWITCH_MAPPING_IMPL_KEY, + classOf[ScriptBasedMapping], classOf[DNSToSwitchMapping]) + if (classOf[ScriptBasedMapping].isAssignableFrom(dnsToSwitchMappingClass)) { + val numArgs = conf.getInt(CommonConfigurationKeysPublic.NET_TOPOLOGY_SCRIPT_NUMBER_ARGS_KEY, + CommonConfigurationKeysPublic.NET_TOPOLOGY_SCRIPT_NUMBER_ARGS_DEFAULT) + if (numArgs < ADVISORY_MINIMUM_NUMBER_SCRIPT_ARGS) { Review comment: OK, so this has no effect on how you prepare the arguments to this script in spark itself, it just controls the behavior of that script, right? so is there a downside to running with a huge number, say 10M? Not knowing anything about that script, I figure there must be *some* tradeoff here. I am not sure you should be setting the value to 10K if you haven't tried anything which hits that limit. ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
