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 2021/08/17 23:48:17 UTC

[GitHub] [pulsar] merlimat opened a new pull request #11693: Refactored PulsarResources to avoid building metadata paths everywhere

merlimat opened a new pull request #11693:
URL: https://github.com/apache/pulsar/pull/11693


   ### Motivation
   
   The `PulsarResources` and its companion classes are all taking `String`s with paths for resources in the metadata store. This has lead to a proliferation of string composition to construct these paths from all over the code base. 
   
   Instead, we should be taking the resource namings (eg: `TopicName`, `NamespaceName`, etc.) and hide the path in the metadata.
   
   ### Modifications
   
    * Changes all methods in `BaseResources` to be protected
    * Each subclass exposes resource specific public methods


-- 
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] merlimat merged pull request #11693: Refactored PulsarResources to avoid building metadata paths everywhere

Posted by GitBox <gi...@apache.org>.
merlimat merged pull request #11693:
URL: https://github.com/apache/pulsar/pull/11693


   


-- 
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] merlimat commented on a change in pull request #11693: Refactored PulsarResources to avoid building metadata paths everywhere

Posted by GitBox <gi...@apache.org>.
merlimat commented on a change in pull request #11693:
URL: https://github.com/apache/pulsar/pull/11693#discussion_r702308689



##########
File path: pulsar-broker-common/src/main/java/org/apache/pulsar/broker/resources/ClusterResources.java
##########
@@ -48,5 +104,33 @@ public FailureDomainResources(MetadataStore store, Class<FailureDomainImpl> claz
                 int operationTimeoutSec) {
             super(store, clazz, operationTimeoutSec);
         }
