[ https://issues.apache.org/jira/browse/SPARK-42703?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17698163#comment-17698163 ]
LiJie2023 commented on SPARK-42703: ----------------------------------- Sorry, this "SPARK-42703" is also submitted by me. I haven't got the correct answer yet. 李杰 leedd1...@163.com ---- 回复的原邮件 ---- [ https://issues.apache.org/jira/browse/SPARK-42703?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Hyukjin Kwon 解决了 SPARK-42703。 ----------------------------- 解决结果: Invalid How to use Fair Scheduler Pools ------------------------------- 关键字: SPARK-42703 URL: https://issues.apache.org/jira/browse/SPARK-42703 项目: Spark 问题类型: Question 模块: Scheduler 影响版本: 3.2.3 报告人: LiJie2023 优先级: 重要 附件: image-2023-03-08-09-53-35-867.png I have two questions to ask: # I wrote a demo referring to the official website, but it didn't meet my expectations. I don't know if there was a problem with my writing.I hope that when I use the following fairscheduler.xml, pool1 always performs tasks before pool2 # What is the relationship between "spark.scheduler.mode" and "{{{}schedulingMode{}}}" in fairscheduler.xml? {code:java} object MultiJobTest { def main(args: Array[String]): Unit = { val conf = new SparkConf() conf.setAppName("test-pool").setMaster("local[1]") conf.set("spark.scheduler.mode", "FAIR") conf.set("spark.scheduler.allocation.file", "file:///D:/tmp/input/fairscheduler.xml") val sparkContext = new SparkContext(conf) val data: RDD[String] = sparkContext.textFile("file:///D:/tmp/input/input.txt") val rdd = data.flatMap(_.split(",")) .map(x => (x(0), x(0))) new Thread(() => { sparkContext.setLocalProperty("spark.scheduler.pool", "pool1") rdd.foreachAsync(x => { println("1======start==" + new SimpleDateFormat("HH:mm:ss").format(new Date())) Thread.sleep(10000) println("1======end==" + new SimpleDateFormat("HH:mm:ss").format(new Date())) }) }).start() new Thread(() => { sparkContext.setLocalProperty("spark.scheduler.pool", "pool2") rdd.foreachAsync(x => { println("2======start==" + new SimpleDateFormat("HH:mm:ss").format(new Date())) Thread.sleep(10000) println("2======end==" + new SimpleDateFormat("HH:mm:ss").format(new Date())) }) }).start() TimeUnit.MINUTES.sleep(2) sparkContext.stop() } } {code} fairscheduler.xml {code:java} <?xml version="1.0"?><!-- 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. --><allocations> <pool name="pool1"> <schedulingMode>FAIR</schedulingMode> <weight>100</weight> <minShare>0</minShare> </pool> <pool name="pool2"> <schedulingMode>FAIR</schedulingMode> <weight>1</weight> <minShare>0</minShare> </pool> </allocations> {code} input.txt {code:java} aa bb {code} -- 这条信息是由Atlassian Jira发送的 (v8.20.10#820010) > How to use Fair Scheduler Pools > ------------------------------- > > Key: SPARK-42703 > URL: https://issues.apache.org/jira/browse/SPARK-42703 > Project: Spark > Issue Type: Question > Components: Scheduler > Affects Versions: 3.2.3 > Reporter: LiJie2023 > Priority: Major > Attachments: image-2023-03-08-09-53-35-867.png > > > I have two questions to ask: > # I wrote a demo referring to the official website, but it didn't meet my > expectations. I don't know if there was a problem with my writing.I hope that > when I use the following fairscheduler.xml, pool1 always performs tasks > before pool2 > # What is the relationship between "spark.scheduler.mode" and > "{{{}schedulingMode{}}}" in fairscheduler.xml? > > > {code:java} > object MultiJobTest { > def main(args: Array[String]): Unit = { > val conf = new SparkConf() > conf.setAppName("test-pool").setMaster("local[1]") > conf.set("spark.scheduler.mode", "FAIR") > conf.set("spark.scheduler.allocation.file", > "file:///D:/tmp/input/fairscheduler.xml") > val sparkContext = new SparkContext(conf) > val data: RDD[String] = > sparkContext.textFile("file:///D:/tmp/input/input.txt") > val rdd = data.flatMap(_.split(",")) > .map(x => (x(0), x(0))) > new Thread(() => { > sparkContext.setLocalProperty("spark.scheduler.pool", "pool1") > rdd.foreachAsync(x => { > println("1======start==" + new > SimpleDateFormat("HH:mm:ss").format(new Date())) > Thread.sleep(10000) > println("1======end==" + new SimpleDateFormat("HH:mm:ss").format(new > Date())) > }) > }).start() > new Thread(() => { > sparkContext.setLocalProperty("spark.scheduler.pool", "pool2") > rdd.foreachAsync(x => { > println("2======start==" + new > SimpleDateFormat("HH:mm:ss").format(new Date())) > Thread.sleep(10000) > println("2======end==" + new SimpleDateFormat("HH:mm:ss").format(new > Date())) > }) > }).start() > TimeUnit.MINUTES.sleep(2) > sparkContext.stop() > } > } {code} > > fairscheduler.xml > > {code:java} > <?xml version="1.0"?><!-- > 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. > --><allocations> > <pool name="pool1"> > <schedulingMode>FAIR</schedulingMode> > <weight>100</weight> > <minShare>0</minShare> > </pool> > <pool name="pool2"> > <schedulingMode>FAIR</schedulingMode> > <weight>1</weight> > <minShare>0</minShare> > </pool> > </allocations> {code} > > > input.txt > > {code:java} > aa bb {code} > > > -- This message was sent by Atlassian Jira (v8.20.10#820010) --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@spark.apache.org For additional commands, e-mail: issues-h...@spark.apache.org