@Throws(Exception::class) private fun waitForReportRunCompletion( reporting: Dfareporting, userProfileId: Long, file: File ): File? { var file: File = file var interval: Int for (i in 0..MAX_POLLING_ATTEMPTS) { if (!file.getStatus().equals("PROCESSING")) { break } interval = (POLL_TIME_INCREMENT * Math.pow(1.6, i.toDouble())) System.out.printf("Polling again in %s ms.%n", interval) Thread.sleep(interval.toLong()) file = reporting.reports().files().get(userProfileId, file.getReportId(), file.getId()) .execute() } return file }
Waits for a report file to generate with exponential back-off .