zoukankan      html  css  js  c++  java
  • 假期学习12

    今天做的是实验六的后一部分。

    这是实验的部分代码:

    package org.apache.spark.examples.streaming
    import org.apache.spark.SparkConf
    import org.apache.spark.storage.StorageLevel
    import org.apache.spark.streaming._
    import org.apache.spark.streaming.flume._
    import org.apache.spark.util.IntParam
    object FlumeEventCount {
     def main(args: Array[String]) {
     if (args.length < 2) {
     System.err.println(
     "Usage: FlumeEventCount <host> <port>")
     System.exit(1)
     }
    StreamingExamples.setStreamingLogLevels()
     val Array(host, IntParam(port)) = args
     val batchInterval = Milliseconds(2000)
     // Create the context and set the batch size
     val sparkConf = new SparkConf().setAppName("FlumeEventCount").setMaster("local
    [2]")
     val ssc = new StreamingContext(sparkConf, batchInterval)
     // Create a flume stream
     val stream = FlumeUtils.createStream(ssc, host, port, StorageLevel.MEMORY_ONLY_S
    ER_2)
     // Print out the count of events received from this server in each batch
     stream.count().map(cnt => "Received " + cnt + " flume events." ).print()
     ssc.start()
     ssc.awaitTermination()
     } }
    package org.apache.spark.examples.streaming
    import org.apache.log4j.{Level, Logger}
    import org.apache.spark.internal.Logging
    object StreamingExamples extends Logging {
     /** Set reasonable logging levels for streaming if the user has not configured log4
    j. */
     def setStreamingLogLevels() {
     val log4jInitialized = Logger.getRootLogger.getAllAppenders.hasMoreElements
     if (!log4jInitialized) {
     // We first log something to initialize Spark's default logging, then we overri
    de the
     // logging level.
     logInfo("Setting log level to [WARN] for streaming example." +
     " To override add a custom log4j.properties to the classpath.")
     Logger.getRootLogger.setLevel(Level.WARN)
     }
     }
    }
  • 相关阅读:
    org.eclipse.core.internal.registry.ExtensionsParser的流程分析
    控件设计时的属性页定位办法
    IE的内存泄漏问题
    <<深入剖析ASP.NET组件设计>>的一个辅助类
    midp2.0 图片文件名问题
    解决了XMLTextReader的用法的一个难题,EndElement
    J2ME开发心得
    解决Js内存泄漏问题的代码片断
    asp.net代码中尖括号和百分号的含义
    string.Format和cookie代码
  • 原文地址:https://www.cnblogs.com/Excusezuo/p/12315279.html
Copyright © 2011-2022 走看看