Skip to content

Commit

Permalink
added sparkContext as input parameter in StreamingContext
Browse files Browse the repository at this point in the history
  • Loading branch information
giwa committed Aug 18, 2014
1 parent e7ebb08 commit 636090a
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions python/pyspark/streaming/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class StreamingContext(object):

def __init__(self, master=None, appName=None, sparkHome=None, pyFiles=None,
environment=None, batchSize=1024, serializer=PickleSerializer(), conf=None,
gateway=None, duration=None):
gateway=None, sparkContext=None, duration=None):
"""
Create a new StreamingContext. At least the master and app name and duration
should be set, either through the named parameters here or through C{conf}.
Expand All @@ -55,14 +55,18 @@ def __init__(self, master=None, appName=None, sparkHome=None, pyFiles=None,
@param conf: A L{SparkConf} object setting Spark properties.
@param gateway: Use an existing gateway and JVM, otherwise a new JVM
will be instatiated.
@param duration: A L{Duration} Duration for SparkStreaming
@param sparkContext: L{SparkContext} object.
@param duration: A L{Duration} object for SparkStreaming.
"""

# Create the Python Sparkcontext
self._sc = SparkContext(master=master, appName=appName, sparkHome=sparkHome,
pyFiles=pyFiles, environment=environment, batchSize=batchSize,
serializer=serializer, conf=conf, gateway=gateway)
if sparkContext is None:
# Create the Python Sparkcontext
self._sc = SparkContext(master=master, appName=appName, sparkHome=sparkHome,
pyFiles=pyFiles, environment=environment, batchSize=batchSize,
serializer=serializer, conf=conf, gateway=gateway)
else:
self._sc = sparkContext

# Start py4j callback server.
# Callback sever is need only by SparkStreming; therefore the callback sever
Expand Down

0 comments on commit 636090a

Please sign in to comment.