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/05/20 15:44:52 UTC

[GitHub] [eventmesh] mxsm opened a new pull request, #3984: [ISSUE #3983] Optimize MessageQueue

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

   <!--
   ### 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 `Closes #<XXX>`.)
   -->
   
   Fixes #3983 
   
   ### Motivation
   
   *Explain the content here.*
   *Explain why you want to make the changes and what problem you're trying to solve.*
   
   
   
   ### Modifications
   
   *Optimize MessageQueue and add some comments*
   
   
   
   ### 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] [eventmesh] pandaapo commented on a diff in pull request #3984: [ISSUE #3983] Optimize MessageQueue

Posted by "pandaapo (via GitHub)" <gi...@apache.org>.
pandaapo commented on code in PR #3984:
URL: https://github.com/apache/eventmesh/pull/3984#discussion_r1201312186


##########
eventmesh-storage-plugin/eventmesh-storage-standalone/src/main/java/org/apache/eventmesh/storage/standalone/broker/MessageQueue.java:
##########
@@ -24,24 +24,27 @@
 
 import com.google.common.base.Preconditions;
 
+import lombok.Getter;
+
 /**
- * This is a block queue, can get entity by offset. The queue is a FIFO data structure.
+ *   This is a block queue, can get entity by offset. The queue is a FIFO data structure

Review Comment:
   It seems meaningless to remove the last period from the original comment and add a space before it. CC @xwm1992



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

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


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


[GitHub] [eventmesh] pandaapo commented on a diff in pull request #3984: [ISSUE #3983] Optimize MessageQueue

Posted by "pandaapo (via GitHub)" <gi...@apache.org>.
pandaapo commented on code in PR #3984:
URL: https://github.com/apache/eventmesh/pull/3984#discussion_r1200938442


##########
eventmesh-storage-plugin/eventmesh-storage-standalone/src/main/java/org/apache/eventmesh/storage/standalone/broker/MessageQueue.java:
##########
@@ -55,21 +58,22 @@ public MessageQueue(int capacity) {
         this.items = new MessageEntity[capacity];
         this.lock = new ReentrantLock();
         this.notEmpty = lock.newCondition();
-        this.notFull = lock.newCondition();
+        this.noteFull = lock.newCondition();

Review Comment:
   It should be 'notFull'.



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

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


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


[GitHub] [eventmesh] pandaapo commented on a diff in pull request #3984: [ISSUE #3983] Optimize MessageQueue

Posted by "pandaapo (via GitHub)" <gi...@apache.org>.
pandaapo commented on code in PR #3984:
URL: https://github.com/apache/eventmesh/pull/3984#discussion_r1199684903


##########
eventmesh-storage-plugin/eventmesh-storage-standalone/src/main/java/org/apache/eventmesh/storage/standalone/broker/MessageQueue.java:
##########
@@ -54,22 +57,23 @@ public MessageQueue(int capacity) {
         }
         this.items = new MessageEntity[capacity];
         this.lock = new ReentrantLock();
-        this.notEmpty = lock.newCondition();
-        this.notFull = lock.newCondition();
+        this.isEmpty = lock.newCondition();
+        this.isFull = lock.newCondition();
     }

Review Comment:
   These modification will confuse the developer or user. We name it `notFull` in situation of waiting on a full queue until not full, `notEmpty`  in situation of waiting on a empty queue util not empty. This naming method comes from jdk. https://github.com/openjdk/jdk/blob/a0f4a948bb76ce5ea11d8fe08e788ed43516ca4e/src/java.base/share/classes/java/util/concurrent/ArrayBlockingQueue.java#L370 
   CC @xwm1992 



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

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


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


[GitHub] [eventmesh] pandaapo commented on a diff in pull request #3984: [ISSUE #3983] Optimize MessageQueue

Posted by "pandaapo (via GitHub)" <gi...@apache.org>.
pandaapo commented on code in PR #3984:
URL: https://github.com/apache/eventmesh/pull/3984#discussion_r1199684903


##########
eventmesh-storage-plugin/eventmesh-storage-standalone/src/main/java/org/apache/eventmesh/storage/standalone/broker/MessageQueue.java:
##########
@@ -54,22 +57,23 @@ public MessageQueue(int capacity) {
         }
         this.items = new MessageEntity[capacity];
         this.lock = new ReentrantLock();
-        this.notEmpty = lock.newCondition();
-        this.notFull = lock.newCondition();
+        this.isEmpty = lock.newCondition();
+        this.isFull = lock.newCondition();
     }

Review Comment:
   These modification will confuse the developer or user. We name it `notFull` in situation of waiting on a full queue until not full, `notEmpty`  in situation of waiting on a empty queue until not empty. This naming method comes from jdk. https://github.com/openjdk/jdk/blob/a0f4a948bb76ce5ea11d8fe08e788ed43516ca4e/src/java.base/share/classes/java/util/concurrent/ArrayBlockingQueue.java#L370 
   CC @xwm1992 



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

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


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


[GitHub] [eventmesh] pandaapo commented on a diff in pull request #3984: [ISSUE #3983] Optimize MessageQueue

Posted by "pandaapo (via GitHub)" <gi...@apache.org>.
pandaapo commented on code in PR #3984:
URL: https://github.com/apache/eventmesh/pull/3984#discussion_r1199684430


##########
eventmesh-storage-plugin/eventmesh-storage-standalone/src/main/java/org/apache/eventmesh/storage/standalone/broker/MessageQueue.java:
##########
@@ -24,24 +24,27 @@
 
 import com.google.common.base.Preconditions;
 
+import lombok.Getter;
+
 /**
- * This is a block queue, can get entity by offset. The queue is a FIFO data structure.
+ *  Represents a message queue that stores instances of MessageEntity.
  */

