Skip to content

Commit

Permalink
[improve][broker] Use immutable base cursor properties (#20400)
Browse files Browse the repository at this point in the history
  • Loading branch information
lhotari authored May 25, 2023
1 parent 25c4b7c commit f0e97f4
Showing 1 changed file with 3 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,18 +120,15 @@ public class PersistentSubscription extends AbstractSubscription implements Subs
// Map of properties that is used to mark this subscription as "replicated".
// Since this is the only field at this point, we can just keep a static
// instance of the map.
private static final Map<String, Long> REPLICATED_SUBSCRIPTION_CURSOR_PROPERTIES = new TreeMap<>();
private static final Map<String, Long> NON_REPLICATED_SUBSCRIPTION_CURSOR_PROPERTIES = Collections.emptyMap();
private static final Map<String, Long> REPLICATED_SUBSCRIPTION_CURSOR_PROPERTIES =
Map.of(REPLICATED_SUBSCRIPTION_PROPERTY, 1L);
private static final Map<String, Long> NON_REPLICATED_SUBSCRIPTION_CURSOR_PROPERTIES = Map.of();

private volatile ReplicatedSubscriptionSnapshotCache replicatedSubscriptionSnapshotCache;
private final PendingAckHandle pendingAckHandle;
private volatile Map<String, String> subscriptionProperties;
private volatile CompletableFuture<Void> fenceFuture;

static {
REPLICATED_SUBSCRIPTION_CURSOR_PROPERTIES.put(REPLICATED_SUBSCRIPTION_PROPERTY, 1L);
}

static Map<String, Long> getBaseCursorProperties(boolean isReplicated) {
return isReplicated ? REPLICATED_SUBSCRIPTION_CURSOR_PROPERTIES : NON_REPLICATED_SUBSCRIPTION_CURSOR_PROPERTIES;
}
Expand Down

0 comments on commit f0e97f4

Please sign in to comment.