Skip to content

Commit ec424c5

Browse files
chaoqin-li1123HeartSaVioR
authored andcommitted
[SPARK-42075][DSTREAM] Deprecate DStream API
### What changes were proposed in this pull request? Deprecate the DStream interface by deprecating the StreamingContext api. ### Why are the changes needed? DStream is not longer maintained. Encourage user to migrate to structured streaming. ### Does this PR introduce _any_ user-facing change? Yes, user that use DStream will see deprecation warning. ### How was this patch tested? No functional change Closes apache#39647 from chaoqin-li1123/deprecate_dstream. Authored-by: Chaoqin Li <[email protected]> Signed-off-by: Jungtaek Lim <[email protected]>
1 parent db06f3e commit ec424c5

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed

python/pyspark/streaming/context.py

+12
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
from pyspark.streaming.listener import StreamingListener
2727
from pyspark.streaming.util import TransformFunction, TransformFunctionSerializer
2828

29+
import warnings
30+
2931
__all__ = ["StreamingContext"]
3032

3133
T = TypeVar("T")
@@ -41,6 +43,12 @@ class StreamingContext:
4143
respectively. `context.awaitTermination()` allows the current thread
4244
to wait for the termination of the context by `stop()` or by an exception.
4345
46+
.. deprecated:: Spark 3.4.0
47+
This is deprecated as of Spark 3.4.0.
48+
There are no longer updates to DStream and it's a legacy project.
49+
There is a newer and easier to use streaming engine in Spark called Structured Streaming.
50+
You should use Spark Structured Streaming for your streaming applications.
51+
4452
Parameters
4553
----------
4654
sparkContext : :class:`SparkContext`
@@ -61,6 +69,10 @@ def __init__(
6169
batchDuration: Optional[int] = None,
6270
jssc: Optional[JavaObject] = None,
6371
):
72+
warnings.warn(
73+
"DStream is deprecated as of Spark 3.4.0. Migrate to Structured Streaming.",
74+
FutureWarning,
75+
)
6476
self._sc = sparkContext
6577
self._jvm = self._sc._jvm
6678
self._jssc = jssc or self._initialize_context(self._sc, batchDuration)

streaming/src/main/scala/org/apache/spark/streaming/StreamingContext.scala

+14-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,13 @@ import org.apache.spark.util.{CallSite, ShutdownHookManager, ThreadUtils, Utils}
6060
* using `context.start()` and `context.stop()`, respectively.
6161
* `context.awaitTermination()` allows the current thread to wait for the termination
6262
* of the context by `stop()` or by an exception.
63+
* @deprecated This is deprecated as of Spark 3.4.0.
64+
* There are no longer updates to DStream and it's a legacy project.
65+
* There is a newer and easier to use streaming engine
66+
* in Spark called Structured Streaming.
67+
* You should use Spark Structured Streaming for your streaming applications.
6368
*/
69+
@deprecated("DStream is deprecated. Migrate to Structured Streaming.", "Spark 3.4.0")
6470
class StreamingContext private[streaming] (
6571
_sc: SparkContext,
6672
_cp: Checkpoint,
@@ -740,13 +746,20 @@ class StreamingContext private[streaming] (
740746
/**
741747
* StreamingContext object contains a number of utility functions related to the
742748
* StreamingContext class.
749+
*
750+
* @deprecated This is deprecated as of Spark 3.4.0.
751+
* There are no longer updates to DStream and it's a legacy project.
752+
* There is a newer and easier to use streaming engine
753+
* in Spark called Structured Streaming.
754+
* You should use Spark Structured Streaming for your streaming applications.
743755
*/
744-
756+
@deprecated("DStream is deprecated. Migrate to Structured Streaming.", "Spark 3.4.0")
745757
object StreamingContext extends Logging {
746758

747759
/**
748760
* Lock that guards activation of a StreamingContext as well as access to the singleton active
749761
* StreamingContext in getActiveOrCreate().
762+
*
750763
*/
751764
private val ACTIVATION_LOCK = new Object()
752765

streaming/src/main/scala/org/apache/spark/streaming/api/java/JavaStreamingContext.scala

+6
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,13 @@ import org.apache.spark.streaming.scheduler.StreamingListener
5050
* computation can be started and stopped using `context.start()` and `context.stop()`,
5151
* respectively. `context.awaitTermination()` allows the current thread to wait for the
5252
* termination of a context by `stop()` or by an exception.
53+
* @deprecated This is deprecated as of Spark 3.4.0.
54+
* There are no longer updates to DStream and it's a legacy project.
55+
* There is a newer and easier to use streaming engine
56+
* in Spark called Structured Streaming.
57+
* You should use Spark Structured Streaming for your streaming applications.
5358
*/
59+
@deprecated("DStream is deprecated. Migrate to Structured Streaming.", "Spark 3.4.0")
5460
class JavaStreamingContext(val ssc: StreamingContext) extends Closeable {
5561

5662
/**

0 commit comments

Comments
 (0)