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/02 05:19:20 UTC

[GitHub] [pulsar] Pomelongan opened a new pull request, #17421: [improve][broker][PIP-149]make setPersistence method async in Namespaces

Pomelongan opened a new pull request, #17421:
URL: https://github.com/apache/pulsar/pull/17421

   ### Motivation
   See https://github.com/apache/pulsar/issues/14365
   
   ### Verifying this change
   
   - [x] Make sure that the change passes the CI checks.
   This change is a trivial rework / code cleanup without any test coverage.
   
   ### Does this pull request potentially affect one of the following parts:
   
   *If `yes` was chosen, please highlight the changes*
   
     - Dependencies (does it add or upgrade a dependency): (no)
     - The public API: (no)
     - The schema: (no)
     - The default values of configurations: (no)
     - The wire protocol: (no)
     - The rest endpoints: (no)
     - The admin cli options: (no)
     - Anything that affects deployment: (no)
   
   ### Documentation
   
   Check the box below or label this PR directly.
   
   Need to update docs? 
     
   - [x] `doc-not-needed` 


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


[GitHub] [pulsar] Pomelongan commented on pull request #17421: [improve][broker][PIP-149]make setPersistence method async in Namespaces

Posted by GitBox <gi...@apache.org>.
Pomelongan commented on PR #17421:
URL: https://github.com/apache/pulsar/pull/17421#issuecomment-1239177264

   /pulsarbot run-failure-checks


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


[GitHub] [pulsar] Pomelongan commented on pull request #17421: [improve][broker][PIP-149]make setPersistence method async in Namespaces

Posted by GitBox <gi...@apache.org>.
Pomelongan commented on PR #17421:
URL: https://github.com/apache/pulsar/pull/17421#issuecomment-1239074296

   /pulsarbot run-failure-checks


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


[GitHub] [pulsar] AnonHxy commented on a diff in pull request #17421: [improve][broker][PIP-149]make setPersistence method async in Namespaces

Posted by GitBox <gi...@apache.org>.
AnonHxy commented on code in PR #17421:
URL: https://github.com/apache/pulsar/pull/17421#discussion_r962179291


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/NamespacesBase.java:
##########
@@ -1559,27 +1559,17 @@ protected CompletableFuture<Void> internalDeletePersistenceAsync() {
                 .thenCompose(__ -> doUpdatePersistenceAsync(null));
     }
 
