From 9d4e8de315fd60f7a86ad12ca1009d2406d10a89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E8=80=80=E8=BE=89?= <916669644@qq.com> Date: Wed, 23 Jun 2021 10:21:53 +0800 Subject: [PATCH 01/14] Looking at the Chinese document, I found that the subtraction operation of countdown timer is missing in asynchronous message push, so I downloaded the code. I found that someone added subtraction operation to the demo code in 18 years, but the document was not repaired, so I did this repair --- docs/cn/RocketMQ_Example.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/cn/RocketMQ_Example.md b/docs/cn/RocketMQ_Example.md index d924ce1d7d1..62961d31509 100644 --- a/docs/cn/RocketMQ_Example.md +++ b/docs/cn/RocketMQ_Example.md @@ -120,13 +120,15 @@ public class AsyncProducer { producer.send(msg, new SendCallback() { @Override public void onSuccess(SendResult sendResult) { + countDownLatch.countDown(); System.out.printf("%-10d OK %s %n", index, sendResult.getMsgId()); } @Override public void onException(Throwable e) { - System.out.printf("%-10d Exception %s %n", index, e); - e.printStackTrace(); + countDownLatch.countDown(); + System.out.printf("%-10d Exception %s %n", index, e); + e.printStackTrace(); } }); } From 5bd7cccfaa699ad04181c6b3f58987ececcb82d8 Mon Sep 17 00:00:00 2001 From: vongosling Date: Thu, 15 Jul 2021 20:14:33 +0800 Subject: [PATCH 02/14] Add little rocketmq robot --- .github/greetings.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 .github/greetings.yml diff --git a/.github/greetings.yml b/.github/greetings.yml new file mode 100644 index 00000000000..e69de29bb2d From d1f9915726aa4c4315ebe835af6ba5d00ba578f9 Mon Sep 17 00:00:00 2001 From: vongosling Date: Thu, 15 Jul 2021 20:18:15 +0800 Subject: [PATCH 03/14] Place into workflows directory --- .github/{ => workflows}/greetings.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/{ => workflows}/greetings.yml (100%) diff --git a/.github/greetings.yml b/.github/workflows/greetings.yml similarity index 100% rename from .github/greetings.yml rename to .github/workflows/greetings.yml From 15b0cdeeea1cf323a5003ef7d9bf6786b69c578c Mon Sep 17 00:00:00 2001 From: von gosling Date: Thu, 15 Jul 2021 20:39:51 +0800 Subject: [PATCH 04/14] Update greetings.yml --- .github/workflows/greetings.yml | 47 +++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/.github/workflows/greetings.yml b/.github/workflows/greetings.yml index e69de29bb2d..d22f73e3155 100644 --- a/.github/workflows/greetings.yml +++ b/.github/workflows/greetings.yml @@ -0,0 +1,47 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +name: Little RocketMQ + +on: [pull_request_target, issues] + +jobs: + greeting: + name: Greeting + runs-on: ubuntu-latest + steps: + - uses: actions/first-interaction@v1 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + issue-message: | + Make sure your issue are not the exist through the search. Follow the issue template, make more details for us. But please be aware that Issue should not be used for FAQs: if you have a question or are simply not sure if it is really an issue or not, please contact [us](https://rocketmq.apache.org/about/contact/) first before you create a new issue. + Please remember subscribe the mailing Lists before sending mail to us: + | Name | Description |Subscribe |Unsubscribe|Archive + | ---- | ---- |---- | ---- | ---- | + |Users |User support and questions mailing list| [Subscribe](mailto:users-subscribe@rocketmq.apache.org) |[Unsubscribe](mailto:users-unsubscribe@rocketmq.apache.org) |[Mail Archives](https://lists.apache.org/list.html?users@rocketmq.apache.org)| + |Development |Development related discussions| [Subscribe](mailto:dev-subscribe@rocketmq.apache.org) |[Unsubscribe](mailto:dev-unsubscribe@rocketmq.apache.org) |[Mail Archives](https://lists.apache.org/list.html?dev@rocketmq.apache.org)| + |Commits |All commits to repositories| [Subscribe](mailto:commits-subscribe@rocketmq.apache.org) |[Unsubscribe](mailto:commits-unsubscribe@rocketmq.apache.org) |[Mail Archives](https://lists.apache.org/list.html?commits@rocketmq.apache.org)| + pr-message: | + We always welcome new contributions, whether for trivial cleanups, [big new features](https://github.com/apache/rocketmq/wiki/RocketMQ-Improvement-Proposal) or other material rewards, more details see [here](http://rocketmq.apache.org/docs/how-to-contribute/). + Please remember subscribe the mailing Lists before sending mail to us: + | Name | Description |Subscribe |Unsubscribe|Archive + | ---- | ---- |---- | ---- | ---- | + |Users |User support and questions mailing list| [Subscribe](mailto:users-subscribe@rocketmq.apache.org) |[Unsubscribe](mailto:users-unsubscribe@rocketmq.apache.org) |[Mail Archives](https://lists.apache.org/list.html?users@rocketmq.apache.org)| + |Development |Development related discussions| [Subscribe](mailto:dev-subscribe@rocketmq.apache.org) |[Unsubscribe](mailto:dev-unsubscribe@rocketmq.apache.org) |[Mail Archives](https://lists.apache.org/list.html?dev@rocketmq.apache.org)| + |Commits |All commits to repositories| [Subscribe](mailto:commits-subscribe@rocketmq From 5a2aa7eabcd65133a86474dc6e3b6cd658021e46 Mon Sep 17 00:00:00 2001 From: von gosling Date: Thu, 15 Jul 2021 21:01:45 +0800 Subject: [PATCH 05/14] Update greetings.yml --- .github/workflows/greetings.yml | 39 ++++++++++----------------------- 1 file changed, 11 insertions(+), 28 deletions(-) diff --git a/.github/workflows/greetings.yml b/.github/workflows/greetings.yml index d22f73e3155..2a3261bf4e9 100644 --- a/.github/workflows/greetings.yml +++ b/.github/workflows/greetings.yml @@ -17,31 +17,14 @@ # under the License. # -name: Little RocketMQ - -on: [pull_request_target, issues] - -jobs: - greeting: - name: Greeting - runs-on: ubuntu-latest - steps: - - uses: actions/first-interaction@v1 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - issue-message: | - Make sure your issue are not the exist through the search. Follow the issue template, make more details for us. But please be aware that Issue should not be used for FAQs: if you have a question or are simply not sure if it is really an issue or not, please contact [us](https://rocketmq.apache.org/about/contact/) first before you create a new issue. - Please remember subscribe the mailing Lists before sending mail to us: - | Name | Description |Subscribe |Unsubscribe|Archive - | ---- | ---- |---- | ---- | ---- | - |Users |User support and questions mailing list| [Subscribe](mailto:users-subscribe@rocketmq.apache.org) |[Unsubscribe](mailto:users-unsubscribe@rocketmq.apache.org) |[Mail Archives](https://lists.apache.org/list.html?users@rocketmq.apache.org)| - |Development |Development related discussions| [Subscribe](mailto:dev-subscribe@rocketmq.apache.org) |[Unsubscribe](mailto:dev-unsubscribe@rocketmq.apache.org) |[Mail Archives](https://lists.apache.org/list.html?dev@rocketmq.apache.org)| - |Commits |All commits to repositories| [Subscribe](mailto:commits-subscribe@rocketmq.apache.org) |[Unsubscribe](mailto:commits-unsubscribe@rocketmq.apache.org) |[Mail Archives](https://lists.apache.org/list.html?commits@rocketmq.apache.org)| - pr-message: | - We always welcome new contributions, whether for trivial cleanups, [big new features](https://github.com/apache/rocketmq/wiki/RocketMQ-Improvement-Proposal) or other material rewards, more details see [here](http://rocketmq.apache.org/docs/how-to-contribute/). - Please remember subscribe the mailing Lists before sending mail to us: - | Name | Description |Subscribe |Unsubscribe|Archive - | ---- | ---- |---- | ---- | ---- | - |Users |User support and questions mailing list| [Subscribe](mailto:users-subscribe@rocketmq.apache.org) |[Unsubscribe](mailto:users-unsubscribe@rocketmq.apache.org) |[Mail Archives](https://lists.apache.org/list.html?users@rocketmq.apache.org)| - |Development |Development related discussions| [Subscribe](mailto:dev-subscribe@rocketmq.apache.org) |[Unsubscribe](mailto:dev-unsubscribe@rocketmq.apache.org) |[Mail Archives](https://lists.apache.org/list.html?dev@rocketmq.apache.org)| - |Commits |All commits to repositories| [Subscribe](mailto:commits-subscribe@rocketmq +- name: Little RocketMQ + uses: actions/first-interaction@v1.1.0 + with: + # Token for the repository. Can be passed in using {{ secrets.GITHUB_TOKEN }} + repo-token: {{ secrets.GITHUB_TOKEN }} + # Comment to post on an individual's first issue + issue-message: # optional + Make sure your issue is not the existence through the issue search. Follow the issue template, make more details for us. But please be aware that Issue should not be used for FAQs: if you have a question or are simply not sure if it is really an issue or not, please contact [us](https://rocketmq.apache.org/about/contact/) first before you create a new issue. + # Comment to post on an individual's first pull request + pr-message: # optional + We always welcome new contributions, whether for trivial cleanups, [big new features](https://github.com/apache/rocketmq/wiki/RocketMQ-Improvement-Proposal) or other material rewards, more details see [here](http://rocketmq.apache.org/docs/how-to-contribute/). From d83b7e58fea209fc6999d2188a6920ce489986f9 Mon Sep 17 00:00:00 2001 From: von gosling Date: Fri, 16 Jul 2021 11:59:15 +0800 Subject: [PATCH 06/14] Fix typo --- .github/workflows/greetings.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/greetings.yml b/.github/workflows/greetings.yml index 2a3261bf4e9..501b65f3314 100644 --- a/.github/workflows/greetings.yml +++ b/.github/workflows/greetings.yml @@ -23,8 +23,6 @@ # Token for the repository. Can be passed in using {{ secrets.GITHUB_TOKEN }} repo-token: {{ secrets.GITHUB_TOKEN }} # Comment to post on an individual's first issue - issue-message: # optional - Make sure your issue is not the existence through the issue search. Follow the issue template, make more details for us. But please be aware that Issue should not be used for FAQs: if you have a question or are simply not sure if it is really an issue or not, please contact [us](https://rocketmq.apache.org/about/contact/) first before you create a new issue. + issue-message: Make sure your issue is not the existence through the issue search. Follow the issue template, make more details for us. But please be aware that Issue should not be used for FAQs: if you have a question or are simply not sure if it is really an issue or not, please contact [us](https://rocketmq.apache.org/about/contact/) first before you create a new issue. # Comment to post on an individual's first pull request - pr-message: # optional - We always welcome new contributions, whether for trivial cleanups, [big new features](https://github.com/apache/rocketmq/wiki/RocketMQ-Improvement-Proposal) or other material rewards, more details see [here](http://rocketmq.apache.org/docs/how-to-contribute/). + pr-message: We always welcome new contributions, whether for trivial cleanups, [big new features](https://github.com/apache/rocketmq/wiki/RocketMQ-Improvement-Proposal) or other material rewards, more details see [here](http://rocketmq.apache.org/docs/how-to-contribute/). From cfadd4d79fab41b110ec787d682bc8a7b7643a2f Mon Sep 17 00:00:00 2001 From: von gosling Date: Fri, 16 Jul 2021 12:04:39 +0800 Subject: [PATCH 07/14] Update greetings.yml --- .github/workflows/greetings.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/greetings.yml b/.github/workflows/greetings.yml index 501b65f3314..39c1de08fd8 100644 --- a/.github/workflows/greetings.yml +++ b/.github/workflows/greetings.yml @@ -21,8 +21,8 @@ uses: actions/first-interaction@v1.1.0 with: # Token for the repository. Can be passed in using {{ secrets.GITHUB_TOKEN }} - repo-token: {{ secrets.GITHUB_TOKEN }} + repo-token: ${{ secrets.GITHUB_TOKEN }} # Comment to post on an individual's first issue - issue-message: Make sure your issue is not the existence through the issue search. Follow the issue template, make more details for us. But please be aware that Issue should not be used for FAQs: if you have a question or are simply not sure if it is really an issue or not, please contact [us](https://rocketmq.apache.org/about/contact/) first before you create a new issue. + issue-message: 'Make sure your issue is not the existence through the issue search. Follow the issue template, make more details for us. But please be aware that Issue should not be used for FAQs: if you have a question or are simply not sure if it is really an issue or not, please contact [us](https://rocketmq.apache.org/about/contact/) first before you create a new issue.' # Comment to post on an individual's first pull request - pr-message: We always welcome new contributions, whether for trivial cleanups, [big new features](https://github.com/apache/rocketmq/wiki/RocketMQ-Improvement-Proposal) or other material rewards, more details see [here](http://rocketmq.apache.org/docs/how-to-contribute/). + pr-message: 'We always welcome new contributions, whether for trivial cleanups, [big new features](https://github.com/apache/rocketmq/wiki/RocketMQ-Improvement-Proposal) or other material rewards, more details see [here](http://rocketmq.apache.org/docs/how-to-contribute/).' From 39f549a8eab6af7106fbc17fea2c858e3836301f Mon Sep 17 00:00:00 2001 From: von gosling Date: Fri, 16 Jul 2021 12:10:28 +0800 Subject: [PATCH 08/14] Update greetings.yml --- .github/workflows/greetings.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/greetings.yml b/.github/workflows/greetings.yml index 39c1de08fd8..4623ffb4c8b 100644 --- a/.github/workflows/greetings.yml +++ b/.github/workflows/greetings.yml @@ -17,12 +17,12 @@ # under the License. # -- name: Little RocketMQ - uses: actions/first-interaction@v1.1.0 - with: - # Token for the repository. Can be passed in using {{ secrets.GITHUB_TOKEN }} - repo-token: ${{ secrets.GITHUB_TOKEN }} - # Comment to post on an individual's first issue - issue-message: 'Make sure your issue is not the existence through the issue search. Follow the issue template, make more details for us. But please be aware that Issue should not be used for FAQs: if you have a question or are simply not sure if it is really an issue or not, please contact [us](https://rocketmq.apache.org/about/contact/) first before you create a new issue.' - # Comment to post on an individual's first pull request - pr-message: 'We always welcome new contributions, whether for trivial cleanups, [big new features](https://github.com/apache/rocketmq/wiki/RocketMQ-Improvement-Proposal) or other material rewards, more details see [here](http://rocketmq.apache.org/docs/how-to-contribute/).' +name: Little RocketMQ +uses: actions/first-interaction@v1.1.0 +with: + # Token for the repository. Can be passed in using {{ secrets.GITHUB_TOKEN }} + repo-token: ${{ secrets.GITHUB_TOKEN }} + # Comment to post on an individual's first issue + issue-message: 'Make sure your issue is not the existence through the issue search. Follow the issue template, make more details for us. But please be aware that Issue should not be used for FAQs: if you have a question or are simply not sure if it is really an issue or not, please contact [us](https://rocketmq.apache.org/about/contact/) first before you create a new issue.' + # Comment to post on an individual's first pull request + pr-message: 'We always welcome new contributions, whether for trivial cleanups, [big new features](https://github.com/apache/rocketmq/wiki/RocketMQ-Improvement-Proposal) or other material rewards, more details see [here](http://rocketmq.apache.org/docs/how-to-contribute/).' From a20f31bb3de242756542c552d7212a7a40000ba4 Mon Sep 17 00:00:00 2001 From: von gosling Date: Fri, 16 Jul 2021 12:18:36 +0800 Subject: [PATCH 09/14] Limit event trigger --- .github/workflows/greetings.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/greetings.yml b/.github/workflows/greetings.yml index 4623ffb4c8b..b95e6e4bd03 100644 --- a/.github/workflows/greetings.yml +++ b/.github/workflows/greetings.yml @@ -18,6 +18,7 @@ # name: Little RocketMQ +on: [pull_request_target, issues] uses: actions/first-interaction@v1.1.0 with: # Token for the repository. Can be passed in using {{ secrets.GITHUB_TOKEN }} From e9c4253218b6b70512f4a365c11d992729169f1c Mon Sep 17 00:00:00 2001 From: zongtanghu Date: Sun, 1 Aug 2021 20:01:39 +0800 Subject: [PATCH 10/14] [maven-release-plugin] prepare release rocketmq-all-4.9.1 --- acl/pom.xml | 2 +- broker/pom.xml | 2 +- client/pom.xml | 2 +- common/pom.xml | 2 +- distribution/pom.xml | 2 +- example/pom.xml | 2 +- filter/pom.xml | 2 +- logappender/pom.xml | 2 +- logging/pom.xml | 2 +- namesrv/pom.xml | 2 +- openmessaging/pom.xml | 2 +- pom.xml | 4 ++-- remoting/pom.xml | 2 +- srvutil/pom.xml | 2 +- store/pom.xml | 2 +- test/pom.xml | 2 +- tools/pom.xml | 2 +- 17 files changed, 18 insertions(+), 18 deletions(-) diff --git a/acl/pom.xml b/acl/pom.xml index d6249341789..8b362ca3695 100644 --- a/acl/pom.xml +++ b/acl/pom.xml @@ -13,7 +13,7 @@ org.apache.rocketmq rocketmq-all - 4.9.1-SNAPSHOT + 4.9.1 rocketmq-acl rocketmq-acl ${project.version} diff --git a/broker/pom.xml b/broker/pom.xml index 3a58aa0c717..4eeb833d363 100644 --- a/broker/pom.xml +++ b/broker/pom.xml @@ -13,7 +13,7 @@ org.apache.rocketmq rocketmq-all - 4.9.1-SNAPSHOT + 4.9.1 4.0.0 diff --git a/client/pom.xml b/client/pom.xml index 95ef4617dd1..40b262c0bff 100644 --- a/client/pom.xml +++ b/client/pom.xml @@ -19,7 +19,7 @@ org.apache.rocketmq rocketmq-all - 4.9.1-SNAPSHOT + 4.9.1 4.0.0 diff --git a/common/pom.xml b/common/pom.xml index ac1d086b4cc..538b2f39833 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -19,7 +19,7 @@ org.apache.rocketmq rocketmq-all - 4.9.1-SNAPSHOT + 4.9.1 4.0.0 diff --git a/distribution/pom.xml b/distribution/pom.xml index a5698bca1c6..da31262d5b9 100644 --- a/distribution/pom.xml +++ b/distribution/pom.xml @@ -20,7 +20,7 @@ org.apache.rocketmq rocketmq-all - 4.9.1-SNAPSHOT + 4.9.1 rocketmq-distribution rocketmq-distribution ${project.version} diff --git a/example/pom.xml b/example/pom.xml index 81f7515dbe3..7c9faad9474 100644 --- a/example/pom.xml +++ b/example/pom.xml @@ -19,7 +19,7 @@ rocketmq-all org.apache.rocketmq - 4.9.1-SNAPSHOT + 4.9.1 4.0.0 diff --git a/filter/pom.xml b/filter/pom.xml index 41bda9d0d22..b4ec32f7d67 100644 --- a/filter/pom.xml +++ b/filter/pom.xml @@ -20,7 +20,7 @@ rocketmq-all org.apache.rocketmq - 4.9.1-SNAPSHOT + 4.9.1 4.0.0 diff --git a/logappender/pom.xml b/logappender/pom.xml index cac520b6103..3ec5be8177e 100644 --- a/logappender/pom.xml +++ b/logappender/pom.xml @@ -19,7 +19,7 @@ org.apache.rocketmq rocketmq-all - 4.9.1-SNAPSHOT + 4.9.1 4.0.0 rocketmq-logappender diff --git a/logging/pom.xml b/logging/pom.xml index 8ebb2430452..db6c8d4a072 100644 --- a/logging/pom.xml +++ b/logging/pom.xml @@ -19,7 +19,7 @@ org.apache.rocketmq rocketmq-all - 4.9.1-SNAPSHOT + 4.9.1 4.0.0 diff --git a/namesrv/pom.xml b/namesrv/pom.xml index 01ef5b60fe9..41f7e012ed0 100644 --- a/namesrv/pom.xml +++ b/namesrv/pom.xml @@ -19,7 +19,7 @@ org.apache.rocketmq rocketmq-all - 4.9.1-SNAPSHOT + 4.9.1 4.0.0 diff --git a/openmessaging/pom.xml b/openmessaging/pom.xml index 4688c040436..db8aebd3d7c 100644 --- a/openmessaging/pom.xml +++ b/openmessaging/pom.xml @@ -20,7 +20,7 @@ rocketmq-all org.apache.rocketmq - 4.9.1-SNAPSHOT + 4.9.1 4.0.0 diff --git a/pom.xml b/pom.xml index 59fe5c8072b..c4fe658d9b4 100644 --- a/pom.xml +++ b/pom.xml @@ -29,7 +29,7 @@ 2012 org.apache.rocketmq rocketmq-all - 4.9.1-SNAPSHOT + 4.9.1 pom Apache RocketMQ ${project.version} http://rocketmq.apache.org/ @@ -38,7 +38,7 @@ git@github.com:apache/rocketmq.git scm:git:git@github.com:apache/rocketmq.git scm:git:git@github.com:apache/rocketmq.git - HEAD + rocketmq-all-4.9.1 diff --git a/remoting/pom.xml b/remoting/pom.xml index 765e1a93bc0..6155379783f 100644 --- a/remoting/pom.xml +++ b/remoting/pom.xml @@ -19,7 +19,7 @@ org.apache.rocketmq rocketmq-all - 4.9.1-SNAPSHOT + 4.9.1 4.0.0 diff --git a/srvutil/pom.xml b/srvutil/pom.xml index 9c4544c0b25..543483fd9bc 100644 --- a/srvutil/pom.xml +++ b/srvutil/pom.xml @@ -19,7 +19,7 @@ org.apache.rocketmq rocketmq-all - 4.9.1-SNAPSHOT + 4.9.1 4.0.0 diff --git a/store/pom.xml b/store/pom.xml index 23e9763d814..ce040d82fac 100644 --- a/store/pom.xml +++ b/store/pom.xml @@ -19,7 +19,7 @@ org.apache.rocketmq rocketmq-all - 4.9.1-SNAPSHOT + 4.9.1 4.0.0 diff --git a/test/pom.xml b/test/pom.xml index 41296501c28..1f159469b48 100644 --- a/test/pom.xml +++ b/test/pom.xml @@ -20,7 +20,7 @@ rocketmq-all org.apache.rocketmq - 4.9.1-SNAPSHOT + 4.9.1 4.0.0 diff --git a/tools/pom.xml b/tools/pom.xml index abe8197de39..85ce2c6c39a 100644 --- a/tools/pom.xml +++ b/tools/pom.xml @@ -19,7 +19,7 @@ org.apache.rocketmq rocketmq-all - 4.9.1-SNAPSHOT + 4.9.1 4.0.0 From bb34171289e98a5b45a7a4aa2c7195ab5731d362 Mon Sep 17 00:00:00 2001 From: zongtanghu Date: Sun, 1 Aug 2021 20:01:59 +0800 Subject: [PATCH 11/14] [maven-release-plugin] prepare for next development iteration --- acl/pom.xml | 2 +- broker/pom.xml | 2 +- client/pom.xml | 2 +- common/pom.xml | 2 +- distribution/pom.xml | 2 +- example/pom.xml | 2 +- filter/pom.xml | 2 +- logappender/pom.xml | 2 +- logging/pom.xml | 2 +- namesrv/pom.xml | 2 +- openmessaging/pom.xml | 2 +- pom.xml | 4 ++-- remoting/pom.xml | 2 +- srvutil/pom.xml | 2 +- store/pom.xml | 2 +- test/pom.xml | 2 +- tools/pom.xml | 2 +- 17 files changed, 18 insertions(+), 18 deletions(-) diff --git a/acl/pom.xml b/acl/pom.xml index 8b362ca3695..f2cbdbe9e2c 100644 --- a/acl/pom.xml +++ b/acl/pom.xml @@ -13,7 +13,7 @@ org.apache.rocketmq rocketmq-all - 4.9.1 + 4.9.2-SNAPSHOT rocketmq-acl rocketmq-acl ${project.version} diff --git a/broker/pom.xml b/broker/pom.xml index 4eeb833d363..40c5730f445 100644 --- a/broker/pom.xml +++ b/broker/pom.xml @@ -13,7 +13,7 @@ org.apache.rocketmq rocketmq-all - 4.9.1 + 4.9.2-SNAPSHOT 4.0.0 diff --git a/client/pom.xml b/client/pom.xml index 40b262c0bff..9387eb3b68c 100644 --- a/client/pom.xml +++ b/client/pom.xml @@ -19,7 +19,7 @@ org.apache.rocketmq rocketmq-all - 4.9.1 + 4.9.2-SNAPSHOT 4.0.0 diff --git a/common/pom.xml b/common/pom.xml index 538b2f39833..defddd224f1 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -19,7 +19,7 @@ org.apache.rocketmq rocketmq-all - 4.9.1 + 4.9.2-SNAPSHOT 4.0.0 diff --git a/distribution/pom.xml b/distribution/pom.xml index da31262d5b9..6f10ff4f9ad 100644 --- a/distribution/pom.xml +++ b/distribution/pom.xml @@ -20,7 +20,7 @@ org.apache.rocketmq rocketmq-all - 4.9.1 + 4.9.2-SNAPSHOT rocketmq-distribution rocketmq-distribution ${project.version} diff --git a/example/pom.xml b/example/pom.xml index 7c9faad9474..9d6aec6433b 100644 --- a/example/pom.xml +++ b/example/pom.xml @@ -19,7 +19,7 @@ rocketmq-all org.apache.rocketmq - 4.9.1 + 4.9.2-SNAPSHOT 4.0.0 diff --git a/filter/pom.xml b/filter/pom.xml index b4ec32f7d67..2dd396e782f 100644 --- a/filter/pom.xml +++ b/filter/pom.xml @@ -20,7 +20,7 @@ rocketmq-all org.apache.rocketmq - 4.9.1 + 4.9.2-SNAPSHOT 4.0.0 diff --git a/logappender/pom.xml b/logappender/pom.xml index 3ec5be8177e..2a1111a624e 100644 --- a/logappender/pom.xml +++ b/logappender/pom.xml @@ -19,7 +19,7 @@ org.apache.rocketmq rocketmq-all - 4.9.1 + 4.9.2-SNAPSHOT 4.0.0 rocketmq-logappender diff --git a/logging/pom.xml b/logging/pom.xml index db6c8d4a072..88c8e24ee32 100644 --- a/logging/pom.xml +++ b/logging/pom.xml @@ -19,7 +19,7 @@ org.apache.rocketmq rocketmq-all - 4.9.1 + 4.9.2-SNAPSHOT 4.0.0 diff --git a/namesrv/pom.xml b/namesrv/pom.xml index 41f7e012ed0..dade790f020 100644 --- a/namesrv/pom.xml +++ b/namesrv/pom.xml @@ -19,7 +19,7 @@ org.apache.rocketmq rocketmq-all - 4.9.1 + 4.9.2-SNAPSHOT 4.0.0 diff --git a/openmessaging/pom.xml b/openmessaging/pom.xml index db8aebd3d7c..dfa0780c05f 100644 --- a/openmessaging/pom.xml +++ b/openmessaging/pom.xml @@ -20,7 +20,7 @@ rocketmq-all org.apache.rocketmq - 4.9.1 + 4.9.2-SNAPSHOT 4.0.0 diff --git a/pom.xml b/pom.xml index c4fe658d9b4..af0db5c52cd 100644 --- a/pom.xml +++ b/pom.xml @@ -29,7 +29,7 @@ 2012 org.apache.rocketmq rocketmq-all - 4.9.1 + 4.9.2-SNAPSHOT pom Apache RocketMQ ${project.version} http://rocketmq.apache.org/ @@ -38,7 +38,7 @@ git@github.com:apache/rocketmq.git scm:git:git@github.com:apache/rocketmq.git scm:git:git@github.com:apache/rocketmq.git - rocketmq-all-4.9.1 + HEAD diff --git a/remoting/pom.xml b/remoting/pom.xml index 6155379783f..a019a4d6241 100644 --- a/remoting/pom.xml +++ b/remoting/pom.xml @@ -19,7 +19,7 @@ org.apache.rocketmq rocketmq-all - 4.9.1 + 4.9.2-SNAPSHOT 4.0.0 diff --git a/srvutil/pom.xml b/srvutil/pom.xml index 543483fd9bc..5ba70577bbf 100644 --- a/srvutil/pom.xml +++ b/srvutil/pom.xml @@ -19,7 +19,7 @@ org.apache.rocketmq rocketmq-all - 4.9.1 + 4.9.2-SNAPSHOT 4.0.0 diff --git a/store/pom.xml b/store/pom.xml index ce040d82fac..09f3dba9f33 100644 --- a/store/pom.xml +++ b/store/pom.xml @@ -19,7 +19,7 @@ org.apache.rocketmq rocketmq-all - 4.9.1 + 4.9.2-SNAPSHOT 4.0.0 diff --git a/test/pom.xml b/test/pom.xml index 1f159469b48..83e0e337055 100644 --- a/test/pom.xml +++ b/test/pom.xml @@ -20,7 +20,7 @@ rocketmq-all org.apache.rocketmq - 4.9.1 + 4.9.2-SNAPSHOT 4.0.0 diff --git a/tools/pom.xml b/tools/pom.xml index 85ce2c6c39a..ffab7442e50 100644 --- a/tools/pom.xml +++ b/tools/pom.xml @@ -19,7 +19,7 @@ org.apache.rocketmq rocketmq-all - 4.9.1 + 4.9.2-SNAPSHOT 4.0.0 From 3a2b172660d489dad3365d777b995abafe50a64d Mon Sep 17 00:00:00 2001 From: zhenhe Date: Wed, 4 Aug 2021 13:59:25 +0800 Subject: [PATCH 12/14] [ISSUE #3006]Replace ScheduledExecutorService instead of Timer to avoid affecting other tasks during exception (#3001) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 采用ScheduledExecutorService替代Timer,避免异常捕获时影响其他任务 多线程并行处理定时任务时,Timer运行多个TimeTask时,只要其中之一没有捕获抛出的异常,其它任务便会自动终止运行,使用ScheduledExecutorService则没有这个问题。 * optimize imports * Add @Override annotation * Revert "Add @Override annotation" This reverts commit 3ddccd88022db33361a2af08b36b0c8f5d963f48. Co-authored-by: wuzh --- .../rocketmq/example/benchmark/Consumer.java | 30 ++++++------ .../rocketmq/example/benchmark/Producer.java | 44 ++++++++++-------- .../benchmark/TransactionProducer.java | 46 ++++++++++--------- 3 files changed, 68 insertions(+), 52 deletions(-) diff --git a/example/src/main/java/org/apache/rocketmq/example/benchmark/Consumer.java b/example/src/main/java/org/apache/rocketmq/example/benchmark/Consumer.java index d3ac36c2046..154e6ed4dac 100644 --- a/example/src/main/java/org/apache/rocketmq/example/benchmark/Consumer.java +++ b/example/src/main/java/org/apache/rocketmq/example/benchmark/Consumer.java @@ -17,18 +17,11 @@ package org.apache.rocketmq.example.benchmark; -import java.io.IOException; -import java.util.LinkedList; -import java.util.List; -import java.util.Timer; -import java.util.TimerTask; -import java.util.concurrent.ThreadLocalRandom; -import java.util.concurrent.atomic.AtomicLong; - import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.Option; import org.apache.commons.cli.Options; import org.apache.commons.cli.PosixParser; +import org.apache.commons.lang3.concurrent.BasicThreadFactory; import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer; import org.apache.rocketmq.client.consumer.MessageSelector; import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext; @@ -42,6 +35,16 @@ import org.apache.rocketmq.remoting.RPCHook; import org.apache.rocketmq.srvutil.ServerUtil; +import java.io.IOException; +import java.util.LinkedList; +import java.util.List; +import java.util.TimerTask; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.ScheduledThreadPoolExecutor; +import java.util.concurrent.ThreadLocalRandom; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicLong; + public class Consumer { public static void main(String[] args) throws MQClientException, IOException { @@ -71,11 +74,12 @@ public static void main(String[] args) throws MQClientException, IOException { final StatsBenchmarkConsumer statsBenchmarkConsumer = new StatsBenchmarkConsumer(); - final Timer timer = new Timer("BenchmarkTimerThread", true); + ScheduledExecutorService executorService = new ScheduledThreadPoolExecutor(1, + new BasicThreadFactory.Builder().namingPattern("BenchmarkTimerThread-%d").daemon(true).build()); final LinkedList snapshotList = new LinkedList(); - timer.scheduleAtFixedRate(new TimerTask() { + executorService.scheduleAtFixedRate(new TimerTask() { @Override public void run() { snapshotList.addLast(statsBenchmarkConsumer.createSnapshot()); @@ -83,9 +87,9 @@ public void run() { snapshotList.removeFirst(); } } - }, 1000, 1000); + }, 1000, 1000, TimeUnit.MILLISECONDS); - timer.scheduleAtFixedRate(new TimerTask() { + executorService.scheduleAtFixedRate(new TimerTask() { private void printStats() { if (snapshotList.size() >= 10) { Long[] begin = snapshotList.getFirst(); @@ -116,7 +120,7 @@ public void run() { e.printStackTrace(); } } - }, 10000, 10000); + }, 10000, 10000, TimeUnit.MILLISECONDS); RPCHook rpcHook = aclEnable ? AclClient.getAclRPCHook() : null; DefaultMQPushConsumer consumer = new DefaultMQPushConsumer(group, rpcHook, new AllocateMessageQueueAveragely(), msgTraceEnable, null); diff --git a/example/src/main/java/org/apache/rocketmq/example/benchmark/Producer.java b/example/src/main/java/org/apache/rocketmq/example/benchmark/Producer.java index 32d4b9f7462..b198a0fc998 100644 --- a/example/src/main/java/org/apache/rocketmq/example/benchmark/Producer.java +++ b/example/src/main/java/org/apache/rocketmq/example/benchmark/Producer.java @@ -16,32 +16,34 @@ */ package org.apache.rocketmq.example.benchmark; -import java.io.UnsupportedEncodingException; -import java.util.Arrays; -import java.util.LinkedList; -import java.util.Random; -import java.util.Timer; -import java.util.TimerTask; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicLong; - import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.Option; import org.apache.commons.cli.Options; import org.apache.commons.cli.PosixParser; +import org.apache.commons.lang3.concurrent.BasicThreadFactory; import org.apache.rocketmq.client.exception.MQBrokerException; import org.apache.rocketmq.client.exception.MQClientException; import org.apache.rocketmq.client.log.ClientLogger; import org.apache.rocketmq.client.producer.DefaultMQProducer; -import org.apache.rocketmq.logging.InternalLogger; import org.apache.rocketmq.common.message.Message; +import org.apache.rocketmq.logging.InternalLogger; import org.apache.rocketmq.remoting.RPCHook; import org.apache.rocketmq.remoting.common.RemotingHelper; import org.apache.rocketmq.remoting.exception.RemotingException; import org.apache.rocketmq.srvutil.ServerUtil; +import java.io.UnsupportedEncodingException; +import java.util.Arrays; +import java.util.LinkedList; +import java.util.Random; +import java.util.TimerTask; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.ScheduledThreadPoolExecutor; +import java.util.concurrent.atomic.AtomicLong; + public class Producer { public static void main(String[] args) throws MQClientException, UnsupportedEncodingException { @@ -73,7 +75,8 @@ public static void main(String[] args) throws MQClientException, UnsupportedEnco final StatsBenchmarkProducer statsBenchmark = new StatsBenchmarkProducer(); - final Timer timer = new Timer("BenchmarkTimerThread", true); + ScheduledExecutorService executorService = new ScheduledThreadPoolExecutor(1, + new BasicThreadFactory.Builder().namingPattern("BenchmarkTimerThread-%d").daemon(true).build()); final LinkedList snapshotList = new LinkedList(); @@ -87,7 +90,7 @@ public static void main(String[] args) throws MQClientException, UnsupportedEnco } } - timer.scheduleAtFixedRate(new TimerTask() { + executorService.scheduleAtFixedRate(new TimerTask() { @Override public void run() { snapshotList.addLast(statsBenchmark.createSnapshot()); @@ -95,9 +98,9 @@ public void run() { snapshotList.removeFirst(); } } - }, 1000, 1000); + }, 1000, 1000, TimeUnit.MILLISECONDS); - timer.scheduleAtFixedRate(new TimerTask() { + executorService.scheduleAtFixedRate(new TimerTask() { private void printStats() { if (snapshotList.size() >= 10) { doPrintStats(snapshotList, statsBenchmark, false); @@ -112,7 +115,7 @@ public void run() { e.printStackTrace(); } } - }, 10000, 10000); + }, 10000, 10000, TimeUnit.MILLISECONDS); RPCHook rpcHook = aclEnable ? AclClient.getAclRPCHook() : null; final DefaultMQProducer producer = new DefaultMQProducer("benchmark_producer", rpcHook, msgTraceEnable, null); @@ -224,7 +227,12 @@ public void run() { try { sendThreadPool.shutdown(); sendThreadPool.awaitTermination(Long.MAX_VALUE, TimeUnit.DAYS); - timer.cancel(); + executorService.shutdown(); + try { + executorService.awaitTermination(5000, TimeUnit.MILLISECONDS); + } catch (InterruptedException e) { + } + if (snapshotList.size() > 1) { doPrintStats(snapshotList, statsBenchmark, true); } else { diff --git a/example/src/main/java/org/apache/rocketmq/example/benchmark/TransactionProducer.java b/example/src/main/java/org/apache/rocketmq/example/benchmark/TransactionProducer.java index 1b511d8a9e5..c4f14a48b9b 100644 --- a/example/src/main/java/org/apache/rocketmq/example/benchmark/TransactionProducer.java +++ b/example/src/main/java/org/apache/rocketmq/example/benchmark/TransactionProducer.java @@ -17,26 +17,11 @@ package org.apache.rocketmq.example.benchmark; -import java.io.UnsupportedEncodingException; -import java.nio.ByteBuffer; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Date; -import java.util.LinkedHashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Timer; -import java.util.TimerTask; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.ThreadLocalRandom; -import java.util.concurrent.atomic.AtomicLong; - import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.Option; import org.apache.commons.cli.Options; import org.apache.commons.cli.PosixParser; +import org.apache.commons.lang3.concurrent.BasicThreadFactory; import org.apache.rocketmq.client.exception.MQClientException; import org.apache.rocketmq.client.producer.LocalTransactionState; import org.apache.rocketmq.client.producer.SendResult; @@ -48,6 +33,24 @@ import org.apache.rocketmq.common.message.MessageExt; import org.apache.rocketmq.srvutil.ServerUtil; +import java.io.UnsupportedEncodingException; +import java.nio.ByteBuffer; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.LinkedHashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.TimerTask; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.ThreadLocalRandom; +import java.util.concurrent.atomic.AtomicLong; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.ScheduledThreadPoolExecutor; +import java.util.concurrent.TimeUnit; + public class TransactionProducer { private static final long START_TIME = System.currentTimeMillis(); private static final AtomicLong MSG_COUNT = new AtomicLong(0); @@ -75,11 +78,12 @@ public static void main(String[] args) throws MQClientException, UnsupportedEnco final StatsBenchmarkTProducer statsBenchmark = new StatsBenchmarkTProducer(); - final Timer timer = new Timer("BenchmarkTimerThread", true); + ScheduledExecutorService executorService = new ScheduledThreadPoolExecutor(1, + new BasicThreadFactory.Builder().namingPattern("BenchmarkTimerThread-%d").daemon(true).build()); final LinkedList snapshotList = new LinkedList<>(); - timer.scheduleAtFixedRate(new TimerTask() { + executorService.scheduleAtFixedRate(new TimerTask() { @Override public void run() { snapshotList.addLast(statsBenchmark.createSnapshot()); @@ -87,9 +91,9 @@ public void run() { snapshotList.removeFirst(); } } - }, 1000, 1000); + }, 1000, 1000, TimeUnit.MILLISECONDS); - timer.scheduleAtFixedRate(new TimerTask() { + executorService.scheduleAtFixedRate(new TimerTask() { private void printStats() { if (snapshotList.size() >= 10) { Snapshot begin = snapshotList.getFirst(); @@ -121,7 +125,7 @@ public void run() { e.printStackTrace(); } } - }, 10000, 10000); + }, 10000, 10000, TimeUnit.MILLISECONDS); final TransactionListener transactionCheckListener = new TransactionListenerImpl(statsBenchmark, config); final TransactionMQProducer producer = new TransactionMQProducer( From 44bdeedad2d0e28717f5012d375d12af76305bb5 Mon Sep 17 00:00:00 2001 From: gorden5566 Date: Wed, 4 Aug 2021 14:02:47 +0800 Subject: [PATCH 13/14] [ISSUE 3203] Replace the class 'StringBuffer' by 'StringBuilder' (#3204) --- .../acl/plain/RemoteAddressStrategyFactory.java | 2 +- .../java/org/apache/rocketmq/common/UtilAll.java | 4 ++-- .../apache/rocketmq/common/message/Message.java | 11 +++++++---- .../rocketmq/common/protocol/NamespaceUtil.java | 2 +- .../org/apache/rocketmq/common/UtilAllTest.java | 13 +++++++++++++ .../rocketmq/common/utils/IOTinyUtilsTest.java | 4 ++-- .../filter/expression/UnaryExpression.java | 16 +++++++++++++++- .../rocketmq/filter/parser/ParseException.java | 7 ++++--- .../rocketmq/filter/parser/TokenMgrError.java | 3 ++- .../org/apache/rocketmq/filter/ParserTest.java | 2 +- .../rocketmq/remoting/common/RemotingHelper.java | 2 +- .../rocketmq/store/stats/BrokerStatsManager.java | 4 ++-- .../message/QueryMsgByUniqueKeySubCommand.java | 5 +++-- 13 files changed, 54 insertions(+), 21 deletions(-) diff --git a/acl/src/main/java/org/apache/rocketmq/acl/plain/RemoteAddressStrategyFactory.java b/acl/src/main/java/org/apache/rocketmq/acl/plain/RemoteAddressStrategyFactory.java index 6ec90ee3fad..1c10fae4b94 100644 --- a/acl/src/main/java/org/apache/rocketmq/acl/plain/RemoteAddressStrategyFactory.java +++ b/acl/src/main/java/org/apache/rocketmq/acl/plain/RemoteAddressStrategyFactory.java @@ -167,7 +167,7 @@ public RangeRemoteAddressStrategy(String remoteAddr) { String[] strArray = StringUtils.split(remoteAddr, "."); if (analysis(strArray, 1) || analysis(strArray, 2) || analysis(strArray, 3)) { AclUtils.verify(remoteAddr, index - 1); - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); for (int j = 0; j < index; j++) { sb.append(strArray[j].trim()).append("."); } diff --git a/common/src/main/java/org/apache/rocketmq/common/UtilAll.java b/common/src/main/java/org/apache/rocketmq/common/UtilAll.java index aa6920817f1..776c991c27e 100644 --- a/common/src/main/java/org/apache/rocketmq/common/UtilAll.java +++ b/common/src/main/java/org/apache/rocketmq/common/UtilAll.java @@ -565,11 +565,11 @@ public static String list2String(List list, String splitor) { if (list == null || list.size() == 0) { return null; } - StringBuffer str = new StringBuffer(); + StringBuilder str = new StringBuilder(); for (int i = 0; i < list.size(); i++) { str.append(list.get(i)); if (i == list.size() - 1) { - continue; + break; } str.append(splitor); } diff --git a/common/src/main/java/org/apache/rocketmq/common/message/Message.java b/common/src/main/java/org/apache/rocketmq/common/message/Message.java index c9a133b4d0c..48e1f45a7f0 100644 --- a/common/src/main/java/org/apache/rocketmq/common/message/Message.java +++ b/common/src/main/java/org/apache/rocketmq/common/message/Message.java @@ -43,11 +43,13 @@ public Message(String topic, String tags, String keys, int flag, byte[] body, bo this.flag = flag; this.body = body; - if (tags != null && tags.length() > 0) + if (tags != null && tags.length() > 0) { this.setTags(tags); + } - if (keys != null && keys.length() > 0) + if (keys != null && keys.length() > 0) { this.setKeys(keys); + } this.setWaitStoreMsgOK(waitStoreMsgOK); } @@ -127,7 +129,7 @@ public String getKeys() { } public void setKeys(Collection keys) { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); for (String k : keys) { sb.append(k); sb.append(MessageConst.KEY_SEPARATOR); @@ -151,8 +153,9 @@ public void setDelayTimeLevel(int level) { public boolean isWaitStoreMsgOK() { String result = this.getProperty(MessageConst.PROPERTY_WAIT_STORE_MSG_OK); - if (null == result) + if (null == result) { return true; + } return Boolean.parseBoolean(result); } diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/NamespaceUtil.java b/common/src/main/java/org/apache/rocketmq/common/protocol/NamespaceUtil.java index 704eb90bd7a..60fadaab181 100644 --- a/common/src/main/java/org/apache/rocketmq/common/protocol/NamespaceUtil.java +++ b/common/src/main/java/org/apache/rocketmq/common/protocol/NamespaceUtil.java @@ -120,7 +120,7 @@ public static String wrapNamespaceAndRetry(String namespace, String consumerGrou return null; } - return new StringBuffer() + return new StringBuilder() .append(MixAll.RETRY_GROUP_TOPIC_PREFIX) .append(wrapNamespace(namespace, consumerGroup)) .toString(); diff --git a/common/src/test/java/org/apache/rocketmq/common/UtilAllTest.java b/common/src/test/java/org/apache/rocketmq/common/UtilAllTest.java index b854099a5bd..e1942b40837 100644 --- a/common/src/test/java/org/apache/rocketmq/common/UtilAllTest.java +++ b/common/src/test/java/org/apache/rocketmq/common/UtilAllTest.java @@ -19,11 +19,15 @@ import java.net.InetAddress; import java.net.UnknownHostException; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; import java.util.Properties; import org.junit.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.within; +import static org.junit.Assert.assertEquals; public class UtilAllTest { @@ -109,6 +113,15 @@ public void testIPv6Check() throws UnknownHostException { assertThat(UtilAll.ipToIPv6Str(nonInternal.getAddress()).toUpperCase()).isEqualTo("2408:4004:0180:8100:3FAA:1DDE:2B3F:898A"); } + @Test + public void testList2String() { + List list = Arrays.asList("groupA=DENY", "groupB=PUB|SUB", "groupC=SUB"); + String comma = ","; + assertEquals("groupA=DENY,groupB=PUB|SUB,groupC=SUB", UtilAll.list2String(list, comma)); + assertEquals(null, UtilAll.list2String(null, comma)); + assertEquals(null, UtilAll.list2String(Collections.emptyList(), comma)); + } + static class DemoConfig { private int demoWidth = 0; private int demoLength = 0; diff --git a/common/src/test/java/org/apache/rocketmq/common/utils/IOTinyUtilsTest.java b/common/src/test/java/org/apache/rocketmq/common/utils/IOTinyUtilsTest.java index e03e0b9648e..6a63eecc223 100644 --- a/common/src/test/java/org/apache/rocketmq/common/utils/IOTinyUtilsTest.java +++ b/common/src/test/java/org/apache/rocketmq/common/utils/IOTinyUtilsTest.java @@ -82,7 +82,7 @@ public void testCopy() throws Exception { @Test public void testReadLines() throws Exception { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); for (int i = 0; i < 10; i++) { sb.append("testReadLines").append("\n"); } @@ -95,7 +95,7 @@ public void testReadLines() throws Exception { @Test public void testToBufferedReader() throws Exception { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); for (int i = 0; i < 10; i++) { sb.append("testToBufferedReader").append("\n"); } diff --git a/filter/src/main/java/org/apache/rocketmq/filter/expression/UnaryExpression.java b/filter/src/main/java/org/apache/rocketmq/filter/expression/UnaryExpression.java index 24845fc0589..7f18ddd5413 100644 --- a/filter/src/main/java/org/apache/rocketmq/filter/expression/UnaryExpression.java +++ b/filter/src/main/java/org/apache/rocketmq/filter/expression/UnaryExpression.java @@ -53,6 +53,7 @@ public UnaryExpression(Expression left, UnaryType unaryType) { public static Expression createNegate(Expression left) { return new UnaryExpression(left, UnaryType.NEGATE) { + @Override public Object evaluate(EvaluationContext context) throws Exception { Object rvalue = right.evaluate(context); if (rvalue == null) { @@ -64,6 +65,7 @@ public Object evaluate(EvaluationContext context) throws Exception { return null; } + @Override public String getExpressionSymbol() { return "-"; } @@ -85,6 +87,7 @@ public static BooleanExpression createInExpression(PropertyExpression right, Lis final Collection inList = t; return new UnaryInExpression(right, UnaryType.IN, inList, not) { + @Override public Object evaluate(EvaluationContext context) throws Exception { Object rvalue = right.evaluate(context); @@ -103,8 +106,9 @@ public Object evaluate(EvaluationContext context) throws Exception { } + @Override public String toString() { - StringBuffer answer = new StringBuffer(); + StringBuilder answer = new StringBuilder(); answer.append(right); answer.append(" "); answer.append(getExpressionSymbol()); @@ -124,6 +128,7 @@ public String toString() { return answer.toString(); } + @Override public String getExpressionSymbol() { if (not) { return "NOT IN"; @@ -139,6 +144,7 @@ public BooleanUnaryExpression(Expression left, UnaryType unaryType) { super(left, unaryType); } + @Override public boolean matches(EvaluationContext context) throws Exception { Object object = evaluate(context); return object != null && object == Boolean.TRUE; @@ -147,6 +153,7 @@ public boolean matches(EvaluationContext context) throws Exception { public static BooleanExpression createNOT(BooleanExpression left) { return new BooleanUnaryExpression(left, UnaryType.NOT) { + @Override public Object evaluate(EvaluationContext context) throws Exception { Boolean lvalue = (Boolean) right.evaluate(context); if (lvalue == null) { @@ -155,6 +162,7 @@ public Object evaluate(EvaluationContext context) throws Exception { return lvalue.booleanValue() ? Boolean.FALSE : Boolean.TRUE; } + @Override public String getExpressionSymbol() { return "NOT"; } @@ -163,6 +171,7 @@ public String getExpressionSymbol() { public static BooleanExpression createBooleanCast(Expression left) { return new BooleanUnaryExpression(left, UnaryType.BOOLEANCAST) { + @Override public Object evaluate(EvaluationContext context) throws Exception { Object rvalue = right.evaluate(context); if (rvalue == null) { @@ -174,10 +183,12 @@ public Object evaluate(EvaluationContext context) throws Exception { return ((Boolean) rvalue).booleanValue() ? Boolean.TRUE : Boolean.FALSE; } + @Override public String toString() { return right.toString(); } + @Override public String getExpressionSymbol() { return ""; } @@ -233,6 +244,7 @@ public void setUnaryType(UnaryType unaryType) { /** * @see Object#toString() */ + @Override public String toString() { return "(" + getExpressionSymbol() + " " + right.toString() + ")"; } @@ -240,6 +252,7 @@ public String toString() { /** * @see Object#hashCode() */ + @Override public int hashCode() { return toString().hashCode(); } @@ -247,6 +260,7 @@ public int hashCode() { /** * @see Object#equals(Object) */ + @Override public boolean equals(Object o) { if (o == null || !this.getClass().equals(o.getClass())) { diff --git a/filter/src/main/java/org/apache/rocketmq/filter/parser/ParseException.java b/filter/src/main/java/org/apache/rocketmq/filter/parser/ParseException.java index 06014cbcbed..0a327bea1c0 100644 --- a/filter/src/main/java/org/apache/rocketmq/filter/parser/ParseException.java +++ b/filter/src/main/java/org/apache/rocketmq/filter/parser/ParseException.java @@ -106,7 +106,7 @@ private static String initialise(Token currentToken, int[][] expectedTokenSequences, String[] tokenImage) { String eol = System.getProperty("line.separator", "\n"); - StringBuffer expected = new StringBuffer(); + StringBuilder expected = new StringBuilder(); int maxSize = 0; for (int i = 0; i < expectedTokenSequences.length; i++) { if (maxSize < expectedTokenSequences[i].length) { @@ -123,8 +123,9 @@ private static String initialise(Token currentToken, String retval = "Encountered \""; Token tok = currentToken.next; for (int i = 0; i < maxSize; i++) { - if (i != 0) + if (i != 0) { retval += " "; + } if (tok.kind == 0) { retval += tokenImage[0]; break; @@ -157,7 +158,7 @@ private static String initialise(Token currentToken, * string literal. */ static String add_escapes(String str) { - StringBuffer retval = new StringBuffer(); + StringBuilder retval = new StringBuilder(); char ch; for (int i = 0; i < str.length(); i++) { switch (str.charAt(i)) { diff --git a/filter/src/main/java/org/apache/rocketmq/filter/parser/TokenMgrError.java b/filter/src/main/java/org/apache/rocketmq/filter/parser/TokenMgrError.java index e8132df5aac..0aeb27cf4ca 100644 --- a/filter/src/main/java/org/apache/rocketmq/filter/parser/TokenMgrError.java +++ b/filter/src/main/java/org/apache/rocketmq/filter/parser/TokenMgrError.java @@ -66,7 +66,7 @@ public class TokenMgrError extends Error { * equivalents in the given string */ protected static final String addEscapes(String str) { - StringBuffer retval = new StringBuffer(); + StringBuilder retval = new StringBuilder(); char ch; for (int i = 0; i < str.length(); i++) { switch (str.charAt(i)) { @@ -141,6 +141,7 @@ protected static String LexicalError(boolean eofSeen, int lexState, int errorLin *

* from this method for such cases in the release version of your parser. */ + @Override public String getMessage() { return super.getMessage(); } diff --git a/filter/src/test/java/org/apache/rocketmq/filter/ParserTest.java b/filter/src/test/java/org/apache/rocketmq/filter/ParserTest.java index 115632faa0a..7dc2ab25468 100644 --- a/filter/src/test/java/org/apache/rocketmq/filter/ParserTest.java +++ b/filter/src/test/java/org/apache/rocketmq/filter/ParserTest.java @@ -84,7 +84,7 @@ public void testParse_decimalOverFlow() { @Test public void testParse_floatOverFlow() { try { - StringBuffer sb = new StringBuffer(210000); + StringBuilder sb = new StringBuilder(210000); sb.append("1"); for (int i = 0; i < 2048; i ++) { sb.append("111111111111111111111111111111111111111111111111111"); diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/common/RemotingHelper.java b/remoting/src/main/java/org/apache/rocketmq/remoting/common/RemotingHelper.java index f244bf4c853..7dacea9c132 100644 --- a/remoting/src/main/java/org/apache/rocketmq/remoting/common/RemotingHelper.java +++ b/remoting/src/main/java/org/apache/rocketmq/remoting/common/RemotingHelper.java @@ -36,7 +36,7 @@ public class RemotingHelper { private static final InternalLogger log = InternalLoggerFactory.getLogger(ROCKETMQ_REMOTING); public static String exceptionSimpleDesc(final Throwable e) { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); if (e != null) { sb.append(e.toString()); diff --git a/store/src/main/java/org/apache/rocketmq/store/stats/BrokerStatsManager.java b/store/src/main/java/org/apache/rocketmq/store/stats/BrokerStatsManager.java index e1518447066..7bb6a8b4f5a 100644 --- a/store/src/main/java/org/apache/rocketmq/store/stats/BrokerStatsManager.java +++ b/store/src/main/java/org/apache/rocketmq/store/stats/BrokerStatsManager.java @@ -159,7 +159,7 @@ public void incGroupGetNums(final String group, final String topic, final int in } public String buildStatsKey(String topic, String group) { - StringBuffer strBuilder = new StringBuffer(); + StringBuilder strBuilder = new StringBuilder(); strBuilder.append(topic); strBuilder.append("@"); strBuilder.append(group); @@ -217,7 +217,7 @@ public void incCommercialValue(final String key, final String owner, final Strin } public String buildCommercialStatsKey(String owner, String topic, String group, String type) { - StringBuffer strBuilder = new StringBuffer(); + StringBuilder strBuilder = new StringBuilder(); strBuilder.append(owner); strBuilder.append("@"); strBuilder.append(topic); diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/message/QueryMsgByUniqueKeySubCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/message/QueryMsgByUniqueKeySubCommand.java index 8c7bec616d7..17abdf218cb 100644 --- a/tools/src/main/java/org/apache/rocketmq/tools/command/message/QueryMsgByUniqueKeySubCommand.java +++ b/tools/src/main/java/org/apache/rocketmq/tools/command/message/QueryMsgByUniqueKeySubCommand.java @@ -114,7 +114,7 @@ private static void showMessage(final DefaultMQAdminExt admin, MessageExt msg, i private static String createBodyFile(MessageExt msg, int index) throws IOException { DataOutputStream dos = null; try { - StringBuffer bodyTmpFilePath = new StringBuffer("/tmp/rocketmq/msgbodys"); + StringBuilder bodyTmpFilePath = new StringBuilder("/tmp/rocketmq/msgbodys"); File file = new File(bodyTmpFilePath.toString()); if (!file.exists()) { file.mkdirs(); @@ -127,8 +127,9 @@ private static String createBodyFile(MessageExt msg, int index) throws IOExcepti dos.write(msg.getBody()); return bodyTmpFilePath.toString(); } finally { - if (dos != null) + if (dos != null) { dos.close(); + } } } From e4d40b927e5994eeb79d0698e7c76315e990aecf Mon Sep 17 00:00:00 2001 From: guyinyou <1094592600@qq.com> Date: Wed, 4 Aug 2021 17:21:05 +0800 Subject: [PATCH 14/14] polish litePullConsumer seek logic --- .../consumer/DefaultLitePullConsumerImpl.java | 28 +++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultLitePullConsumerImpl.java b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultLitePullConsumerImpl.java index d28d23ad6bb..46a72fb5e84 100644 --- a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultLitePullConsumerImpl.java +++ b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultLitePullConsumerImpl.java @@ -593,8 +593,19 @@ public synchronized void seek(MessageQueue messageQueue, long offset) throws MQC } final Object objLock = messageQueueLock.fetchLockObject(messageQueue); synchronized (objLock) { - assignedMessageQueue.setSeekOffset(messageQueue, offset); clearMessageQueueInCache(messageQueue); + + PullTaskImpl oldPullTaskImpl = this.taskTable.get(messageQueue); + if (oldPullTaskImpl != null) { + oldPullTaskImpl.tryInterrupt(); + this.taskTable.remove(messageQueue); + } + assignedMessageQueue.setSeekOffset(messageQueue, offset); + if (!this.taskTable.containsKey(messageQueue)) { + PullTaskImpl pullTask = new PullTaskImpl(messageQueue); + this.taskTable.put(messageQueue, pullTask); + this.scheduledThreadPoolExecutor.schedule(pullTask, 0, TimeUnit.MILLISECONDS); + } } } @@ -718,16 +729,29 @@ public long searchOffset(MessageQueue mq, long timestamp) throws MQClientExcepti public class PullTaskImpl implements Runnable { private final MessageQueue messageQueue; private volatile boolean cancelled = false; + private Thread currentThread; public PullTaskImpl(final MessageQueue messageQueue) { this.messageQueue = messageQueue; } + public void tryInterrupt() { + setCancelled(true); + if (currentThread == null) { + return; + } + if (!currentThread.isInterrupted()) { + currentThread.interrupt(); + } + } + @Override public void run() { if (!this.isCancelled()) { + this.currentThread = Thread.currentThread(); + if (assignedMessageQueue.isPaused(messageQueue)) { scheduledThreadPoolExecutor.schedule(this, PULL_TIME_DELAY_MILLS_WHEN_PAUSE, TimeUnit.MILLISECONDS); log.debug("Message Queue: {} has been paused!", messageQueue); @@ -803,7 +827,7 @@ public void run() { } else { subscriptionData = FilterAPI.buildSubscriptionData(topic, SubscriptionData.SUB_ALL); } - + PullResult pullResult = pull(messageQueue, subscriptionData, offset, defaultLitePullConsumer.getPullBatchSize()); if (this.isCancelled() || processQueue.isDropped()) { return;