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/09/18 17:12:07 UTC

[GitHub] [pulsar] bookjiang opened a new pull request #12096: Improve statistical indicators

bookjiang opened a new pull request #12096:
URL: https://github.com/apache/pulsar/pull/12096


   <!--
   ### Contribution Checklist
     
     - Name the pull request in the form "[Issue XYZ][component] Title of the pull request", where *XYZ* should be replaced by the actual issue number.
       Skip *Issue XYZ* if there is no associated github issue for this pull request.
       Skip *component* if you are unsure about which is the best component. E.g. `[docs] Fix typo in produce method`.
   
     - 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, not mix up code from multiple issues.
     
     - Each commit in the pull request has 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 #<xyz>`.)*
   
   Fixes #<xyz>
   
   *(or if this PR is one task of a github issue, please add `Master Issue: #<xyz>` to link to the master issue.)*
   
   Master Issue: #<xyz>
   -->
   ### Motivation
   “开源软件供应链点亮计划-暑期2021” 中项目 “改进主题的消息写入统计指标”;当broker重启或者主题变更时,恢复主题的写入数.
   
   
   ### Modifications
   ManagedLedgerImpl.java中增加了getLastEntry()方法获取主题的最后一个写入数据。
   BrokerService.java中增加当主题恢复到broker中时同时恢复写入数量。
   BrokerServiceTest.java中加入对此解决方案的各种情况测试。
   
   ### Verifying this change
   
   - [ ] Make sure that the change passes the CI checks.
   
   *(Please pick either of the following options)*
   
   This change added tests and can be verified as follows:
   
     - *测试了在没有batch设置下broker重启后恢复写入数的测试*
     -  *测试了在异步发送时没有batch设置下broker重启后恢复写入数的测试*
     - *测试了在异步发送时有batch设置下broker重启后恢复写入数的测试*
     -  *测试了在异步发送时有batch设置下主题所有权变更后恢复写入数的测试*
   
   ### 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 and label this PR (if you have committer privilege).
   
   Need to update docs? 
   
   - [ ] doc-required 
     
     (If you need help on updating docs, create a doc issue)
     
   - [x] no-need-doc 
     
     (Please explain why)
     
   - [ ] doc 
     
     (If this PR contains doc changes)
   
   
   


-- 
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] bookjiang commented on a change in pull request #12096: Improve statistical indicators

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



##########
File path: managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerImpl.java
##########
@@ -3964,5 +3966,19 @@ private void updateLastLedgerCreatedTimeAndScheduleRolloverTask() {
                     safeRun(this::rollCurrentLedgerIfFull), this.maximumRolloverTimeMs, TimeUnit.MILLISECONDS);
         }
     }
+    public CompletableFuture<LedgerEntry> getLastEntry() {
+        if (lastConfirmedEntry.getEntryId() == -1){
+            return new CompletableFuture<>();

Review comment:
       Thank you, teacher, it has been corrected.




-- 
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] gaoran10 commented on a change in pull request #12096: Improve statistical indicators

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



##########
File path: managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerImpl.java
##########
@@ -3964,5 +3966,19 @@ private void updateLastLedgerCreatedTimeAndScheduleRolloverTask() {
                     safeRun(this::rollCurrentLedgerIfFull), this.maximumRolloverTimeMs, TimeUnit.MILLISECONDS);
         }
     }
+    public CompletableFuture<LedgerEntry> getLastEntry() {
+        if (lastConfirmedEntry.getEntryId() == -1){
+            return new CompletableFuture<>();

Review comment:
       The new CompletableFuture is not complete. You could use this `CompletableFuture.completedFuture(null)`.

##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerService.java
##########
@@ -1248,6 +1252,21 @@ public void openLedgerComplete(ManagedLedger ledger, Object ctx) {
                                             topics.remove(topic, topicFuture);
                                         });
                                     } else {
+                                        ManagedLedgerImpl managedLedger =
+                                                (ManagedLedgerImpl) persistentTopic.getManagedLedger();
+                                        CompletableFuture<LedgerEntry> entryFuture = managedLedger.getLastEntry();
+                                        entryFuture.whenCompleteAsync((ledgerEntry, e)->{
+                                            if (e != null) {
+                                                log.error("fetch lastEntry error---{}", e.getMessage());

Review comment:
       ```suggestion
                                                   log.error("Failed to get last entry {}.", managedLedger.getLastConfirmedEntry(), e);
   ```

##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerService.java
##########
@@ -1248,6 +1252,21 @@ public void openLedgerComplete(ManagedLedger ledger, Object ctx) {
                                             topics.remove(topic, topicFuture);
                                         });
                                     } else {
+                                        ManagedLedgerImpl managedLedger =
+                                                (ManagedLedgerImpl) persistentTopic.getManagedLedger();
+                                        CompletableFuture<LedgerEntry> entryFuture = managedLedger.getLastEntry();
+                                        entryFuture.whenCompleteAsync((ledgerEntry, e)->{
+                                            if (e != null) {
+                                                log.error("fetch lastEntry error---{}", e.getMessage());

Review comment:
       If message count recovery failed, the topic creation should fail.




-- 
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] github-actions[bot] commented on pull request #12096: Improve statistical indicators

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on pull request #12096:
URL: https://github.com/apache/pulsar/pull/12096#issuecomment-1054903050


   The pr had no activity for 30 days, mark with Stale label.


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