7 Star 3 Fork 3

src-openEuler/rocketmq

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
patch027-backport-Utilizing-cache-to-avoid-duplicate-parsing.patch 5.79 KB
一键复制 编辑 原始数据 按行查看 历史
From f0f15b5e21acd3caf9141375be5db3ef726a2173 Mon Sep 17 00:00:00 2001
From: guyinyou <36399867+guyinyou@users.noreply.github.com>
Date: Thu, 19 Oct 2023 10:14:29 +0800
Subject: [PATCH 1/2] [ISSUE #7454] Utilizing cache to avoid duplicate parsing
(#7455)
* Utilizing cache to avoid duplicate parsing
* add a method argument to decide cacheable
* Renaming variable names from cacheAble to isCached
---------
Co-authored-by: guyinyou <guyinyou.gyy@alibaba-inc.com>
Co-authored-by: RongtongJin <jinrongtong16@mails.ucas.ac.cn>
---
.../broker/processor/PopMessageProcessor.java | 2 +-
.../remoting/protocol/RemotingCommand.java | 14 ++++++++++++--
.../protocol/header/FastCodesHeaderTest.java | 2 +-
3 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/processor/PopMessageProcessor.java b/broker/src/main/java/org/apache/rocketmq/broker/processor/PopMessageProcessor.java
index f5d07c5aa..7ed4d53ab 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/processor/PopMessageProcessor.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/processor/PopMessageProcessor.java
@@ -204,7 +204,7 @@ public class PopMessageProcessor implements NettyRequestProcessor {
RemotingCommand response = RemotingCommand.createResponseCommand(PopMessageResponseHeader.class);
final PopMessageResponseHeader responseHeader = (PopMessageResponseHeader) response.readCustomHeader();
final PopMessageRequestHeader requestHeader =
- (PopMessageRequestHeader) request.decodeCommandCustomHeader(PopMessageRequestHeader.class);
+ (PopMessageRequestHeader) request.decodeCommandCustomHeader(PopMessageRequestHeader.class, true);
StringBuilder startOffsetInfo = new StringBuilder(64);
StringBuilder msgOffsetInfo = new StringBuilder(64);
StringBuilder orderCountInfo = null;
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RemotingCommand.java b/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RemotingCommand.java
index d27135132..e93072adf 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RemotingCommand.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RemotingCommand.java
@@ -89,6 +89,7 @@ public class RemotingCommand {
private String remark;
private HashMap<String, String> extFields;
private transient CommandCustomHeader customHeader;
+ private transient CommandCustomHeader cachedHeader;
private SerializeType serializeTypeCurrentRPC = serializeTypeConfigInThisServer;
@@ -260,10 +261,19 @@ public class RemotingCommand {
public CommandCustomHeader decodeCommandCustomHeader(
Class<? extends CommandCustomHeader> classHeader) throws RemotingCommandException {
- return decodeCommandCustomHeader(classHeader, true);
+ return decodeCommandCustomHeader(classHeader, false);
}
- public CommandCustomHeader decodeCommandCustomHeader(Class<? extends CommandCustomHeader> classHeader,
+ public CommandCustomHeader decodeCommandCustomHeader(
+ Class<? extends CommandCustomHeader> classHeader, boolean isCached) throws RemotingCommandException {
+ if (isCached && cachedHeader != null) {
+ return cachedHeader;
+ }
+ cachedHeader = decodeCommandCustomHeaderDirectly(classHeader, true);
+ return cachedHeader;
+ }
+
+ public CommandCustomHeader decodeCommandCustomHeaderDirectly(Class<? extends CommandCustomHeader> classHeader,
boolean useFastEncode) throws RemotingCommandException {
CommandCustomHeader objectHeader;
try {
diff --git a/remoting/src/test/java/org/apache/rocketmq/remoting/protocol/header/FastCodesHeaderTest.java b/remoting/src/test/java/org/apache/rocketmq/remoting/protocol/header/FastCodesHeaderTest.java
index 6bb100f57..b6a0d6311 100644
--- a/remoting/src/test/java/org/apache/rocketmq/remoting/protocol/header/FastCodesHeaderTest.java
+++ b/remoting/src/test/java/org/apache/rocketmq/remoting/protocol/header/FastCodesHeaderTest.java
@@ -73,7 +73,7 @@ public class FastCodesHeaderTest {
private void check(RemotingCommand command, List<Field> fields,
Class<? extends CommandCustomHeader> classHeader) throws Exception {
- CommandCustomHeader o1 = command.decodeCommandCustomHeader(classHeader, false);
+ CommandCustomHeader o1 = command.decodeCommandCustomHeaderDirectly(classHeader, false);
CommandCustomHeader o2 = classHeader.getDeclaredConstructor().newInstance();
((FastCodesHeader)o2).decode(command.getExtFields());
for (Field f : fields) {
--
2.32.0.windows.2
From dbc633d92b6c8c35922234611d698d3cb0a1a234 Mon Sep 17 00:00:00 2001
From: Ji Juntao <juntao.jjt@alibaba-inc.com>
Date: Thu, 19 Oct 2023 14:12:33 +0800
Subject: [PATCH 2/2] Check the input yaml and the path in ACL (#7475)
* check the input yaml and the path.
* only modify the path, no yaml.
* remove useless import
---
.../org/apache/rocketmq/acl/plain/PlainPermissionManager.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/acl/src/main/java/org/apache/rocketmq/acl/plain/PlainPermissionManager.java b/acl/src/main/java/org/apache/rocketmq/acl/plain/PlainPermissionManager.java
index f6699fa13..345aed06c 100644
--- a/acl/src/main/java/org/apache/rocketmq/acl/plain/PlainPermissionManager.java
+++ b/acl/src/main/java/org/apache/rocketmq/acl/plain/PlainPermissionManager.java
@@ -484,7 +484,7 @@ public class PlainPermissionManager {
return false;
}
- if (!fileName.startsWith(fileHome)) {
+ if (!file.getAbsolutePath().startsWith(fileHome)) {
log.error("Parameter value " + fileName + " is not in the directory rocketmq.home.dir " + fileHome);
return false;
}
--
2.32.0.windows.2
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/src-openeuler/rocketmq.git
git@gitee.com:src-openeuler/rocketmq.git
src-openeuler
rocketmq
rocketmq
master

搜索帮助