logger.debug("source:data does not exist, no-op"); result = Status.RemoveExpired; } else if (matches(source, currSnapshot.getSource())) { // remove of current snapshot Map.Entry<Source, InstanceInfo> newHead = dataStore.nextEntry(); if (newHead == null) { // removed last copy result = Status.RemovedLast; } else { // promote the newHead as the snapshot and publish a modify notification Snapshot<InstanceInfo> newSnapshot = new Snapshot<>(newHead.getKey(), newHead.getValue()); snapshot = newSnapshot; (snapshot.getSource().getOrigin() != Source.Origin.LOCAL)) { ChangeNotification<InstanceInfo> deleteNotification = new SourcedChangeNotification<>(ChangeNotification.Kind.Delete, removed, source); = new SourcedChangeNotification<>(ChangeNotification.Kind.Add, snapshot.getData(), snapshot.getSource()); pauseableSubject.onNext(addNotification); } else { Set<Delta<?>> delta = newSnapshot.getData().diffOlder(currSnapshot.getData()); if (!delta.isEmpty()) { ChangeNotification<InstanceInfo> modifyNotification = new SourcedModifyNotification<>(newSnapshot.getData(), delta, newSnapshot.getSource()); pauseableSubject.onNext(modifyNotification); } else { logger.debug("No-change update for {}#{}", currSnapshot.getSource(), currSnapshot.getData().getId()); logger.debug("removed non-head (head={}, received={})", currSnapshot.getSource(), source);
Snapshot<InstanceInfo> newSnapshot = new Snapshot<>(source, data); Status result = Status.AddedChange; pauseableSubject.onNext(newSnapshot.getNotification()); result = Status.AddedFirst; } else if ((currSnapshot.getSource().getOrigin() != Source.Origin.LOCAL) && pauseableSubject.onNext(newSnapshot.getNotification()); } else { if (matches(currSnapshot.getSource(), newSnapshot.getSource())) { // modify to current snapshot snapshot = newSnapshot; Set<Delta<?>> delta = newSnapshot.getData().diffOlder(currSnapshot.getData()); if (!delta.isEmpty()) { ChangeNotification<InstanceInfo> modifyNotification = new SourcedModifyNotification<>(newSnapshot.getData(), delta, newSnapshot.getSource()); pauseableSubject.onNext(modifyNotification); } else { logger.debug("No-change update for {}#{}", currSnapshot.getSource(), currSnapshot.getData().getId()); currSnapshot.getSource(), newSnapshot.getSource() );
@Override public SourcedChangeNotification<InstanceInfo> getChangeNotification() { if (snapshot != null) { return snapshot.getNotification(); } return null; }
@Override public Source getSource() { if (snapshot != null) { return snapshot.getSource(); } return null; }
@Override public InstanceInfo get() { if (snapshot != null) { return snapshot.getData(); } return null; }