메뉴 건너뛰기

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()
  }
}

번호 제목 날짜 조회 수
21 streaming작업시 입력된 값에 대한 사본을 만들게 되는데 이것이 실패했을때 발생하는 경고메세지 2017.04.03 3841
20 Scala버젼 변경 혹은 상황에 맞게 Spark소스 컴파일하기 2016.05.31 4005
19 start-all.sh로 spark데몬 기동시 "JAVA_HOME is not set"오류 발생시 조치사항 2016.08.01 4091
18 It is indirectly referenced from required .class files 오류 발생시 조치방법 2017.03.09 4109
17 java.lang.OutOfMemoryError: unable to create new native thread오류 발생지 조치사항 2016.10.17 4159
16 Apache Spark와 Drools를 이용한 CEP구현 테스트 2016.07.15 4212
15 spark 온라인 책자링크 (제목 : mastering-apache-spark) 2016.05.25 4248
14 spark-env.sh에서 사용할 수있는 항목. 2016.05.24 4275
13 scala application 샘플소스(SparkSession이용) 2018.03.07 4363
12 Windows7 64bit 환경에서 Apache Spark 2.2.0 설치하기 2017.07.26 4395
11 spark-submit으로 spark application실행하는 다양한 방법 2016.05.25 4406
» Scala에서 countByWindow를 이용하기(예제) 2018.03.08 4421
9 Spark 1.6.1 설치후 HA구성 2016.05.24 4439
8 spark client프로그램 기동시 "Error initializing SparkContext"오류 발생할때 조치사항 2016.05.27 4551
7 "Initial job has not accepted any resources; check your cluster UI to ensure that workers are registered and have sufficient resources"오류 발생시 조치사항 2016.05.25 4562
6 spark에서 hive table을 읽어 출력하는 예제 소스 2017.03.09 4846
5 VisualVM 1.3.9을 이용한 spark-submit JVM 모니터링을 위한 설정및 spark-submit실행 옵션 2016.10.28 4855
4 Spark 2.1.1 clustering(5대) 설치(YARN기반) 2016.04.22 4957
3 spark-sql실행시 Caused by: java.lang.NumberFormatException: For input string: "0s" 오류발생시 조치사항 2016.06.09 7107
2 Spark에서 Serializable관련 오류및 조치사항 2017.04.21 7743
위로