Review Comment:
   It seems meaningless to remove the last period from the original comment and add a space before it. CC @xwm1992 



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

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


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


[GitHub] [eventmesh] codecov[bot] commented on pull request #3984: [ISSUE #3983] Optimize MessageQueue

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

   ## [Codecov](https://app.codecov.io/gh/apache/eventmesh/pull/3984?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   > Merging [#3984](https://app.codecov.io/gh/apache/eventmesh/pull/3984?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) (6287319) into [master](https://app.codecov.io/gh/apache/eventmesh/commit/7c0ed46bc169f0e0a277e312c837826ab07d0cc6?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) (7c0ed46) will **increase** coverage by `0.17%`.
   > The diff coverage is `0.00%`.
   
   > :exclamation: Current head 6287319 differs from pull request most recent head 79a06db. Consider uploading reports for the commit 79a06db to get more accurate results
   
   ```diff
   @@             Coverage Diff              @@
   ##             master    #3984      +/-   ##
   ============================================
   + Coverage     14.03%   14.20%   +0.17%     
   - Complexity     1293     1320      +27     
   ============================================
     Files           572      579       +7     
     Lines         28839    28967     +128     
     Branches       2808     2801       -7     
   ============================================
   + Hits           4047     4116      +69     
   - Misses        24416    24458      +42     
   - Partials        376      393      +17     
   ```
   
   
   | [Impacted Files](https://app.codecov.io/gh/apache/eventmesh/pull/3984?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
   |---|---|---|
   | [.../eventmesh/common/loadbalance/LoadBalanceType.java](https://app.codecov.io/gh/apache/eventmesh/pull/3984?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZXZlbnRtZXNoLWNvbW1vbi9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvZXZlbnRtZXNoL2NvbW1vbi9sb2FkYmFsYW5jZS9Mb2FkQmFsYW5jZVR5cGUuamF2YQ==) | `80.00% <ø> (ø)` | |
   | [...col/http/body/message/PushMessageResponseBody.java](https://app.codecov.io/gh/apache/eventmesh/pull/3984?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZXZlbnRtZXNoLWNvbW1vbi9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvZXZlbnRtZXNoL2NvbW1vbi9wcm90b2NvbC9odHRwL2JvZHkvbWVzc2FnZS9QdXNoTWVzc2FnZVJlc3BvbnNlQm9keS5qYXZh) | `0.00% <0.00%> (ø)` | |
   | [...ol/http/body/message/ReplyMessageResponseBody.java](https://app.codecov.io/gh/apache/eventmesh/pull/3984?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZXZlbnRtZXNoLWNvbW1vbi9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvZXZlbnRtZXNoL2NvbW1vbi9wcm90b2NvbC9odHRwL2JvZHkvbWVzc2FnZS9SZXBseU1lc3NhZ2VSZXNwb25zZUJvZHkuamF2YQ==) | `0.00% <0.00%> (ø)` | |
   | [...ttp/body/message/SendMessageBatchResponseBody.java](https://app.codecov.io/gh/apache/eventmesh/pull/3984?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZXZlbnRtZXNoLWNvbW1vbi9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvZXZlbnRtZXNoL2NvbW1vbi9wcm90b2NvbC9odHRwL2JvZHkvbWVzc2FnZS9TZW5kTWVzc2FnZUJhdGNoUmVzcG9uc2VCb2R5LmphdmE=) | `0.00% <0.00%> (ø)` | |
   | [...p/body/message/SendMessageBatchV2ResponseBody.java](https://app.codecov.io/gh/apache/eventmesh/pull/3984?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZXZlbnRtZXNoLWNvbW1vbi9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvZXZlbnRtZXNoL2NvbW1vbi9wcm90b2NvbC9odHRwL2JvZHkvbWVzc2FnZS9TZW5kTWVzc2FnZUJhdGNoVjJSZXNwb25zZUJvZHkuamF2YQ==) | `0.00% <0.00%> (ø)` | |
   | [...col/http/body/message/SendMessageResponseBody.java](https://app.codecov.io/gh/apache/eventmesh/pull/3984?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZXZlbnRtZXNoLWNvbW1vbi9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvZXZlbnRtZXNoL2NvbW1vbi9wcm90b2NvbC9odHRwL2JvZHkvbWVzc2FnZS9TZW5kTWVzc2FnZVJlc3BvbnNlQm9keS5qYXZh) | `0.00% <0.00%> (ø)` | |
   | [...h/runtime/admin/controller/HttpHandlerManager.java](https://app.codecov.io/gh/apache/eventmesh/pull/3984?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZXZlbnRtZXNoLXJ1bnRpbWUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2V2ZW50bWVzaC9ydW50aW1lL2FkbWluL2NvbnRyb2xsZXIvSHR0cEhhbmRsZXJNYW5hZ2VyLmphdmE=) | `100.00% <ø> (ø)` | |
   | [.../eventmesh/runtime/admin/handler/EventHandler.java](https://app.codecov.io/gh/apache/eventmesh/pull/3984?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZXZlbnRtZXNoLXJ1bnRpbWUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2V2ZW50bWVzaC9ydW50aW1lL2FkbWluL2hhbmRsZXIvRXZlbnRIYW5kbGVyLmphdmE=) | `6.18% <0.00%> (-0.07%)` | :arrow_down: |
   | [...tmesh/runtime/admin/handler/GrpcClientHandler.java](https://app.codecov.io/gh/apache/eventmesh/pull/3984?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZXZlbnRtZXNoLXJ1bnRpbWUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2V2ZW50bWVzaC9ydW50aW1lL2FkbWluL2hhbmRsZXIvR3JwY0NsaWVudEhhbmRsZXIuamF2YQ==) | `4.54% <0.00%> (-0.06%)` | :arrow_down: |
   | [...tmesh/runtime/admin/handler/HTTPClientHandler.java](https://app.codecov.io/gh/apache/eventmesh/pull/3984?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZXZlbnRtZXNoLXJ1bnRpbWUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2V2ZW50bWVzaC9ydW50aW1lL2FkbWluL2hhbmRsZXIvSFRUUENsaWVudEhhbmRsZXIuamF2YQ==) | `4.87% <0.00%> (-0.13%)` | :arrow_down: |
   | ... and [69 more](https://app.codecov.io/gh/apache/eventmesh/pull/3984?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | |
   
   ... and [21 files with indirect coverage changes](https://app.codecov.io/gh/apache/eventmesh/pull/3984/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   
   :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=apache)
   


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

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


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


[GitHub] [eventmesh] pandaapo commented on a diff in pull request #3984: [ISSUE #3983] Optimize MessageQueue

Posted by "pandaapo (via GitHub)" <gi...@apache.org>.
pandaapo commented on code in PR #3984:
URL: https://github.com/apache/eventmesh/pull/3984#discussion_r1199684430


##########
eventmesh-storage-plugin/eventmesh-storage-standalone/src/main/java/org/apache/eventmesh/storage/standalone/broker/MessageQueue.java:
##########
@@ -24,24 +24,27 @@
 
 import com.google.common.base.Preconditions;
 
+import lombok.Getter;
+
 /**
- * This is a block queue, can get entity by offset. The queue is a FIFO data structure.
+ *  Represents a message queue that stores instances of MessageEntity.
  */

Review Comment:
   I think the original comment seems to be clear for making developer or user understand this class easier and faster. And the modifications to `put(MessageEntity messageEntity)`, `take()`, `getByOffset(long offset)` are in the same situation. Maybe you can combine original comments and yours. CC @xwm1992 



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

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


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


[GitHub] [eventmesh] mxsm commented on pull request #3984: [ISSUE #3983] Optimize MessageQueue

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

   > @mxsm please take a look for review suggestions, and fix the ci check error, thanks.
   
   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: issues-unsubscribe@eventmesh.apache.org

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


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


[GitHub] [eventmesh] pandaapo commented on a diff in pull request #3984: [ISSUE #3983] Optimize MessageQueue

Posted by "pandaapo (via GitHub)" <gi...@apache.org>.
pandaapo commented on code in PR #3984:
URL: https://github.com/apache/eventmesh/pull/3984#discussion_r1199684430


##########
eventmesh-storage-plugin/eventmesh-storage-standalone/src/main/java/org/apache/eventmesh/storage/standalone/broker/MessageQueue.java:
##########
@@ -24,24 +24,27 @@
 
 import com.google.common.base.Preconditions;
 
+import lombok.Getter;
+
 /**
- * This is a block queue, can get entity by offset. The queue is a FIFO data structure.
+ *  Represents a message queue that stores instances of MessageEntity.
  */

Review Comment:
   It seems meaningless to remove the last period from the original comment and add a space before it. CC @xwm1992 



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

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


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


[GitHub] [eventmesh] pandaapo commented on a diff in pull request #3984: [ISSUE #3983] Optimize MessageQueue

Posted by "pandaapo (via GitHub)" <gi...@apache.org>.
pandaapo commented on code in PR #3984:
URL: https://github.com/apache/eventmesh/pull/3984#discussion_r1199684903


##########
eventmesh-storage-plugin/eventmesh-storage-standalone/src/main/java/org/apache/eventmesh/storage/standalone/broker/MessageQueue.java:
##########
@@ -54,22 +57,23 @@ public MessageQueue(int capacity) {
         }
         this.items = new MessageEntity[capacity];
         this.lock = new ReentrantLock();
-        this.notEmpty = lock.newCondition();
-        this.notFull = lock.newCondition();
+        this.isEmpty = lock.newCondition();
+        this.isFull = lock.newCondition();
     }

Review Comment:
   These modification will confuse the developer or user. We name it `notFull` in situation of waiting on a full queue until not full, `notEmpty`  in situation of waiting on a empty queue util not empty. This naming method comes from jdk. https://github.com/openjdk/jdk/blob/a0f4a948bb76ce5ea11d8fe08e788ed43516ca4e/src/java.base/share/classes/java/util/concurrent/ArrayBlockingQueue.java#L370 CC @xwm1992 



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

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


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


[GitHub] [eventmesh] pandaapo commented on a diff in pull request #3984: [ISSUE #3983] Optimize MessageQueue

Posted by "pandaapo (via GitHub)" <gi...@apache.org>.
pandaapo commented on code in PR #3984:
URL: https://github.com/apache/eventmesh/pull/3984#discussion_r1199684430


##########
eventmesh-storage-plugin/eventmesh-storage-standalone/src/main/java/org/apache/eventmesh/storage/standalone/broker/MessageQueue.java:
##########
@@ -24,24 +24,27 @@
 
 import com.google.common.base.Preconditions;
 
+import lombok.Getter;
+
 /**
- * This is a block queue, can get entity by offset. The queue is a FIFO data structure.
+ *  Represents a message queue that stores instances of MessageEntity.
  */

Review Comment:
   I think the original comment seems to be more clear. It can make developer or user understand this class easier and faster. And the modifications to `put(MessageEntity messageEntity)`, `take()`, `getByOffset(long offset)` are in the same situation.



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

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


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


[GitHub] [eventmesh] pandaapo commented on a diff in pull request #3984: [ISSUE #3983] Optimize MessageQueue

Posted by "pandaapo (via GitHub)" <gi...@apache.org>.
pandaapo commented on code in PR #3984:
URL: https://github.com/apache/eventmesh/pull/3984#discussion_r1200926164


##########
eventmesh-storage-plugin/eventmesh-storage-standalone/src/main/java/org/apache/eventmesh/storage/standalone/broker/MessageQueue.java:
##########
@@ -143,24 +147,30 @@ public MessageEntity getTail() {
     }
 
     /**
-     * Get the message by offset, since the offset is increment, so we can get the first message in this queue and calculate the index of this offset
+     * Retrieves the MessageEntity object with the specified offset.
      *
-     * @param offset
-     * @return MessageEntity
+     * @param offset The offset of the MessageEntity object to be retrieved.
+     * @return The MessageEntity object with the specified offset, or null if no such object exists in the queue.
+     * @throws RuntimeException if the specified offset is less than the offset of the head MessageEntity object.
      */
     public MessageEntity getByOffset(long offset) {
         ReentrantLock lock = this.lock;
         lock.lock();
         try {
-            MessageEntity head = getHead();
-            if (head == null) {
+            if (count == 0) {
                 return null;
             }
+            int headIndex = takeIndex;
+            int tailIndex = putIndex - 1;
+            MessageEntity head = itemAt(headIndex);
             if (head.getOffset() > offset) {

Review Comment:
   `int headIndex = takeIndex`, this assignment seems to be unnecessary. CC @xwm1992 



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

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


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


[GitHub] [eventmesh] xwm1992 commented on pull request #3984: [ISSUE #3983] Optimize MessageQueue

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

   @mxsm please take a look for review suggestions, and fix the ci check error, 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: issues-unsubscribe@eventmesh.apache.org

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


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


[GitHub] [eventmesh] xwm1992 merged pull request #3984: [ISSUE #3983] Optimize MessageQueue

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


-- 
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] [eventmesh] pandaapo commented on a diff in pull request #3984: [ISSUE #3983] Optimize MessageQueue

Posted by "pandaapo (via GitHub)" <gi...@apache.org>.
pandaapo commented on code in PR #3984:
URL: https://github.com/apache/eventmesh/pull/3984#discussion_r1200873283


##########
eventmesh-storage-plugin/eventmesh-storage-standalone/src/main/java/org/apache/eventmesh/storage/standalone/broker/MessageQueue.java:
##########
@@ -55,21 +58,22 @@ public MessageQueue(int capacity) {
         this.items = new MessageEntity[capacity];
         this.lock = new ReentrantLock();
         this.notEmpty = lock.newCondition();
-        this.notFull = lock.newCondition();
+        this.noteFull = lock.newCondition();
     }
 
     /**
-     * Insert the message at the tail of this queue, waiting for space to become available if the queue is full
+     * Inserts the specified MessageEntity object into the queue.
      *

Review Comment:
   I think the original comment seems to be clear for making developer or user understand this method easier and faster. Maybe you can combine original comments and yours. CC @xwm1992



##########
eventmesh-storage-plugin/eventmesh-storage-standalone/src/main/java/org/apache/eventmesh/storage/standalone/broker/MessageQueue.java:
##########
@@ -143,24 +147,30 @@ public MessageEntity getTail() {
     }
 
     /**
-     * Get the message by offset, since the offset is increment, so we can get the first message in this queue and calculate the index of this offset
+     * Retrieves the MessageEntity object with the specified offset.
      *
-     * @param offset
-     * @return MessageEntity
+     * @param offset The offset of the MessageEntity object to be retrieved.
+     * @return The MessageEntity object with the specified offset, or null if no such object exists in the queue.
+     * @throws RuntimeException if the specified offset is less than the offset of the head MessageEntity object.
      */
     public MessageEntity getByOffset(long offset) {
         ReentrantLock lock = this.lock;
         lock.lock();
         try {
-            MessageEntity head = getHead();
-            if (head == null) {
+            if (count == 0) {
                 return null;
             }
+            int headIndex = takeIndex;
+            int tailIndex = putIndex - 1;
+            MessageEntity head = itemAt(headIndex);
             if (head.getOffset() > offset) {
                 throw new RuntimeException(String.format("The message has been deleted, offset: %s", offset));
             }
-            MessageEntity tail = getTail();
-            if (tail == null || tail.getOffset() < offset) {
+            if (tailIndex < 0) {
+                tailIndex += items.length;
+            }
+            MessageEntity tail = itemAt(tailIndex);
+            if (tail.getOffset() < offset) {

Review Comment:
   The logic of returning null when `tail == null` is lost in your modification. CC @xwm1992 



##########
eventmesh-storage-plugin/eventmesh-storage-standalone/src/main/java/org/apache/eventmesh/storage/standalone/broker/MessageQueue.java:
##########
@@ -78,10 +82,10 @@ public void put(MessageEntity messageEntity) throws InterruptedException {
     }
 
     /**
-     * Get the first message at this queue, waiting for the message is available if the queue is empty, this method will not remove the message
+     * Retrieves and removes the head of the queue.
      *

Review Comment:
   I think the original comment seems to be more clear for making developer or user understand this method easier and faster. CC @xwm1992



##########
eventmesh-storage-plugin/eventmesh-storage-standalone/src/main/java/org/apache/eventmesh/storage/standalone/broker/MessageQueue.java:
##########
@@ -143,24 +147,30 @@ public MessageEntity getTail() {
     }
 
     /**
-     * Get the message by offset, since the offset is increment, so we can get the first message in this queue and calculate the index of this offset
+     * Retrieves the MessageEntity object with the specified offset.
      *

Review Comment:
   I think the original comment seems to be more clear for making developer or user understand this class easier and faster. CC @xwm1992



##########
eventmesh-storage-plugin/eventmesh-storage-standalone/src/main/java/org/apache/eventmesh/storage/standalone/broker/MessageQueue.java:
##########
@@ -143,24 +147,30 @@ public MessageEntity getTail() {
     }
 
     /**
-     * Get the message by offset, since the offset is increment, so we can get the first message in this queue and calculate the index of this offset
+     * Retrieves the MessageEntity object with the specified offset.
      *
-     * @param offset
-     * @return MessageEntity
+     * @param offset The offset of the MessageEntity object to be retrieved.
+     * @return The MessageEntity object with the specified offset, or null if no such object exists in the queue.
+     * @throws RuntimeException if the specified offset is less than the offset of the head MessageEntity object.
      */
     public MessageEntity getByOffset(long offset) {
         ReentrantLock lock = this.lock;
         lock.lock();
         try {
-            MessageEntity head = getHead();
-            if (head == null) {
+            if (count == 0) {
                 return null;
             }
+            int headIndex = takeIndex;
+            int tailIndex = putIndex - 1;
+            MessageEntity head = itemAt(headIndex);
             if (head.getOffset() > offset) {

Review Comment:
   `int headIndex = takeIndex`, this assignment seems to make no sense. CC @xwm1992 



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

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


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


[GitHub] [eventmesh] mxsm commented on pull request #3984: [ISSUE #3983] Optimize MessageQueue

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

   > @mxsm please fix the conflicts.
   
   @xwm1992  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: issues-unsubscribe@eventmesh.apache.org

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


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


[GitHub] [eventmesh] pandaapo commented on a diff in pull request #3984: [ISSUE #3983] Optimize MessageQueue

Posted by "pandaapo (via GitHub)" <gi...@apache.org>.
pandaapo commented on code in PR #3984:
URL: https://github.com/apache/eventmesh/pull/3984#discussion_r1199684903


##########
eventmesh-storage-plugin/eventmesh-storage-standalone/src/main/java/org/apache/eventmesh/storage/standalone/broker/MessageQueue.java:
##########
@@ -54,22 +57,23 @@ public MessageQueue(int capacity) {
         }
         this.items = new MessageEntity[capacity];
         this.lock = new ReentrantLock();
-        this.notEmpty = lock.newCondition();
-        this.notFull = lock.newCondition();
+        this.isEmpty = lock.newCondition();
+        this.isFull = lock.newCondition();
     }

Review Comment:
   These modification will confuse the developer or user. We name it `notFull` in situation of waiting on a full queue until not full, `notEmpty`  in situation of waiting on a empty queue util not empty. This naming method comes from jdk. https://github.com/openjdk/jdk/blob/a0f4a948bb76ce5ea11d8fe08e788ed43516ca4e/src/java.base/share/classes/java/util/concurrent/ArrayBlockingQueue.java#L370



##########
eventmesh-storage-plugin/eventmesh-storage-standalone/src/main/java/org/apache/eventmesh/storage/standalone/broker/MessageQueue.java:
##########
@@ -24,24 +24,27 @@
 
 import com.google.common.base.Preconditions;
 
+import lombok.Getter;
+
 /**
- * This is a block queue, can get entity by offset. The queue is a FIFO data structure.
+ *  Represents a message queue that stores instances of MessageEntity.
  */

Review Comment:
   I think the original comment seems to be more clear. It can make developer or user easier and faster understand this class. And the modifications to `put(MessageEntity messageEntity)`, `take()`, `getByOffset(long offset)` are in the same situation.



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

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


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


[GitHub] [eventmesh] pandaapo commented on a diff in pull request #3984: [ISSUE #3983] Optimize MessageQueue

Posted by "pandaapo (via GitHub)" <gi...@apache.org>.
pandaapo commented on code in PR #3984:
URL: https://github.com/apache/eventmesh/pull/3984#discussion_r1199684430


##########
eventmesh-storage-plugin/eventmesh-storage-standalone/src/main/java/org/apache/eventmesh/storage/standalone/broker/MessageQueue.java:
##########
@@ -24,24 +24,27 @@
 
 import com.google.common.base.Preconditions;
 
+import lombok.Getter;
+
 /**
- * This is a block queue, can get entity by offset. The queue is a FIFO data structure.
+ *  Represents a message queue that stores instances of MessageEntity.
  */

Review Comment:
   I think the original comment seems to be more clear. It can make developer or user understand this class easier and faster. And the modifications to `put(MessageEntity messageEntity)`, `take()`, `getByOffset(long offset)` are in the same situation. CC @xwm1992 



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

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


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


[GitHub] [eventmesh] xwm1992 commented on pull request #3984: [ISSUE #3983] Optimize MessageQueue

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

   @mxsm please fix the conflicts.


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

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


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


[GitHub] [eventmesh] pandaapo commented on a diff in pull request #3984: [ISSUE #3983] Optimize MessageQueue

Posted by "pandaapo (via GitHub)" <gi...@apache.org>.
pandaapo commented on code in PR #3984:
URL: https://github.com/apache/eventmesh/pull/3984#discussion_r1199684903


##########
eventmesh-storage-plugin/eventmesh-storage-standalone/src/main/java/org/apache/eventmesh/storage/standalone/broker/MessageQueue.java:
##########
@@ -54,22 +57,23 @@ public MessageQueue(int capacity) {
         }
         this.items = new MessageEntity[capacity];
         this.lock = new ReentrantLock();
-        this.notEmpty = lock.newCondition();
-        this.notFull = lock.newCondition();
+        this.isEmpty = lock.newCondition();
+        this.isFull = lock.newCondition();
     }

Review Comment:
   It should be 'notFull' .



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

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


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


[GitHub] [eventmesh] pandaapo commented on a diff in pull request #3984: [ISSUE #3983] Optimize MessageQueue

Posted by "pandaapo (via GitHub)" <gi...@apache.org>.
pandaapo commented on code in PR #3984:
URL: https://github.com/apache/eventmesh/pull/3984#discussion_r1199684903


##########
eventmesh-storage-plugin/eventmesh-storage-standalone/src/main/java/org/apache/eventmesh/storage/standalone/broker/MessageQueue.java:
##########
@@ -54,22 +57,23 @@ public MessageQueue(int capacity) {
         }
         this.items = new MessageEntity[capacity];
         this.lock = new ReentrantLock();
-        this.notEmpty = lock.newCondition();
-        this.notFull = lock.newCondition();
+        this.isEmpty = lock.newCondition();
+        this.isFull = lock.newCondition();
     }

Review Comment:
   It should be 'notFull' .



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

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


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