메뉴 건너뛰기

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

번호 제목 날짜 조회 수
240 Cloudera설치중에 "Error, CM server guid updated"오류 발생시 조치방법 2018.03.29 290
239 Cloudera가 사용하는 서비스별 포트 2018.03.29 427
238 Cloudera가 사용하는 서비스별 디렉토리 2018.03.29 360
237 cloudera-scm-agent 설정파일 위치및 재시작 명령문 2018.03.29 405
236 Components of the Impala Server 2018.03.21 378
235 HDFS Balancer설정및 수행 2018.03.21 277
234 hadoop 클러스터 실행 스크립트 정리 2018.03.20 699
233 HA(Namenode, ResourceManager, Kerberos) 및 보안(Zookeeper, Hadoop) 2018.03.16 188
232 update 샘플 2018.03.12 1030
» Scala에서 countByWindow를 이용하기(예제) 2018.03.08 630
230 Scala를 이용한 Streaming예제 2018.03.08 508
229 scala application 샘플소스(SparkSession이용) 2018.03.07 304
228 spark-submit 실행시 "java.lang.OutOfMemoryError: Java heap space"발생시 조치사항 2018.02.01 641
227 Could not compute split, block input-0-1517397051800 not found형태의 오류가 발생시 조치방법 2018.02.01 334
226 Hadoop의 Datanode를 Decommission하고 나서 HBase의 regionservers파일에 해당 노드명을 지웠는데 여전히 "Dead regionser"로 표시되는 경우 처리 2018.01.25 494
225 spark stream처리할때 두개의 client프로그램이 동일한 checkpoint로 접근할때 발생하는 오류 내용 2018.01.16 1167
224 [Decommission]시 시간이 많이 걸리면서(수일) Decommission이 완료되지 않는 경우 조치 2018.01.03 6062
223 [2.7.2] distribute-exclude.sh사용할때 ssh 포트변경에 따른 오류발생시 조치사항 2018.01.02 561
222 hadoop cluster에 포함된 노드중에서 문제있는 decommission하는 방법및 절차 file 2017.12.28 996
221 [DBeaver 4.3.0]import/export시 "Client home is not specified for connection" 오류발생시 조치사항 2017.12.21 884
위로