private void handleFailure(File file) {
        failures.putIfAbsent(file, 0);
        var failCount = failures.compute(file, (f, count) -> count + 1);
        if (failCount > maxFailures) {
            log.log(Level.WARNING, "Unable to process file " + file + " after trying " + maxFailures + " times, moving it to " + failuresPath);
            moveProcessedFile(file, failuresPath);
        } else {
            log.log(Level.INFO, "Unable to process file " + file + " after trying " + maxFailures + " times, will retry");
        }
    }
Spooler that will write an entry to a file and read files that are ready to be sent.
Files are written in JSON Lines text file format.

@author hmusum
container-search/src/main/java/com/yahoo/search/logging/Spooler.java