in aws-lambda-server/src/main/java/jetbrains/buildServer/runner/lambda/web/FinishLambdaController.kt [36:62]
override fun handle(project: SProject, request: HttpServletRequest, properties: Map<String, String>): Nothing? {
val buildId = request.getParameter(LambdaConstants.BUILD_ID)?.toLong()
?: throw JsonControllerException("Parameter missing: ${LambdaConstants.BUILD_ID}", HttpStatus.BAD_REQUEST)
val invocationId = request.getParameter(LambdaConstants.INVOCATION_ID)?.toLong()
?: throw JsonControllerException("Parameter missing: ${LambdaConstants.INVOCATION_ID}", HttpStatus.BAD_REQUEST)
val build by lazy {
runningBuildsManager.findRunningBuildById(buildId) ?: throw JsonControllerException("No build $buildId found", HttpStatus.BAD_REQUEST)
}
val invocationDetails = invocationsCount.compute(buildId) { _, value ->
val invocationDetails = value ?: kotlin.run {
val buildPromotion = build.buildPromotion as BuildPromotionEx
val numBuilds = buildPromotion.getAttribute(LambdaConstants.NUM_INVOCATIONS_PARAM) as Long?
?: throw JsonControllerException("No number of invocations has been stored", HttpStatus.INTERNAL_SERVER_ERROR)
InvocationDetails(numBuilds.toInt(), emptySet())
}
invocationDetails.copy(finishedBuilds = invocationDetails.finishedBuilds + invocationId)
}!!
if (invocationDetails.numBuilds == invocationDetails.finishedBuilds.size) {
build.finish(Date())
invocationsCount.remove(buildId)
}
return null
}