You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/09/05 12:00:44 UTC

[GitHub] [pulsar] eolivelli commented on a diff in pull request #17164: [improve][broker] Make cursor properties support modify single value concurrently.

eolivelli commented on code in PR #17164:
URL: https://github.com/apache/pulsar/pull/17164#discussion_r962829422


##########
managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorImpl.java:
##########
@@ -365,6 +372,50 @@ public void operationFailed(MetaStoreException e) {
         return updateCursorPropertiesResult;
     }
 
+    @Override
+    public CompletableFuture<Void> setCursorProperties(Map<String, String> cursorProperties) {
+        MutableObject<CompletableFuture<Void>> updateCursorPropertiesResultRef = new MutableObject<>();
+        CURSOR_PROPERTIES_UPDATER.updateAndGet(this, map -> {
+            Map<String, String> newProperties =
+                    cursorProperties == null ? new TreeMap<>() : new TreeMap<>(cursorProperties);
+            if (map != null) {
+                map.forEach((k, v) -> {
+                    if (((String) k).startsWith(CURSOR_INTERNAL_PROPERTY_PREFIX)) {
+                        newProperties.put((String) k, (String) v);
+                    }
+                });
+
+                updateCursorPropertiesResultRef.setValue(asyncUpdateCursorProperties(newProperties));

Review Comment:
   the new properties must take effect only after they are persisted to storage.
   otherwise:
   - in case of failure the value is no consistent on storage
   - other readers of the value won't see the value consistently (who reads from this node may see something that will never been read)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org