Skip to content

Commit

Permalink
Made python checkpoint recovery use java to find the checkpoint files
Browse files Browse the repository at this point in the history
  • Loading branch information
tdas committed Aug 21, 2015
1 parent f5b028e commit 9bf151b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
10 changes: 5 additions & 5 deletions python/pyspark/streaming/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,15 +150,15 @@ def getOrCreate(cls, checkpointPath, setupFunc):
@param checkpointPath: Checkpoint directory used in an earlier streaming program
@param setupFunc: Function to create a new context and setup DStreams
"""
# TODO: support checkpoint in HDFS
if not os.path.exists(checkpointPath) or not os.listdir(checkpointPath):
cls._ensure_initialized()
gw = SparkContext._gateway

# Check whether valid checkpoint information exists in the given path
if gw.jvm.CheckpointReader.read(checkpointPath).isEmpty():
ssc = setupFunc()
ssc.checkpoint(checkpointPath)
return ssc

cls._ensure_initialized()
gw = SparkContext._gateway

try:
jssc = gw.jvm.JavaStreamingContext(checkpointPath)
except Exception:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,15 @@ class CheckpointWriter(
private[streaming]
object CheckpointReader extends Logging {

/**
* Read checkpoint files present in the given checkpoint directory. If there are no checkpoint
* files, then return None, else try to return the latest valid checkpoint object. If no
* checkpoint files could be read correctly, then return None.
*/
def read(checkpointDir: String): Option[Checkpoint] = {
read(checkpointDir, new SparkConf(), SparkHadoopUtil.get.conf, ignoreReadError = true)
}

/**
* Read checkpoint files present in the given checkpoint directory. If there are no checkpoint
* files, then return None, else try to return the latest valid checkpoint object. If no
Expand Down

0 comments on commit 9bf151b

Please sign in to comment.