+
+        public List<String> listFailureDomains(String clusterName) throws MetadataStoreException {
+            return getChildren(joinPath(BASE_CLUSTERS_PATH, clusterName, FAILURE_DOMAIN));
+        }
+
+        public Optional<FailureDomainImpl> getFailureDomain(String clusterName, String domainName)
+                throws MetadataStoreException {
+            return get(joinPath(BASE_CLUSTERS_PATH, clusterName, FAILURE_DOMAIN, domainName));
+        }
+
+        public void deleteFailureDomain(String clusterName, String domainName) throws MetadataStoreException {
+            delete(joinPath(BASE_CLUSTERS_PATH, clusterName, FAILURE_DOMAIN, domainName));
+        }
+
+        public void deleteFailureDomains(String clusterName) throws MetadataStoreException {
+            String failureDomainPath = joinPath(BASE_CLUSTERS_PATH, clusterName, FAILURE_DOMAIN);
+            for (String domain : getCache().getChildren(failureDomainPath).join()) {

Review comment:
       In this case it's redundant but correct. The exists and getChildren are cached directly in the MetadataStore implementation, the MetadataCache is for keeping a typed cache of the objects. 
   The delete operation on the cache is just a convenience method that is just forwarded to the store implementation




-- 
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] Anonymitaet commented on pull request #11693: Refactored PulsarResources to avoid building metadata paths everywhere

Posted by GitBox <gi...@apache.org>.
Anonymitaet commented on pull request #11693:
URL: https://github.com/apache/pulsar/pull/11693#issuecomment-900741551


   Thanks for your contribution. For this PR, do we need to update docs?
   
   (The [PR template contains info about doc](https://github.com/apache/pulsar/blob/master/.github/PULL_REQUEST_TEMPLATE.md#documentation), which helps others know more about the changes. Can you provide doc-related info in this and future PR descriptions? Thanks) 


-- 
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] eolivelli commented on a change in pull request #11693: Refactored PulsarResources to avoid building metadata paths everywhere

Posted by GitBox <gi...@apache.org>.
eolivelli commented on a change in pull request #11693:
URL: https://github.com/apache/pulsar/pull/11693#discussion_r702317404



##########
File path: pulsar-broker-common/src/main/java/org/apache/pulsar/broker/resources/ClusterResources.java
##########
@@ -48,5 +104,33 @@ public FailureDomainResources(MetadataStore store, Class<FailureDomainImpl> claz
                 int operationTimeoutSec) {
             super(store, clazz, operationTimeoutSec);
         }
+
+        public List<String> listFailureDomains(String clusterName) throws MetadataStoreException {
+            return getChildren(joinPath(BASE_CLUSTERS_PATH, clusterName, FAILURE_DOMAIN));
+        }
+
+        public Optional<FailureDomainImpl> getFailureDomain(String clusterName, String domainName)
+                throws MetadataStoreException {
+            return get(joinPath(BASE_CLUSTERS_PATH, clusterName, FAILURE_DOMAIN, domainName));
+        }
+
+        public void deleteFailureDomain(String clusterName, String domainName) throws MetadataStoreException {
+            delete(joinPath(BASE_CLUSTERS_PATH, clusterName, FAILURE_DOMAIN, domainName));
+        }
+
+        public void deleteFailureDomains(String clusterName) throws MetadataStoreException {
+            String failureDomainPath = joinPath(BASE_CLUSTERS_PATH, clusterName, FAILURE_DOMAIN);
+            for (String domain : getCache().getChildren(failureDomainPath).join()) {

Review comment:
       Makes sense. Thanks




-- 
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] merlimat commented on a change in pull request #11693: Refactored PulsarResources to avoid building metadata paths everywhere

Posted by GitBox <gi...@apache.org>.
merlimat commented on a change in pull request #11693:
URL: https://github.com/apache/pulsar/pull/11693#discussion_r702308550



##########
File path: pulsar-broker-common/src/main/java/org/apache/pulsar/broker/resources/TopicResources.java
##########
@@ -36,17 +38,39 @@
         this.store = store;
     }
 
+    public CompletableFuture<List<String>> listPersistentTopicsAsync(NamespaceName ns) {
+        String path = "/managed-ledgers/" + ns + "/persistent";

Review comment:
       👍 




-- 
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] Anonymitaet commented on pull request #11693: Refactored PulsarResources to avoid building metadata paths everywhere

Posted by GitBox <gi...@apache.org>.
Anonymitaet commented on pull request #11693:
URL: https://github.com/apache/pulsar/pull/11693#issuecomment-900741551


   Thanks for your contribution. For this PR, do we need to update docs?
   
   (The [PR template contains info about doc](https://github.com/apache/pulsar/blob/master/.github/PULL_REQUEST_TEMPLATE.md#documentation), which helps others know more about the changes. Can you provide doc-related info in this and future PR descriptions? Thanks) 


-- 
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] merlimat commented on pull request #11693: Refactored PulsarResources to avoid building metadata paths everywhere

Posted by GitBox <gi...@apache.org>.
merlimat commented on pull request #11693:
URL: https://github.com/apache/pulsar/pull/11693#issuecomment-900742467


   > Thanks for your contribution. For this PR, do we need to update docs?
    @Anonymitaet no need for docs changes here. Just labeled.


-- 
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] eolivelli commented on a change in pull request #11693: Refactored PulsarResources to avoid building metadata paths everywhere

Posted by GitBox <gi...@apache.org>.
eolivelli commented on a change in pull request #11693:
URL: https://github.com/apache/pulsar/pull/11693#discussion_r702304449



##########
File path: pulsar-broker-common/src/main/java/org/apache/pulsar/broker/resources/ClusterResources.java
##########
@@ -48,5 +104,33 @@ public FailureDomainResources(MetadataStore store, Class<FailureDomainImpl> claz
                 int operationTimeoutSec) {
             super(store, clazz, operationTimeoutSec);
         }
+
+        public List<String> listFailureDomains(String clusterName) throws MetadataStoreException {
+            return getChildren(joinPath(BASE_CLUSTERS_PATH, clusterName, FAILURE_DOMAIN));
+        }
+
+        public Optional<FailureDomainImpl> getFailureDomain(String clusterName, String domainName)
+                throws MetadataStoreException {
+            return get(joinPath(BASE_CLUSTERS_PATH, clusterName, FAILURE_DOMAIN, domainName));
+        }
+
+        public void deleteFailureDomain(String clusterName, String domainName) throws MetadataStoreException {
+            delete(joinPath(BASE_CLUSTERS_PATH, clusterName, FAILURE_DOMAIN, domainName));
+        }
+
+        public void deleteFailureDomains(String clusterName) throws MetadataStoreException {
+            String failureDomainPath = joinPath(BASE_CLUSTERS_PATH, clusterName, FAILURE_DOMAIN);
+            for (String domain : getCache().getChildren(failureDomainPath).join()) {

Review comment:
       Is it correct to use 'cache' here?

##########
File path: pulsar-broker-common/src/main/java/org/apache/pulsar/broker/resources/TopicResources.java
##########
@@ -36,17 +38,39 @@
         this.store = store;
     }
 
+    public CompletableFuture<List<String>> listPersistentTopicsAsync(NamespaceName ns) {
+        String path = "/managed-ledgers/" + ns + "/persistent";

Review comment:
       Nit: use constant ?




-- 
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] merlimat commented on pull request #11693: Refactored PulsarResources to avoid building metadata paths everywhere

Posted by GitBox <gi...@apache.org>.
merlimat commented on pull request #11693:
URL: https://github.com/apache/pulsar/pull/11693#issuecomment-900742467


   > Thanks for your contribution. For this PR, do we need to update docs?
    @Anonymitaet no need for docs changes here. Just labeled.


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