use of com.zimbra.cs.redolog.RedoLogManager in project zm-mailbox by Zimbra.
the class AllAccountsWaitSet method syncToCommitId.
/**
* Given a CommitId, bring this waitset into sync using the RedoLog system
*
* @param commitIdStr
* @throws ServiceException
* @throws IOException
*/
private void syncToCommitId(String commitIdStr) throws ServiceException, IOException {
assert (mBufferedCommits != null);
assert (!Thread.holdsLock(this));
//
// Step one, go through the redo logs and get the redo logs set of mailboxes
//
RedoLogManager rmgr = RedoLogProvider.getInstance().getRedoLogManager();
CommitId cid = CommitId.decodeFromString(commitIdStr);
Pair<Set<Integer>, CommitId> changes = rmgr.getChangedMailboxesSince(cid);
if (changes == null) {
throw ServiceException.FAILURE("Unable to sync to commit id " + commitIdStr, null);
}
Set<Integer> mailboxes = changes.getFirst();
for (Integer id : mailboxes) {
try {
Mailbox mbox = MailboxManager.getInstance().getMailboxById(id);
if (mbox != null) {
String accountId = mbox.getAccountId();
synchronized (this) {
mCurrentSignalledSessions.add(accountId);
}
}
} catch (ServiceException e) {
ZimbraLog.session.warn("AllAccountsWaitSet skipping notification of mailbox id %d because we could not fetch it", id, e);
}
}
mNextSeqNo = changes.getSecond().encodeToString();
//
synchronized (this) {
for (Pair<String, String> /*commitId*/
p : mBufferedCommits) {
mCurrentSignalledSessions.add(p.getFirst());
mNextSeqNo = p.getSecond();
}
// no more buffering!
mBufferedCommits = null;
if (mCurrentSignalledSessions.size() > 0) {
trySendData();
}
}
}
Aggregations