Search in sources :

Example 1 with IdAndType

use of com.zimbra.soap.type.IdAndType 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)

Example 2 with IdAndType

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

the class WaitSetBase method handleQuery.

@Override
public synchronized WaitSetInfo handleQuery() {
    WaitSetInfo info = WaitSetInfo.createForWaitSetIdOwnerInterestsLastAccessDate(mWaitSetId, mOwnerAccountId, WaitSetRequest.expandInterestStr(defaultInterest), mLastAccessedTime);
    if (mCurrentErrors.size() > 0) {
        for (WaitSetError error : mCurrentErrors) {
            info.addError(new IdAndType(error.accountId, error.error.name()));
        }
    }
    // signaled accounts
    if (mCurrentSignalledAccounts.size() > 0) {
        StringBuilder signaledStr = new StringBuilder();
        for (String accountId : mCurrentSignalledAccounts) {
            if (signaledStr.length() > 0)
                signaledStr.append(",");
            signaledStr.append(accountId);
        }
        info.setSignalledAccounts(new AccountsAttrib(signaledStr.toString()));
    }
    return info;
}
Also used : WaitSetInfo(com.zimbra.soap.admin.type.WaitSetInfo) AccountsAttrib(com.zimbra.soap.admin.type.AccountsAttrib) IdAndType(com.zimbra.soap.type.IdAndType)

Aggregations

IdAndType (com.zimbra.soap.type.IdAndType)2 WaitSetError (com.zimbra.cs.session.WaitSetError)1 AccountsAttrib (com.zimbra.soap.admin.type.AccountsAttrib)1 WaitSetInfo (com.zimbra.soap.admin.type.WaitSetInfo)1 AccountWithModifications (com.zimbra.soap.type.AccountWithModifications)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1