本期内容:
1. Spark Streaming的Transformation、Action源码图解
2. Spark Streaming的Input、Output源码图解

StreamingContext成员:socketStream

  /**
   * Create a input stream from TCP source hostname:port. Data is received using
   * a TCP socket and the receive bytes it interepreted as object using the given
   * converter.
   * @param hostname      Hostname to connect to for receiving data
   * @param port          Port to connect to for receiving data
   * @param converter     Function to convert the byte stream to objects
   * @param storageLevel  Storage level to use for storing the received objects
   * @tparam T            Type of the objects received (after converting bytes to objects)
   */
  def socketStream[T: ClassTag](
      hostname: String,
      port: Int,
      converter: (InputStream) => Iterator[T],
      storageLevel: StorageLevel
    ): ReceiverInputDStream[T] = {
    new SocketInputDStream[T](this, hostname, port, converter, storageLevel)
  }

SocketInputDStream:

class SocketInputDStream[T: ClassTag](
    ssc_ : StreamingContext,
    host: String,
    port: Int,
    bytesToObjects: InputStream => Iterator[T],
    storageLevel: StorageLevel
  ) extends ReceiverInputDStream[T](ssc_) {

  def getReceiver(): Receiver[T] = {
    new SocketReceiver(host, port, bytesToObjects, storageLevel)
  }
}

ReceiverInputDStream:

abstract class ReceiverInputDStream[T: ClassTag](ssc_ : StreamingContext)
  extends InputDStream[T](ssc_) {
...

InputDStream:

  ssc.graph.addInputStream(this)

把ImputDStream放入到了graph中。
DStream.foreachRDD产生ForEachDStream对象,该对象通过register对象也放入了graph中。

Spark学习笔记(23)Transformation、Action等源码图解

相关文章:

  • 2021-10-17
  • 2021-04-19
  • 2021-12-29
  • 2022-12-23
  • 2021-06-09
  • 2021-12-07
  • 2021-04-07
  • 2022-12-23
猜你喜欢
  • 2021-05-25
  • 2021-10-03
  • 2021-08-30
  • 2021-09-19
  • 2021-10-26
  • 2021-11-07
相关资源
相似解决方案