Created
January 24, 2019 17:14
-
-
Save rssanders3/3d7631f29565e3c2bbd71f1d8596d467 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| val checkpointDirectory = "hdfs://..." // define checkpoint directory | |
| // Function to create and setup a new StreamingContext | |
| def functionToCreateContext(): StreamingContext = { | |
| val ssc = new StreamingContext(...) // new context | |
| val lines = ssc.socketTextStream(...) // create DStreams | |
| ... | |
| ssc.checkpoint(checkpointDirectory) // set checkpoint directory | |
| ssc // Return the StreamingContext | |
| } | |
| // Get StreamingContext from checkpoint data or create a new one | |
| val ssc = StreamingContext.getOrCreate(checkpointDirectory, functionToCreateContext) | |
| ssc.start() // Start the context |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment