private void rolloverCheck()

in activeio-core/src/main/java/org/apache/activeio/journal/active/JournalImpl.java [268:313]


    private void rolloverCheck() throws IOException {

        // See if we need to issue an overflow notification.
        if (eventListener != null && file.isPastHalfActive()
                && overflowNotificationTime + OVERFLOW_RENOTIFICATION_DELAY < System.currentTimeMillis() && !doingNotification ) {
            doingNotification = true;
            try {
                // We need to send an overflow notification to free up
                // some logFiles.
                Location safeSpot = file.getFirstRecordLocationOfSecondActiveLogFile();
                eventListener.overflowNotification(safeSpot);
                overflowNotificationTime = System.currentTimeMillis();
            } finally {
                doingNotification = false;
            }
        }

        // Is it time to roll over?
        if (appendLogFileOffset > rolloverFence ) {

            // Can we roll over?
            if ( !file.canActivateNextLogFile() ) {
                // don't delay the next overflow notification.
                overflowNotificationTime -= OVERFLOW_RENOTIFICATION_DELAY;
                
            } else {
                
                try {
                    final FutureTask result = new FutureTask(new Callable() {
                        public Object call() throws Exception {
                            return queuedActivateNextLogFile();
                        }});
                    executor.execute(result);
                    Location location = (Location) result.get();
                    appendLogFileId = location.getLogFileId();
                    appendLogFileOffset = location.getLogFileOffset();
    
                } catch (InterruptedException e) {
                    throw (IOException) new IOException("Interrupted.").initCause(e);
                }
                catch (ExecutionException e) {
                    throw handleExecutionException(e);
                }
            }
        }
    }