本文整理汇总了Scala中org.apache.spark.SecurityManager类的典型用法代码示例。如果您正苦于以下问题:Scala SecurityManager类的具体用法?Scala SecurityManager怎么用?Scala SecurityManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SecurityManager类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Scala代码示例。
示例1: KafkaSink
//设置package包名称以及导入依赖的类
package org.apache.spark.metrics.sink
import java.util.{ Properties, Locale }
import java.util.concurrent.TimeUnit
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import com.codahale.metrics.MetricRegistry
import org.apache.spark.SecurityManager
import com.manyangled.kafkasink.KafkaReporter
class KafkaSink(val properties: Properties, val registry: MetricRegistry,
securityMgr: SecurityManager) extends org.apache.spark.metrics.sink.Sink {
val logger: Logger = LoggerFactory.getLogger(this.getClass)
private def popt(prop: String): Option[String] =
Option(properties.getProperty(prop))
// These are non-negotiable
val broker = popt("broker").get
val topic = popt("topic").get
lazy val reporter = new KafkaReporter(registry, broker, topic, properties)
def start(): Unit = {
logger.info(s"Starting Kafka metric reporter at $broker, topic $topic")
val period = popt("period").getOrElse("10").toLong
val tstr = popt("unit").getOrElse("seconds").toUpperCase(Locale.ROOT)
val tunit = TimeUnit.valueOf(tstr)
reporter.start(period, tunit)
}
def stop(): Unit = {
logger.info(s"Stopping Kafka metric reporter at $broker, topic $topic")
reporter.stop()
}
def report(): Unit = {
logger.info(s"Reporting metrics to Kafka reporter at $broker, topic $topic")
reporter.report()
}
}
开发者ID:erikerlandson,项目名称:spark-kafka-sink,代码行数:46,代码来源:KafkaSink.scala
注:本文中的org.apache.spark.SecurityManager类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论