谢谢-我就是这样实现的
val tobeprocessed:Seq[String]=Seq(“FileName1”,“FileName2”,“FileName3,”FileName4)//创建了一个具有文件名的Seq
val latch = new CDL(tobeProcesssed.size)
val trackFutures: Future[Seq[Try[Boolean]]] = Future.traverse(tobeProcesssed.seq) { fileNm =>
Future {
LOG.info("In the Futures Loop for {}", fileNm)
Try {
doProcessing(fileNm)
}
}
}
trackFutures.map { seq =>
seq.map {
case Success(state) => {
if (state) {
LOG.info("On Sucess - {} - {}", latch.getCount, state)
return = 0
latch.countDown()
} else {
LOG.error("Failed - {} - {}", latch.getCount, state)
while (latch.getCount > 0) {
return = 1
latch.countDown()
}
}
}
case Failure(exception) => {
LOG.error("Versioning Failed -{} - {}", latch.countDown(), exception)
while (latch.getCount > 0) {
return = = 1
latch.countDown()
}
}
}
}
latch.await()