Spark ForEachPartitionAsync可以在工作节点上异步吗?

时间:2018-12-09 16:40:21

标签: scala apache-spark asynchronous

我写了一个自定义的火花塞。在我的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。)。

0 个答案:

没有答案
相关问题