From 0b8bc725fe13a7421906c48c55ff29df7ba5d320 Mon Sep 17 00:00:00 2001 From: Ivan Rakov Date: Tue, 2 Mar 2021 15:30:18 +0300 Subject: [PATCH] Return old dirtyEntries as deprecated to keep compatibility --- .../net/openhft/chronicle/map/Replica.java | 9 +++++ .../chronicle/map/ReplicatedChronicleMap.java | 35 ++++++++++++++----- 2 files changed, 35 insertions(+), 9 deletions(-) diff --git a/src/main/java/net/openhft/chronicle/map/Replica.java b/src/main/java/net/openhft/chronicle/map/Replica.java index 511a6aa41..cf8c7edfe 100644 --- a/src/main/java/net/openhft/chronicle/map/Replica.java +++ b/src/main/java/net/openhft/chronicle/map/Replica.java @@ -130,6 +130,15 @@ public interface Replica extends Closeable { */ boolean nextEntry(@NotNull final Callback callback, final int chronicleId); + /** + * Synchronous version which is kept for binary API compatibility. + * + * @deprecated see {@link #dirtyEntries(long, EventLoop)} + * @param fromTimeStamp the timestamp from which all entries should be dirty + */ + @Deprecated(/* to be removed in x.22 */) + void dirtyEntries(long fromTimeStamp); + /** * Dirties all entries with a modification time equal to {@code fromTimeStamp} or newer and * origin identifier equal to the current node identifier. It means all these entries will diff --git a/src/main/java/net/openhft/chronicle/map/ReplicatedChronicleMap.java b/src/main/java/net/openhft/chronicle/map/ReplicatedChronicleMap.java index e1bcc4d8e..54600a378 100644 --- a/src/main/java/net/openhft/chronicle/map/ReplicatedChronicleMap.java +++ b/src/main/java/net/openhft/chronicle/map/ReplicatedChronicleMap.java @@ -992,8 +992,12 @@ public class ReplicatedChronicleMap extends VanillaChronicleMap= actualSegments) - workCompleted(); + if (segmentIndex >= actualSegments) { + if (iterationContext != null) + iterationContext.close(); + + throw new InvalidEventHandlerException("background work is done, removing the handler"); + } if (!segmentPredicate.test(segmentIndex)) { segmentIndex++; @@ -1033,7 +1037,10 @@ public class ReplicatedChronicleMap extends VanillaChronicleMap extends VanillaChronicleMap true, fromTimeStamp); + + try { + for (int i = 0; i < actualSegments; i++) + syncHandler.action(); + } + catch (InvalidEventHandlerException e) { + if (e.getCause() instanceof ChronicleHashClosedException) + throw (ChronicleHashClosedException)e.getCause(); + } + } @Override public void dirtyEntries(long fromTimeStamp, @NotNull EventLoop eventLoop) {