Search in sources :

Example 6 with AccountWithModifications

use of com.zimbra.soap.type.AccountWithModifications in project zm-mailbox by Zimbra.

the class ImapServerListener method processAdminWaitSetResponse.

private synchronized void processAdminWaitSetResponse(AdminWaitSetResponse wsResp) throws Exception {
    String respWSId = wsResp.getWaitSetId();
    if (wsID == null || !wsID.equalsIgnoreCase(respWSId)) {
        // rogue response, which we are not interested in
        ZimbraLog.imap.error("Received AdminWaitSetResponse for another waitset ", respWSId);
        return;
    }
    if (wsResp.getCanceled() != null && wsResp.getCanceled().booleanValue() && wsID.equalsIgnoreCase(respWSId)) {
        // this waitset was canceled
        ZimbraLog.imap.warn("AdminWaitSet %s was cancelled", respWSId);
        deleteWaitSet();
        restoreWaitSet();
        return;
    }
    String seqNum = wsResp.getSeqNo();
    int modSeq = 0;
    if (seqNum != null) {
        modSeq = Integer.parseInt(wsResp.getSeqNo());
    }
    ZimbraLog.imap.debug("Received AdminWaitSetResponse for waitset %s. Updating sequence to %s", respWSId, wsResp.getSeqNo());
    lastSequence.set(modSeq);
    List<AccountWithModifications> signalledAccounts = wsResp.getSignalledAccounts();
    if (signalledAccounts != null && signalledAccounts.size() > 0) {
        Iterator<AccountWithModifications> iter = signalledAccounts.iterator();
        while (iter.hasNext()) {
            AccountWithModifications accInfo = iter.next();
            notifyAccountChange(accInfo);
            removeNotifyWhenCaughtUp(accInfo.getId(), accInfo.getLastChangeId());
        }
    }
    cleanupCatchupToKnownLastChangeId();
    // check for errors
    List<IdAndType> errors = wsResp.getErrors();
    if (errors != null) {
        Iterator<IdAndType> iter = errors.iterator();
        while (iter.hasNext()) {
            IdAndType error = iter.next();
            String errorType = error.getType();
            String accId = error.getId();
            if (errorType != null) {
                ZimbraLog.imap.error("AdminWaitSetResponse returned an error for account %s. Error: %s", accId, errorType);
                WaitSetError.Type err = WaitSetError.Type.valueOf(errorType);
                if (err == WaitSetError.Type.NO_SUCH_ACCOUNT || err == WaitSetError.Type.MAILBOX_DELETED || err == WaitSetError.Type.MAINTENANCE_MODE || err == WaitSetError.Type.WRONG_HOST_FOR_ACCOUNT || err == WaitSetError.Type.ERROR_LOADING_MAILBOX) {
                    ConcurrentHashMap<Integer, Set<ImapRemoteSession>> foldersToSessions = sessionMap.get(accId);
                    sessionMap.remove(accId);
                    if (foldersToSessions != null && !foldersToSessions.isEmpty()) {
                        foldersToSessions.forEach((folderId, listeners) -> {
                            if (listeners != null) {
                                for (ImapRemoteSession l : listeners) {
                                    SessionCache.clearSession(l);
                                }
                            }
                        });
                    }
                }
            }
        }
    }
    if (sessionMap.isEmpty()) {
        deleteWaitSet();
    } else {
        continueWaitSet();
    }
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) AccountWithModifications(com.zimbra.soap.type.AccountWithModifications) WaitSetError(com.zimbra.cs.session.WaitSetError) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) IdAndType(com.zimbra.soap.type.IdAndType)

Aggregations

AccountWithModifications (com.zimbra.soap.type.AccountWithModifications)6 ZMailbox (com.zimbra.client.ZMailbox)3 Mailbox (com.zimbra.cs.mailbox.Mailbox)3 AdminCreateWaitSetResponse (com.zimbra.soap.admin.message.AdminCreateWaitSetResponse)3 AdminWaitSetRequest (com.zimbra.soap.admin.message.AdminWaitSetRequest)3 AdminWaitSetResponse (com.zimbra.soap.admin.message.AdminWaitSetResponse)3 PendingFolderModifications (com.zimbra.soap.mail.type.PendingFolderModifications)3 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)3 Test (org.junit.Test)3 ZFolder (com.zimbra.client.ZFolder)2 AdminCreateWaitSetRequest (com.zimbra.soap.admin.message.AdminCreateWaitSetRequest)2 AdminDestroyWaitSetRequest (com.zimbra.soap.admin.message.AdminDestroyWaitSetRequest)2 AdminDestroyWaitSetResponse (com.zimbra.soap.admin.message.AdminDestroyWaitSetResponse)2 QueryWaitSetRequest (com.zimbra.soap.admin.message.QueryWaitSetRequest)2 QueryWaitSetResponse (com.zimbra.soap.admin.message.QueryWaitSetResponse)2 CreateWaitSetRequest (com.zimbra.soap.mail.message.CreateWaitSetRequest)2 CreateWaitSetResponse (com.zimbra.soap.mail.message.CreateWaitSetResponse)2 WaitSetRequest (com.zimbra.soap.mail.message.WaitSetRequest)2 WaitSetResponse (com.zimbra.soap.mail.message.WaitSetResponse)2 HashSet (java.util.HashSet)2