메뉴 건너뛰기

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

번호 제목 날짜 조회 수
501 Cloudera가 사용하는 서비스별 포트 2018.03.29 456
500 Cloudera가 사용하는 서비스별 디렉토리 2018.03.29 436
499 cloudera-scm-agent 설정파일 위치및 재시작 명령문 2018.03.29 731
498 [CentOS] 네트워크 설정 2018.03.26 494
497 Components of the Impala Server 2018.03.21 401
496 HDFS Balancer설정및 수행 2018.03.21 340
495 hadoop 클러스터 실행 스크립트 정리 2018.03.20 728
494 HA(Namenode, ResourceManager, Kerberos) 및 보안(Zookeeper, Hadoop) 2018.03.16 213
493 자주쓰는 유용한 프로그램 2018.03.16 1398
492 에러 추적(Error Tracking) 및 로그 취합(logging aggregation) 시스템인 Sentry 설치 2018.03.14 273
491 update 샘플 2018.03.12 1108
490 이미지 관리 오픈소스 목록 2018.03.11 519
» Scala에서 countByWindow를 이용하기(예제) 2018.03.08 695
488 Scala를 이용한 Streaming예제 2018.03.08 673
487 scala application 샘플소스(SparkSession이용) 2018.03.07 821
486 fuseki의 endpoint를 이용한 insert, delete하는 sparql예시 2018.02.14 246
485 프로세스를 확인해서 프로세스를 삭제하는 shell script예제(cryptonight) 2018.02.02 509
484 spark-submit 실행시 "java.lang.OutOfMemoryError: Java heap space"발생시 조치사항 2018.02.01 693
483 Could not compute split, block input-0-1517397051800 not found형태의 오류가 발생시 조치방법 2018.02.01 389
482 Hadoop의 Datanode를 Decommission하고 나서 HBase의 regionservers파일에 해당 노드명을 지웠는데 여전히 "Dead regionser"로 표시되는 경우 처리 2018.01.25 635
위로