@Override public NotificationResult findNotificationsAfterEpoch(CallingContext context, Long lastEpochSeen) { return new NotificationResult(); }
@Override public NotificationResult findNotificationsAfterEpoch(CallingContext context, Long lastEpochSeen) { NotificationResult result = new NotificationResult(currentEpoch); for (long epoch = lastEpochSeen; epoch < currentEpoch; epoch++) { NotificationInfo info = notifications.get(epoch); String originKernelId = info.getKernelId(); // prevent kernel from receiving notifications from itself, which can cause race conditions if (originKernelId != null && originKernelId.equals(context.getContext())) { continue; } result.addId(info.getId()); } return result; }
public void run() { while (!shouldQuit) { try { NotificationResult result = notificationApi.findNotificationsAfterEpoch(context, notificationName, currentEpoch); currentEpoch = result.getCurrentEpoch(); for (String change : result.getReferences()) { handleReference(change); } } catch (RaptureException e) { resetApi(); } if (!shouldQuit) { try { sleep(1000); } catch (InterruptedException e) { } } } } }