This is an automated email from the ASF dual-hosted git repository.
chenwenkang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shenyu.git
The following commit(s) were added to refs/heads/master by this push:
new 3e7df1cea3 [feat] motan plugin config based on selector (#6058)
3e7df1cea3 is described below
commit 3e7df1cea3cff5a3e9e4f9e3262e82449e4eaf8e
Author: Yu Siheng <[email protected]>
AuthorDate: Sun Sep 21 20:02:04 2025 +0800
[feat] motan plugin config based on selector (#6058)
* [feat] motan plugin config based on selector
* add test file
---------
Co-authored-by: aias00 <[email protected]>
Co-authored-by: Misaya295 <[email protected]>
---
db/init/mysql/schema.sql | 5 +-
db/init/ob/schema.sql | 2 +
db/init/og/create-table.sql | 2 +
db/init/oracle/schema.sql | 6 +
db/init/pg/create-table.sql | 2 +
db/upgrade/2.7.0-upgrade-2.7.1-mysql.sql | 7 +
db/upgrade/2.7.0-upgrade-2.7.1-ob.sql | 11 +-
db/upgrade/2.7.0-upgrade-2.7.1-og.sql | 12 +-
db/upgrade/2.7.0-upgrade-2.7.1-oracle.sql | 8 +
db/upgrade/2.7.0-upgrade-2.7.1-pg.sql | 8 +
.../src/main/resources/sql-script/h2/schema.sql | 5 +-
.../common/dto/convert/selector/MotanUpstream.java | 274 +++++++++++++++++++++
.../apache/shenyu/plugin/motan/MotanPlugin.java | 2 +-
.../plugin/motan/cache/ApplicationConfigCache.java | 162 +++++++++++-
.../plugin/motan/handler/MotanMetaDataHandler.java | 3 +-
.../motan/handler/MotanPluginDataHandler.java | 23 ++
.../plugin/motan/proxy/MotanProxyService.java | 36 ++-
.../shenyu/plugin/motan/MotanPluginTest.java | 2 +-
.../plugin/motan/proxy/MotanProxyServiceTest.java | 99 ++++++++
19 files changed, 656 insertions(+), 13 deletions(-)
diff --git a/db/init/mysql/schema.sql b/db/init/mysql/schema.sql
index b9e215ab35..0a5fe4cbd1 100644
--- a/db/init/mysql/schema.sql
+++ b/db/init/mysql/schema.sql
@@ -1144,6 +1144,9 @@ INSERT INTO `plugin_handle` VALUES
('1529402613204172835', '17', 'corethreads',
INSERT INTO `plugin_handle` VALUES ('1529402613204172836', '17', 'threads',
'threads', 1, 3, 3,
'{\"required\":\"0\",\"defaultValue\":\"2147483647\",\"placeholder\":\"threads\",\"rule\":\"\"}',
'2022-05-25 18:02:53', '2022-05-25 18:02:53');
INSERT INTO `plugin_handle` VALUES ('1529402613204172837', '17', 'queues',
'queues', 1, 3, 4,
'{\"required\":\"0\",\"defaultValue\":\"0\",\"placeholder\":\"queues\",\"rule\":\"\"}',
'2022-05-25 18:02:53', '2022-05-25 18:02:53');
INSERT INTO `plugin_handle` VALUES ('1529402613204172838', '17', 'threadpool',
'threadpool', 3, 3, 5,
'{\"required\":\"0\",\"defaultValue\":\"cached\",\"placeholder\":\"threadpool\",\"rule\":\"\"}',
'2022-05-25 18:02:53', '2022-05-25 18:02:53');
+INSERT INTO `plugin_handle` VALUES ('1678997557628272641', '17',
'registerAddress', 'registerAddress', 2, 3, 1,
'{\"required\":\"0\",\"defaultValue\":\"127.0.0.1:2181\",\"placeholder\":\"registerAddress\",\"rule\":\"\"}',
'2023-01-10 10:08:01.158', '2023-01-10 10:08:01.158');
+INSERT INTO `plugin_handle` VALUES ('1829402613204172834', '17',
'registerProtocol', 'registerProtocol', 2, 1, 0,
'{\"required\":\"0\",\"defaultValue\":\"\",\"placeholder\":\"registerProtocol\",\"rule\":\"\"}',
'2022-05-25 18:02:53', '2022-05-25 18:02:53');
+INSERT INTO `plugin_handle` VALUES ('1878997557628272641', '17',
'registerAddress', 'registerAddress', 2, 1, 1,
'{\"required\":\"0\",\"defaultValue\":\"\",\"placeholder\":\"registerAddress\",\"rule\":\"\"}',
'2023-01-10 10:08:01.158', '2023-01-10 10:08:01.158');
INSERT INTO `plugin_handle` VALUES ('1529402613204172839', '28', 'port',
'port', 1, 3, 1, NULL, '2022-05-25 18:02:53', '2022-05-25 18:02:53');
INSERT INTO `plugin_handle` VALUES ('1529402613204172840', '28',
'bossGroupThreadCount', 'bossGroupThreadCount', 1, 3, 1, NULL, '2022-05-25
18:02:53', '2022-05-25 18:02:53');
INSERT INTO `plugin_handle` VALUES ('1529402613204172841', '28',
'maxPayloadSize', 'maxPayloadSize', 1, 3, 1, NULL, '2022-05-25 18:02:53',
'2022-05-25 18:02:53');
@@ -1316,8 +1319,6 @@ INSERT INTO `plugin_handle` VALUES
('1678997769998467072', '42', 'clientMaxLifeT
INSERT INTO `plugin_handle` VALUES ('1678997277012557824', '42',
'clientMaxConnections', 'clientMaxConnections', 2, 1, 6,
'{\"required\":\"0\",\"defaultValue\":\"20\",\"rule\":\"\"}', '2023-01-10
10:08:01.158', '2023-01-10 10:08:01.158');
INSERT INTO `plugin_handle` VALUES ('1678997557628272640', '42',
'clientPendingAcquireTimeout', 'clientPendingAcquireTimeout', 2, 1, 5,
'{\"required\":\"0\",\"defaultValue\":\"5\",\"rule\":\"\"}', '2023-01-10
10:08:01.158', '2023-01-10 10:08:01.158');
-INSERT INTO `plugin_handle` VALUES ('1678997557628272641', '17',
'registerAddress', 'registerAddress', 2, 3, 1,
'{\"required\":\"0\",\"defaultValue\":\"127.0.0.1:2181\",\"placeholder\":\"registerAddress\",\"rule\":\"\"}',
'2023-01-10 10:08:01.158', '2023-01-10 10:08:01.158');
-
INSERT INTO `plugin_handle` VALUES ('1678997557628272642', '15',
'loadBalance', 'loadBalance', 3, 2, 3,
'{\"required\":\"0\",\"defaultValue\":\"random\",\"rule\":\"\"}', '2023-09-05
18:02:53', '2023-09-05 18:02:53');
INSERT INTO `plugin_handle` VALUES ('1678997557628272643', '44',
'defaultHandleJson', 'defaultHandleJson', 2, 3, 2,
'{\"required\":\"0\",\"defaultValue\":\"{\\\"authorization\\\":\\\"test:test123\\\"}\",\"placeholder\":\"\"}',
'2022-05-25 18:02:53', '2022-05-25 18:02:53');
diff --git a/db/init/ob/schema.sql b/db/init/ob/schema.sql
index 65b03ac012..6a98e306e7 100644
--- a/db/init/ob/schema.sql
+++ b/db/init/ob/schema.sql
@@ -1111,6 +1111,8 @@ INSERT INTO `plugin_handle` VALUES
('1529402613204172835', '17', 'corethreads',
INSERT INTO `plugin_handle` VALUES ('1529402613204172836', '17', 'threads',
'threads', 1, 3, 3,
'{\"required\":\"0\",\"defaultValue\":\"2147483647\",\"placeholder\":\"threads\",\"rule\":\"\"}',
'2022-05-25 18:02:53', '2022-05-25 18:02:53');
INSERT INTO `plugin_handle` VALUES ('1529402613204172837', '17', 'queues',
'queues', 1, 3, 4,
'{\"required\":\"0\",\"defaultValue\":\"0\",\"placeholder\":\"queues\",\"rule\":\"\"}',
'2022-05-25 18:02:53', '2022-05-25 18:02:53');
INSERT INTO `plugin_handle` VALUES ('1529402613204172838', '17', 'threadpool',
'threadpool', 3, 3, 5,
'{\"required\":\"0\",\"defaultValue\":\"cached\",\"placeholder\":\"threadpool\",\"rule\":\"\"}',
'2022-05-25 18:02:53', '2022-05-25 18:02:53');
+INSERT INTO `plugin_handle` VALUES ('1829402613204172834', '17',
'registerProtocol', 'registerProtocol', 2, 1, 0,
'{\"required\":\"0\",\"defaultValue\":\"\",\"placeholder\":\"registerProtocol\",\"rule\":\"\"}',
'2022-05-25 18:02:53', '2022-05-25 18:02:53');
+INSERT INTO `plugin_handle` VALUES ('1878997557628272641', '17',
'registerAddress', 'registerAddress', 2, 1, 1,
'{\"required\":\"0\",\"defaultValue\":\"\",\"placeholder\":\"registerAddress\",\"rule\":\"\"}',
'2023-01-10 10:08:01.158', '2023-01-10 10:08:01.158');
INSERT INTO `plugin_handle` VALUES ('1529402613204172839', '28', 'port',
'port', 1, 3, 1, NULL, '2022-05-25 18:02:53', '2022-05-25 18:02:53');
INSERT INTO `plugin_handle` VALUES ('1529402613204172840', '28',
'bossGroupThreadCount', 'bossGroupThreadCount', 1, 3, 1, NULL, '2022-05-25
18:02:53', '2022-05-25 18:02:53');
INSERT INTO `plugin_handle` VALUES ('1529402613204172841', '28',
'maxPayloadSize', 'maxPayloadSize', 1, 3, 1, NULL, '2022-05-25 18:02:53',
'2022-05-25 18:02:53');
diff --git a/db/init/og/create-table.sql b/db/init/og/create-table.sql
index 6a050ef959..563c4653c0 100644
--- a/db/init/og/create-table.sql
+++ b/db/init/og/create-table.sql
@@ -1150,6 +1150,8 @@ INSERT INTO "public"."plugin_handle" VALUES
('1529403902783524880', '17', 'coret
INSERT INTO "public"."plugin_handle" VALUES ('1529403902783524881', '17',
'threads', 'threads', 1, 3, 3,
'{"required":"0","defaultValue":"2147483647","placeholder":"threads","rule":""}',
'2022-05-25 18:08:01', '2022-05-25 18:08:01');
INSERT INTO "public"."plugin_handle" VALUES ('1529403902783524882', '17',
'queues', 'queues', 1, 3, 4,
'{"required":"0","defaultValue":"0","placeholder":"queues","rule":""}',
'2022-05-25 18:08:01', '2022-05-25 18:08:01');
INSERT INTO "public"."plugin_handle" VALUES ('1529403902783524883', '17',
'threadpool', 'threadpool', 3, 3, 5,
'{"required":"0","defaultValue":"cached","placeholder":"threadpool","rule":""}',
'2022-05-25 18:08:01', '2022-05-25 18:08:01');
+INSERT INTO "public"."plugin_handle" VALUES ('1829402613204172834', '17',
'registerProtocol', 'registerProtocol', 2, 1, 0,
'{"required":"0","defaultValue":"","placeholder":"registerProtocol","rule":""}',
'2022-05-25 18:02:53', '2022-05-25 18:02:53');
+INSERT INTO "public"."plugin_handle" VALUES ('1878997557628272641', '17',
'registerAddress', 'registerAddress', 2, 1, 1,
'{"required":"0","defaultValue":"","placeholder":"registerAddress","rule":""}',
'2023-01-10 10:08:01.158', '2023-01-10 10:08:01.158');
INSERT INTO "public"."plugin_handle" VALUES ('1529403902783524884', '28',
'port', 'port', 1, 3, 1, NULL, '2022-05-25 18:08:01', '2022-05-25 18:08:01');
INSERT INTO "public"."plugin_handle" VALUES ('1529403902783524885', '28',
'bossGroupThreadCount', 'bossGroupThreadCount', 1, 3, 1, NULL, '2022-05-25
18:08:01', '2022-05-25 18:08:01');
INSERT INTO "public"."plugin_handle" VALUES ('1529403902783524886', '28',
'maxPayloadSize', 'maxPayloadSize', 1, 3, 1, NULL, '2022-05-25 18:08:01',
'2022-05-25 18:08:01');
diff --git a/db/init/oracle/schema.sql b/db/init/oracle/schema.sql
index a9fed158bb..92c26372dd 100644
--- a/db/init/oracle/schema.sql
+++ b/db/init/oracle/schema.sql
@@ -1264,6 +1264,12 @@ values ('1518229897214468142', '17', 'registerProtocol',
'registerProtocol', 2,
insert /*+ IGNORE_ROW_ON_DUPKEY_INDEX(plugin_handle(plugin_id, field, type))
*/ into plugin_handle (ID, PLUGIN_ID, FIELD, LABEL, DATA_TYPE, TYPE, SORT,
EXT_OBJ)
values ('1679002911061737473', '17', 'registerAddress', 'registerAddress', 2,
3, 1,
'{"required":"0","defaultValue":"127.0.0.1:2181","placeholder":"registerAddress","rule":""}');
+insert /*+ IGNORE_ROW_ON_DUPKEY_INDEX(plugin_handle(plugin_id, field, type))
*/ into plugin_handle (ID, PLUGIN_ID, FIELD, LABEL, DATA_TYPE, TYPE, SORT,
EXT_OBJ)
+values ('1818229897214468142', '17', 'registerProtocol', 'registerProtocol',
2, 1, 0,
'{"required":"0","defaultValue":"","placeholder":"registerProtocol","rule":""}');
+
+insert /*+ IGNORE_ROW_ON_DUPKEY_INDEX(plugin_handle(plugin_id, field, type))
*/ into plugin_handle (ID, PLUGIN_ID, FIELD, LABEL, DATA_TYPE, TYPE, SORT,
EXT_OBJ)
+values ('1879002911061737473', '17', 'registerAddress', 'registerAddress', 2,
1, 1,
'{"required":"0","defaultValue":"","placeholder":"registerAddress","rule":""}');
+
insert /*+ IGNORE_ROW_ON_DUPKEY_INDEX(plugin_handle(plugin_id, field, type))
*/ into plugin_handle (ID, PLUGIN_ID, FIELD, LABEL, DATA_TYPE, TYPE, SORT,
EXT_OBJ)
values ('1518229897214468143', '28', 'port', 'port', 1, 3, 1, null);
diff --git a/db/init/pg/create-table.sql b/db/init/pg/create-table.sql
index e5567d6849..e2e6999964 100644
--- a/db/init/pg/create-table.sql
+++ b/db/init/pg/create-table.sql
@@ -1210,6 +1210,8 @@ INSERT INTO "public"."plugin_handle" VALUES
('1529403902783524880', '17', 'coret
INSERT INTO "public"."plugin_handle" VALUES ('1529403902783524881', '17',
'threads', 'threads', 1, 3, 3,
'{"required":"0","defaultValue":"2147483647","placeholder":"threads","rule":""}',
'2022-05-25 18:08:01', '2022-05-25 18:08:01');
INSERT INTO "public"."plugin_handle" VALUES ('1529403902783524882', '17',
'queues', 'queues', 1, 3, 4,
'{"required":"0","defaultValue":"0","placeholder":"queues","rule":""}',
'2022-05-25 18:08:01', '2022-05-25 18:08:01');
INSERT INTO "public"."plugin_handle" VALUES ('1529403902783524883', '17',
'threadpool', 'threadpool', 3, 3, 5,
'{"required":"0","defaultValue":"cached","placeholder":"threadpool","rule":""}',
'2022-05-25 18:08:01', '2022-05-25 18:08:01');
+INSERT INTO "public"."plugin_handle" VALUES ('1829403902783524879', '17',
'registerProtocol', 'registerProtocol', 2, 1, 0,
'{"required":"0","defaultValue":"","placeholder":"registerProtocol","rule":""}',
'2022-05-25 18:08:01', '2022-05-25 18:08:01');
+INSERT INTO "public"."plugin_handle" VALUES ('1878997557628272641', '17',
'registerAddress', 'registerAddress', 2, 1, 1,
'{"required":"0","defaultValue":"","placeholder":"registerAddress","rule":""}',
'2022-05-25 18:08:01', '2022-05-25 18:08:01');
INSERT INTO "public"."plugin_handle" VALUES ('1529403902783524884', '28',
'port', 'port', 1, 3, 1, NULL, '2022-05-25 18:08:01', '2022-05-25 18:08:01');
INSERT INTO "public"."plugin_handle" VALUES ('1529403902783524885', '28',
'bossGroupThreadCount', 'bossGroupThreadCount', 1, 3, 1, NULL, '2022-05-25
18:08:01', '2022-05-25 18:08:01');
INSERT INTO "public"."plugin_handle" VALUES ('1529403902783524886', '28',
'maxPayloadSize', 'maxPayloadSize', 1, 3, 1, NULL, '2022-05-25 18:08:01',
'2022-05-25 18:08:01');
diff --git a/db/upgrade/2.7.0-upgrade-2.7.1-mysql.sql
b/db/upgrade/2.7.0-upgrade-2.7.1-mysql.sql
index 14f6887c6e..206e46c9a9 100755
--- a/db/upgrade/2.7.0-upgrade-2.7.1-mysql.sql
+++ b/db/upgrade/2.7.0-upgrade-2.7.1-mysql.sql
@@ -238,6 +238,13 @@ DELETE FROM `plugin_handle` WHERE `plugin_id` = '8';
INSERT INTO `plugin_handle` VALUES ('1529402613204173925', '6', 'registry',
'registry', 2, 1, 0, '{\"required\":\"0\",\"rule\":\"\"}', '2025-02-27
17:20:50.233', '2025-02-27 17:20:50.233');
UPDATE `plugin_handle` SET ext_obj = '{\"required\":\"0\",\"rule\":\"\"}'
WHERE plugin_id = '6' AND label = 'ip:port' AND data_type = 2;
+INSERT INTO `plugin_handle` VALUES ('1829402613204172834', '17',
'registerProtocol', 'registerProtocol', 2, 1, 0,
'{\"required\":\"0\",\"defaultValue\":\"\",\"placeholder\":\"registerProtocol\",\"rule\":\"\"}',
'2022-05-25 18:02:53', '2022-05-25 18:02:53');
+INSERT INTO `plugin_handle` VALUES ('1829402613204172835', '17',
'corethreads', 'corethreads', 1, 1, 2,
'{\"required\":\"0\",\"defaultValue\":\"\",\"placeholder\":\"corethreads\",\"rule\":\"\"}',
'2022-05-25 18:02:53', '2022-05-25 18:02:53');
+INSERT INTO `plugin_handle` VALUES ('1829402613204172836', '17', 'threads',
'threads', 1, 1, 3,
'{\"required\":\"0\",\"defaultValue\":\"\",\"placeholder\":\"threads\",\"rule\":\"\"}',
'2022-05-25 18:02:53', '2022-05-25 18:02:53');
+INSERT INTO `plugin_handle` VALUES ('1829402613204172837', '17', 'queues',
'queues', 1, 1, 4,
'{\"required\":\"0\",\"defaultValue\":\"\",\"placeholder\":\"queues\",\"rule\":\"\"}',
'2022-05-25 18:02:53', '2022-05-25 18:02:53');
+INSERT INTO `plugin_handle` VALUES ('1829402613204172838', '17', 'threadpool',
'threadpool', 3, 1, 5,
'{\"required\":\"0\",\"defaultValue\":\"\",\"placeholder\":\"threadpool\",\"rule\":\"\"}',
'2022-05-25 18:02:53', '2022-05-25 18:02:53');
+INSERT INTO `plugin_handle` VALUES ('1878997557628272641', '17',
'registerAddress', 'registerAddress', 2, 1, 1,
'{\"required\":\"0\",\"defaultValue\":\"\",\"placeholder\":\"registerAddress\",\"rule\":\"\"}',
'2023-01-10 10:08:01.158', '2023-01-10 10:08:01.158');
+
INSERT INTO `plugin_handle` VALUES ('1942847622591684608', '61',
'messageEndpoint', 'messageEndpoint', 2, 1, 0,
'{"required":"0","defaultValue":"/message","rule":""}', '2025-07-09
07:25:44.249', '2025-07-09 07:25:44.249');
CREATE TABLE `registry_config` (
diff --git a/db/upgrade/2.7.0-upgrade-2.7.1-ob.sql
b/db/upgrade/2.7.0-upgrade-2.7.1-ob.sql
index f372ccbb75..0a1da3257d 100755
--- a/db/upgrade/2.7.0-upgrade-2.7.1-ob.sql
+++ b/db/upgrade/2.7.0-upgrade-2.7.1-ob.sql
@@ -206,6 +206,14 @@ DELETE FROM `plugin_handle` WHERE `plugin_id` = '8';
INSERT INTO `plugin_handle` VALUES ('1529402613204173925', '6', 'registry',
'registry', 2, 1, 0, '{\"required\":\"0\",\"rule\":\"\"}', '2025-02-27
17:20:50.233', '2025-02-27 17:20:50.233');
UPDATE `plugin_handle` SET ext_obj = '{\"required\":\"0\",\"rule\":\"\"}'
WHERE plugin_id = '6' AND label = 'ip:port' AND data_type = 2;
+
+INSERT INTO `plugin_handle` VALUES ('1829402613204172834', '17',
'registerProtocol', 'registerProtocol', 2, 1, 0,
'{\"required\":\"0\",\"defaultValue\":\"\",\"placeholder\":\"registerProtocol\",\"rule\":\"\"}',
'2022-05-25 18:02:53', '2022-05-25 18:02:53');
+INSERT INTO `plugin_handle` VALUES ('1829402613204172835', '17',
'corethreads', 'corethreads', 1, 1, 2,
'{\"required\":\"0\",\"defaultValue\":\"\",\"placeholder\":\"corethreads\",\"rule\":\"\"}',
'2022-05-25 18:02:53', '2022-05-25 18:02:53');
+INSERT INTO `plugin_handle` VALUES ('1829402613204172836', '17', 'threads',
'threads', 1, 1, 3,
'{\"required\":\"0\",\"defaultValue\":\"\",\"placeholder\":\"threads\",\"rule\":\"\"}',
'2022-05-25 18:02:53', '2022-05-25 18:02:53');
+INSERT INTO `plugin_handle` VALUES ('1829402613204172837', '17', 'queues',
'queues', 1, 1, 4,
'{\"required\":\"0\",\"defaultValue\":\"\",\"placeholder\":\"queues\",\"rule\":\"\"}',
'2022-05-25 18:02:53', '2022-05-25 18:02:53');
+INSERT INTO `plugin_handle` VALUES ('1829402613204172838', '17', 'threadpool',
'threadpool', 3, 1, 5,
'{\"required\":\"0\",\"defaultValue\":\"\",\"placeholder\":\"threadpool\",\"rule\":\"\"}',
'2022-05-25 18:02:53', '2022-05-25 18:02:53');
+INSERT INTO `plugin_handle` VALUES ('1878997557628272641', '17',
'registerAddress', 'registerAddress', 2, 1, 1,
'{\"required\":\"0\",\"defaultValue\":\"\",\"placeholder\":\"registerAddress\",\"rule\":\"\"}',
'2023-01-10 10:08:01.158', '2023-01-10 10:08:01.158');
+
INSERT INTO `plugin_handle` VALUES ('1942847622591684608', '61',
'messageEndpoint', 'messageEndpoint', 2, 1, 0,
'{"required":"0","defaultValue":"/message","rule":""}', '2025-07-09
07:25:44.249', '2025-07-09 07:25:44.249');
@@ -260,9 +268,10 @@ INSERT INTO `permission` (`id`, `object_id`,
`resource_id`, `date_created`, `dat
INSERT INTO `permission` (`id`, `object_id`, `resource_id`, `date_created`,
`date_updated`) VALUES ('1953049887387303905', '1346358560427216896',
'1953048313980116904', '2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000');
ALTER TABLE `rule` MODIFY COLUMN `handle` text;
+
ALTER TABLE `selector` CHANGE COLUMN `type` `selector_type` int(0) NOT NULL
COMMENT 'type (0, full flow, 1 custom flow)';
ALTER TABLE `selector` CHANGE COLUMN `sort` `sort_code` int(0) NOT NULL
COMMENT 'sort';
ALTER TABLE `selector` CHANGE COLUMN `name` `selector_name` varchar(64)
CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'selector
name';
ALTER TABLE `tag` CHANGE COLUMN `name` `tag_name` varchar(128) CHARACTER SET
utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'tag name';
ALTER TABLE `rule` CHANGE COLUMN `sort` `sort_code` int(0) NOT NULL COMMENT
'sort';
-ALTER TABLE `rule` CHANGE COLUMN `name` `rule_name` varchar(128) CHARACTER SET
utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'rule name';
+ALTER TABLE `rule` CHANGE COLUMN `name` `rule_name` varchar(128) CHARACTER SET
utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'rule name';
\ No newline at end of file
diff --git a/db/upgrade/2.7.0-upgrade-2.7.1-og.sql
b/db/upgrade/2.7.0-upgrade-2.7.1-og.sql
index 0e6cddb81f..e8b752f459 100644
--- a/db/upgrade/2.7.0-upgrade-2.7.1-og.sql
+++ b/db/upgrade/2.7.0-upgrade-2.7.1-og.sql
@@ -220,6 +220,15 @@ DELETE FROM `plugin_handle` WHERE `plugin_id` = '8';
INSERT INTO "public"."plugin_handle" VALUES ('1529402613204173925', '6',
'registry', 'registry', 2, 1, 0, '{"required":"0","rule":""}', '2025-02-27
17:20:50.233', '2025-02-27 17:20:50.233');
UPDATE "public"."plugin_handle" SET ext_obj = '{"required":"0","rule":""}'
WHERE plugin_id = '6' AND label = 'ip:port' AND data_type = 2;
+
+INSERT INTO "public"."plugin_handle" VALUES ('1829402613204172834', '17',
'registerProtocol', 'registerProtocol', 2, 1, 0,
'{"required":"0","defaultValue":"","placeholder":"registerProtocol","rule":""}',
'2022-05-25 18:02:53', '2022-05-25 18:02:53');
+INSERT INTO "public"."plugin_handle" VALUES ('1829402613204172835', '17',
'corethreads', 'corethreads', 1, 1, 2,
'{"required":"0","defaultValue":"","placeholder":"corethreads","rule":""}',
'2022-05-25 18:02:53', '2022-05-25 18:02:53');
+INSERT INTO "public"."plugin_handle" VALUES ('1829402613204172836', '17',
'threads', 'threads', 1, 1, 3,
'{"required":"0","defaultValue":"","placeholder":"threads","rule":""}',
'2022-05-25 18:02:53', '2022-05-25 18:02:53');
+INSERT INTO "public"."plugin_handle" VALUES ('1829402613204172837', '17',
'queues', 'queues', 1, 1, 4,
'{"required":"0","defaultValue":"","placeholder":"queues","rule":""}',
'2022-05-25 18:02:53', '2022-05-25 18:02:53');
+INSERT INTO "public"."plugin_handle" VALUES ('1829402613204172838', '17',
'threadpool', 'threadpool', 3, 1, 5,
'{"required":"0","defaultValue":"","placeholder":"threadpool","rule":""}',
'2022-05-25 18:02:53', '2022-05-25 18:02:53');
+INSERT INTO "public"."plugin_handle" VALUES ('1878997557628272641', '17',
'registerAddress', 'registerAddress', 2, 1, 1,
'{"required":"0","defaultValue":"","placeholder":"registerAddress","rule":""}',
'2023-01-10 10:08:01.158', '2023-01-10 10:08:01.158');
+
+
INSERT INTO "public"."plugin" VALUES ('61', 'mcpServer', NULL, 'MCP', 180, 0,
'2023-12-20 18:02:53', '2023-12-20 18:02:53', NULL);
INSERT INTO "public"."namespace_plugin_rel" VALUES ('1801816010882832189',
'649330b6-c2d7-4edc-be8e-8a54df9eb385', '61', NULL, 180, 0, '2022-05-25
18:02:53.000', '2022-05-25 18:02:53.000');
INSERT INTO "public"."plugin_handle" VALUES ('1942847622591684608', '61',
'messageEndpoint', 'messageEndpoint', 2, 1, 0,
'{"required":"0","defaultValue":"/message","rule":""}', '2025-07-09
07:25:44.249', '2025-07-09 07:25:44.249');
@@ -284,9 +293,10 @@ INSERT INTO "public"."permission" VALUES
('1953049887387303904', '13463585604272
INSERT INTO "public"."permission" VALUES ('1953049887387303905',
'1346358560427216896', '1953048313980116904', '2025-08-06 17:00:00.000',
'2025-08-06 17:00:00.000');
ALTER TABLE "public"."rule" ALTER COLUMN "handle" TYPE text;
+
ALTER TABLE "public"."selector" RENAME COLUMN "type" TO "selector_type";
ALTER TABLE "public"."selector" RENAME COLUMN "sort" TO "sort_code";
ALTER TABLE "public"."selector" RENAME COLUMN "name" TO "selector_name";
ALTER TABLE "public"."tag" RENAME COLUMN "name" TO "tag_name";
ALTER TABLE "public"."rule" RENAME COLUMN "sort" TO "sort_code";
-ALTER TABLE "public"."rule" RENAME COLUMN "name" TO "rule_name";
+ALTER TABLE "public"."rule" RENAME COLUMN "name" TO "rule_name";
\ No newline at end of file
diff --git a/db/upgrade/2.7.0-upgrade-2.7.1-oracle.sql
b/db/upgrade/2.7.0-upgrade-2.7.1-oracle.sql
index 91e74a515c..355fb43db3 100755
--- a/db/upgrade/2.7.0-upgrade-2.7.1-oracle.sql
+++ b/db/upgrade/2.7.0-upgrade-2.7.1-oracle.sql
@@ -484,6 +484,13 @@ VALUES ('1722804548510507249', '53', 'content', 'content',
2, 2, 4, '{"required"
delete from plugin_handle where plugin_id = '8';
+
+insert /*+ IGNORE_ROW_ON_DUPKEY_INDEX(plugin_handle(plugin_id, field, type))
*/ into plugin_handle (ID, PLUGIN_ID, FIELD, LABEL, DATA_TYPE, TYPE, SORT,
EXT_OBJ)
+values ('1818229897214468142', '17', 'registerProtocol', 'registerProtocol',
2, 1, 0,
'{"required":"0","defaultValue":"","placeholder":"registerProtocol","rule":""}');
+
+insert /*+ IGNORE_ROW_ON_DUPKEY_INDEX(plugin_handle(plugin_id, field, type))
*/ into plugin_handle (ID, PLUGIN_ID, FIELD, LABEL, DATA_TYPE, TYPE, SORT,
EXT_OBJ)
+values ('1879002911061737473', '17', 'registerAddress', 'registerAddress', 2,
1, 1,
'{"required":"0","defaultValue":"","placeholder":"registerAddress","rule":""}');
+
INSERT /*+ IGNORE_ROW_ON_DUPKEY_INDEX(plugin(id)) */ INTO plugin (id, name,
ext_obj, type, sort, enabled, date_created, date_updated)
VALUES ('61', 'mcpServer', NULL, 'MCP', 180, 0, sysdate, sysdate);
@@ -574,6 +581,7 @@ UPDATE rule SET handle_new = handle;
COMMIT;
ALTER TABLE rule DROP COLUMN handle;
ALTER TABLE rule RENAME COLUMN handle_new TO handle;
+
ALTER TABLE selector RENAME COLUMN "type" TO "selector_type";
ALTER TABLE selector RENAME COLUMN "sort" TO "sort_code";
ALTER TABLE selector RENAME COLUMN "name" TO "selector_name";
diff --git a/db/upgrade/2.7.0-upgrade-2.7.1-pg.sql
b/db/upgrade/2.7.0-upgrade-2.7.1-pg.sql
index fee3028b93..642ad20e63 100755
--- a/db/upgrade/2.7.0-upgrade-2.7.1-pg.sql
+++ b/db/upgrade/2.7.0-upgrade-2.7.1-pg.sql
@@ -218,6 +218,13 @@ INSERT INTO "public"."permission" VALUES
('1697146860569742760', '13463585604272
DELETE FROM "public"."plugin_handle" WHERE plugin_id = '8';
+INSERT INTO "public"."plugin_handle" VALUES ('1829403902783524879', '17',
'registerProtocol', 'registerProtocol', 2, 1, 0,
'{"required":"0","defaultValue":"","placeholder":"registerProtocol","rule":""}',
'2022-05-25 18:08:01', '2022-05-25 18:08:01');
+INSERT INTO "public"."plugin_handle" VALUES ('1878997557628272641', '17',
'registerAddress', 'registerAddress', 2, 1, 1,
'{"required":"0","defaultValue":"","placeholder":"registerAddress","rule":""}',
'2022-05-25 18:08:01', '2022-05-25 18:08:01');
+INSERT INTO "public"."plugin_handle" VALUES ('1829403902783524880', '17',
'corethreads', 'corethreads', 1, 1, 2,
'{"required":"0","defaultValue":"","placeholder":"corethreads","rule":""}',
'2022-05-25 18:08:01', '2022-05-25 18:08:01');
+INSERT INTO "public"."plugin_handle" VALUES ('1829403902783524881', '17',
'threads', 'threads', 1, 1, 3,
'{"required":"0","defaultValue":"","placeholder":"threads","rule":""}',
'2022-05-25 18:08:01', '2022-05-25 18:08:01');
+INSERT INTO "public"."plugin_handle" VALUES ('1829403902783524882', '17',
'queues', 'queues', 1, 1, 4,
'{"required":"0","defaultValue":"","placeholder":"queues","rule":""}',
'2022-05-25 18:08:01', '2022-05-25 18:08:01');
+INSERT INTO "public"."plugin_handle" VALUES ('1829403902783524883', '17',
'threadpool', 'threadpool', 3, 1, 5,
'{"required":"0","defaultValue":"","placeholder":"threadpool","rule":""}',
'2022-05-25 18:08:01', '2022-05-25 18:08:01');
+
INSERT INTO "public"."plugin" VALUES ('61', 'mcpServer', NULL, 'MCP', 180, 0,
'2023-12-20 18:02:53', '2023-12-20 18:02:53', NULL);
INSERT INTO "public"."namespace_plugin_rel" VALUES ('1801816010882832189',
'649330b6-c2d7-4edc-be8e-8a54df9eb385', '61', NULL, 180, 0, '2022-05-25
18:02:53.000', '2022-05-25 18:02:53.000');
INSERT INTO "public"."plugin_handle" VALUES ('1942847622591684608', '61',
'messageEndpoint', 'messageEndpoint', 2, 1, 0,
'{"required":"0","defaultValue":"/message","rule":""}', '2025-07-09
07:25:44.249', '2025-07-09 07:25:44.249');
@@ -282,6 +289,7 @@ INSERT INTO "public"."permission" VALUES
('1953049887387303904', '13463585604272
INSERT INTO "public"."permission" VALUES ('1953049887387303905',
'1346358560427216896', '1953048313980116904', '2025-08-06 17:00:00.000',
'2025-08-06 17:00:00.000');
ALTER TABLE "public"."rule" ALTER COLUMN "handle" TYPE text;
+
ALTER TABLE "public"."selector" RENAME COLUMN "type" TO "selector_type";
ALTER TABLE "public"."selector" RENAME COLUMN "sort" TO "sort_code";
ALTER TABLE "public"."selector" RENAME COLUMN "name" TO "selector_name";
diff --git a/shenyu-admin/src/main/resources/sql-script/h2/schema.sql
b/shenyu-admin/src/main/resources/sql-script/h2/schema.sql
index 6ef6385d17..0e5254d78e 100644
--- a/shenyu-admin/src/main/resources/sql-script/h2/schema.sql
+++ b/shenyu-admin/src/main/resources/sql-script/h2/schema.sql
@@ -719,6 +719,9 @@ INSERT IGNORE INTO plugin_handle (`id`,
`plugin_id`,`field`,`label`,`data_type`,
INSERT IGNORE INTO plugin_handle (`id`,
`plugin_id`,`field`,`label`,`data_type`,`type`,`sort`,`ext_obj`) VALUES
('1529402613204172836', '17', 'threads', 'threads', 1, 3, 3,
'{"required":"0","defaultValue":"2147483647","placeholder":"threads","rule":""}');
INSERT IGNORE INTO plugin_handle (`id`,
`plugin_id`,`field`,`label`,`data_type`,`type`,`sort`,`ext_obj`) VALUES
('1529402613204172837', '17', 'queues', 'queues', 1, 3, 4,
'{"required":"0","defaultValue":"0","placeholder":"queues","rule":""}');
INSERT IGNORE INTO plugin_handle (`id`,
`plugin_id`,`field`,`label`,`data_type`,`type`,`sort`,`ext_obj`) VALUES
('1529402613204172838', '17', 'threadpool', 'threadpool', 3, 3, 5,
'{"required":"0","defaultValue":"cached","placeholder":"threadpool","rule":""}');
+INSERT IGNORE INTO plugin_handle (`id`,
`plugin_id`,`field`,`label`,`data_type`,`type`,`sort`,`ext_obj`) VALUES
('1678997557628272641', '17', 'registerAddress', 'registerAddress', 2, 3,
1,'{"required":"0","defaultValue":"127.0.0.1:2181","placeholder":"registerAddress","rule":""}');
+INSERT IGNORE INTO plugin_handle (`id`,
`plugin_id`,`field`,`label`,`data_type`,`type`,`sort`,`ext_obj`) VALUES
('1829402613204172834', '17', 'registerProtocol', 'registerProtocol', 2, 1, 0,
'{"required":"0","defaultValue":"","placeholder":"registerProtocol","rule":""}');
+INSERT IGNORE INTO plugin_handle (`id`,
`plugin_id`,`field`,`label`,`data_type`,`type`,`sort`,`ext_obj`) VALUES
('1878997557628272641', '17', 'registerAddress', 'registerAddress', 2, 1,
1,'{"required":"0","defaultValue":"","placeholder":"registerAddress","rule":""}');
INSERT IGNORE INTO plugin_handle (`id`,
`plugin_id`,`field`,`label`,`data_type`,`type`,`sort`) VALUES
('1529402613204172839', '28', 'port', 'port', 1, 3, 1);
INSERT IGNORE INTO plugin_handle (`id`,
`plugin_id`,`field`,`label`,`data_type`,`type`,`sort`) VALUES
('1529402613204172840', '28', 'bossGroupThreadCount', 'bossGroupThreadCount',
1, 3, 1);
INSERT IGNORE INTO plugin_handle (`id`,
`plugin_id`,`field`,`label`,`data_type`,`type`,`sort`) VALUES
('1529402613204172841', '28', 'maxPayloadSize', 'maxPayloadSize', 1, 3, 1);
@@ -897,8 +900,6 @@ INSERT IGNORE INTO plugin_handle (`id`,
`plugin_id`,`field`,`label`,`data_type`,
INSERT IGNORE INTO plugin_handle (`id`,
`plugin_id`,`field`,`label`,`data_type`,`type`,`sort`,`ext_obj`) VALUES
('1678997277012557824', '42', 'clientMaxConnections', 'clientMaxConnections',
2, 1, 6, '{"required":"0","defaultValue":"20","rule":""}');
INSERT IGNORE INTO plugin_handle (`id`,
`plugin_id`,`field`,`label`,`data_type`,`type`,`sort`,`ext_obj`) VALUES
('1678997557628272640', '42', 'clientPendingAcquireTimeout',
'clientPendingAcquireTimeout', 2, 1, 5,
'{"required":"0","defaultValue":"5","rule":""}');
-INSERT IGNORE INTO plugin_handle (`id`,
`plugin_id`,`field`,`label`,`data_type`,`type`,`sort`,`ext_obj`) VALUES
('1678997557628272641', '17', 'registerAddress', 'registerAddress', 2, 3,
1,'{"required":"0","defaultValue":"127.0.0.1:2181","placeholder":"registerAddress","rule":""}');
-
INSERT IGNORE INTO plugin_handle (`id`,
`plugin_id`,`field`,`label`,`data_type`,`type`,`sort`,`ext_obj`) VALUES
('1678997557628272642', '15', 'loadBalance', 'loadBalance', 3, 2, 3,
'{"required":"0","defaultValue":"random","rule":""}');
INSERT IGNORE INTO plugin_handle (`id`,
`plugin_id`,`field`,`label`,`data_type`,`type`,`sort`,`ext_obj`) VALUES
('1678997557628272643', '44', 'defaultHandleJson', 'defaultHandleJson', 2, 3,
2,
'{"required":"0","defaultValue":"{\"authorization\":\"test:test123\"}","placeholder":""}');
diff --git
a/shenyu-common/src/main/java/org/apache/shenyu/common/dto/convert/selector/MotanUpstream.java
b/shenyu-common/src/main/java/org/apache/shenyu/common/dto/convert/selector/MotanUpstream.java
new file mode 100644
index 0000000000..40732fc0c9
--- /dev/null
+++
b/shenyu-common/src/main/java/org/apache/shenyu/common/dto/convert/selector/MotanUpstream.java
@@ -0,0 +1,274 @@
+/*
+ * 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.
+ */
+
+package org.apache.shenyu.common.dto.convert.selector;
+
+import java.util.Objects;
+
+/**
+ * this is motan upstream.
+ */
+public final class MotanUpstream extends CommonUpstream {
+
+ /**
+ * registerAddress.
+ */
+ private String registerAddress;
+
+ /**
+ * registerProtocol.
+ */
+ private String registerProtocol;
+
+ /**
+ * builder constructor.
+ *
+ * @param builder builder
+ */
+ private MotanUpstream(final Builder builder) {
+ boolean statusValue = builder.statusValue;
+ if (!builder.statusSet) {
+ statusValue = defaultStatus();
+ }
+ setUpstreamHost(builder.upstreamHost);
+ setProtocol(builder.protocol);
+ setUpstreamUrl(builder.upstreamUrl);
+ setStatus(statusValue);
+ setTimestamp(builder.timestamp);
+ setRegisterAddress(builder.registerAddress);
+ setRegisterProtocol(builder.registerProtocol);
+ }
+
+ /**
+ * class builder.
+ *
+ * @return Builder
+ */
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ /**
+ * get registerAddress.
+ *
+ * @return registerAddress
+ */
+ public String getRegisterAddress() {
+ return registerAddress;
+ }
+
+ /**
+ * set registerAddress.
+ *
+ * @param registerAddress registerAddress
+ */
+ public void setRegisterAddress(final String registerAddress) {
+ this.registerAddress = registerAddress;
+ }
+
+ /**
+ * get registerProtocol.
+ *
+ * @return registerProtocol
+ */
+ public String getRegisterProtocol() {
+ return registerProtocol;
+ }
+
+ /**
+ * set registerProtocol.
+ *
+ * @param registerProtocol registerProtocol
+ */
+ public void setRegisterProtocol(final String registerProtocol) {
+ this.registerProtocol = registerProtocol;
+ }
+
+ @Override
+ public boolean equals(final Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (!(o instanceof MotanUpstream)) {
+ return false;
+ }
+ MotanUpstream that = (MotanUpstream) o;
+ return Objects.equals(registerAddress, that.registerAddress)
+ && Objects.equals(this.getProtocol(), that.getProtocol())
+ && Objects.equals(this.getUpstreamUrl(), that.getUpstreamUrl())
+ && Objects.equals(this.isGray(), that.isGray())
+ && Objects.equals(this.registerProtocol,
that.registerProtocol);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(registerAddress, registerProtocol, this.isGray());
+ }
+
+ @Override
+ public String toString() {
+ return "MotanUpstream{"
+ + "registerAddress='" + registerAddress
+ + ", registerProtocol=" + registerProtocol
+ + "', protocol='" + this.getProtocol()
+ + ", upstreamUrl='" + this.getUpstreamUrl()
+ + "', gray=" + this.isGray()
+ + ", status=" + isStatus()
+ + ", timestamp=" + getTimestamp()
+ + "'}";
+ }
+
+ /**
+ * class builder.
+ */
+ public static final class Builder {
+
+ /**
+ * upstreamHost.
+ */
+ private String upstreamHost;
+
+ /**
+ * protocol.
+ */
+ private String protocol;
+
+ /**
+ * upstreamUrl.
+ */
+ private String upstreamUrl;
+
+ /**
+ * status.
+ */
+ private boolean statusSet;
+
+ /**
+ * status.
+ */
+ private boolean statusValue;
+
+ /**
+ * timestamp.
+ */
+ private long timestamp;
+
+ /**
+ * registerAddress.
+ */
+ private String registerAddress;
+
+ /**
+ * registerProtocol.
+ */
+ private String registerProtocol;
+
+ /**
+ * no args constructor.
+ */
+ private Builder() {
+ }
+
+ /**
+ * build new Object.
+ *
+ * @return DivideUpstream
+ */
+ public MotanUpstream build() {
+ return new MotanUpstream(this);
+ }
+
+ /**
+ * build upstreamHost.
+ *
+ * @param upstreamHost upstreamHost
+ * @return this
+ */
+ public Builder upstreamHost(final String upstreamHost) {
+ this.upstreamHost = upstreamHost;
+ return this;
+ }
+
+ /**
+ * build protocol.
+ *
+ * @param protocol protocol
+ * @return this
+ */
+ public Builder protocol(final String protocol) {
+ this.protocol = protocol;
+ return this;
+ }
+
+ /**
+ * build upstreamUrl.
+ *
+ * @param upstreamUrl upstreamUrl
+ * @return this
+ */
+ public Builder upstreamUrl(final String upstreamUrl) {
+ this.upstreamUrl = upstreamUrl;
+ return this;
+ }
+
+ /**
+ * build status.
+ *
+ * @param status status
+ * @return this
+ */
+ public Builder status(final boolean status) {
+ this.statusValue = status;
+ this.statusSet = true;
+ return this;
+ }
+
+ /**
+ * build timestamp.
+ *
+ * @param timestamp timestamp
+ * @return this
+ */
+ public Builder timestamp(final long timestamp) {
+ this.timestamp = timestamp;
+ return this;
+ }
+
+ /**
+ * build registerAddress.
+ *
+ * @param registerAddress registerAddress
+ * @return this
+ */
+ public Builder registerAddress(final String registerAddress) {
+ this.registerAddress = registerAddress;
+ return this;
+ }
+
+ /**
+ * build registerAddress.
+ *
+ * @param registerProtocol registerProtocol
+ * @return this
+ */
+ public Builder registerProtocol(final String registerProtocol) {
+ this.registerProtocol = registerProtocol;
+ return this;
+ }
+ }
+
+}
diff --git
a/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-rpc/shenyu-plugin-motan/src/main/java/org/apache/shenyu/plugin/motan/MotanPlugin.java
b/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-rpc/shenyu-plugin-motan/src/main/java/org/apache/shenyu/plugin/motan/MotanPlugin.java
index e98680ce1c..43c20d66ea 100644
---
a/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-rpc/shenyu-plugin-motan/src/main/java/org/apache/shenyu/plugin/motan/MotanPlugin.java
+++
b/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-rpc/shenyu-plugin-motan/src/main/java/org/apache/shenyu/plugin/motan/MotanPlugin.java
@@ -83,7 +83,7 @@ public class MotanPlugin extends AbstractShenyuPlugin {
Object error = ShenyuResultWrap.error(exchange,
ShenyuResultEnum.MOTAN_HAVE_BODY_PARAM);
return WebFluxResultUtils.result(exchange, error);
}
- final Mono<Object> result = motanProxyService.genericInvoker(param,
metaData, exchange);
+ final Mono<Object> result = motanProxyService.genericInvoker(param,
metaData, exchange, selector);
return result.then(chain.execute(exchange));
}
diff --git
a/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-rpc/shenyu-plugin-motan/src/main/java/org/apache/shenyu/plugin/motan/cache/ApplicationConfigCache.java
b/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-rpc/shenyu-plugin-motan/src/main/java/org/apache/shenyu/plugin/motan/cache/ApplicationConfigCache.java
index 527c28db81..59e54d0cbe 100644
---
a/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-rpc/shenyu-plugin-motan/src/main/java/org/apache/shenyu/plugin/motan/cache/ApplicationConfigCache.java
+++
b/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-rpc/shenyu-plugin-motan/src/main/java/org/apache/shenyu/plugin/motan/cache/ApplicationConfigCache.java
@@ -20,6 +20,7 @@ package org.apache.shenyu.plugin.motan.cache;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
+import com.google.common.collect.Maps;
import com.weibo.api.motan.config.ProtocolConfig;
import com.weibo.api.motan.config.RefererConfig;
import com.weibo.api.motan.config.RegistryConfig;
@@ -30,17 +31,25 @@ import org.apache.commons.lang3.tuple.Pair;
import org.apache.shenyu.common.constant.Constants;
import org.apache.shenyu.common.dto.MetaData;
import org.apache.shenyu.common.dto.convert.plugin.MotanRegisterConfig;
+import org.apache.shenyu.common.dto.convert.selector.MotanUpstream;
import org.apache.shenyu.common.exception.ShenyuException;
+import org.apache.shenyu.common.utils.DigestUtils;
import org.apache.shenyu.common.utils.GsonUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.lang.NonNull;
import java.lang.reflect.Field;
+
import java.util.List;
+import java.util.Map;
import java.util.Objects;
import java.util.Optional;
+import java.util.Set;
+import java.util.StringJoiner;
+import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ExecutionException;
+import java.util.stream.Collectors;
/**
* The cache info.
@@ -49,6 +58,8 @@ public final class ApplicationConfigCache {
private static final Logger LOG =
LoggerFactory.getLogger(ApplicationConfigCache.class);
+ private static final Map<String, MotanUpstream> UPSTREAM_CACHE_MAP =
Maps.newConcurrentMap();
+
private RegistryConfig registryConfig;
private ProtocolConfig protocolConfig;
@@ -95,9 +106,9 @@ public final class ApplicationConfigCache {
registryConfig = new RegistryConfig();
registryConfig.setId("shenyu_motan_proxy");
registryConfig.setRegister(false);
-
registryConfig.setRegProtocol(motanRegisterConfig.getRegisterProtocol());
-
registryConfig.setAddress(motanRegisterConfig.getRegisterAddress());
}
+
registryConfig.setRegProtocol(motanRegisterConfig.getRegisterProtocol());
+ registryConfig.setAddress(motanRegisterConfig.getRegisterAddress());
if (Objects.isNull(protocolConfig)) {
protocolConfig = new ProtocolConfig();
protocolConfig.setId("motan2");
@@ -140,6 +151,28 @@ public final class ApplicationConfigCache {
}
+ /**
+ * Init ref reference config.
+ *
+ * @param selectorId the select id
+ * @param metaData the meta data
+ * @param motanUpstream the motan upstream
+ * @return the reference config
+ */
+ public RefererConfig<CommonClient> initRef(final String selectorId, final
MetaData metaData, final MotanUpstream motanUpstream) {
+ try {
+ setUpstream(selectorId, motanUpstream);
+ RefererConfig<CommonClient> referenceConfig =
cache.get(generateUpstreamCacheKey(selectorId, metaData.getPath(),
motanUpstream));
+ if
(StringUtils.isNoneBlank(referenceConfig.getServiceInterface())) {
+ return referenceConfig;
+ }
+ } catch (ExecutionException e) {
+ LOG.error("init motan ref ex:{}", e.getMessage());
+ }
+ return build(selectorId, metaData, motanUpstream);
+
+ }
+
/**
* Build reference config.
*
@@ -172,6 +205,95 @@ public final class ApplicationConfigCache {
return reference;
}
+ /**
+ * Build reference config.
+ *
+ * @param selectorId the select id
+ * @param metaData the meta data
+ * @param motanUpstream the motan upstream
+ * @return the reference config
+ */
+ public RefererConfig<CommonClient> build(final String selectorId, final
MetaData metaData, final MotanUpstream motanUpstream) {
+ if (Objects.isNull(protocolConfig) || Objects.isNull(registryConfig)) {
+ return new RefererConfig<>();
+ }
+ if (Objects.isNull(motanUpstream)) {
+ return this.build(metaData);
+ }
+ RefererConfig<CommonClient> reference = new RefererConfig<>();
+ reference.setInterface(CommonClient.class);
+ reference.setServiceInterface(metaData.getServiceName());
+ // the group of motan rpc call
+ MotanParamExtInfo motanParamExtInfo =
GsonUtils.getInstance().fromJson(metaData.getRpcExt(), MotanParamExtInfo.class);
+ reference.setGroup(motanParamExtInfo.getGroup());
+ reference.setVersion("1.0");
+
reference.setRequestTimeout(Optional.ofNullable(motanParamExtInfo.getTimeout()).orElse(1000));
+ RegistryConfig registryConfig = new RegistryConfig();
+ registryConfig.setId("shenyu_motan_proxy");
+ registryConfig.setRegister(false);
+ if (StringUtils.isNoneBlank(motanUpstream.getRegisterProtocol())
+ &&
StringUtils.isNoneBlank(motanUpstream.getRegisterAddress())) {
+
Optional.ofNullable(motanUpstream.getRegisterProtocol()).ifPresent(registryConfig::setRegProtocol);
+
Optional.ofNullable(motanUpstream.getRegisterAddress()).ifPresent(registryConfig::setAddress);
+ }
+ reference.setRegistry(registryConfig);
+ if (StringUtils.isNotEmpty(motanParamExtInfo.getRpcProtocol())) {
+ protocolConfig.setName(motanParamExtInfo.getRpcProtocol());
+ protocolConfig.setId(motanParamExtInfo.getRpcProtocol());
+ }
+ reference.setProtocol(protocolConfig);
+ CommonClient obj = reference.getRef();
+ if (Objects.nonNull(obj)) {
+ LOG.info("init motan reference success there meteData is :{}",
metaData);
+ cache.put(generateUpstreamCacheKey(selectorId, metaData.getPath(),
motanUpstream), reference);
+ }
+ return reference;
+ }
+
+ /**
+ * generate motan upstream reference cache key.
+ *
+ * @param selectorId selectorId
+ * @param metaDataPath metaDataPath
+ * @param motanUpstream dubboUpstream
+ * @return the reference config cache key
+ */
+ public String generateUpstreamCacheKey(final String selectorId, final
String metaDataPath, final MotanUpstream motanUpstream) {
+ StringJoiner stringJoiner = new
StringJoiner(Constants.SEPARATOR_UNDERLINE);
+ stringJoiner.add(selectorId);
+ stringJoiner.add(metaDataPath);
+ if (StringUtils.isNotBlank(motanUpstream.getProtocol())) {
+ stringJoiner.add(motanUpstream.getProtocol());
+ }
+ // use registry hash to short reference cache key
+ if (StringUtils.isNotBlank(motanUpstream.getRegisterAddress())) {
+ String registryHash =
DigestUtils.md5Hex(motanUpstream.getRegisterAddress());
+ stringJoiner.add(registryHash);
+ }
+ return stringJoiner.toString();
+ }
+
+ /**
+ * get motanUpstream.
+ *
+ * @param path path
+ * @return motanUpstream
+ */
+ public MotanUpstream getUpstream(final String path) {
+ return UPSTREAM_CACHE_MAP.get(path);
+ }
+
+ /**
+ * set motanUpstream.
+ *
+ * @param path path
+ * @param motanUpstream motanUpstream
+ * @return motanUpstream
+ */
+ public MotanUpstream setUpstream(final String path, final MotanUpstream
motanUpstream) {
+ return UPSTREAM_CACHE_MAP.put(path, motanUpstream);
+ }
+
/**
* Invalidate.
*
@@ -188,6 +310,42 @@ public final class ApplicationConfigCache {
cache.invalidateAll();
}
+ /**
+ * Invalidate with metadataPath.
+ *
+ * @param metadataPath metadataPath
+ */
+ public void invalidateWithMetadataPath(final String metadataPath) {
+ ConcurrentMap<String, RefererConfig<CommonClient>> map = cache.asMap();
+ if (map.isEmpty()) {
+ return;
+ }
+ Set<String> allKeys = map.keySet();
+ Set<String> needInvalidateKeys = allKeys.stream().filter(key ->
key.contains(metadataPath)).collect(Collectors.toSet());
+ if (needInvalidateKeys.isEmpty()) {
+ return;
+ }
+ needInvalidateKeys.forEach(cache::invalidate);
+ }
+
+ /**
+ * invalidate with selectorId.
+ *
+ * @param selectorId selectorId
+ */
+ public void invalidateWithSelectorId(final String selectorId) {
+ ConcurrentMap<String, RefererConfig<CommonClient>> map = cache.asMap();
+ if (map.isEmpty()) {
+ return;
+ }
+ Set<String> allKeys = map.keySet();
+ Set<String> needInvalidateKeys = allKeys.stream().filter(key ->
key.contains(selectorId)).collect(Collectors.toSet());
+ if (needInvalidateKeys.isEmpty()) {
+ return;
+ }
+ needInvalidateKeys.forEach(cache::invalidate);
+ }
+
/**
* The type Application config cache instance.
*/
diff --git
a/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-rpc/shenyu-plugin-motan/src/main/java/org/apache/shenyu/plugin/motan/handler/MotanMetaDataHandler.java
b/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-rpc/shenyu-plugin-motan/src/main/java/org/apache/shenyu/plugin/motan/handler/MotanMetaDataHandler.java
index 29e24b7835..da47366aa8 100644
---
a/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-rpc/shenyu-plugin-motan/src/main/java/org/apache/shenyu/plugin/motan/handler/MotanMetaDataHandler.java
+++
b/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-rpc/shenyu-plugin-motan/src/main/java/org/apache/shenyu/plugin/motan/handler/MotanMetaDataHandler.java
@@ -51,6 +51,7 @@ public class MotanMetaDataHandler implements MetaDataHandler {
} else {
if (!exist.getServiceName().equals(metaData.getServiceName())
|| !exist.getRpcExt().equals(metaData.getRpcExt())) {
// update
+
ApplicationConfigCache.getInstance().invalidateWithMetadataPath(metaData.getPath());
ApplicationConfigCache.getInstance().build(metaData);
}
}
@@ -62,7 +63,7 @@ public class MotanMetaDataHandler implements MetaDataHandler {
@Override
public void remove(final MetaData metaData) {
- ApplicationConfigCache.getInstance().invalidate(metaData.getPath());
+
ApplicationConfigCache.getInstance().invalidateWithMetadataPath(metaData.getPath());
META_DATA.remove(metaData.getPath());
}
diff --git
a/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-rpc/shenyu-plugin-motan/src/main/java/org/apache/shenyu/plugin/motan/handler/MotanPluginDataHandler.java
b/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-rpc/shenyu-plugin-motan/src/main/java/org/apache/shenyu/plugin/motan/handler/MotanPluginDataHandler.java
index da7991a144..215d67c428 100644
---
a/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-rpc/shenyu-plugin-motan/src/main/java/org/apache/shenyu/plugin/motan/handler/MotanPluginDataHandler.java
+++
b/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-rpc/shenyu-plugin-motan/src/main/java/org/apache/shenyu/plugin/motan/handler/MotanPluginDataHandler.java
@@ -17,8 +17,10 @@
package org.apache.shenyu.plugin.motan.handler;
+import org.apache.shenyu.common.dto.SelectorData;
import org.apache.shenyu.common.dto.convert.plugin.MotanRegisterConfig;
import org.apache.shenyu.common.dto.PluginData;
+import org.apache.shenyu.common.dto.convert.selector.MotanUpstream;
import org.apache.shenyu.common.enums.PluginEnum;
import org.apache.shenyu.common.utils.GsonUtils;
import org.apache.shenyu.plugin.base.handler.PluginDataHandler;
@@ -49,6 +51,27 @@ public class MotanPluginDataHandler implements
PluginDataHandler {
}
}
+ @Override
+ public void removePlugin(final PluginData pluginData) {
+ ApplicationConfigCache.getInstance().invalidateAll();
+ }
+
+ @Override
+ public void handlerSelector(final SelectorData selectorData) {
+ MotanUpstream motanUpstream =
GsonUtils.getInstance().fromJson(selectorData.getHandle(), MotanUpstream.class);
+ if (Objects.equals(motanUpstream, ApplicationConfigCache
+ .getInstance().getUpstream(selectorData.getId()))) {
+ return;
+ }
+
ApplicationConfigCache.getInstance().invalidateWithSelectorId(selectorData.getId());
+ ApplicationConfigCache.getInstance().setUpstream(selectorData.getId(),
motanUpstream);
+ }
+
+ @Override
+ public void removeSelector(final SelectorData selectorData) {
+
ApplicationConfigCache.getInstance().invalidateWithSelectorId(selectorData.getId());
+ }
+
@Override
public String pluginNamed() {
return PluginEnum.MOTAN.getName();
diff --git
a/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-rpc/shenyu-plugin-motan/src/main/java/org/apache/shenyu/plugin/motan/proxy/MotanProxyService.java
b/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-rpc/shenyu-plugin-motan/src/main/java/org/apache/shenyu/plugin/motan/proxy/MotanProxyService.java
index 379d5dc0cf..8adcf600b9 100644
---
a/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-rpc/shenyu-plugin-motan/src/main/java/org/apache/shenyu/plugin/motan/proxy/MotanProxyService.java
+++
b/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-rpc/shenyu-plugin-motan/src/main/java/org/apache/shenyu/plugin/motan/proxy/MotanProxyService.java
@@ -30,10 +30,13 @@ import
org.apache.shenyu.common.concurrent.ShenyuThreadFactory;
import org.apache.shenyu.common.concurrent.ShenyuThreadPoolExecutor;
import org.apache.shenyu.common.constant.Constants;
import org.apache.shenyu.common.dto.MetaData;
+import org.apache.shenyu.common.dto.SelectorData;
import org.apache.shenyu.common.dto.convert.plugin.MotanRegisterConfig;
+import org.apache.shenyu.common.dto.convert.selector.MotanUpstream;
import org.apache.shenyu.common.enums.PluginEnum;
import org.apache.shenyu.common.enums.ResultEnum;
import org.apache.shenyu.common.exception.ShenyuException;
+import org.apache.shenyu.common.utils.GsonUtils;
import org.apache.shenyu.common.utils.ParamCheckUtils;
import org.apache.shenyu.common.utils.Singleton;
import org.apache.shenyu.plugin.api.utils.BodyParamUtils;
@@ -74,16 +77,17 @@ public class MotanProxyService {
* @param body the body
* @param metaData the meta data
* @param exchange the exchange
+ * @param selectorData the selectorData
* @return the object
* @throws ShenyuException the shenyu exception
*/
@SuppressWarnings("all")
- public Mono<Object> genericInvoker(final String body, final MetaData
metaData, final ServerWebExchange exchange) throws ShenyuException {
+ public Mono<Object> genericInvoker(final String body, final MetaData
metaData, final ServerWebExchange exchange, final SelectorData selectorData)
throws ShenyuException {
Map<String, Map<String, String>> rpcContext =
exchange.getAttribute(Constants.GENERAL_CONTEXT);
Optional.ofNullable(rpcContext).map(context ->
context.get(PluginEnum.MOTAN.getName())).ifPresent(context -> {
context.forEach((k, v) ->
RpcContext.getContext().setRpcAttachment(k, v));
});
- RefererConfig<CommonClient> reference =
ApplicationConfigCache.getInstance().get(metaData.getPath());
+ RefererConfig<CommonClient> reference =
getConsumerConfig(selectorData, metaData);
if (Objects.isNull(reference) ||
StringUtils.isEmpty(reference.getServiceInterface())) {
ApplicationConfigCache.getInstance().invalidate(metaData.getPath());
reference = ApplicationConfigCache.getInstance().initRef(metaData);
@@ -118,6 +122,34 @@ public class MotanProxyService {
})).onErrorMap(ShenyuException::new);
}
+ /**
+ * get motan reference config.
+ *
+ * @param selectorData the selector data
+ * @param metaData the meta data
+ * @return motan reference config
+ */
+ public RefererConfig<CommonClient> getConsumerConfig(final SelectorData
selectorData, final MetaData metaData) {
+ String referenceKey = metaData.getPath();
+ MotanUpstream motanUpstream =
GsonUtils.getInstance().fromJson(selectorData.getHandle(), MotanUpstream.class);
+ // if motanUpstream is empty, use default plugin config
+ if (Objects.isNull(motanUpstream)) {
+ RefererConfig<CommonClient> reference =
ApplicationConfigCache.getInstance().get(referenceKey);
+ if (StringUtils.isBlank(reference.getServiceInterface())) {
+ ApplicationConfigCache.getInstance().invalidate(referenceKey);
+ reference =
ApplicationConfigCache.getInstance().initRef(metaData);
+ }
+ return reference;
+ }
+ referenceKey =
ApplicationConfigCache.getInstance().generateUpstreamCacheKey(selectorData.getId(),
metaData.getPath(), motanUpstream);
+ RefererConfig<CommonClient> reference =
ApplicationConfigCache.getInstance().get(referenceKey);
+ if (StringUtils.isBlank(reference.getServiceInterface())) {
+ ApplicationConfigCache.getInstance().invalidate(referenceKey);
+ reference =
ApplicationConfigCache.getInstance().initRef(selectorData.getId(), metaData,
motanUpstream);
+ }
+ return reference;
+ }
+
private void initThreadPool() {
if (Objects.nonNull(threadPool)) {
return;
diff --git
a/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-rpc/shenyu-plugin-motan/src/test/java/org/apache/shenyu/plugin/motan/MotanPluginTest.java
b/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-rpc/shenyu-plugin-motan/src/test/java/org/apache/shenyu/plugin/motan/MotanPluginTest.java
index 0fcd9c58d4..120e82b77d 100644
---
a/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-rpc/shenyu-plugin-motan/src/test/java/org/apache/shenyu/plugin/motan/MotanPluginTest.java
+++
b/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-rpc/shenyu-plugin-motan/src/test/java/org/apache/shenyu/plugin/motan/MotanPluginTest.java
@@ -80,7 +80,7 @@ public final class MotanPluginTest {
exchange.getAttributes().put(Constants.PARAM_TRANSFORM, PARAM);
exchange.getAttributes().put(Constants.META_DATA, metaData);
this.motanProxyService = mock(MotanProxyService.class);
- when(motanProxyService.genericInvoker(PARAM, metaData,
exchange)).thenReturn(Mono.empty());
+ when(motanProxyService.genericInvoker(PARAM, metaData, exchange,
selectorData)).thenReturn(Mono.empty());
this.motanPlugin = new MotanPlugin(motanProxyService);
}
diff --git
a/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-rpc/shenyu-plugin-motan/src/test/java/org/apache/shenyu/plugin/motan/proxy/MotanProxyServiceTest.java
b/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-rpc/shenyu-plugin-motan/src/test/java/org/apache/shenyu/plugin/motan/proxy/MotanProxyServiceTest.java
new file mode 100644
index 0000000000..ec94ff49c3
--- /dev/null
+++
b/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-rpc/shenyu-plugin-motan/src/test/java/org/apache/shenyu/plugin/motan/proxy/MotanProxyServiceTest.java
@@ -0,0 +1,99 @@
+/*
+ * 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.
+ */
+
+package org.apache.shenyu.plugin.motan.proxy;
+
+import com.weibo.api.motan.config.RefererConfig;
+import com.weibo.api.motan.proxy.CommonClient;
+import com.weibo.api.motan.rpc.Request;
+import com.weibo.api.motan.rpc.ResponseFuture;
+import org.apache.shenyu.common.dto.MetaData;
+import org.apache.shenyu.common.dto.SelectorData;
+import org.apache.shenyu.common.dto.convert.plugin.MotanRegisterConfig;
+import org.apache.shenyu.common.enums.RpcTypeEnum;
+import org.apache.shenyu.plugin.motan.cache.ApplicationConfigCache;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.springframework.mock.http.server.reactive.MockServerHttpRequest;
+import org.springframework.mock.web.server.MockServerWebExchange;
+import org.springframework.web.server.ServerWebExchange;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+/**
+ * MotanProxyServiceTest.
+ */
+@ExtendWith(MockitoExtension.class)
+public class MotanProxyServiceTest {
+
+ private MetaData metaData;
+
+ private ServerWebExchange exchange;
+
+ @BeforeEach
+ public void setup() {
+ exchange =
MockServerWebExchange.from(MockServerHttpRequest.get("localhost").build());
+ metaData = new MetaData();
+ metaData.setId("1332017966661636096");
+ metaData.setAppName("sofa");
+ metaData.setPath("/motan/findAll");
+
metaData.setServiceName("org.apache.shenyu.test.motan.api.service.MotanTestService");
+ metaData.setMethodName("findAll");
+ metaData.setRpcType(RpcTypeEnum.MOTAN.getName());
+ metaData.setRpcExt("{\"loadbalance\": \"loadbalance\"}");
+ }
+
+ @AfterEach
+ public void after() {
+ ApplicationConfigCache.getInstance().invalidateAll();
+ }
+
+ @Test
+ @SuppressWarnings("all")
+ public void testGenericInvoker() {
+
+ ApplicationConfigCache.getInstance().init(new MotanRegisterConfig());
+ SelectorData selectorData = mock(SelectorData.class);
+
+ RefererConfig<CommonClient> reference = mock(RefererConfig.class);
+ CommonClient commonClient = mock(CommonClient.class);
+ when(reference.getRef()).thenReturn(commonClient);
+
when(reference.getServiceInterface()).thenReturn("org.apache.shenyu.test.motan.api.service.MotanTestService");
+
+ MotanProxyService motanProxyService = spy(new MotanProxyService());
+
doReturn(reference).when(motanProxyService).getConsumerConfig(selectorData,
metaData);
+
+ ResponseFuture responseFuture = mock(ResponseFuture.class);
+ try {
+ when(commonClient.asyncCall(any(Request.class),
eq(Object.class))).thenReturn(responseFuture);
+ } catch (Throwable e) {
+ throw new RuntimeException(e);
+ }
+ when(responseFuture.getValue()).thenReturn("success");
+
+ motanProxyService.genericInvoker("", metaData, exchange, selectorData);
+ }
+
+}