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 2020/06/25 14:18:18 UTC

[GitHub] [pulsar] merlimat commented on a change in pull request #7357: Fix bug related to managedLedger properties

merlimat commented on a change in pull request #7357:
URL: https://github.com/apache/pulsar/pull/7357#discussion_r445590129



##########
File path: managed-ledger/src/main/java/org/apache/bookkeeper/mledger/ManagedLedger.java
##########
@@ -453,19 +453,23 @@
     /**
      * Update managed-ledger's properties.
      *
-     * @param properties key-values of properties
+     * @param properties  key-values of properties
+     * @param isOverwrite set true to overwrite original value of managed-ledger's properties; set false to append the
+     *                    properties to managed-ledger's properties.
      */
-    void setProperties(Map<String, String> properties) throws InterruptedException;
+    void setProperties(Map<String, String> properties, boolean isOverwrite) throws InterruptedException;

Review comment:
       Using `isOverwrite` feels a bit weird compared to similar properties APIs.
   
   What about having: 
    * `setProperty()` 
    * `setProperties()` (with `isOverwrite==false` behavior)
    * `deleteProperty()` 

##########
File path: managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerTest.java
##########
@@ -1174,43 +1174,49 @@ public void testSetProperties() throws Exception {
         properties.put("key1", "value1");
         properties.put("key2", "value2");
         properties.put("key3", "value3");
-        ledger.setProperties(properties);
+        ledger.setProperties(properties, true);
         assertEquals(ledger.getProperties(), properties);
 
         Map<String, String> newProperties = new HashMap<>();
         newProperties.put("key4", "value4");
         newProperties.put("key5", "value5");
         newProperties.put("key6", "value6");
-        ledger.setProperties(newProperties);
+        ledger.setProperties(newProperties, true);
+        assertEquals(ledger.getProperties(), newProperties);
+
+        ledger.setProperties(properties, false);
+        newProperties.putAll(properties);

Review comment:
       Please also try to add entries in the ledger, to verify that we're not fenced off from the metadata updates. 
   
   Change the settings to force multiple rollovers, eg: 
   
   ```java
   ManagedLedger ledger = factory.open("my_test_ledger",
        new ManagedLedgerConfig().setMaxEntriesPerLedger(1));
   ```




----------------------------------------------------------------
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.

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