Search in sources :

Example 1 with MailboxInMaintenanceException

use of com.zimbra.cs.mailbox.MailServiceException.MailboxInMaintenanceException in project zm-mailbox by Zimbra.

the class ImapSessionManager method closeFolder.

void closeFolder(ImapSession session, boolean isUnregistering) {
    // detach session from handler and jettison session state from folder
    if (session.isInteractive()) {
        session.inactivate();
    }
    // no fancy stuff for search folders since they're always recalculated on load
    if (session.isVirtual()) {
        session.detach();
        return;
    }
    // checkpoint the folder data if desired
    if (SERIALIZE_ON_CLOSE) {
        try {
            // could use session.serialize() if we want to leave it in memory...
            ZimbraLog.imap.debug("Paging session during close: %s", session);
            session.unload(false);
        } catch (MailboxInMaintenanceException miMe) {
            if (ZimbraLog.imap.isDebugEnabled()) {
                ZimbraLog.imap.info("Mailbox in maintenance detected during close - will detach %s", session, miMe);
            } else {
                ZimbraLog.imap.info("Mailbox in maintenance detected during close - will detach %s", session);
            }
            session.detach();
            return;
        } catch (Exception e) {
            ZimbraLog.imap.warn("Skipping error while trying to serialize during close %s", session, e);
        }
    }
    if (isUnregistering) {
        return;
    }
    // recognize if we're not configured to allow sessions to hang around after end of SELECT
    if (TERMINATE_ON_CLOSE) {
        session.detach();
        return;
    }
    // if there are still other listeners on this folder, this session is unnecessary
    Mailbox mbox = session.getMailbox();
    if (mbox != null) {
        mbox.lock.lock();
        try {
            for (Session listener : mbox.getListeners(Session.Type.IMAP)) {
                ImapSession i4listener = (ImapSession) listener;
                if (i4listener != session && i4listener.getFolderId() == session.getFolderId()) {
                    ZimbraLog.imap.trace("more recent listener exists for folder.  Detaching %s", session);
                    session.detach();
                    recordAccess(i4listener);
                    return;
                }
            }
        } finally {
            mbox.lock.release();
        }
    }
}
Also used : Mailbox(com.zimbra.cs.mailbox.Mailbox) MailboxInMaintenanceException(com.zimbra.cs.mailbox.MailServiceException.MailboxInMaintenanceException) ServiceException(com.zimbra.common.service.ServiceException) MailboxInMaintenanceException(com.zimbra.cs.mailbox.MailServiceException.MailboxInMaintenanceException) Session(com.zimbra.cs.session.Session)

Example 2 with MailboxInMaintenanceException

use of com.zimbra.cs.mailbox.MailServiceException.MailboxInMaintenanceException in project zm-mailbox by Zimbra.

the class ImapSessionManager method closeFolder.

protected void closeFolder(ImapListener session, boolean isUnregistering) {
    // detach session from handler and jettison session state from folder
    if (session.isInteractive()) {
        session.inactivate();
    }
    // no fancy stuff for search folders since they're always recalculated on load
    if (session.isVirtual()) {
        session.detach();
        return;
    }
    // checkpoint the folder data if desired
    if (SERIALIZE_ON_CLOSE) {
        try {
            // could use session.serialize() if we want to leave it in memory...
            ZimbraLog.imap.debug("Paging session during close: %s", session);
            session.unload(false);
        } catch (MailboxInMaintenanceException miMe) {
            if (ZimbraLog.imap.isDebugEnabled()) {
                ZimbraLog.imap.info("Mailbox in maintenance detected during close - will detach %s", session, miMe);
            } else {
                ZimbraLog.imap.info("Mailbox in maintenance detected during close - will detach %s", session);
            }
            session.detach();
            return;
        } catch (Exception e) {
            ZimbraLog.imap.warn("Skipping error while trying to serialize during close %s", session, e);
        }
    }
    if (isUnregistering) {
        return;
    }
    // recognize if we're not configured to allow sessions to hang around after end of SELECT
    if (TERMINATE_ON_CLOSE) {
        session.detach();
        return;
    }
    // if there are still other listeners on this folder, this session is unnecessary
    MailboxStore mbox = session.getMailbox();
    if (mbox != null) {
        mbox.lock(true);
        try {
            for (ImapListener i4listener : session.getImapMboxStore().getListeners(session.getFolderItemIdentifier())) {
                if (differentSessions(i4listener, session)) {
                    ZimbraLog.imap.trace("more recent listener exists for folder.  Detaching %s", session);
                    session.detach();
                    recordAccess(i4listener);
                    return;
                }
            }
        } finally {
            mbox.unlock();
        }
    }
}
Also used : MailboxStore(com.zimbra.common.mailbox.MailboxStore) MailboxInMaintenanceException(com.zimbra.cs.mailbox.MailServiceException.MailboxInMaintenanceException) ServiceException(com.zimbra.common.service.ServiceException) MailboxInMaintenanceException(com.zimbra.cs.mailbox.MailServiceException.MailboxInMaintenanceException) MailServiceException(com.zimbra.cs.mailbox.MailServiceException)

Aggregations

ServiceException (com.zimbra.common.service.ServiceException)2 MailboxInMaintenanceException (com.zimbra.cs.mailbox.MailServiceException.MailboxInMaintenanceException)2 MailboxStore (com.zimbra.common.mailbox.MailboxStore)1 MailServiceException (com.zimbra.cs.mailbox.MailServiceException)1 Mailbox (com.zimbra.cs.mailbox.Mailbox)1 Session (com.zimbra.cs.session.Session)1