我写了一个自定义的火花塞。在我的addBatch
方法中,我使用了ForEachPartitionAsync
,如果我没有记错的话,它只会使驱动程序异步工作,并返回将来。
val work: FutureAction[Unit] = rdd.foreachPartitionAsync { rows =>
val sourceInfo: StreamSourceInfo = serializeRowsAsInputStream(schema, rows)
val ackIngestion = Future {
ingestRows(sourceInfo) } andThen {
case Success(ingestion) => ackIngestionDone(partitionId, ingestion)
}
Await.result(ackIngestion, timeOut) // I would like to remove this line..
}
work onSuccess {
case _ => // move data from temporary table, report success of all workers
}
work onFailure{
//delete tmp data
case t => throw t.getCause
}
我找不到在不阻塞Await调用的情况下运行工作程序节点的方法,好像我删除了它们一样,尽管将来还没有真正完成,但已向work
将来对象报告了成功。 / p>
有没有办法向驾驶员报告所有工人都完成了 他们的异步作业?
注意:我看过foreachPartitionAsync
函数,它只有一个实现期望一个函数返回一个Unit(我希望它有另一个实现返回一个Future或一个CountDownLatch。)。