메뉴 건너뛰기

Cloudera, BigData, Semantic IoT, Hadoop, NoSQL

Cloudera CDH/CDP 및 Hadoop EcoSystem, Semantic IoT등의 개발/운영 기술을 정리합니다. gooper@gooper.com로 문의 주세요.


import org.apache.spark.SparkContext
import org.apache.spark.streaming.StreamingContext
import org.apache.spark.streaming.Seconds

object StreamingLogsMB {
  def main(args: Array[String]) {
    if (args.length < 2) {

      System.err.println("Usage: stubs.StreamingLogsMB <hostname> <port>")
      System.exit(1)
    }

    // get hostname and port of data source from application arguments
    val hostname = args(0)
    val port = args(1).toInt

    // Create a Spark Context
    val sc = new SparkContext()

    // Set log level to ERROR to avoid distracting extra output
    sc.setLogLevel("ERROR")

    // Configure the Streaming Context with a 1 second batch duration
    val ssc = new StreamingContext(sc,Seconds(1))

    // Create a DStream of log data from the server and port specified
    val logs = ssc.socketTextStream(hostname,port)

    ssc.checkpoint("logcheckpt")

    logs.countByWindow(Seconds(5), Seconds(2)).print

    ssc.start()
    ssc.awaitTermination()
  }
}

번호 제목 날짜 조회 수
85 spark에서 hive table을 읽어 출력하는 예제 소스 2017.03.09 4848
84 spark2.0.0에서 hive 2.0.1 table을 읽어 출력하는 예제 소스(HiveContext, SparkSession, SQLContext) 2017.03.09 3255
83 It is indirectly referenced from required .class files 오류 발생시 조치방법 2017.03.09 4198
82 spark 2.0.0의 api를 이용하는 예제 프로그램 2017.03.15 3108
81 JavaStreamingContext를 이용하여 스트림으로 들어오는 문자열 카운트 소스 2017.03.30 2551
80 streaming작업시 입력된 값에 대한 사본을 만들게 되는데 이것이 실패했을때 발생하는 경고메세지 2017.04.03 3841
79 Caused by: java.lang.ClassNotFoundException: org.apache.spark.Logging 발생시 조치사항 2017.04.19 3754
78 Spark에서 Serializable관련 오류및 조치사항 2017.04.21 7743
77 Spark에서 KafkaUtils.createStream()를 이용하여 이용하여 kafka topic에 접근하여 객채로 저장된 값을 가져오고 처리하는 예제 소스 2017.04.26 2802
76 Ubuntu 16.04 LTS에 Hive 2.1.1설치하면서 "Version information not found in metastore"발생하는 오류원인및 조치사항 2017.05.03 3088
75 Hive MetaStore Server기동시 Could not create "increment"/"table" value-generation container SEQUENCE_TABLE since autoCreate flags do not allow it. 오류발생시 조치사항 2017.05.03 3112
74 Windows7 64bit 환경에서 Apache Spark 2.2.0 설치하기 2017.07.26 4409
73 spark stream처리할때 두개의 client프로그램이 동일한 checkpoint로 접근할때 발생하는 오류 내용 2018.01.16 3537
72 Could not compute split, block input-0-1517397051800 not found형태의 오류가 발생시 조치방법 2018.02.01 3290
71 spark-submit 실행시 "java.lang.OutOfMemoryError: Java heap space"발생시 조치사항 2018.02.01 3712
70 scala application 샘플소스(SparkSession이용) 2018.03.07 4366
69 Scala를 이용한 Streaming예제 2018.03.08 4302
» Scala에서 countByWindow를 이용하기(예제) 2018.03.08 4838
67 beeline으로 접근시 "User: gooper is not allowed to impersonate anonymous (state=08S01,code=0)"가 발생하면서 "No current connection"이 발생하는 경우 조치 2018.04.15 4105
66 우분투 16.04LTS에 Jupyter설치 2018.04.17 4022
위로