This method is called by the system when the receiver is started.
This method is called by the system when the receiver is started. This function
must initialize all resources (threads, buffers, etc.) necessary for receiving data.
This function must be non-blocking, so receiving the data must occur on a different
thread. Received data can be stored with Spark by calling store(data)
.
If there are errors in threads started here, then following options can be done
(i) reportError(...)
can be called to report the error to the driver.
The receiving of data will continue uninterrupted.
(ii) stop(...)
can be called to stop receiving data. This will call onStop()
to
clear up all resources allocated (threads, buffers, etc.) during onStart()
.
(iii) restart(...)
can be called to restart the receiver. This will call onStop()
immediately, and then onStart()
after a delay.
This method is called by the system when the receiver is stopped.
This method is called by the system when the receiver is stopped. All resources
(threads, buffers, etc.) set up in onStart()
must be cleaned up in this method.
Check if the receiver has started or not.
Check if receiver has been marked for stopping.
Check if receiver has been marked for stopping. Use this to identify when the receiving of data should be stopped.
Override this to specify a preferred location (hostname).
Report exceptions in receiving data.
Restart the receiver.
Restart the receiver. This method schedules the restart and returns
immediately. The stopping and subsequent starting of the receiver
(by calling onStop()
and onStart()
) is performed asynchronously
in a background thread.
Restart the receiver.
Restart the receiver. This method schedules the restart and returns
immediately. The stopping and subsequent starting of the receiver
(by calling onStop()
and onStart()
) is performed asynchronously
in a background thread. The delay between the stopping and the starting
is defined by the Spark configuration spark.streaming.receiverRestartDelay
.
The message
and exception
will be reported to the driver.
Restart the receiver.
Restart the receiver. This method schedules the restart and returns
immediately. The stopping and subsequent starting of the receiver
(by calling onStop()
and onStart()
) is performed asynchronously
in a background thread. The delay between the stopping and the starting
is defined by the Spark configuration spark.streaming.receiverRestartDelay
.
The message
will be reported to the driver.
Stop the receiver completely due to an exception
Stop the receiver completely.
Store the bytes of received data as a data block into Spark's memory.
Store the bytes of received data as a data block into Spark's memory. The metadata will be associated with this block of data for being used in the corresponding InputDStream.
Store the bytes of received data as a data block into Spark's memory.
Store the bytes of received data as a data block into Spark's memory. Note that the data in the ByteBuffer must be serialized using the same serializer that Spark is configured to use.
Store an iterator of received data as a data block into Spark's memory.
Store an iterator of received data as a data block into Spark's memory. The metadata will be associated with this block of data for being used in the corresponding InputDStream.
Store an iterator of received data as a data block into Spark's memory.
Store an iterator of received data as a data block into Spark's memory.
Store an iterator of received data as a data block into Spark's memory. The metadata will be associated with this block of data for being used in the corresponding InputDStream.
Store an iterator of received data as a data block into Spark's memory.
Store an ArrayBuffer of received data as a data block into Spark's memory.
Store an ArrayBuffer of received data as a data block into Spark's memory. The metadata will be associated with this block of data for being used in the corresponding InputDStream.
Store an ArrayBuffer of received data as a data block into Spark's memory.
Store a single item of received data to Spark's memory.
Store a single item of received data to Spark's memory. These single items will be aggregated together into data blocks before being pushed into Spark's memory.
Get the unique identifier the receiver input stream that this receiver is associated with.
:: DeveloperApi :: Abstract class of a receiver that can be run on worker nodes to receive external data. A custom receiver can be defined by defining the functions
onStart()
andonStop()
.onStart()
should define the setup steps necessary to start receiving data, andonStop()
should define the cleanup steps necessary to stop receiving data. Exceptions while receiving can be handled either by restarting the receiver withrestart(...)
or stopped completely bystop(...)
.A custom receiver in Scala would look like this.
A custom receiver in Java would look like this.