Spark设置setMaster=local,不提交集群,在本地启用多线程模拟运行
object SparkUtil { private val logger = Logger.getLogger(getClass.getName, true) def getSparkContext(appName:String, local:Boolean=false, threadNum:Int=4):SparkContext = { val conf = new SparkConf().setAppName(appName) if(local) conf.setMaster(s"""local[$threadNum]""") val sc = new SparkContext(conf) return sc } }
SparkUtil.getSparkContext("testApp",true) 本地启4个线程模拟运行
本文出自 “脚踏实地,仰望星空” 博客,请务必保留此出处http://xubcing.blog.51cto.com/3502962/1698930
原文地址:http://xubcing.blog.51cto.com/3502962/1698930