private void rollAll(final boolean force) {
        LOGGER.debug("rollAll()");

        final Instant currentTime = Instant.now();
        currentDestinations.forEach(1, (key, destination) -> {
            // We have to do this here as foreach runs multiple threads so each thread needs to run as proc user
            securityContext.asProcessingUser(() -> {
                // Try and lock this destination as we can't flush or roll it if
                // another thread has the lock.
                boolean rolled = false;
                if (destination.tryLock()) {
                    try {
                        try {
                            rolled = destination.tryFlushAndRoll(force, currentTime);
                        } catch (final IOException | RuntimeException e) {
                            rolled = true;
                            LOGGER.error(e.getMessage(), e);
                        }

                        if (rolled) {
                            removeDestination(key, destination);
                        }

                    } finally {
                        destination.unlock();
                    }
                }

                if (force && !rolled) {
                    destination.lock();
                    try {
                        try {
                            rolled = destination.tryFlushAndRoll(force, currentTime);
                        } catch (final IOException | RuntimeException e) {
                            rolled = true;
                            LOGGER.error(e.getMessage(), e);
                        }

                        if (rolled) {
                            removeDestination(key, destination);
                        }

                    } finally {
                        destination.unlock();
                    }
                }
            });
        });
    }
Try and lock this destination so that the current thread has exclusive access. Once locked we will attempt to
roll this destination if it needs rolling.
<p>
If it is rolled then this method will return null as this destination can no longer be used, if the destination
does not need rolling yet then it will be returned for use.

@param key         The key that this destination is associated with.
@param destination The destination to lock and attempt to roll.
@return The destination if it didn't need rolling and can be used, null otherwise. The returned
destination is locked for exclusive use by the current thread.
@throws IOException Could be thrown while attempting to flush or close the destination on roll.
stroom-pipeline/src/main/java/stroom/pipeline/destination/RollingDestinations.java