私は自分のプログラムで長時間の反復を行っており、数回の反復ごとにキャッシュしてチェックポイントを設定したいので (この手法は、Web で長い系統をカットするために推奨されています)、これを行うことで StackOverflowError が発生しません。
for (i <- 2 to 100) {
//cache and checkpoint ever 30 iterations
if (i % 30 == 0) {
graph.cache
graph.checkpoint
//I use numEdges in order to start the transformation I need
graph.numEdges
}
//graphs are stored to a list
//here I use the graph of previous iteration to this iteration
//and perform a transformation
}
そして、このようにチェックポイントディレクトリを設定しました
val sc = new SparkContext(conf)
sc.setCheckpointDir("checkpoints/")
ただし、最終的にプログラムを実行すると、例外が発生します
Exception in thread "main" org.apache.spark.SparkException: Invalid checkpoint directory
私は 3 台のコンピューターを使用しており、各コンピューターには Ubuntu 14.04 がインストールされており、各コンピューターで Hadoop 2.4 以降を備えたビルド済みバージョンの spark 1.4.1 も使用しています。