use of com.zimbra.client.ZMailbox.LastChange in project zm-mailbox by Zimbra.
the class ImapSessionManager method waitForWaitSetNotifications.
private void waitForWaitSetNotifications(ImapMailboxStore imapStore, FolderStore folder, ImapRemoteSession irs) {
ZMailbox sessMboxStore = (ZMailbox) irs.getMailbox();
if (sessMboxStore.isUsingSession()) {
return;
/* can rely on SOAP notifications */
}
LastChange zmboxLastKnownChange = sessMboxStore.getLastChange();
if (irs.getLastKnownChangeId() >= zmboxLastKnownChange.getId()) {
return;
/* WaitSet based notifications at least as current as anything we've done */
}
long start = System.currentTimeMillis();
ImapServerListener svrListener = imapStore.getServerListener(folder.getFolderItemIdentifier());
if (svrListener == null) {
return;
}
// Should be rare to have to wait for much of this time
long timeout = LC.imap_max_time_to_wait_for_catchup_millis.longValue();
if (zmboxLastKnownChange.getTime() != 0) {
if (start - zmboxLastKnownChange.getTime() >= timeout) {
ZimbraLog.imap.debug("ImapSessionManager.waitForWaitSetNotifications known a long time");
return;
}
timeout = timeout - (start - zmboxLastKnownChange.getTime());
}
CountDownLatch doneSignal = new CountDownLatch(1);
svrListener.addNotifyWhenCaughtUp(imapStore.getAccountId(), zmboxLastKnownChange.getId(), doneSignal);
try {
doneSignal.await(timeout, TimeUnit.MILLISECONDS);
} catch (InterruptedException ie) {
}
ZimbraLog.imap.debug("ImapSessionManager.waitForWaitSetNotifications folder=%s mboxCID=%s irsCID=%s timeout=%s %s", folder, zmboxLastKnownChange, irs.getLastKnownChangeId(), timeout, ZimbraLog.elapsedTime(start, System.currentTimeMillis()));
}
Aggregations