You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@eventmesh.apache.org by "mxsm (via GitHub)" <gi...@apache.org> on 2023/02/11 03:27:59 UTC

[GitHub] [incubator-eventmesh] mxsm opened a new pull request, #3119: [ISSUE #3118]Refactor Acl

mxsm opened a new pull request, #3119:
URL: https://github.com/apache/incubator-eventmesh/pull/3119

   <!--
   ### Contribution Checklist
   
     - Name the pull request in the form "[ISSUE #XXXX] Title of the pull request", 
       where *XXXX* should be replaced by the actual issue number.
       Skip *[ISSUE #XXXX]* if there is no associated github issue for this pull request.
   
     - Fill out the template below to describe the changes contributed by the pull request. 
       That will give reviewers the context they need to do the review.
     
     - Each pull request should address only one issue. 
       Please do not mix up code from multiple issues.
     
     - Each commit in the pull request should have a meaningful commit message.
   
     - Once all items of the checklist are addressed, remove the above text and this checklist, 
       leaving only the filled out template below.
   
   (The sections below can be removed for hotfixes of typos)
   -->
   
   <!--
   (If this PR fixes a GitHub issue, please add `Fixes #<XXX>` or `Cloese #<XXX>`.)
   -->
   
   Fixes #3118 
   
   ### Motivation
   
   *Explain the content here.*
   *Explain why you want to make the changes and what problem you're trying to solve.*
   
   
   
   ### Modifications
   
   *Refactor Acl*
   
   
   
   ### Documentation
   
   - Does this pull request introduce a new feature? (yes / no)
   - If yes, how is the feature documented? (not applicable / docs / JavaDocs / not documented)
   - If a feature is not applicable for documentation, explain why?
   - If a feature is not documented yet in this PR, please create a followup issue for adding the documentation
   


-- 
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: dev-unsubscribe@eventmesh.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: dev-help@eventmesh.apache.org


[GitHub] [incubator-eventmesh] mxsm commented on a diff in pull request #3119: [ISSUE #3118]Refactor Acl

Posted by "mxsm (via GitHub)" <gi...@apache.org>.
mxsm commented on code in PR #3119:
URL: https://github.com/apache/incubator-eventmesh/pull/3119#discussion_r1103915285


##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/acl/Acl.java:
##########
@@ -26,14 +26,25 @@
 import org.apache.commons.lang3.StringUtils;
 
 import java.util.Properties;
-import java.util.ServiceLoader;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public class Acl {
+
     private static final Logger logger = LoggerFactory.getLogger(Acl.class);

Review Comment:
   @jonyangx  I want to submit a separate PR to unified fix the logging issue. Use  lombok @slf4j annotation consistently



-- 
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: dev-unsubscribe@eventmesh.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: dev-help@eventmesh.apache.org


[GitHub] [incubator-eventmesh] jonyangx commented on a diff in pull request #3119: [ISSUE #3118]Refactor Acl

Posted by "jonyangx (via GitHub)" <gi...@apache.org>.
jonyangx commented on code in PR #3119:
URL: https://github.com/apache/incubator-eventmesh/pull/3119#discussion_r1103913879


##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/acl/Acl.java:
##########
@@ -26,14 +26,25 @@
 import org.apache.commons.lang3.StringUtils;
 
 import java.util.Properties;
-import java.util.ServiceLoader;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public class Acl {
+
     private static final Logger logger = LoggerFactory.getLogger(Acl.class);

Review Comment:
   Simplify code using Lombok @Slf4j.



-- 
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: dev-unsubscribe@eventmesh.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: dev-help@eventmesh.apache.org


[GitHub] [incubator-eventmesh] jonyangx commented on a diff in pull request #3119: [ISSUE #3118]Refactor Acl

Posted by "jonyangx (via GitHub)" <gi...@apache.org>.
jonyangx commented on code in PR #3119:
URL: https://github.com/apache/incubator-eventmesh/pull/3119#discussion_r1103917760


##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/acl/Acl.java:
##########
@@ -26,14 +26,25 @@
 import org.apache.commons.lang3.StringUtils;
 
 import java.util.Properties;
-import java.util.ServiceLoader;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public class Acl {
+
     private static final Logger logger = LoggerFactory.getLogger(Acl.class);
-    private static AclService aclService;
+
+    private static final Acl INSTANCE = new Acl();
+
+    private AclService aclService;
+
+    private Acl() {
+
+    }
+
+    public static Acl getInstance() {

Review Comment:
   Suggest merge getInstance() and init() method.
   eg. public static Acl getInstance(String aclPluginType) .
   Add collection for Acl instannce and pluginType mapping.
   
   @mxsm 



-- 
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: dev-unsubscribe@eventmesh.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: dev-help@eventmesh.apache.org


[GitHub] [incubator-eventmesh] jonyangx commented on a diff in pull request #3119: [ISSUE #3118]Refactor Acl

Posted by "jonyangx (via GitHub)" <gi...@apache.org>.
jonyangx commented on code in PR #3119:
URL: https://github.com/apache/incubator-eventmesh/pull/3119#discussion_r1103917760


##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/acl/Acl.java:
##########
@@ -26,14 +26,25 @@
 import org.apache.commons.lang3.StringUtils;
 
 import java.util.Properties;
-import java.util.ServiceLoader;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public class Acl {
+
     private static final Logger logger = LoggerFactory.getLogger(Acl.class);
-    private static AclService aclService;
+
+    private static final Acl INSTANCE = new Acl();
+
+    private AclService aclService;
+
+    private Acl() {
+
+    }
+
+    public static Acl getInstance() {

Review Comment:
   Suggest merge getInstance() and init() method.
   eg. public static Acl getInstance(String aclPluginType) .
   Add collection for Acl instannce and pluginType mapping.



-- 
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: dev-unsubscribe@eventmesh.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: dev-help@eventmesh.apache.org


[GitHub] [incubator-eventmesh] codecov[bot] commented on pull request #3119: [ISSUE #3118]Refactor Acl

Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #3119:
URL: https://github.com/apache/incubator-eventmesh/pull/3119#issuecomment-1426606216

   # [Codecov](https://codecov.io/gh/apache/incubator-eventmesh/pull/3119?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#3119](https://codecov.io/gh/apache/incubator-eventmesh/pull/3119?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (9a30135) into [master](https://codecov.io/gh/apache/incubator-eventmesh/commit/89df2b07561d0c91d0f9d5924b6ab2df220b6e87?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (89df2b0) will **increase** coverage by `0.02%`.
   > The diff coverage is `0.00%`.
   
   ```diff
   @@             Coverage Diff              @@
   ##             master    #3119      +/-   ##
   ============================================
   + Coverage     12.93%   12.95%   +0.02%     
   - Complexity     1106     1110       +4     
   ============================================
     Files           548      548              
     Lines         28646    28625      -21     
     Branches       2866     2853      -13     
   ============================================
   + Hits           3705     3709       +4     
   + Misses        24622    24598      -24     
   + Partials        319      318       -1     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/incubator-eventmesh/pull/3119?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...ain/java/org/apache/eventmesh/runtime/acl/Acl.java](https://codecov.io/gh/apache/incubator-eventmesh/pull/3119?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZXZlbnRtZXNoLXJ1bnRpbWUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2V2ZW50bWVzaC9ydW50aW1lL2FjbC9BY2wuamF2YQ==) | `0.00% <0.00%> (ø)` | |
   | [...apache/eventmesh/runtime/boot/EventMeshServer.java](https://codecov.io/gh/apache/incubator-eventmesh/pull/3119?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZXZlbnRtZXNoLXJ1bnRpbWUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2V2ZW50bWVzaC9ydW50aW1lL2Jvb3QvRXZlbnRNZXNoU2VydmVyLmphdmE=) | `0.00% <0.00%> (ø)` | |
   | [...l/grpc/processor/BatchPublishMessageProcessor.java](https://codecov.io/gh/apache/incubator-eventmesh/pull/3119?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZXZlbnRtZXNoLXJ1bnRpbWUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2V2ZW50bWVzaC9ydW50aW1lL2NvcmUvcHJvdG9jb2wvZ3JwYy9wcm9jZXNzb3IvQmF0Y2hQdWJsaXNoTWVzc2FnZVByb2Nlc3Nvci5qYXZh) | `0.00% <0.00%> (ø)` | |
   | [...re/protocol/grpc/processor/HeartbeatProcessor.java](https://codecov.io/gh/apache/incubator-eventmesh/pull/3119?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZXZlbnRtZXNoLXJ1bnRpbWUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2V2ZW50bWVzaC9ydW50aW1lL2NvcmUvcHJvdG9jb2wvZ3JwYy9wcm9jZXNzb3IvSGVhcnRiZWF0UHJvY2Vzc29yLmphdmE=) | `0.00% <0.00%> (ø)` | |
   | [...protocol/grpc/processor/ReplyMessageProcessor.java](https://codecov.io/gh/apache/incubator-eventmesh/pull/3119?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZXZlbnRtZXNoLXJ1bnRpbWUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2V2ZW50bWVzaC9ydW50aW1lL2NvcmUvcHJvdG9jb2wvZ3JwYy9wcm9jZXNzb3IvUmVwbHlNZXNzYWdlUHJvY2Vzc29yLmphdmE=) | `0.00% <0.00%> (ø)` | |
   | [...otocol/grpc/processor/RequestMessageProcessor.java](https://codecov.io/gh/apache/incubator-eventmesh/pull/3119?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZXZlbnRtZXNoLXJ1bnRpbWUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2V2ZW50bWVzaC9ydW50aW1lL2NvcmUvcHJvdG9jb2wvZ3JwYy9wcm9jZXNzb3IvUmVxdWVzdE1lc3NhZ2VQcm9jZXNzb3IuamF2YQ==) | `0.00% <0.00%> (ø)` | |
   | [...ocol/grpc/processor/SendAsyncMessageProcessor.java](https://codecov.io/gh/apache/incubator-eventmesh/pull/3119?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZXZlbnRtZXNoLXJ1bnRpbWUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2V2ZW50bWVzaC9ydW50aW1lL2NvcmUvcHJvdG9jb2wvZ3JwYy9wcm9jZXNzb3IvU2VuZEFzeW5jTWVzc2FnZVByb2Nlc3Nvci5qYXZh) | `0.00% <0.00%> (ø)` | |
   | [...re/protocol/grpc/processor/SubscribeProcessor.java](https://codecov.io/gh/apache/incubator-eventmesh/pull/3119?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZXZlbnRtZXNoLXJ1bnRpbWUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2V2ZW50bWVzaC9ydW50aW1lL2NvcmUvcHJvdG9jb2wvZ3JwYy9wcm9jZXNzb3IvU3Vic2NyaWJlUHJvY2Vzc29yLmphdmE=) | `0.00% <0.00%> (ø)` | |
   | [...tocol/grpc/processor/SubscribeStreamProcessor.java](https://codecov.io/gh/apache/incubator-eventmesh/pull/3119?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZXZlbnRtZXNoLXJ1bnRpbWUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2V2ZW50bWVzaC9ydW50aW1lL2NvcmUvcHJvdG9jb2wvZ3JwYy9wcm9jZXNzb3IvU3Vic2NyaWJlU3RyZWFtUHJvY2Vzc29yLmphdmE=) | `0.00% <0.00%> (ø)` | |
   | [...ocol/http/processor/BatchSendMessageProcessor.java](https://codecov.io/gh/apache/incubator-eventmesh/pull/3119?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZXZlbnRtZXNoLXJ1bnRpbWUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2V2ZW50bWVzaC9ydW50aW1lL2NvcmUvcHJvdG9jb2wvaHR0cC9wcm9jZXNzb3IvQmF0Y2hTZW5kTWVzc2FnZVByb2Nlc3Nvci5qYXZh) | `0.00% <0.00%> (ø)` | |
   | ... and [23 more](https://codecov.io/gh/apache/incubator-eventmesh/pull/3119?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   :mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   


-- 
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: dev-unsubscribe@eventmesh.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: dev-help@eventmesh.apache.org


[GitHub] [incubator-eventmesh] mxsm commented on a diff in pull request #3119: [ISSUE #3118]Refactor Acl

Posted by "mxsm (via GitHub)" <gi...@apache.org>.
mxsm commented on code in PR #3119:
URL: https://github.com/apache/incubator-eventmesh/pull/3119#discussion_r1103915285


##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/acl/Acl.java:
##########
@@ -26,14 +26,25 @@
 import org.apache.commons.lang3.StringUtils;
 
 import java.util.Properties;
-import java.util.ServiceLoader;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public class Acl {
+
     private static final Logger logger = LoggerFactory.getLogger(Acl.class);

Review Comment:
   @jonyangx  I want to submit a separate PR to unified fix the logging issue. Use  lombok @slf4j annotation consistently. If there are no other problems with this PR you can merge first.
   



-- 
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: dev-unsubscribe@eventmesh.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: dev-help@eventmesh.apache.org


[GitHub] [incubator-eventmesh] jonyangx commented on a diff in pull request #3119: [ISSUE #3118]Refactor Acl

Posted by "jonyangx (via GitHub)" <gi...@apache.org>.
jonyangx commented on code in PR #3119:
URL: https://github.com/apache/incubator-eventmesh/pull/3119#discussion_r1103920679


##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/acl/Acl.java:
##########
@@ -26,14 +26,25 @@
 import org.apache.commons.lang3.StringUtils;
 
 import java.util.Properties;
-import java.util.ServiceLoader;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public class Acl {
+
     private static final Logger logger = LoggerFactory.getLogger(Acl.class);
-    private static AclService aclService;
+
+    private static final Acl INSTANCE = new Acl();
+
+    private AclService aclService;
+
+    private Acl() {
+
+    }
+
+    public static Acl getInstance() {

Review Comment:
   @mxsm Pls Consider start() and stop()  methods, how to manage thd aclService lifecycle.



-- 
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: dev-unsubscribe@eventmesh.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: dev-help@eventmesh.apache.org


[GitHub] [incubator-eventmesh] mxsm commented on a diff in pull request #3119: [ISSUE #3118]Refactor Acl

Posted by "mxsm (via GitHub)" <gi...@apache.org>.
mxsm commented on code in PR #3119:
URL: https://github.com/apache/incubator-eventmesh/pull/3119#discussion_r1107192607


##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/acl/Acl.java:
##########
@@ -25,33 +25,44 @@
 
 import org.apache.commons.lang3.StringUtils;
 
+import java.util.HashMap;
+import java.util.Map;
 import java.util.Properties;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class Acl {
 
-    private static final Logger logger = LoggerFactory.getLogger(Acl.class);
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
+public class Acl {
 
-    private static final Acl INSTANCE = new Acl();
+    private static final Map<String, Acl> ACL_CACHE = new HashMap<>(16);
 
     private AclService aclService;
 
     private Acl() {
 
     }
 
-    public static Acl getInstance() {
-        return INSTANCE;
+    public static Acl getInstance(String aclPluginType) {
+        return ACL_CACHE.computeIfAbsent(aclPluginType, key -> aclBuilder(key));
     }
 
-    public void init(String aclPluginType) throws AclException {
-        aclService = EventMeshExtensionFactory.getExtension(AclService.class, aclPluginType);
-        if (aclService == null) {
-            logger.error("can't load the aclService plugin, please check.");
+    private static Acl aclBuilder(String aclPluginType) {
+        AclService aclServiceExt = EventMeshExtensionFactory.getExtension(AclService.class, aclPluginType);
+        if (aclServiceExt == null) {
+            log.error("can't load the aclService plugin, please check.");
             throw new RuntimeException("doesn't load the aclService plugin, please check.");
         }
+        Acl acl = new Acl();
+        acl.aclService = aclServiceExt;
+
+        return acl;
+    }
+
+    public void init() throws AclException {
         aclService.init();

Review Comment:
   @jonyangx  done



-- 
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: dev-unsubscribe@eventmesh.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: dev-help@eventmesh.apache.org


[GitHub] [incubator-eventmesh] mxsm commented on a diff in pull request #3119: [ISSUE #3118]Refactor Acl

Posted by "mxsm (via GitHub)" <gi...@apache.org>.
mxsm commented on code in PR #3119:
URL: https://github.com/apache/incubator-eventmesh/pull/3119#discussion_r1103918615


##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/acl/Acl.java:
##########
@@ -26,14 +26,25 @@
 import org.apache.commons.lang3.StringUtils;
 
 import java.util.Properties;
-import java.util.ServiceLoader;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public class Acl {
+
     private static final Logger logger = LoggerFactory.getLogger(Acl.class);
-    private static AclService aclService;
+
+    private static final Acl INSTANCE = new Acl();
+
+    private AclService aclService;
+
+    private Acl() {
+
+    }
+
+    public static Acl getInstance() {

Review Comment:
   @jonyangx  Thanks for you suggest. I will do it and resubmit later!



##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/acl/Acl.java:
##########
@@ -26,14 +26,25 @@
 import org.apache.commons.lang3.StringUtils;
 
 import java.util.Properties;
-import java.util.ServiceLoader;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public class Acl {
+
     private static final Logger logger = LoggerFactory.getLogger(Acl.class);
-    private static AclService aclService;
+
+    private static final Acl INSTANCE = new Acl();
+
+    private AclService aclService;
+
+    private Acl() {
+
+    }
+
+    public static Acl getInstance() {

Review Comment:
   @jonyangx  Thanks for you suggestion. I will do it and resubmit later!



-- 
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: dev-unsubscribe@eventmesh.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: dev-help@eventmesh.apache.org


[GitHub] [incubator-eventmesh] mxsm commented on pull request #3119: [ISSUE #3118]Refactor Acl

Posted by "mxsm (via GitHub)" <gi...@apache.org>.
mxsm commented on PR #3119:
URL: https://github.com/apache/incubator-eventmesh/pull/3119#issuecomment-1429979442

   @jonyangx  The lifetime of the ACL is the same as the lifetime of the EventMeshServer. PTAL~ 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: dev-unsubscribe@eventmesh.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: dev-help@eventmesh.apache.org


[GitHub] [incubator-eventmesh] jonyangx commented on a diff in pull request #3119: [ISSUE #3118]Refactor Acl

Posted by "jonyangx (via GitHub)" <gi...@apache.org>.
jonyangx commented on code in PR #3119:
URL: https://github.com/apache/incubator-eventmesh/pull/3119#discussion_r1107173568


##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/acl/Acl.java:
##########
@@ -25,33 +25,44 @@
 
 import org.apache.commons.lang3.StringUtils;
 
+import java.util.HashMap;
+import java.util.Map;
 import java.util.Properties;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class Acl {
 
-    private static final Logger logger = LoggerFactory.getLogger(Acl.class);
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
+public class Acl {
 
-    private static final Acl INSTANCE = new Acl();
+    private static final Map<String, Acl> ACL_CACHE = new HashMap<>(16);
 
     private AclService aclService;
 
     private Acl() {
 
     }
 
-    public static Acl getInstance() {
-        return INSTANCE;
+    public static Acl getInstance(String aclPluginType) {
+        return ACL_CACHE.computeIfAbsent(aclPluginType, key -> aclBuilder(key));
     }
 
-    public void init(String aclPluginType) throws AclException {
-        aclService = EventMeshExtensionFactory.getExtension(AclService.class, aclPluginType);
-        if (aclService == null) {
-            logger.error("can't load the aclService plugin, please check.");
+    private static Acl aclBuilder(String aclPluginType) {
+        AclService aclServiceExt = EventMeshExtensionFactory.getExtension(AclService.class, aclPluginType);
+        if (aclServiceExt == null) {
+            log.error("can't load the aclService plugin, please check.");
             throw new RuntimeException("doesn't load the aclService plugin, please check.");
         }
+        Acl acl = new Acl();
+        acl.aclService = aclServiceExt;
+
+        return acl;
+    }
+
+    public void init() throws AclException {
         aclService.init();

Review Comment:
   Suggest add init,start,stop flag to avoid call multiple times. @mxsm 



-- 
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: dev-unsubscribe@eventmesh.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: dev-help@eventmesh.apache.org


[GitHub] [incubator-eventmesh] jonyangx merged pull request #3119: [ISSUE #3118]Refactor Acl

Posted by "jonyangx (via GitHub)" <gi...@apache.org>.
jonyangx merged PR #3119:
URL: https://github.com/apache/incubator-eventmesh/pull/3119


-- 
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: dev-unsubscribe@eventmesh.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: dev-help@eventmesh.apache.org


[GitHub] [incubator-eventmesh] jonyangx commented on a diff in pull request #3119: [ISSUE #3118]Refactor Acl

Posted by "jonyangx (via GitHub)" <gi...@apache.org>.
jonyangx commented on code in PR #3119:
URL: https://github.com/apache/incubator-eventmesh/pull/3119#discussion_r1103920679


##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/acl/Acl.java:
##########
@@ -26,14 +26,25 @@
 import org.apache.commons.lang3.StringUtils;
 
 import java.util.Properties;
-import java.util.ServiceLoader;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public class Acl {
+
     private static final Logger logger = LoggerFactory.getLogger(Acl.class);
-    private static AclService aclService;
+
+    private static final Acl INSTANCE = new Acl();
+
+    private AclService aclService;
+
+    private Acl() {
+
+    }
+
+    public static Acl getInstance() {

Review Comment:
   @mxsm Pls consider start() and stop()  methods, how to manage  aclService lifecycle. 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: dev-unsubscribe@eventmesh.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: dev-help@eventmesh.apache.org


[GitHub] [incubator-eventmesh] mxsm commented on a diff in pull request #3119: [ISSUE #3118]Refactor Acl

Posted by "mxsm (via GitHub)" <gi...@apache.org>.
mxsm commented on code in PR #3119:
URL: https://github.com/apache/incubator-eventmesh/pull/3119#discussion_r1103921410


##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/acl/Acl.java:
##########
@@ -26,14 +26,25 @@
 import org.apache.commons.lang3.StringUtils;
 
 import java.util.Properties;
-import java.util.ServiceLoader;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public class Acl {
+
     private static final Logger logger = LoggerFactory.getLogger(Acl.class);
-    private static AclService aclService;
+
+    private static final Acl INSTANCE = new Acl();
+
+    private AclService aclService;
+
+    private Acl() {
+
+    }
+
+    public static Acl getInstance() {

Review Comment:
   @jonyangx  OK, I will



-- 
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: dev-unsubscribe@eventmesh.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: dev-help@eventmesh.apache.org