-    protected void internalSetPersistence(PersistencePolicies persistence) {
-        validateNamespacePolicyOperation(namespaceName, PolicyName.PERSISTENCE, PolicyOperation.WRITE);
-        validatePoliciesReadOnlyAccess();
-        validatePersistencePolicies(persistence);
-
-        doUpdatePersistence(persistence);
-    }
-
-    private void doUpdatePersistence(PersistencePolicies persistence) {
-        try {
-            updatePolicies(namespaceName, policies -> {
-                policies.persistence = persistence;
-                return policies;
-            });
-            log.info("[{}] Successfully updated persistence configuration: namespace={}, map={}", clientAppId(),
-                    namespaceName, jsonMapper().writeValueAsString(persistence));
-        } catch (Exception e) {
-            log.error("[{}] Failed to update persistence configuration for namespace {}", clientAppId(), namespaceName,
-                    e);
-            throw new RestException(e);
-        }
+    protected CompletableFuture<Void> internalSetPersistenceAsync(PersistencePolicies persistence) {
+        return validateNamespacePolicyOperationAsync(namespaceName, PolicyName.PERSISTENCE, PolicyOperation.WRITE)
+                .thenCompose(__ -> validatePoliciesReadOnlyAccessAsync())
+                .thenAccept(__ -> validatePersistencePolicies(persistence))
+                .thenCompose(__ -> {
+                    return CompletableFuture.supplyAsync(() -> {
+                        validatePersistencePolicies(persistence);
+                        return null;
+                    });
+                })

Review Comment:
   I think we should remove this code block from line1566 to line1571



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


[GitHub] [pulsar] Pomelongan commented on pull request #17421: [improve][broker][PIP-149]make setPersistence method async in Namespaces

Posted by GitBox <gi...@apache.org>.
Pomelongan commented on PR #17421:
URL: https://github.com/apache/pulsar/pull/17421#issuecomment-1237069039

   /pulsarbot run-failure-checks


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


[GitHub] [pulsar] AnonHxy commented on a diff in pull request #17421: [improve][broker][PIP-149]make setPersistence method async in Namespaces

Posted by GitBox <gi...@apache.org>.
AnonHxy commented on code in PR #17421:
URL: https://github.com/apache/pulsar/pull/17421#discussion_r962179028


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/NamespacesBase.java:
##########
@@ -1559,27 +1559,17 @@ protected CompletableFuture<Void> internalDeletePersistenceAsync() {
                 .thenCompose(__ -> doUpdatePersistenceAsync(null));
     }
 
-    protected void internalSetPersistence(PersistencePolicies persistence) {
-        validateNamespacePolicyOperation(namespaceName, PolicyName.PERSISTENCE, PolicyOperation.WRITE);
-        validatePoliciesReadOnlyAccess();
-        validatePersistencePolicies(persistence);
-
-        doUpdatePersistence(persistence);
-    }
-
-    private void doUpdatePersistence(PersistencePolicies persistence) {
-        try {
-            updatePolicies(namespaceName, policies -> {
-                policies.persistence = persistence;
-                return policies;
-            });
-            log.info("[{}] Successfully updated persistence configuration: namespace={}, map={}", clientAppId(),
-                    namespaceName, jsonMapper().writeValueAsString(persistence));
-        } catch (Exception e) {
-            log.error("[{}] Failed to update persistence configuration for namespace {}", clientAppId(), namespaceName,
-                    e);
-            throw new RestException(e);
-        }
+    protected CompletableFuture<Void> internalSetPersistenceAsync(PersistencePolicies persistence) {
+        return validateNamespacePolicyOperationAsync(namespaceName, PolicyName.PERSISTENCE, PolicyOperation.WRITE)
+                .thenCompose(__ -> validatePoliciesReadOnlyAccessAsync())
+                .thenAccept(__ -> validatePersistencePolicies(persistence))
+                .thenCompose(__ -> {
+                    return CompletableFuture.supplyAsync(() -> {
+                        validatePersistencePolicies(persistence);
+                        return null;
+                    });
+                })

Review Comment:
   We should remove this cold block I think



##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/NamespacesBase.java:
##########
@@ -1559,27 +1559,17 @@ protected CompletableFuture<Void> internalDeletePersistenceAsync() {
                 .thenCompose(__ -> doUpdatePersistenceAsync(null));
     }
 
-    protected void internalSetPersistence(PersistencePolicies persistence) {
-        validateNamespacePolicyOperation(namespaceName, PolicyName.PERSISTENCE, PolicyOperation.WRITE);
-        validatePoliciesReadOnlyAccess();
-        validatePersistencePolicies(persistence);
-
-        doUpdatePersistence(persistence);
-    }
-
-    private void doUpdatePersistence(PersistencePolicies persistence) {
-        try {
-            updatePolicies(namespaceName, policies -> {
-                policies.persistence = persistence;
-                return policies;
-            });
-            log.info("[{}] Successfully updated persistence configuration: namespace={}, map={}", clientAppId(),
-                    namespaceName, jsonMapper().writeValueAsString(persistence));
-        } catch (Exception e) {
-            log.error("[{}] Failed to update persistence configuration for namespace {}", clientAppId(), namespaceName,
-                    e);
-            throw new RestException(e);
-        }
+    protected CompletableFuture<Void> internalSetPersistenceAsync(PersistencePolicies persistence) {
+        return validateNamespacePolicyOperationAsync(namespaceName, PolicyName.PERSISTENCE, PolicyOperation.WRITE)
+                .thenCompose(__ -> validatePoliciesReadOnlyAccessAsync())
+                .thenAccept(__ -> validatePersistencePolicies(persistence))
+                .thenCompose(__ -> {
+                    return CompletableFuture.supplyAsync(() -> {
+                        validatePersistencePolicies(persistence);
+                        return null;
+                    });
+                })
+                .thenCompose(__ -> doUpdatePersistenceAsync(null));

Review Comment:
   `doUpdatePersistenceAsync(null)` -> `doUpdatePersistenceAsync(persistence)`



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


[GitHub] [pulsar] Pomelongan commented on pull request #17421: [improve][broker][PIP-149]make setPersistence method async in Namespaces

Posted by GitBox <gi...@apache.org>.
Pomelongan commented on PR #17421:
URL: https://github.com/apache/pulsar/pull/17421#issuecomment-1240143496

   /pulsarbot run-failure-checks


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


[GitHub] [pulsar] Pomelongan commented on pull request #17421: [improve][broker][PIP-149]make setPersistence method async in Namespaces

Posted by GitBox <gi...@apache.org>.
Pomelongan commented on PR #17421:
URL: https://github.com/apache/pulsar/pull/17421#issuecomment-1235090851

   /pulsarbot run-failure-checks


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


[GitHub] [pulsar] Pomelongan commented on pull request #17421: [improve][broker][PIP-149]make setPersistence method async in Namespaces

Posted by GitBox <gi...@apache.org>.
Pomelongan commented on PR #17421:
URL: https://github.com/apache/pulsar/pull/17421#issuecomment-1240337259

   
   /pulsarbot run-failure-checks
   
   


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


[GitHub] [pulsar] Pomelongan commented on a diff in pull request #17421: [improve][broker][PIP-149]make setPersistence method async in Namespaces

Posted by GitBox <gi...@apache.org>.
Pomelongan commented on code in PR #17421:
URL: https://github.com/apache/pulsar/pull/17421#discussion_r962281527


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/NamespacesBase.java:
##########
@@ -1559,27 +1559,17 @@ protected CompletableFuture<Void> internalDeletePersistenceAsync() {
                 .thenCompose(__ -> doUpdatePersistenceAsync(null));
     }
 
-    protected void internalSetPersistence(PersistencePolicies persistence) {
-        validateNamespacePolicyOperation(namespaceName, PolicyName.PERSISTENCE, PolicyOperation.WRITE);
-        validatePoliciesReadOnlyAccess();
-        validatePersistencePolicies(persistence);
-
-        doUpdatePersistence(persistence);
-    }
-
-    private void doUpdatePersistence(PersistencePolicies persistence) {
-        try {
-            updatePolicies(namespaceName, policies -> {
-                policies.persistence = persistence;
-                return policies;
-            });
-            log.info("[{}] Successfully updated persistence configuration: namespace={}, map={}", clientAppId(),
-                    namespaceName, jsonMapper().writeValueAsString(persistence));
-        } catch (Exception e) {
-            log.error("[{}] Failed to update persistence configuration for namespace {}", clientAppId(), namespaceName,
-                    e);
-            throw new RestException(e);
-        }
+    protected CompletableFuture<Void> internalSetPersistenceAsync(PersistencePolicies persistence) {
+        return validateNamespacePolicyOperationAsync(namespaceName, PolicyName.PERSISTENCE, PolicyOperation.WRITE)
+                .thenCompose(__ -> validatePoliciesReadOnlyAccessAsync())
+                .thenAccept(__ -> validatePersistencePolicies(persistence))
+                .thenCompose(__ -> {
+                    return CompletableFuture.supplyAsync(() -> {
+                        validatePersistencePolicies(persistence);
+                        return null;
+                    });
+                })

Review Comment:
    @AnonHxy PTAL



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


[GitHub] [pulsar] Technoboy- commented on pull request #17421: [improve][broker][PIP-149]make setPersistence method async in Namespaces

Posted by GitBox <gi...@apache.org>.
Technoboy- commented on PR #17421:
URL: https://github.com/apache/pulsar/pull/17421#issuecomment-1237579822

   Please fix the check style issue.


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


[GitHub] [pulsar] AnonHxy commented on pull request #17421: [improve][broker][PIP-149]make setPersistence method async in Namespaces

Posted by GitBox <gi...@apache.org>.
AnonHxy commented on PR #17421:
URL: https://github.com/apache/pulsar/pull/17421#issuecomment-1236859930

   Please fix the CI  `org.apache.pulsar.broker.admin.NamespacesTest#testPersistenceUnauthorized`  @Pomelongan 


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


[GitHub] [pulsar] AnonHxy merged pull request #17421: [improve][broker][PIP-149]make setPersistence method async in Namespaces

Posted by GitBox <gi...@apache.org>.
AnonHxy merged PR #17421:
URL: https://github.com/apache/pulsar/pull/17421


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


[GitHub] [pulsar] Pomelongan commented on pull request #17421: [improve][broker][PIP-149]make setPersistence method async in Namespaces

Posted by GitBox <gi...@apache.org>.
Pomelongan commented on PR #17421:
URL: https://github.com/apache/pulsar/pull/17421#issuecomment-1239394206

   > Please fix the check style issue.
   @Technoboy-  PTAL~
   


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


[GitHub] [pulsar] Pomelongan commented on pull request #17421: [improve][broker][PIP-149]make setPersistence method async in Namespaces

Posted by GitBox <gi...@apache.org>.
Pomelongan commented on PR #17421:
URL: https://github.com/apache/pulsar/pull/17421#issuecomment-1236378732

   /pulsarbot run-failure-checks


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