diff --git a/.github/workflows/integrated-test-k8s-ingress.yml b/.github/workflows/integrated-test-k8s-ingress.yml index ec6dbdf954ca..d97d242ce032 100644 --- a/.github/workflows/integrated-test-k8s-ingress.yml +++ b/.github/workflows/integrated-test-k8s-ingress.yml @@ -29,7 +29,6 @@ jobs: - shenyu-integrated-test-k8s-ingress-http - shenyu-integrated-test-k8s-ingress-apache-dubbo - shenyu-integrated-test-k8s-ingress-motan - - shenyu-integrated-test-k8s-ingress-spring-cloud - shenyu-integrated-test-k8s-ingress-websocket - shenyu-integrated-test-k8s-ingress-grpc # - shenyu-integrated-test-k8s-ingress-sofa diff --git a/db/init/mysql/schema.sql b/db/init/mysql/schema.sql index 041e0cdd650f..e04ebc3215d3 100644 --- a/db/init/mysql/schema.sql +++ b/db/init/mysql/schema.sql @@ -51,7 +51,7 @@ CREATE TABLE `api` ( `consume` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'consume content-type', `produce` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'produce content-type', `version` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'api version,for example V0.01', - `rpc_type` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'http,dubbo,sofa,tars,websocket,springCloud,motan,grpc', + `rpc_type` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'http,dubbo,sofa,tars,websocket,motan,grpc', `state` tinyint(4) NOT NULL COMMENT '0-unpublished,1-published,2-offline', `ext` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'extended fields', `api_owner` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'api_owner', @@ -909,7 +909,6 @@ INSERT INTO `plugin` VALUES ('30', 'cache', '{\"cacheType\":\"memory\"}', 'Cache INSERT INTO `plugin` VALUES ('4', 'rateLimiter', '{\"master\":\"mymaster\",\"mode\":\"standalone\",\"url\":\"192.168.1.1:6379\",\"password\":\"abc\"}', 'FaultTolerance', 60, 0, '2022-05-25 18:02:53', '2022-05-25 18:02:53',null); INSERT INTO `plugin` VALUES ('5', 'divide', '{\"multiSelectorHandle\":\"1\",\"multiRuleHandle\":\"0\"}', 'Proxy', 200, 1, '2022-05-25 18:02:53', '2022-05-25 18:02:53',null); INSERT INTO `plugin` VALUES ('6', 'dubbo', '{\"register\":\"zookeeper://localhost:2181\",\"multiSelectorHandle\":\"1\",\"threadpool\":\"shared\",\"corethreads\":0,\"threads\":2147483647,\"queues\":0}', 'Proxy', 310, 0, '2022-05-25 18:02:53', '2022-05-25 18:02:53',null); -INSERT INTO `plugin` VALUES ('8', 'springCloud', NULL, 'Proxy', 200, 0, '2022-05-25 18:02:53', '2022-05-25 18:02:53',null); INSERT INTO `plugin` VALUES ('9', 'hystrix', NULL, 'FaultTolerance', 130, 0, '2022-05-25 18:02:53', '2022-05-25 18:02:53',null); INSERT INTO `plugin` VALUES ('32', 'loggingElasticSearch','{\"host\":\"localhost\", \"port\": \"9200\"}', 'Logging', 190, 0, '2022-06-19 22:00:00', '2022-06-19 22:00:00',null); INSERT INTO `plugin` VALUES ('33', 'loggingKafka','{\"host\":\"localhost\", \"port\": \"9092\"}', 'Logging', 180, 0, '2022-07-04 22:00:00', '2022-07-02 22:00:00',null); @@ -966,9 +965,6 @@ INSERT INTO `plugin_handle` VALUES ('1529402613199978511', '3', 'regex', 'regex' INSERT INTO `plugin_handle` VALUES ('1529402613199978512', '3', 'replace', 'replace', 2, 2, 2, NULL, '2022-05-25 18:02:53', '2022-05-25 18:02:53'); INSERT INTO `plugin_handle` VALUES ('1697146860569596304', '3', 'percentage', 'percentage', 1, 2, 3, NULL, '2023-09-15 20:25:53', '2023-09-15 20:25:53'); INSERT INTO `plugin_handle` VALUES ('1529402613199978513', '16', 'redirectURI', 'redirectURI', 2, 2, 1, NULL, '2022-05-25 18:02:53', '2022-05-25 18:02:53'); -INSERT INTO `plugin_handle` VALUES ('1529402613199978514', '8', 'path', 'path', 2, 2, 1, NULL, '2022-05-25 18:02:53', '2022-05-25 18:02:53'); -INSERT INTO `plugin_handle` VALUES ('1529402613199978515', '8', 'timeout', 'timeout ms)', 1, 2, 2, NULL, '2022-05-25 18:02:53', '2022-05-25 18:02:53'); -INSERT INTO `plugin_handle` VALUES ('1529402613199978516', '8', 'serviceId', 'serviceId', 2, 1, 1, NULL, '2022-05-25 18:02:53', '2022-05-25 18:02:53'); INSERT INTO `plugin_handle` VALUES ('1529402613199978517', '12', 'timeoutDurationRate', 'timeoutDurationRate ms)', 1, 2, 1, '{\"required\":\"1\",\"defaultValue\":\"5000\",\"rule\":\"\"}', '2022-05-25 18:02:53', '2022-05-25 18:02:53'); INSERT INTO `plugin_handle` VALUES ('1529402613199978518', '12', 'limitRefreshPeriod', 'limitRefreshPeriod ms)', 1, 2, 0, '{\"required\":\"1\",\"defaultValue\":\"500\",\"rule\":\"\"}', '2022-05-25 18:02:53', '2022-05-25 18:02:53'); INSERT INTO `plugin_handle` VALUES ('1529402613199978519', '12', 'limitForPeriod', 'limitForPeriod', 1, 2, 0, '{\"required\":\"1\",\"defaultValue\":\"50\",\"rule\":\"\"}', '2022-05-25 18:02:53', '2022-05-25 18:02:53'); @@ -1172,7 +1168,6 @@ INSERT INTO `plugin_handle` VALUES ('1529402613204172933', '36', 'retries', 'ret INSERT INTO `plugin_handle` VALUES ('1529402613204172934', '36', 'maxReservedAttempts', 'maxReservedAttempts', 1, 3, 13, '{\"required\":\"0\",\"defaultValue\":11}', '2022-06-30 21:00:00', '2022-06-30 21:00:00'); INSERT INTO `plugin_handle` VALUES ('1529402613204172935', '36', 'baseRetryBackoffMs', 'baseRetryBackoffMs', 1, 3, 14, '{\"required\":\"0\",\"defaultValue\":100}', '2022-06-30 21:00:00', '2022-06-30 21:00:00'); INSERT INTO `plugin_handle` VALUES ('1529402613204172936', '36', 'maxRetryBackoffMs', 'maxRetryBackoffMs', 1, 3, 15, '{\"required\":\"0\",\"defaultValue\":50000}', '2022-06-30 21:00:00', '2022-06-30 21:00:00'); -INSERT INTO `plugin_handle` VALUES ('1529402613204172742', '8', 'loadBalance', 'loadStrategy', 3, 2, 3, '{\"defaultValue\":\"roundRobin\",\"rule\":\"\"}', '2022-05-25 18:02:53', '2022-05-25 18:02:53'); INSERT INTO `plugin_handle` VALUES ('1529402613204172743', '10', 'flowRuleMaxQueueingTimeMs', 'flowRuleMaxQueueingTimeMs', 1, 2, 6, '{\"required\":\"0\",\"defaultValue\":\"500\"}', '2022-05-25 18:02:53', '2022-05-25 18:02:53'); INSERT INTO `plugin_handle` VALUES ('1529402613204172744', '10', 'flowRuleWarmUpPeriodSec', 'flowRuleWarmUpPeriodSec', 1, 2, 6, '{\"required\":\"0\",\"defaultValue\":\"10\"}', '2022-05-25 18:02:53', '2022-05-25 18:02:53'); INSERT INTO `plugin_handle` VALUES ('1529402613204172745', '14', 'addPrefixed', 'addPrefixed', 3, 2, 3, '{\"required\":\"1\",\"defaultValue\":\"false\"}', '2022-09-27 12:00:00', '2022-09-27 12:00:00'); @@ -1290,9 +1285,6 @@ INSERT INTO `plugin_handle` VALUES ('1722804548510507021', '14', 'rewriteContext INSERT INTO `plugin_handle` VALUES ('1722804548510507022', '14', 'percentage', 'percentage', 1, 2, 3, '{"required":"1","defaultValue":"100"}', '2024-02-07 14:31:49', '2024-02-07 14:31:49'); INSERT INTO `plugin_handle` VALUES ('1722804548510507023', '3', 'rewriteMetaData', 'rewriteMetaData', 3, 2, 3, '{"required":"1","defaultValue":"false"}', '2024-02-07 14:31:49', '2024-02-07 14:31:49'); -INSERT INTO `plugin_handle` VALUES ('1722804548510507024', '8', 'registerType', 'registerType', 2, 3, 1, NULL, '2024-08-24 09:40:03.293', '2024-08-24 21:52:27.920'); -INSERT INTO `plugin_handle` VALUES ('1722804548510507025', '8', 'serverLists', 'serverLists', 2, 3, 2, NULL, '2024-08-24 21:52:51.179', '2024-08-24 21:53:27.483'); -INSERT INTO `plugin_handle` VALUES ('1722804548510507026', '8', 'props', 'props', 4, 3, 3, NULL, '2024-08-24 21:53:25.764', '2024-08-24 21:53:30.255'); -- ---------------------------- -- Table structure for resource @@ -1405,7 +1397,6 @@ INSERT INTO `resource` VALUES ('1529402639284355094', '1346775491550474240', 'ca INSERT INTO `resource` VALUES ('1529402639284355095', '1346775491550474240', 'rateLimiter', 'rateLimiter', '/plug/rateLimiter', 'rateLimiter', 1, 0, 'key', 0, 0, '', 1, '2022-05-25 18:02:58', '2022-05-25 18:02:58'); INSERT INTO `resource` VALUES ('1529402639284355096', '1346775491550474240', 'divide', 'divide', '/plug/divide', 'divide', 1, 0, 'stop', 0, 0, '', 1, '2022-05-25 18:02:58', '2022-05-25 18:02:58'); INSERT INTO `resource` VALUES ('1529402639284355097', '1346775491550474240', 'dubbo', 'dubbo', '/plug/dubbo', 'dubbo', 1, 0, 'fire', 0, 0, '', 1, '2022-05-25 18:02:58', '2022-05-25 18:02:58'); -INSERT INTO `resource` VALUES ('1529402639284355098', '1346775491550474240', 'springCloud', 'springCloud', '/plug/springCloud', 'springCloud', 1, 0, 'border-bottom', 0, 0, '', 1, '2022-05-25 18:02:58', '2022-05-25 18:02:58'); INSERT INTO `resource` VALUES ('1529402639284355099', '1346775491550474240', 'hystrix', 'hystrix', '/plug/hystrix', 'hystrix', 1, 0, 'border-bottom', 0, 0, '', 1, '2022-05-25 18:02:58', '2022-05-25 18:02:58'); INSERT INTO `resource` VALUES ('1529402639368241152', '1529402639271772160', 'SHENYU.BUTTON.PLUGIN.SELECTOR.ADD', '', '', '', 2, 0, '', 1, 0, 'plugin:signSelector:add', 1, '2022-05-25 18:02:58', '2022-05-25 18:02:58'); INSERT INTO `resource` VALUES ('1529402639368241153', '1529402639271772160', 'SHENYU.BUTTON.PLUGIN.SELECTOR.QUERY', '', '', '', 2, 0, '', 1, 0, 'plugin:signSelector:query', 1, '2022-05-25 18:02:58', '2022-05-25 18:02:58'); @@ -1650,15 +1641,6 @@ INSERT INTO `resource` VALUES ('1529402639372435641', '1529402639284355097', 'SH INSERT INTO `resource` VALUES ('1529402639372435642', '1529402639284355097', 'SHENYU.BUTTON.PLUGIN.RULE.EDIT', '', '', '', 2, 0, '', 1, 0, 'plugin:dubboRule:edit', 1, '2022-05-25 18:02:58', '2022-05-25 18:02:58'); INSERT INTO `resource` VALUES ('1529402639372435643', '1529402639284355097', 'SHENYU.BUTTON.PLUGIN.RULE.DELETE', '', '', '', 2, 0, '', 1, 0, 'plugin:dubboRule:delete', 1, '2022-05-25 18:02:58', '2022-05-25 18:02:58'); INSERT INTO `resource` VALUES ('1529402639372435644', '1529402639284355097', 'SHENYU.BUTTON.PLUGIN.SYNCHRONIZE', '', '', '', 2, 0, '', 1, 0, 'plugin:dubbo:modify', 1, '2022-05-25 18:02:58', '2022-05-25 18:02:58'); -INSERT INTO `resource` VALUES ('1529402639372435645', '1529402639284355098', 'SHENYU.BUTTON.PLUGIN.SELECTOR.ADD', '', '', '', 2, 0, '', 1, 0, 'plugin:springCloudSelector:add', 1, '2022-05-25 18:02:58', '2022-05-25 18:02:58'); -INSERT INTO `resource` VALUES ('1529402639372435646', '1529402639284355098', 'SHENYU.BUTTON.PLUGIN.SELECTOR.QUERY', '', '', '', 2, 0, '', 1, 0, 'plugin:springCloudSelector:query', 1, '2022-05-25 18:02:58', '2022-05-25 18:02:58'); -INSERT INTO `resource` VALUES ('1529402639372435647', '1529402639284355098', 'SHENYU.BUTTON.PLUGIN.SELECTOR.EDIT', '', '', '', 2, 0, '', 1, 0, 'plugin:springCloudSelector:edit', 1, '2022-05-25 18:02:58', '2022-05-25 18:02:58'); -INSERT INTO `resource` VALUES ('1529402639372435648', '1529402639284355098', 'SHENYU.BUTTON.PLUGIN.SELECTOR.DELETE', '', '', '', 2, 0, '', 1, 0, 'plugin:springCloudSelector:delete', 1, '2022-05-25 18:02:58', '2022-05-25 18:02:58'); -INSERT INTO `resource` VALUES ('1529402639372435649', '1529402639284355098', 'SHENYU.BUTTON.PLUGIN.RULE.ADD', '', '', '', 2, 0, '', 1, 0, 'plugin:springCloudRule:add', 1, '2022-05-25 18:02:58', '2022-05-25 18:02:58'); -INSERT INTO `resource` VALUES ('1529402639372435650', '1529402639284355098', 'SHENYU.BUTTON.PLUGIN.RULE.QUERY', '', '', '', 2, 0, '', 1, 0, 'plugin:springCloudRule:query', 1, '2022-05-25 18:02:58', '2022-05-25 18:02:58'); -INSERT INTO `resource` VALUES ('1529402639372435651', '1529402639284355098', 'SHENYU.BUTTON.PLUGIN.RULE.EDIT', '', '', '', 2, 0, '', 1, 0, 'plugin:springCloudRule:edit', 1, '2022-05-25 18:02:58', '2022-05-25 18:02:58'); -INSERT INTO `resource` VALUES ('1529402639372435652', '1529402639284355098', 'SHENYU.BUTTON.PLUGIN.RULE.DELETE', '', '', '', 2, 0, '', 1, 0, 'plugin:springCloudRule:delete', 1, '2022-05-25 18:02:58', '2022-05-25 18:02:58'); -INSERT INTO `resource` VALUES ('1529402639372435653', '1529402639284355098', 'SHENYU.BUTTON.PLUGIN.SYNCHRONIZE', '', '', '', 2, 0, '', 1, 0, 'plugin:springCloud:modify', 1, '2022-05-25 18:02:58', '2022-05-25 18:02:58'); INSERT INTO `resource` VALUES ('1529402639372435654', '1529402639284355099', 'SHENYU.BUTTON.PLUGIN.SELECTOR.ADD', '', '', '', 2, 0, '', 1, 0, 'plugin:hystrixSelector:add', 1, '2022-05-25 18:02:58', '2022-05-25 18:02:58'); INSERT INTO `resource` VALUES ('1529402639372435655', '1529402639284355099', 'SHENYU.BUTTON.PLUGIN.SELECTOR.QUERY', '', '', '', 2, 0, '', 1, 0, 'plugin:hystrixSelector:query', 1, '2022-05-25 18:02:58', '2022-05-25 18:02:58'); INSERT INTO `resource` VALUES ('1529402639372435656', '1529402639284355099', 'SHENYU.BUTTON.PLUGIN.SELECTOR.EDIT', '', '', '', 2, 0, '', 1, 0, 'plugin:hystrixSelector:edit', 1, '2022-05-25 18:02:58', '2022-05-25 18:02:58'); @@ -2372,7 +2354,6 @@ INSERT INTO `namespace_plugin_rel` (`id`,`namespace_id`,`plugin_id`, `config`, ` INSERT INTO `namespace_plugin_rel` (`id`,`namespace_id`,`plugin_id`, `config`, `sort`, `enabled`, `date_created`, `date_updated`) VALUES ('1801816010882822182','649330b6-c2d7-4edc-be8e-8a54df9eb385','45', '{\"host\":\"127.0.0.1\",\"port\":5672,\"password\":\"admin\",\"username\":\"admin\",\"exchangeName\":\"exchange.logging.plugin\",\"queueName\":\"queue.logging.plugin\",\"routingKey\":\"topic.logging\",\"virtualHost\":\"/\",\"exchangeType\":\"direct\",\"durable\":\"true\",\"exclusive\":\"false\",\"autoDelete\":\"false\"}', 171, 0, '2023-11-06 15:49:56.454', '2023-11-10 10:40:58.447'); INSERT INTO `namespace_plugin_rel` (`id`,`namespace_id`,`plugin_id`, `config`, `sort`, `enabled`, `date_created`, `date_updated`) VALUES ('1801816010882822183','649330b6-c2d7-4edc-be8e-8a54df9eb385','5', '{\"multiSelectorHandle\":\"1\",\"multiRuleHandle\":\"0\"}', 200, 1, '2022-05-25 18:02:53.000', '2022-05-25 18:02:53.000'); INSERT INTO `namespace_plugin_rel` (`id`,`namespace_id`,`plugin_id`, `config`, `sort`, `enabled`, `date_created`, `date_updated`) VALUES ('1801816010882822184','649330b6-c2d7-4edc-be8e-8a54df9eb385','6', '{\"register\":\"zookeeper://localhost:2181\",\"multiSelectorHandle\":\"1\",\"threadpool\":\"shared\",\"corethreads\":0,\"threads\":2147483647,\"queues\":0}', 310, 0, '2022-05-25 18:02:53.000', '2022-05-25 18:02:53.000'); -INSERT INTO `namespace_plugin_rel` (`id`,`namespace_id`,`plugin_id`, `config`, `sort`, `enabled`, `date_created`, `date_updated`) VALUES ('1801816010882822185','649330b6-c2d7-4edc-be8e-8a54df9eb385','8', '{\"enabled\":false,\"registerType\":\"eureka\",\"serverLists\":\"http://localhost:8761/eureka\",\"props\": {}}', 200, 0, '2022-05-25 18:02:53.000', '2022-05-25 18:02:53.000'); INSERT INTO `namespace_plugin_rel` (`id`,`namespace_id`,`plugin_id`, `config`, `sort`, `enabled`, `date_created`, `date_updated`) VALUES ('1801816010882822186','649330b6-c2d7-4edc-be8e-8a54df9eb385','9', NULL, 130, 0, '2022-05-25 18:02:53.000', '2022-05-25 18:02:53.000'); diff --git a/db/init/ob/schema.sql b/db/init/ob/schema.sql index cd6ff2b36c05..a3ccd09a5b70 100644 --- a/db/init/ob/schema.sql +++ b/db/init/ob/schema.sql @@ -51,7 +51,7 @@ CREATE TABLE `api` ( `consume` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'consume content-type', `produce` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'produce content-type', `version` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'api version,for example V0.01', - `rpc_type` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'http,dubbo,sofa,tars,websocket,springCloud,motan,grpc', + `rpc_type` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'http,dubbo,sofa,tars,websocket,motan,grpc', `state` tinyint(4) NOT NULL COMMENT '0-unpublished,1-published,2-offline', `ext` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'extended fields', `api_owner` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'api_owner', @@ -902,7 +902,6 @@ INSERT INTO `plugin` VALUES ('30', 'cache', '{\"cacheType\":\"memory\"}', 'Cache INSERT INTO `plugin` VALUES ('4', 'rateLimiter', '{\"master\":\"mymaster\",\"mode\":\"standalone\",\"url\":\"192.168.1.1:6379\",\"password\":\"abc\"}', 'FaultTolerance', 60, 0, '2022-05-25 18:02:53', '2022-05-25 18:02:53',null); INSERT INTO `plugin` VALUES ('5', 'divide', '{\"multiSelectorHandle\":\"1\",\"multiRuleHandle\":\"0\"}', 'Proxy', 200, 1, '2022-05-25 18:02:53', '2022-05-25 18:02:53',null); INSERT INTO `plugin` VALUES ('6', 'dubbo', '{\"register\":\"zookeeper://localhost:2181\",\"multiSelectorHandle\":\"1\",\"threadpool\":\"shared\",\"corethreads\":0,\"threads\":2147483647,\"queues\":0}', 'Proxy', 310, 0, '2022-05-25 18:02:53', '2022-05-25 18:02:53',null); -INSERT INTO `plugin` VALUES ('8', 'springCloud', NULL, 'Proxy', 200, 0, '2022-05-25 18:02:53', '2022-05-25 18:02:53',null); INSERT INTO `plugin` VALUES ('9', 'hystrix', NULL, 'FaultTolerance', 130, 0, '2022-05-25 18:02:53', '2022-05-25 18:02:53',null); INSERT INTO `plugin` VALUES ('32', 'loggingElasticSearch','{\"host\":\"localhost\", \"port\": \"9200\"}', 'Logging', 190, 0, '2022-06-19 22:00:00', '2022-06-19 22:00:00',null); INSERT INTO `plugin` VALUES ('33', 'loggingKafka','{\"host\":\"localhost\", \"port\": \"9092\"}', 'Logging', 180, 0, '2022-07-04 22:00:00', '2022-07-02 22:00:00',null); @@ -959,9 +958,6 @@ INSERT INTO `plugin_handle` VALUES ('1529402613199978511', '3', 'regex', 'regex' INSERT INTO `plugin_handle` VALUES ('1529402613199978512', '3', 'replace', 'replace', 2, 2, 2, NULL, '2022-05-25 18:02:53', '2022-05-25 18:02:53'); INSERT INTO `plugin_handle` VALUES ('1697146860569596304', '3', 'percentage', 'percentage', 1, 2, 3, NULL, '2023-09-15 20:25:53', '2023-09-15 20:25:53'); INSERT INTO `plugin_handle` VALUES ('1529402613199978513', '16', 'redirectURI', 'redirectURI', 2, 2, 1, NULL, '2022-05-25 18:02:53', '2022-05-25 18:02:53'); -INSERT INTO `plugin_handle` VALUES ('1529402613199978514', '8', 'path', 'path', 2, 2, 1, NULL, '2022-05-25 18:02:53', '2022-05-25 18:02:53'); -INSERT INTO `plugin_handle` VALUES ('1529402613199978515', '8', 'timeout', 'timeout ms)', 1, 2, 2, NULL, '2022-05-25 18:02:53', '2022-05-25 18:02:53'); -INSERT INTO `plugin_handle` VALUES ('1529402613199978516', '8', 'serviceId', 'serviceId', 2, 1, 1, NULL, '2022-05-25 18:02:53', '2022-05-25 18:02:53'); INSERT INTO `plugin_handle` VALUES ('1529402613199978517', '12', 'timeoutDurationRate', 'timeoutDurationRate ms)', 1, 2, 1, '{\"required\":\"1\",\"defaultValue\":\"5000\",\"rule\":\"\"}', '2022-05-25 18:02:53', '2022-05-25 18:02:53'); INSERT INTO `plugin_handle` VALUES ('1529402613199978518', '12', 'limitRefreshPeriod', 'limitRefreshPeriod ms)', 1, 2, 0, '{\"required\":\"1\",\"defaultValue\":\"500\",\"rule\":\"\"}', '2022-05-25 18:02:53', '2022-05-25 18:02:53'); INSERT INTO `plugin_handle` VALUES ('1529402613199978519', '12', 'limitForPeriod', 'limitForPeriod', 1, 2, 0, '{\"required\":\"1\",\"defaultValue\":\"50\",\"rule\":\"\"}', '2022-05-25 18:02:53', '2022-05-25 18:02:53'); @@ -1165,7 +1161,6 @@ INSERT INTO `plugin_handle` VALUES ('1529402613204172933', '36', 'retries', 'ret INSERT INTO `plugin_handle` VALUES ('1529402613204172934', '36', 'maxReservedAttempts', 'maxReservedAttempts', 1, 3, 13, '{\"required\":\"0\",\"defaultValue\":11}', '2022-06-30 21:00:00', '2022-06-30 21:00:00'); INSERT INTO `plugin_handle` VALUES ('1529402613204172935', '36', 'baseRetryBackoffMs', 'baseRetryBackoffMs', 1, 3, 14, '{\"required\":\"0\",\"defaultValue\":100}', '2022-06-30 21:00:00', '2022-06-30 21:00:00'); INSERT INTO `plugin_handle` VALUES ('1529402613204172936', '36', 'maxRetryBackoffMs', 'maxRetryBackoffMs', 1, 3, 15, '{\"required\":\"0\",\"defaultValue\":50000}', '2022-06-30 21:00:00', '2022-06-30 21:00:00'); -INSERT INTO `plugin_handle` VALUES ('1529402613204172742', '8', 'loadBalance', 'loadStrategy', 3, 2, 3, '{\"defaultValue\":\"roundRobin\",\"rule\":\"\"}', '2022-05-25 18:02:53', '2022-05-25 18:02:53'); INSERT INTO `plugin_handle` VALUES ('1529402613204172743', '10', 'flowRuleMaxQueueingTimeMs', 'flowRuleMaxQueueingTimeMs', 1, 2, 6, '{\"required\":\"0\",\"defaultValue\":\"500\"}', '2022-05-25 18:02:53', '2022-05-25 18:02:53'); INSERT INTO `plugin_handle` VALUES ('1529402613204172744', '10', 'flowRuleWarmUpPeriodSec', 'flowRuleWarmUpPeriodSec', 1, 2, 6, '{\"required\":\"0\",\"defaultValue\":\"10\"}', '2022-05-25 18:02:53', '2022-05-25 18:02:53'); INSERT INTO `plugin_handle` VALUES ('1529402613204172745', '14', 'addPrefixed', 'addPrefixed', 3, 2, 3, '{\"required\":\"1\",\"defaultValue\":\"false\"}', '2022-09-27 12:00:00', '2022-09-27 12:00:00'); @@ -1283,10 +1278,6 @@ INSERT INTO `plugin_handle` VALUES ('1722804548510507021', '14', 'rewriteContext INSERT INTO `plugin_handle` VALUES ('1722804548510507022', '14', 'percentage', 'percentage', 1, 2, 3, '{"required":"1","defaultValue":"100"}', '2024-02-07 14:31:49', '2024-02-07 14:31:49'); INSERT INTO `plugin_handle` VALUES ('1722804548510507023', '3', 'rewriteMetaData', 'rewriteMetaData', 3, 2, 3, '{"required":"1","defaultValue":"false"}', '2024-02-07 14:31:49', '2024-02-07 14:31:49'); -INSERT INTO `plugin_handle` VALUES ('1722804548510507024', '8', 'registerType', 'registerType', 2, 3, 1, NULL, '2024-08-24 09:40:03.293', '2024-08-24 21:52:27.920'); -INSERT INTO `plugin_handle` VALUES ('1722804548510507025', '8', 'serverLists', 'serverLists', 2, 3, 2, NULL, '2024-08-24 21:52:51.179', '2024-08-24 21:53:27.483'); -INSERT INTO `plugin_handle` VALUES ('1722804548510507026', '8', 'props', 'props', 4, 3, 3, NULL, '2024-08-24 21:53:25.764', '2024-08-24 21:53:30.255'); - -- ---------------------------- -- Table structure for resource -- ---------------------------- @@ -1398,7 +1389,6 @@ INSERT INTO `resource` VALUES ('1529402639284355094', '1346775491550474240', 'ca INSERT INTO `resource` VALUES ('1529402639284355095', '1346775491550474240', 'rateLimiter', 'rateLimiter', '/plug/rateLimiter', 'rateLimiter', 1, 0, 'key', 0, 0, '', 1, '2022-05-25 18:02:58', '2022-05-25 18:02:58'); INSERT INTO `resource` VALUES ('1529402639284355096', '1346775491550474240', 'divide', 'divide', '/plug/divide', 'divide', 1, 0, 'stop', 0, 0, '', 1, '2022-05-25 18:02:58', '2022-05-25 18:02:58'); INSERT INTO `resource` VALUES ('1529402639284355097', '1346775491550474240', 'dubbo', 'dubbo', '/plug/dubbo', 'dubbo', 1, 0, 'fire', 0, 0, '', 1, '2022-05-25 18:02:58', '2022-05-25 18:02:58'); -INSERT INTO `resource` VALUES ('1529402639284355098', '1346775491550474240', 'springCloud', 'springCloud', '/plug/springCloud', 'springCloud', 1, 0, 'border-bottom', 0, 0, '', 1, '2022-05-25 18:02:58', '2022-05-25 18:02:58'); INSERT INTO `resource` VALUES ('1529402639284355099', '1346775491550474240', 'hystrix', 'hystrix', '/plug/hystrix', 'hystrix', 1, 0, 'border-bottom', 0, 0, '', 1, '2022-05-25 18:02:58', '2022-05-25 18:02:58'); INSERT INTO `resource` VALUES ('1529402639368241152', '1529402639271772160', 'SHENYU.BUTTON.PLUGIN.SELECTOR.ADD', '', '', '', 2, 0, '', 1, 0, 'plugin:signSelector:add', 1, '2022-05-25 18:02:58', '2022-05-25 18:02:58'); INSERT INTO `resource` VALUES ('1529402639368241153', '1529402639271772160', 'SHENYU.BUTTON.PLUGIN.SELECTOR.QUERY', '', '', '', 2, 0, '', 1, 0, 'plugin:signSelector:query', 1, '2022-05-25 18:02:58', '2022-05-25 18:02:58'); @@ -1643,15 +1633,6 @@ INSERT INTO `resource` VALUES ('1529402639372435641', '1529402639284355097', 'SH INSERT INTO `resource` VALUES ('1529402639372435642', '1529402639284355097', 'SHENYU.BUTTON.PLUGIN.RULE.EDIT', '', '', '', 2, 0, '', 1, 0, 'plugin:dubboRule:edit', 1, '2022-05-25 18:02:58', '2022-05-25 18:02:58'); INSERT INTO `resource` VALUES ('1529402639372435643', '1529402639284355097', 'SHENYU.BUTTON.PLUGIN.RULE.DELETE', '', '', '', 2, 0, '', 1, 0, 'plugin:dubboRule:delete', 1, '2022-05-25 18:02:58', '2022-05-25 18:02:58'); INSERT INTO `resource` VALUES ('1529402639372435644', '1529402639284355097', 'SHENYU.BUTTON.PLUGIN.SYNCHRONIZE', '', '', '', 2, 0, '', 1, 0, 'plugin:dubbo:modify', 1, '2022-05-25 18:02:58', '2022-05-25 18:02:58'); -INSERT INTO `resource` VALUES ('1529402639372435645', '1529402639284355098', 'SHENYU.BUTTON.PLUGIN.SELECTOR.ADD', '', '', '', 2, 0, '', 1, 0, 'plugin:springCloudSelector:add', 1, '2022-05-25 18:02:58', '2022-05-25 18:02:58'); -INSERT INTO `resource` VALUES ('1529402639372435646', '1529402639284355098', 'SHENYU.BUTTON.PLUGIN.SELECTOR.QUERY', '', '', '', 2, 0, '', 1, 0, 'plugin:springCloudSelector:query', 1, '2022-05-25 18:02:58', '2022-05-25 18:02:58'); -INSERT INTO `resource` VALUES ('1529402639372435647', '1529402639284355098', 'SHENYU.BUTTON.PLUGIN.SELECTOR.EDIT', '', '', '', 2, 0, '', 1, 0, 'plugin:springCloudSelector:edit', 1, '2022-05-25 18:02:58', '2022-05-25 18:02:58'); -INSERT INTO `resource` VALUES ('1529402639372435648', '1529402639284355098', 'SHENYU.BUTTON.PLUGIN.SELECTOR.DELETE', '', '', '', 2, 0, '', 1, 0, 'plugin:springCloudSelector:delete', 1, '2022-05-25 18:02:58', '2022-05-25 18:02:58'); -INSERT INTO `resource` VALUES ('1529402639372435649', '1529402639284355098', 'SHENYU.BUTTON.PLUGIN.RULE.ADD', '', '', '', 2, 0, '', 1, 0, 'plugin:springCloudRule:add', 1, '2022-05-25 18:02:58', '2022-05-25 18:02:58'); -INSERT INTO `resource` VALUES ('1529402639372435650', '1529402639284355098', 'SHENYU.BUTTON.PLUGIN.RULE.QUERY', '', '', '', 2, 0, '', 1, 0, 'plugin:springCloudRule:query', 1, '2022-05-25 18:02:58', '2022-05-25 18:02:58'); -INSERT INTO `resource` VALUES ('1529402639372435651', '1529402639284355098', 'SHENYU.BUTTON.PLUGIN.RULE.EDIT', '', '', '', 2, 0, '', 1, 0, 'plugin:springCloudRule:edit', 1, '2022-05-25 18:02:58', '2022-05-25 18:02:58'); -INSERT INTO `resource` VALUES ('1529402639372435652', '1529402639284355098', 'SHENYU.BUTTON.PLUGIN.RULE.DELETE', '', '', '', 2, 0, '', 1, 0, 'plugin:springCloudRule:delete', 1, '2022-05-25 18:02:58', '2022-05-25 18:02:58'); -INSERT INTO `resource` VALUES ('1529402639372435653', '1529402639284355098', 'SHENYU.BUTTON.PLUGIN.SYNCHRONIZE', '', '', '', 2, 0, '', 1, 0, 'plugin:springCloud:modify', 1, '2022-05-25 18:02:58', '2022-05-25 18:02:58'); INSERT INTO `resource` VALUES ('1529402639372435654', '1529402639284355099', 'SHENYU.BUTTON.PLUGIN.SELECTOR.ADD', '', '', '', 2, 0, '', 1, 0, 'plugin:hystrixSelector:add', 1, '2022-05-25 18:02:58', '2022-05-25 18:02:58'); INSERT INTO `resource` VALUES ('1529402639372435655', '1529402639284355099', 'SHENYU.BUTTON.PLUGIN.SELECTOR.QUERY', '', '', '', 2, 0, '', 1, 0, 'plugin:hystrixSelector:query', 1, '2022-05-25 18:02:58', '2022-05-25 18:02:58'); INSERT INTO `resource` VALUES ('1529402639372435656', '1529402639284355099', 'SHENYU.BUTTON.PLUGIN.SELECTOR.EDIT', '', '', '', 2, 0, '', 1, 0, 'plugin:hystrixSelector:edit', 1, '2022-05-25 18:02:58', '2022-05-25 18:02:58'); @@ -2359,7 +2340,6 @@ INSERT INTO `namespace_plugin_rel` (`id`,`namespace_id`,`plugin_id`, `config`, ` INSERT INTO `namespace_plugin_rel` (`id`,`namespace_id`,`plugin_id`, `config`, `sort`, `enabled`, `date_created`, `date_updated`) VALUES ('1801816010882822182','649330b6-c2d7-4edc-be8e-8a54df9eb385','45', '{\"host\":\"127.0.0.1\",\"port\":5672,\"password\":\"admin\",\"username\":\"admin\",\"exchangeName\":\"exchange.logging.plugin\",\"queueName\":\"queue.logging.plugin\",\"routingKey\":\"topic.logging\",\"virtualHost\":\"/\",\"exchangeType\":\"direct\",\"durable\":\"true\",\"exclusive\":\"false\",\"autoDelete\":\"false\"}', 171, 0, '2023-11-06 15:49:56.454', '2023-11-10 10:40:58.447'); INSERT INTO `namespace_plugin_rel` (`id`,`namespace_id`,`plugin_id`, `config`, `sort`, `enabled`, `date_created`, `date_updated`) VALUES ('1801816010882822183','649330b6-c2d7-4edc-be8e-8a54df9eb385','5', '{\"multiSelectorHandle\":\"1\",\"multiRuleHandle\":\"0\"}', 200, 1, '2022-05-25 18:02:53.000', '2022-05-25 18:02:53.000'); INSERT INTO `namespace_plugin_rel` (`id`,`namespace_id`,`plugin_id`, `config`, `sort`, `enabled`, `date_created`, `date_updated`) VALUES ('1801816010882822184','649330b6-c2d7-4edc-be8e-8a54df9eb385','6', '{\"register\":\"zookeeper://localhost:2181\",\"multiSelectorHandle\":\"1\",\"threadpool\":\"shared\",\"corethreads\":0,\"threads\":2147483647,\"queues\":0}', 310, 0, '2022-05-25 18:02:53.000', '2022-05-25 18:02:53.000'); -INSERT INTO `namespace_plugin_rel` (`id`,`namespace_id`,`plugin_id`, `config`, `sort`, `enabled`, `date_created`, `date_updated`) VALUES ('1801816010882822185','649330b6-c2d7-4edc-be8e-8a54df9eb385','8', '{\"enabled\":false,\"registerType\":\"eureka\",\"serverLists\":\"http://localhost:8761/eureka\",\"props\": {}}', 200, 0, '2022-05-25 18:02:53.000', '2022-05-25 18:02:53.000'); INSERT INTO `namespace_plugin_rel` (`id`,`namespace_id`,`plugin_id`, `config`, `sort`, `enabled`, `date_created`, `date_updated`) VALUES ('1801816010882822186','649330b6-c2d7-4edc-be8e-8a54df9eb385','9', NULL, 130, 0, '2022-05-25 18:02:53.000', '2022-05-25 18:02:53.000'); diff --git a/db/init/og/create-table.sql b/db/init/og/create-table.sql index 74576c5ecfd8..8434cb32492e 100644 --- a/db/init/og/create-table.sql +++ b/db/init/og/create-table.sql @@ -79,7 +79,7 @@ COMMENT ON COLUMN "public"."api"."http_method" IS '0-get,1-head,2-post,3-put,4-p COMMENT ON COLUMN "public"."api"."consume" IS 'consume content-type'; COMMENT ON COLUMN "public"."api"."produce" IS 'produce content-type'; COMMENT ON COLUMN "public"."api"."version" IS 'api version,for example V0.01'; -COMMENT ON COLUMN "public"."api"."rpc_type" IS 'http,dubbo,sofa,tars,websocket,springCloud,motan,grpc'; +COMMENT ON COLUMN "public"."api"."rpc_type" IS 'http,dubbo,sofa,tars,websocket,motan,grpc'; COMMENT ON COLUMN "public"."api"."state" IS '0-unpublished,1-published,2-offline'; COMMENT ON COLUMN "public"."api"."ext" IS 'extended fields'; COMMENT ON COLUMN "public"."api"."api_owner" IS 'api_owner'; @@ -969,7 +969,6 @@ INSERT INTO "public"."plugin" VALUES ('3', 'rewrite', NULL, 'HttpProcess', 90, 0 INSERT INTO "public"."plugin" VALUES ('4', 'rateLimiter', '{"master":"mymaster","mode":"standalone","url":"192.168.1.1:6379","password":"abc"}', 'FaultTolerance', 60, 0, '2022-05-25 18:08:01', '2022-05-25 18:08:01', null); INSERT INTO "public"."plugin" VALUES ('5', 'divide', '{"multiSelectorHandle":"1","multiRuleHandle":"0"}', 'Proxy', 200, 1, '2022-05-25 18:08:01', '2022-05-25 18:08:01', null); INSERT INTO "public"."plugin" VALUES ('6', 'dubbo', '{"register":"zookeeper://localhost:2181","multiSelectorHandle":"1","threadpool":"shared","corethreads":0,"threads":2147483647,"queues":0}', 'Proxy', 310, 0, '2022-05-25 18:08:01', '2022-05-25 18:08:01', null); -INSERT INTO "public"."plugin" VALUES ('8', 'springCloud', NULL, 'Proxy', 200, 0, '2022-05-25 18:08:01', '2022-05-25 18:08:01', null); INSERT INTO "public"."plugin" VALUES ('9', 'hystrix', NULL, 'FaultTolerance', 130, 0, '2022-05-25 18:08:01', '2022-05-25 18:08:01', null); INSERT INTO "public"."plugin" VALUES ('27', 'generalContext', NULL, 'Common', 125, 0, '2022-05-25 18:08:01', '2022-05-25 18:08:01', null); INSERT INTO "public"."plugin" VALUES ('28', 'mqtt', '{"port": 9500,"bossGroupThreadCount": 1,"maxPayloadSize": 65536,"workerGroupThreadCount": 12,"userName": "shenyu","password": "shenyu","isEncryptPassword": false,"encryptMode": "","leakDetectorLevel": "DISABLED"}', 'Proxy', 125, 0, '2022-05-25 18:08:01', '2022-05-25 18:08:01', null); @@ -1039,9 +1038,6 @@ INSERT INTO "public"."plugin_handle" VALUES ('1529403902775136266', '3', 'regex' INSERT INTO "public"."plugin_handle" VALUES ('1529403902775136267', '3', 'replace', 'replace', 2, 2, 2, NULL, '2022-05-25 18:08:01', '2022-05-25 18:08:01'); INSERT INTO "public"."plugin_handle" VALUES ('1697146860569596304', '3', 'percentage', 'percentage', 1, 2, 3, NULL, '2023-09-15 20:25:53', '2023-09-15 20:25:53'); INSERT INTO "public"."plugin_handle" VALUES ('1529403902775136268', '16', 'redirectURI', 'redirectURI', 2, 2, 1, NULL, '2022-05-25 18:08:01', '2022-05-25 18:08:01'); -INSERT INTO "public"."plugin_handle" VALUES ('1529403902775136269', '8', 'path', 'path', 2, 2, 1, NULL, '2022-05-25 18:08:01', '2022-05-25 18:08:01'); -INSERT INTO "public"."plugin_handle" VALUES ('1529403902775136270', '8', 'timeout', 'timeout ms)', 1, 2, 2, NULL, '2022-05-25 18:08:01', '2022-05-25 18:08:01'); -INSERT INTO "public"."plugin_handle" VALUES ('1529403902775136271', '8', 'serviceId', 'serviceId', 2, 1, 1, NULL, '2022-05-25 18:08:01', '2022-05-25 18:08:01'); INSERT INTO "public"."plugin_handle" VALUES ('1529403902775136272', '12', 'timeoutDurationRate', 'timeoutDurationRate ms)', 1, 2, 1, '{"required":"1","defaultValue":"5000","rule":""}', '2022-05-25 18:08:01', '2022-05-25 18:08:01'); INSERT INTO "public"."plugin_handle" VALUES ('1529403902775136273', '12', 'limitRefreshPeriod', 'limitRefreshPeriod ms)', 1, 2, 0, '{"required":"1","defaultValue":"500","rule":""}', '2022-05-25 18:08:01', '2022-05-25 18:08:01'); INSERT INTO "public"."plugin_handle" VALUES ('1529403902775136274', '12', 'limitForPeriod', 'limitForPeriod', 1, 2, 0, '{"required":"1","defaultValue":"50","rule":""}', '2022-05-25 18:08:01', '2022-05-25 18:08:01'); @@ -1257,7 +1253,6 @@ INSERT INTO "public"."plugin_handle" VALUES ('1529403902783524999', '38', 'datab INSERT INTO "public"."plugin_handle" VALUES ('1529402613204172800', '38', 'username', 'username', 2, 2, 0, '{"required":"0","defaultValue":"foo","placeholder":"username"}', '2022-06-30 21:00:00', '2022-06-30 21:00:00'); INSERT INTO "public"."plugin_handle" VALUES ('1529402613204172801', '38', 'password', 'password', 2, 2, 0, '{"required":"0","defaultValue":"bar","placeholder":"password"}', '2022-06-30 21:00:00', '2022-06-30 21:00:00'); INSERT INTO "public"."plugin_handle" VALUES ('1529402613204172777', '38', 'ttl', 'ttl', 3, 3, 10, '{"required":"0","defaultValue":"30"}', '2023-03-01 11:14:15', '2023-08-16 11:15:14'); -INSERT INTO "public"."plugin_handle" VALUES ('1529402613204172802', '8', 'loadBalance', 'loadStrategy', 3, 2, 3, '{"defaultValue":"roundRobin","rule":""}', '2022-06-30 21:00:00', '2022-06-30 21:00:00'); INSERT INTO "public"."plugin_handle" VALUES ('1529402613204172803', '10', 'flowRuleMaxQueueingTimeMs', 'flowRuleMaxQueueingTimeMs', 1, 2, 6, '{"required":"0","defaultValue":"500"}', '2022-06-30 21:00:00', '2022-06-30 21:00:00'); INSERT INTO "public"."plugin_handle" VALUES ('1529402613204172804', '10', 'flowRuleWarmUpPeriodSec', 'flowRuleWarmUpPeriodSec', 1, 2, 6, '{"required":"0","defaultValue":"10"}', '2022-06-30 21:00:00', '2022-06-30 21:00:00'); INSERT INTO "public"."plugin_handle" VALUES ('1529402613204172805', '14', 'addPrefixed', 'addPrefixed', 3, 2, 3, '{"required":"1","defaultValue":"false"}', '2022-09-27 12:00:00', '2022-09-27 12:00:00'); @@ -1367,9 +1362,6 @@ INSERT INTO "public"."plugin_handle" VALUES ('1722804548510507021', '14', 'rewri INSERT INTO "public"."plugin_handle" VALUES ('1722804548510507022', '14', 'percentage', 'percentage', 1, 2, 3, '{"required":"1","defaultValue":"100"}', '2024-02-07 14:31:49', '2024-02-07 14:31:49'); INSERT INTO "public"."plugin_handle" VALUES ('1722804548510507023', '3', 'rewriteMetaData', 'rewriteMetaData', 3, 2, 3, '{"required":"1","defaultValue":"false"}', '2024-02-07 14:31:49', '2024-02-07 14:31:49'); -INSERT INTO "public"."plugin_handle" VALUES ('1722804548510507024', '8', 'registerType', 'registerType', 2, 3, 1, NULL, '2024-08-24 09:40:03.293', '2024-08-24 21:52:27.920'); -INSERT INTO "public"."plugin_handle" VALUES ('1722804548510507025', '8', 'serverLists', 'serverLists', 2, 3, 2, NULL, '2024-08-24 21:52:51.179', '2024-08-24 21:53:27.483'); -INSERT INTO "public"."plugin_handle" VALUES ('1722804548510507026', '8', 'props', 'props', 4, 3, 3, NULL, '2024-08-24 21:53:25.764', '2024-08-24 21:53:30.255'); -- ---------------------------- -- Table structure for resource @@ -1494,7 +1486,6 @@ INSERT INTO "public"."resource" VALUES ('1529403932781187090', '1346775491550474 INSERT INTO "public"."resource" VALUES ('1529403932781187091', '1346775491550474240', 'rateLimiter', 'rateLimiter', '/plug/rateLimiter', 'rateLimiter', 1, 0, 'pic-center', 0, 0, '', 1, '2022-05-25 18:08:07', '2022-05-25 18:08:07'); INSERT INTO "public"."resource" VALUES ('1529403932781187092', '1346775491550474240', 'divide', 'divide', '/plug/divide', 'divide', 1, 0, 'block', 0, 0, '', 1, '2022-05-25 18:08:07', '2022-05-25 18:08:07'); INSERT INTO "public"."resource" VALUES ('1529403932781187093', '1346775491550474240', 'dubbo', 'dubbo', '/plug/dubbo', 'dubbo', 1, 0, 'align-left', 0, 0, '', 1, '2022-05-25 18:08:07', '2022-05-25 18:08:07'); -INSERT INTO "public"."resource" VALUES ('1529403932781187094', '1346775491550474240', 'springCloud', 'springCloud', '/plug/springCloud', 'springCloud', 1, 0, 'stop', 0, 0, '', 1, '2022-05-25 18:08:07', '2022-05-25 18:08:07'); INSERT INTO "public"."resource" VALUES ('1529403932781187095', '1346775491550474240', 'hystrix', 'hystrix', '/plug/hystrix', 'hystrix', 1, 0, 'fire', 0, 0, '', 1, '2022-05-25 18:08:07', '2022-05-25 18:08:07'); INSERT INTO "public"."resource" VALUES ('1529403932781187096', '1346775491550474240', 'generalContext', 'generalContext', '/plug/generalContext', 'generalContext', 1, 0, 'highlight', 0, 0, '', 1, '2022-05-25 18:08:07', '2022-05-25 18:08:07'); INSERT INTO "public"."resource" VALUES ('1529403932781187097', '1346775491550474240', 'mqtt', 'mqtt', '/plug/mqtt', 'mqtt', 1, 0, 'database', 0, 0, '', 1, '2022-05-25 18:08:07', '2022-05-25 18:08:07'); @@ -1707,15 +1698,6 @@ INSERT INTO "public"."resource" VALUES ('1529403932881850454', '1529403932781187 INSERT INTO "public"."resource" VALUES ('1529403932881850455', '1529403932781187093', 'SHENYU.BUTTON.PLUGIN.RULE.EDIT', '', '', '', 2, 0, '', 1, 0, 'plugin:dubboRule:edit', 1, '2022-05-25 18:08:07', '2022-05-25 18:08:07'); INSERT INTO "public"."resource" VALUES ('1529403932881850456', '1529403932781187093', 'SHENYU.BUTTON.PLUGIN.RULE.DELETE', '', '', '', 2, 0, '', 1, 0, 'plugin:dubboRule:delete', 1, '2022-05-25 18:08:07', '2022-05-25 18:08:07'); INSERT INTO "public"."resource" VALUES ('1529403932881850457', '1529403932781187093', 'SHENYU.BUTTON.PLUGIN.SYNCHRONIZE', '', '', '', 2, 0, '', 1, 0, 'plugin:dubbo:modify', 1, '2022-05-25 18:08:07', '2022-05-25 18:08:07'); -INSERT INTO "public"."resource" VALUES ('1529403932881850458', '1529403932781187094', 'SHENYU.BUTTON.PLUGIN.SELECTOR.ADD', '', '', '', 2, 0, '', 1, 0, 'plugin:springCloudSelector:add', 1, '2022-05-25 18:08:07', '2022-05-25 18:08:07'); -INSERT INTO "public"."resource" VALUES ('1529403932881850459', '1529403932781187094', 'SHENYU.BUTTON.PLUGIN.SELECTOR.QUERY', '', '', '', 2, 0, '', 1, 0, 'plugin:springCloudSelector:query', 1, '2022-05-25 18:08:07', '2022-05-25 18:08:07'); -INSERT INTO "public"."resource" VALUES ('1529403932881850460', '1529403932781187094', 'SHENYU.BUTTON.PLUGIN.SELECTOR.EDIT', '', '', '', 2, 0, '', 1, 0, 'plugin:springCloudSelector:edit', 1, '2022-05-25 18:08:07', '2022-05-25 18:08:07'); -INSERT INTO "public"."resource" VALUES ('1529403932881850461', '1529403932781187094', 'SHENYU.BUTTON.PLUGIN.SELECTOR.DELETE', '', '', '', 2, 0, '', 1, 0, 'plugin:springCloudSelector:delete', 1, '2022-05-25 18:08:07', '2022-05-25 18:08:07'); -INSERT INTO "public"."resource" VALUES ('1529403932881850462', '1529403932781187094', 'SHENYU.BUTTON.PLUGIN.RULE.ADD', '', '', '', 2, 0, '', 1, 0, 'plugin:springCloudRule:add', 1, '2022-05-25 18:08:07', '2022-05-25 18:08:07'); -INSERT INTO "public"."resource" VALUES ('1529403932881850463', '1529403932781187094', 'SHENYU.BUTTON.PLUGIN.RULE.QUERY', '', '', '', 2, 0, '', 1, 0, 'plugin:springCloudRule:query', 1, '2022-05-25 18:08:07', '2022-05-25 18:08:07'); -INSERT INTO "public"."resource" VALUES ('1529403932881850464', '1529403932781187094', 'SHENYU.BUTTON.PLUGIN.RULE.EDIT', '', '', '', 2, 0, '', 1, 0, 'plugin:springCloudRule:edit', 1, '2022-05-25 18:08:07', '2022-05-25 18:08:07'); -INSERT INTO "public"."resource" VALUES ('1529403932881850465', '1529403932781187094', 'SHENYU.BUTTON.PLUGIN.RULE.DELETE', '', '', '', 2, 0, '', 1, 0, 'plugin:springCloudRule:delete', 1, '2022-05-25 18:08:07', '2022-05-25 18:08:07'); -INSERT INTO "public"."resource" VALUES ('1529403932881850466', '1529403932781187094', 'SHENYU.BUTTON.PLUGIN.SYNCHRONIZE', '', '', '', 2, 0, '', 1, 0, 'plugin:springCloud:modify', 1, '2022-05-25 18:08:07', '2022-05-25 18:08:07'); INSERT INTO "public"."resource" VALUES ('1529403932881850467', '1529403932781187095', 'SHENYU.BUTTON.PLUGIN.SELECTOR.ADD', '', '', '', 2, 0, '', 1, 0, 'plugin:hystrixSelector:add', 1, '2022-05-25 18:08:07', '2022-05-25 18:08:07'); INSERT INTO "public"."resource" VALUES ('1529403932881850468', '1529403932781187095', 'SHENYU.BUTTON.PLUGIN.SELECTOR.QUERY', '', '', '', 2, 0, '', 1, 0, 'plugin:hystrixSelector:query', 1, '2022-05-25 18:08:07', '2022-05-25 18:08:07'); INSERT INTO "public"."resource" VALUES ('1529403932881850469', '1529403932781187095', 'SHENYU.BUTTON.PLUGIN.SELECTOR.EDIT', '', '', '', 2, 0, '', 1, 0, 'plugin:hystrixSelector:edit', 1, '2022-05-25 18:08:07', '2022-05-25 18:08:07'); @@ -2680,7 +2662,6 @@ INSERT INTO "public"."namespace_plugin_rel" VALUES ('1801816010882822181','64933 INSERT INTO "public"."namespace_plugin_rel" VALUES ('1801816010882822182','649330b6-c2d7-4edc-be8e-8a54df9eb385','45', '{"host":"127.0.0.1","port":5672,"password":"admin","username":"admin","exchangeName":"exchange.logging.plugin","queueName":"queue.logging.plugin","routingKey":"topic.logging","virtualHost":"/","exchangeType":"direct","durable":"true","exclusive":"false","autoDelete":"false"}', 171, 0, '2023-11-06 15:49:56.454', '2023-11-10 10:40:58.447'); INSERT INTO "public"."namespace_plugin_rel" VALUES ('1801816010882822183','649330b6-c2d7-4edc-be8e-8a54df9eb385','5', '{"multiSelectorHandle":"1","multiRuleHandle":"0"}', 200, 1, '2022-05-25 18:02:53.000', '2022-05-25 18:02:53.000'); INSERT INTO "public"."namespace_plugin_rel" VALUES ('1801816010882822184','649330b6-c2d7-4edc-be8e-8a54df9eb385','6', '{"register":"zookeeper://localhost:2181","multiSelectorHandle":"1","threadpool":"shared","corethreads":0,"threads":2147483647,"queues":0}', 310, 0, '2022-05-25 18:02:53.000', '2022-05-25 18:02:53.000'); -INSERT INTO "public"."namespace_plugin_rel" VALUES ('1801816010882822185','649330b6-c2d7-4edc-be8e-8a54df9eb385','8', '{"enabled":false,"registerType":"eureka","serverLists":"http://localhost:8761/eureka","props":{}}', 200, 0, '2022-05-25 18:02:53.000', '2022-05-25 18:02:53.000'); INSERT INTO "public"."namespace_plugin_rel" VALUES ('1801816010882822186','649330b6-c2d7-4edc-be8e-8a54df9eb385','9', NULL, 130, 0, '2022-05-25 18:02:53.000', '2022-05-25 18:02:53.000'); diff --git a/db/init/oracle/schema.sql b/db/init/oracle/schema.sql index 1ec2dde1cfaf..c64d0f891f26 100644 --- a/db/init/oracle/schema.sql +++ b/db/init/oracle/schema.sql @@ -439,7 +439,7 @@ comment on column API.produce comment on column API.version is 'api version,for example V0.01'; comment on column API.rpc_type - is 'http,dubbo,sofa,tars,websocket,springCloud,motan,grpc'; + is 'http,dubbo,sofa,tars,websocket,motan,grpc'; comment on column API.state is '0-unpublished,1-published,2-offline'; comment on column API.ext @@ -1133,7 +1133,6 @@ INSERT /*+ IGNORE_ROW_ON_DUPKEY_INDEX(plugin(id)) */ INTO plugin (id, name, role INSERT /*+ IGNORE_ROW_ON_DUPKEY_INDEX(plugin(id)) */ INTO plugin (id, name, role, sort, config,enabled) VALUES ('4','rateLimiter','FaultTolerance', 60,'{"master":"mymaster","mode":"standalone","url":"192.168.1.1:6379","password":"abc"}', '0'); INSERT /*+ IGNORE_ROW_ON_DUPKEY_INDEX(plugin(id)) */ INTO plugin (id, name, role, sort, config,enabled) VALUES ('5','divide', 'Proxy', 200,'{"multiSelectorHandle":"1","multiRuleHandle":"0"}','1'); INSERT /*+ IGNORE_ROW_ON_DUPKEY_INDEX(plugin(id)) */ INTO plugin (id, name, role, sort, config,enabled) VALUES ('6','dubbo','Proxy', 310,'{"register":"zookeeper://localhost:2181","multiSelectorHandle":"1","threadpool":"shared","corethreads":0,"threads":2147483647,"queues":0}', '0'); -INSERT /*+ IGNORE_ROW_ON_DUPKEY_INDEX(plugin(id)) */ INTO plugin (id, name, role, sort, enabled) VALUES ('8','springCloud','Proxy', 200, '0'); INSERT /*+ IGNORE_ROW_ON_DUPKEY_INDEX(plugin(id)) */ INTO plugin (id, name, role, sort, enabled) VALUES ('9','hystrix', 'FaultTolerance', 130,'0'); INSERT /*+ IGNORE_ROW_ON_DUPKEY_INDEX(plugin(id)) */ INTO plugin (id, name, role, sort, enabled) VALUES ('10','sentinel', 'FaultTolerance', 140,'0'); INSERT /*+ IGNORE_ROW_ON_DUPKEY_INDEX(plugin(id)) */ INTO plugin (id, name, role, sort, config, enabled) VALUES ('11','sofa', 'Proxy', 310, '{"protocol":"zookeeper","register":"127.0.0.1:2181","threadpool":"shared"}', '0'); @@ -1413,15 +1412,6 @@ VALUES ('1697146860569596304', '3', 'percentage', 'percentage', 1, 2, 3, null); 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 ('1518229897210273804', '16', 'redirectURI', 'redirectURI', 2, 2, 1, null); -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 ('1518229897210273805', '8', 'path', 'path', 2, 2, 1, null); - -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 ('1518229897210273806', '8', 'timeout', 'timeout ms)', 1, 2, 2, null); - -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 ('1518229897210273807', '8', 'serviceId', 'serviceId', 2, 1, 1, null); - 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 ('1518229897210273808', '12', 'timeoutDurationRate', 'timeoutDurationRate ms)', 1, 2, 1, '{"required":"1","defaultValue":"5000","rule":""}'); @@ -1864,9 +1854,6 @@ values ('1518229897214468226', '38', 'username', 'username', 2, 2, 0, '{"require 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 ('1518229897214468227', '38', 'password', 'password', 2, 2, 0, '{"required":"0","defaultValue":"bar","placeholder":"password"}'); -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 ('1518229897214468228', '8', 'loadBalance', 'loadStrategy', 3, 2, 3, '{"defaultValue":"roundRobin","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 ('1518229897214468229', '10', 'flowRuleMaxQueueingTimeMs', 'flowRuleMaxQueueingTimeMs', 1, 2, 6, '{"required":"0","defaultValue":"500"}'); @@ -2167,15 +2154,6 @@ values ('1722804548510507022', '14', 'percentage', 'percentage', 1, 2, 3, '{"req 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 ('1722804548510507023', '3', 'rewriteMetaData', 'rewriteMetaData', 3, 2, 3, '{"required":"1","defaultValue":"false"}'); -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 ('1722804548510507024', '8', 'registerType', 'registerType', 2, 3, 1, NULL); - -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 ('1722804548510507025', '8', 'serverLists', 'serverLists', 2, 3, 2, NULL); - -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 ('1722804548510507026', '8', 'props', 'props', 4, 3, 3, NULL); - insert /*+ IGNORE_ROW_ON_DUPKEY_INDEX(shenyu_dict(type, dict_code, dict_name)) */ into SHENYU_DICT (ID, TYPE, DICT_CODE, DICT_NAME, DICT_VALUE, "desc", SORT, ENABLED) VALUES ('1529402613195784272', 'securityProtocol', 'SECURITY_PROTOCOL', 'PLAINTEXT', 'PLAINTEXT', '', 1, 1); @@ -2880,7 +2858,6 @@ INSERT /*+ IGNORE_ROW_ON_DUPKEY_INDEX (namespace_plugin_rel(id)) */ INTO namespa INSERT /*+ IGNORE_ROW_ON_DUPKEY_INDEX (namespace_plugin_rel(id)) */ INTO namespace_plugin_rel (id,namespace_id,plugin_id, config, sort, enabled) VALUES ('1801816010882822182','649330b6-c2d7-4edc-be8e-8a54df9eb385','45', '{"host":"127.0.0.1","port":5672,"password":"admin","username":"admin","exchangeName":"exchange.logging.plugin","queueName":"queue.logging.plugin","routingKey":"topic.logging","virtualHost":"/","exchangeType":"direct","durable":"true","exclusive":"false","autoDelete":"false"}', 171, 0); INSERT /*+ IGNORE_ROW_ON_DUPKEY_INDEX (namespace_plugin_rel(id)) */ INTO namespace_plugin_rel (id,namespace_id,plugin_id, config, sort, enabled) VALUES ('1801816010882822183','649330b6-c2d7-4edc-be8e-8a54df9eb385','5', '{"multiSelectorHandle":"1","multiRuleHandle":"0"}', 200, 1); INSERT /*+ IGNORE_ROW_ON_DUPKEY_INDEX (namespace_plugin_rel(id)) */ INTO namespace_plugin_rel (id,namespace_id,plugin_id, config, sort, enabled) VALUES ('1801816010882822184','649330b6-c2d7-4edc-be8e-8a54df9eb385','6', '{"register":"zookeeper://localhost:2181","multiSelectorHandle":"1","threadpool":"shared","corethreads":0,"threads":2147483647,"queues":0}', 310, 0); -INSERT /*+ IGNORE_ROW_ON_DUPKEY_INDEX (namespace_plugin_rel(id)) */ INTO namespace_plugin_rel (id,namespace_id,plugin_id, config, sort, enabled) VALUES ('1801816010882822185','649330b6-c2d7-4edc-be8e-8a54df9eb385','8', '{"enabled":false,"registerType":"eureka","serverLists":"http://localhost:8761/eureka","props":{}}', 200, 0); INSERT /*+ IGNORE_ROW_ON_DUPKEY_INDEX (namespace_plugin_rel(id)) */ INTO namespace_plugin_rel (id,namespace_id,plugin_id, config, sort, enabled) VALUES ('1801816010882822186','649330b6-c2d7-4edc-be8e-8a54df9eb385','9', NULL, 130, 0); diff --git a/db/init/pg/create-table.sql b/db/init/pg/create-table.sql index 8d4ba5008f9f..35744c3df93d 100644 --- a/db/init/pg/create-table.sql +++ b/db/init/pg/create-table.sql @@ -79,7 +79,7 @@ COMMENT ON COLUMN "public"."api"."http_method" IS '0-get,1-head,2-post,3-put,4-p COMMENT ON COLUMN "public"."api"."consume" IS 'consume content-type'; COMMENT ON COLUMN "public"."api"."produce" IS 'produce content-type'; COMMENT ON COLUMN "public"."api"."version" IS 'api version,for example V0.01'; -COMMENT ON COLUMN "public"."api"."rpc_type" IS 'http,dubbo,sofa,tars,websocket,springCloud,motan,grpc'; +COMMENT ON COLUMN "public"."api"."rpc_type" IS 'http,dubbo,sofa,tars,websocket,motan,grpc'; COMMENT ON COLUMN "public"."api"."state" IS '0-unpublished,1-published,2-offline'; COMMENT ON COLUMN "public"."api"."ext" IS 'extended fields'; COMMENT ON COLUMN "public"."api"."api_owner" IS 'api_owner'; @@ -1030,7 +1030,6 @@ INSERT INTO "public"."plugin" VALUES ('3', 'rewrite', NULL, 'HttpProcess', 90, 0 INSERT INTO "public"."plugin" VALUES ('4', 'rateLimiter', '{"master":"mymaster","mode":"standalone","url":"192.168.1.1:6379","password":"abc"}', 'FaultTolerance', 60, 0, '2022-05-25 18:08:01', '2022-05-25 18:08:01', null); INSERT INTO "public"."plugin" VALUES ('5', 'divide', '{"multiSelectorHandle":"1","multiRuleHandle":"0"}', 'Proxy', 200, 1, '2022-05-25 18:08:01', '2022-05-25 18:08:01', null); INSERT INTO "public"."plugin" VALUES ('6', 'dubbo', '{"register":"zookeeper://localhost:2181","multiSelectorHandle":"1","threadpool":"shared","corethreads":0,"threads":2147483647,"queues":0}', 'Proxy', 310, 0, '2022-05-25 18:08:01', '2022-05-25 18:08:01', null); -INSERT INTO "public"."plugin" VALUES ('8', 'springCloud', NULL, 'Proxy', 200, 0, '2022-05-25 18:08:01', '2022-05-25 18:08:01', null); INSERT INTO "public"."plugin" VALUES ('9', 'hystrix', NULL, 'FaultTolerance', 130, 0, '2022-05-25 18:08:01', '2022-05-25 18:08:01', null); INSERT INTO "public"."plugin" VALUES ('27', 'generalContext', NULL, 'Common', 125, 0, '2022-05-25 18:08:01', '2022-05-25 18:08:01', null); INSERT INTO "public"."plugin" VALUES ('28', 'mqtt', '{"port": 9500,"bossGroupThreadCount": 1,"maxPayloadSize": 65536,"workerGroupThreadCount": 12,"userName": "shenyu","password": "shenyu","isEncryptPassword": false,"encryptMode": "","leakDetectorLevel": "DISABLED"}', 'Proxy', 125, 0, '2022-05-25 18:08:01', '2022-05-25 18:08:01', null); @@ -1099,9 +1098,6 @@ INSERT INTO "public"."plugin_handle" VALUES ('1529403902775136266', '3', 'regex' INSERT INTO "public"."plugin_handle" VALUES ('1529403902775136267', '3', 'replace', 'replace', 2, 2, 2, NULL, '2022-05-25 18:08:01', '2022-05-25 18:08:01'); INSERT INTO "public"."plugin_handle" VALUES ('1697146860569596304', '3', 'percentage', 'percentage', 1, 2, 3, NULL, '2023-09-15 20:25:53', '2023-09-15 20:25:53'); INSERT INTO "public"."plugin_handle" VALUES ('1529403902775136268', '16', 'redirectURI', 'redirectURI', 2, 2, 1, NULL, '2022-05-25 18:08:01', '2022-05-25 18:08:01'); -INSERT INTO "public"."plugin_handle" VALUES ('1529403902775136269', '8', 'path', 'path', 2, 2, 1, NULL, '2022-05-25 18:08:01', '2022-05-25 18:08:01'); -INSERT INTO "public"."plugin_handle" VALUES ('1529403902775136270', '8', 'timeout', 'timeout ms)', 1, 2, 2, NULL, '2022-05-25 18:08:01', '2022-05-25 18:08:01'); -INSERT INTO "public"."plugin_handle" VALUES ('1529403902775136271', '8', 'serviceId', 'serviceId', 2, 1, 1, NULL, '2022-05-25 18:08:01', '2022-05-25 18:08:01'); INSERT INTO "public"."plugin_handle" VALUES ('1529403902775136272', '12', 'timeoutDurationRate', 'timeoutDurationRate ms)', 1, 2, 1, '{"required":"1","defaultValue":"5000","rule":""}', '2022-05-25 18:08:01', '2022-05-25 18:08:01'); INSERT INTO "public"."plugin_handle" VALUES ('1529403902775136273', '12', 'limitRefreshPeriod', 'limitRefreshPeriod ms)', 1, 2, 0, '{"required":"1","defaultValue":"500","rule":""}', '2022-05-25 18:08:01', '2022-05-25 18:08:01'); INSERT INTO "public"."plugin_handle" VALUES ('1529403902775136274', '12', 'limitForPeriod', 'limitForPeriod', 1, 2, 0, '{"required":"1","defaultValue":"50","rule":""}', '2022-05-25 18:08:01', '2022-05-25 18:08:01'); @@ -1315,7 +1311,6 @@ INSERT INTO "public"."plugin_handle" VALUES ('1529403902783524998', '38', 'port' INSERT INTO "public"."plugin_handle" VALUES ('1529403902783524999', '38', 'database', 'database', 2, 2, 0, '{"required":"0","defaultValue":"shenyu-gateway","placeholder":"database"}', '2022-06-30 21:00:00', '2022-06-30 21:00:00'); INSERT INTO "public"."plugin_handle" VALUES ('1529402613204172800', '38', 'username', 'username', 2, 2, 0, '{"required":"0","defaultValue":"foo","placeholder":"username"}', '2022-06-30 21:00:00', '2022-06-30 21:00:00'); INSERT INTO "public"."plugin_handle" VALUES ('1529402613204172801', '38', 'password', 'password', 2, 2, 0, '{"required":"0","defaultValue":"bar","placeholder":"password"}', '2022-06-30 21:00:00', '2022-06-30 21:00:00'); -INSERT INTO "public"."plugin_handle" VALUES ('1529402613204172802', '8', 'loadBalance', 'loadStrategy', 3, 2, 3, '{"defaultValue":"roundRobin","rule":""}', '2022-06-30 21:00:00', '2022-06-30 21:00:00'); INSERT INTO "public"."plugin_handle" VALUES ('1529402613204172803', '10', 'flowRuleMaxQueueingTimeMs', 'flowRuleMaxQueueingTimeMs', 1, 2, 6, '{"required":"0","defaultValue":"500"}', '2022-06-30 21:00:00', '2022-06-30 21:00:00'); INSERT INTO "public"."plugin_handle" VALUES ('1529402613204172804', '10', 'flowRuleWarmUpPeriodSec', 'flowRuleWarmUpPeriodSec', 1, 2, 6, '{"required":"0","defaultValue":"10"}', '2022-06-30 21:00:00', '2022-06-30 21:00:00'); INSERT INTO "public"."plugin_handle" VALUES ('1529402613204172805', '14', 'addPrefixed', 'addPrefixed', 3, 2, 3, '{"required":"1","defaultValue":"false"}', '2022-09-27 12:00:00', '2022-09-27 12:00:00'); @@ -1427,10 +1422,6 @@ INSERT INTO "public"."plugin_handle" VALUES ('1722804548510507021', '14', 'rewri INSERT INTO "public"."plugin_handle" VALUES ('1722804548510507022', '14', 'percentage', 'percentage', 1, 2, 3, '{"required":"1","defaultValue":"100"}', '2024-02-07 14:31:49', '2024-02-07 14:31:49'); INSERT INTO "public"."plugin_handle" VALUES ('1722804548510507023', '3', 'rewriteMetaData', 'rewriteMetaData', 3, 2, 3, '{"required":"1","defaultValue":"false"}', '2024-02-07 14:31:49', '2024-02-07 14:31:49'); -INSERT INTO "public"."plugin_handle" VALUES ('1722804548510507024', '8', 'registerType', 'registerType', 2, 3, 1, NULL, '2024-08-24 09:40:03.293', '2024-08-24 21:52:27.920'); -INSERT INTO "public"."plugin_handle" VALUES ('1722804548510507025', '8', 'serverLists', 'serverLists', 2, 3, 2, NULL, '2024-08-24 21:52:51.179', '2024-08-24 21:53:27.483'); -INSERT INTO "public"."plugin_handle" VALUES ('1722804548510507026', '8', 'props', 'props', 4, 3, 3, NULL, '2024-08-24 21:53:25.764', '2024-08-24 21:53:30.255'); - -- ---------------------------- -- Table structure for resource -- ---------------------------- @@ -1554,7 +1545,6 @@ INSERT INTO "public"."resource" VALUES ('1529403932781187090', '1346775491550474 INSERT INTO "public"."resource" VALUES ('1529403932781187091', '1346775491550474240', 'rateLimiter', 'rateLimiter', '/plug/rateLimiter', 'rateLimiter', 1, 0, 'pic-center', 0, 0, '', 1, '2022-05-25 18:08:07', '2022-05-25 18:08:07'); INSERT INTO "public"."resource" VALUES ('1529403932781187092', '1346775491550474240', 'divide', 'divide', '/plug/divide', 'divide', 1, 0, 'block', 0, 0, '', 1, '2022-05-25 18:08:07', '2022-05-25 18:08:07'); INSERT INTO "public"."resource" VALUES ('1529403932781187093', '1346775491550474240', 'dubbo', 'dubbo', '/plug/dubbo', 'dubbo', 1, 0, 'align-left', 0, 0, '', 1, '2022-05-25 18:08:07', '2022-05-25 18:08:07'); -INSERT INTO "public"."resource" VALUES ('1529403932781187094', '1346775491550474240', 'springCloud', 'springCloud', '/plug/springCloud', 'springCloud', 1, 0, 'stop', 0, 0, '', 1, '2022-05-25 18:08:07', '2022-05-25 18:08:07'); INSERT INTO "public"."resource" VALUES ('1529403932781187095', '1346775491550474240', 'hystrix', 'hystrix', '/plug/hystrix', 'hystrix', 1, 0, 'fire', 0, 0, '', 1, '2022-05-25 18:08:07', '2022-05-25 18:08:07'); INSERT INTO "public"."resource" VALUES ('1529403932781187096', '1346775491550474240', 'generalContext', 'generalContext', '/plug/generalContext', 'generalContext', 1, 0, 'highlight', 0, 0, '', 1, '2022-05-25 18:08:07', '2022-05-25 18:08:07'); INSERT INTO "public"."resource" VALUES ('1529403932781187097', '1346775491550474240', 'mqtt', 'mqtt', '/plug/mqtt', 'mqtt', 1, 0, 'database', 0, 0, '', 1, '2022-05-25 18:08:07', '2022-05-25 18:08:07'); @@ -1767,15 +1757,6 @@ INSERT INTO "public"."resource" VALUES ('1529403932881850454', '1529403932781187 INSERT INTO "public"."resource" VALUES ('1529403932881850455', '1529403932781187093', 'SHENYU.BUTTON.PLUGIN.RULE.EDIT', '', '', '', 2, 0, '', 1, 0, 'plugin:dubboRule:edit', 1, '2022-05-25 18:08:07', '2022-05-25 18:08:07'); INSERT INTO "public"."resource" VALUES ('1529403932881850456', '1529403932781187093', 'SHENYU.BUTTON.PLUGIN.RULE.DELETE', '', '', '', 2, 0, '', 1, 0, 'plugin:dubboRule:delete', 1, '2022-05-25 18:08:07', '2022-05-25 18:08:07'); INSERT INTO "public"."resource" VALUES ('1529403932881850457', '1529403932781187093', 'SHENYU.BUTTON.PLUGIN.SYNCHRONIZE', '', '', '', 2, 0, '', 1, 0, 'plugin:dubbo:modify', 1, '2022-05-25 18:08:07', '2022-05-25 18:08:07'); -INSERT INTO "public"."resource" VALUES ('1529403932881850458', '1529403932781187094', 'SHENYU.BUTTON.PLUGIN.SELECTOR.ADD', '', '', '', 2, 0, '', 1, 0, 'plugin:springCloudSelector:add', 1, '2022-05-25 18:08:07', '2022-05-25 18:08:07'); -INSERT INTO "public"."resource" VALUES ('1529403932881850459', '1529403932781187094', 'SHENYU.BUTTON.PLUGIN.SELECTOR.QUERY', '', '', '', 2, 0, '', 1, 0, 'plugin:springCloudSelector:query', 1, '2022-05-25 18:08:07', '2022-05-25 18:08:07'); -INSERT INTO "public"."resource" VALUES ('1529403932881850460', '1529403932781187094', 'SHENYU.BUTTON.PLUGIN.SELECTOR.EDIT', '', '', '', 2, 0, '', 1, 0, 'plugin:springCloudSelector:edit', 1, '2022-05-25 18:08:07', '2022-05-25 18:08:07'); -INSERT INTO "public"."resource" VALUES ('1529403932881850461', '1529403932781187094', 'SHENYU.BUTTON.PLUGIN.SELECTOR.DELETE', '', '', '', 2, 0, '', 1, 0, 'plugin:springCloudSelector:delete', 1, '2022-05-25 18:08:07', '2022-05-25 18:08:07'); -INSERT INTO "public"."resource" VALUES ('1529403932881850462', '1529403932781187094', 'SHENYU.BUTTON.PLUGIN.RULE.ADD', '', '', '', 2, 0, '', 1, 0, 'plugin:springCloudRule:add', 1, '2022-05-25 18:08:07', '2022-05-25 18:08:07'); -INSERT INTO "public"."resource" VALUES ('1529403932881850463', '1529403932781187094', 'SHENYU.BUTTON.PLUGIN.RULE.QUERY', '', '', '', 2, 0, '', 1, 0, 'plugin:springCloudRule:query', 1, '2022-05-25 18:08:07', '2022-05-25 18:08:07'); -INSERT INTO "public"."resource" VALUES ('1529403932881850464', '1529403932781187094', 'SHENYU.BUTTON.PLUGIN.RULE.EDIT', '', '', '', 2, 0, '', 1, 0, 'plugin:springCloudRule:edit', 1, '2022-05-25 18:08:07', '2022-05-25 18:08:07'); -INSERT INTO "public"."resource" VALUES ('1529403932881850465', '1529403932781187094', 'SHENYU.BUTTON.PLUGIN.RULE.DELETE', '', '', '', 2, 0, '', 1, 0, 'plugin:springCloudRule:delete', 1, '2022-05-25 18:08:07', '2022-05-25 18:08:07'); -INSERT INTO "public"."resource" VALUES ('1529403932881850466', '1529403932781187094', 'SHENYU.BUTTON.PLUGIN.SYNCHRONIZE', '', '', '', 2, 0, '', 1, 0, 'plugin:springCloud:modify', 1, '2022-05-25 18:08:07', '2022-05-25 18:08:07'); INSERT INTO "public"."resource" VALUES ('1529403932881850467', '1529403932781187095', 'SHENYU.BUTTON.PLUGIN.SELECTOR.ADD', '', '', '', 2, 0, '', 1, 0, 'plugin:hystrixSelector:add', 1, '2022-05-25 18:08:07', '2022-05-25 18:08:07'); INSERT INTO "public"."resource" VALUES ('1529403932881850468', '1529403932781187095', 'SHENYU.BUTTON.PLUGIN.SELECTOR.QUERY', '', '', '', 2, 0, '', 1, 0, 'plugin:hystrixSelector:query', 1, '2022-05-25 18:08:07', '2022-05-25 18:08:07'); INSERT INTO "public"."resource" VALUES ('1529403932881850469', '1529403932781187095', 'SHENYU.BUTTON.PLUGIN.SELECTOR.EDIT', '', '', '', 2, 0, '', 1, 0, 'plugin:hystrixSelector:edit', 1, '2022-05-25 18:08:07', '2022-05-25 18:08:07'); @@ -2801,7 +2782,6 @@ INSERT INTO "public"."namespace_plugin_rel" VALUES ('1801816010882822181','64933 INSERT INTO "public"."namespace_plugin_rel" VALUES ('1801816010882822182','649330b6-c2d7-4edc-be8e-8a54df9eb385','45', '{"host":"127.0.0.1","port":5672,"password":"admin","username":"admin","exchangeName":"exchange.logging.plugin","queueName":"queue.logging.plugin","routingKey":"topic.logging","virtualHost":"/","exchangeType":"direct","durable":"true","exclusive":"false","autoDelete":"false"}', 171, 0, '2023-11-06 15:49:56.454', '2023-11-10 10:40:58.447'); INSERT INTO "public"."namespace_plugin_rel" VALUES ('1801816010882822183','649330b6-c2d7-4edc-be8e-8a54df9eb385','5', '{"multiSelectorHandle":"1","multiRuleHandle":"0"}', 200, 1, '2022-05-25 18:02:53.000', '2022-05-25 18:02:53.000'); INSERT INTO "public"."namespace_plugin_rel" VALUES ('1801816010882822184','649330b6-c2d7-4edc-be8e-8a54df9eb385','6', '{"register":"zookeeper://localhost:2181","multiSelectorHandle":"1","threadpool":"shared","corethreads":0,"threads":2147483647,"queues":0}', 310, 0, '2022-05-25 18:02:53.000', '2022-05-25 18:02:53.000'); -INSERT INTO "public"."namespace_plugin_rel" VALUES ('1801816010882822185','649330b6-c2d7-4edc-be8e-8a54df9eb385','8', '{"enabled":false,"registerType":"eureka","serverLists":"http://localhost:8761/eureka","props":{}}', 200, 0, '2022-05-25 18:02:53.000', '2022-05-25 18:02:53.000'); INSERT INTO "public"."namespace_plugin_rel" VALUES ('1801816010882822186','649330b6-c2d7-4edc-be8e-8a54df9eb385','9', NULL, 130, 0, '2022-05-25 18:02:53.000', '2022-05-25 18:02:53.000'); diff --git a/pom.xml b/pom.xml index 5b29e20f8568..23ba47eb7b85 100644 --- a/pom.xml +++ b/pom.xml @@ -45,7 +45,6 @@ shenyu-dist shenyu-alert shenyu-sdk - shenyu-discovery shenyu-registry shenyu-kubernetes-controller diff --git a/shenyu-admin/pom.xml b/shenyu-admin/pom.xml index 293b75287a6c..9e2ae4c32757 100644 --- a/shenyu-admin/pom.xml +++ b/shenyu-admin/pom.xml @@ -296,38 +296,6 @@ spring-boot-starter-validation - - - org.apache.shenyu - shenyu-discovery-etcd - ${project.version} - - - - org.apache.shenyu - shenyu-discovery-zookeeper - ${project.version} - - - - org.apache.shenyu - shenyu-discovery-nacos - ${project.version} - - - - org.apache.shenyu - shenyu-discovery-eureka - - - jakarta.servlet - servlet-api - - - ${project.version} - - - org.apache.shenyu @@ -371,7 +339,12 @@ compile - + + + org.apache.shenyu + shenyu-registry-core + ${project.version} + diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/discovery/APDiscoveryProcessor.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/discovery/APDiscoveryProcessor.java index 744cede74780..6533f94f8f3f 100644 --- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/discovery/APDiscoveryProcessor.java +++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/discovery/APDiscoveryProcessor.java @@ -17,6 +17,8 @@ package org.apache.shenyu.admin.discovery; +import org.apache.shenyu.admin.discovery.listener.DataChangedEventListener; +import org.apache.shenyu.admin.discovery.listener.DiscoveryDataChangedEvent; import org.apache.shenyu.admin.exception.ShenyuAdminException; import org.apache.shenyu.admin.listener.DataChangedEvent; import org.apache.shenyu.admin.mapper.DiscoveryUpstreamMapper; @@ -25,7 +27,8 @@ import org.apache.shenyu.admin.transfer.DiscoveryTransfer; import org.apache.shenyu.common.enums.ConfigGroupEnum; import org.apache.shenyu.common.enums.DataEventTypeEnum; -import org.apache.shenyu.discovery.api.ShenyuDiscoveryService; +import org.apache.shenyu.registry.api.ShenyuInstanceRegisterRepository; +import org.apache.shenyu.registry.api.event.ChangedEventListener; import java.util.Collections; import java.util.Objects; @@ -44,7 +47,7 @@ public APDiscoveryProcessor(final DiscoveryUpstreamMapper discoveryUpstreamMappe @Override public void createProxySelector(final DiscoveryHandlerDTO discoveryHandlerDTO, final ProxySelectorDTO proxySelectorDTO) { - ShenyuDiscoveryService shenyuDiscoveryService = getShenyuDiscoveryService(discoveryHandlerDTO.getDiscoveryId()); + ShenyuInstanceRegisterRepository shenyuDiscoveryService = getShenyuDiscoveryService(discoveryHandlerDTO.getDiscoveryId()); String key = super.buildProxySelectorKey(discoveryHandlerDTO.getListenerNode()); if (Objects.isNull(shenyuDiscoveryService)) { throw new ShenyuAdminException(String.format("before start ProxySelector you need init DiscoveryId=%s", discoveryHandlerDTO.getDiscoveryId())); @@ -52,10 +55,25 @@ public void createProxySelector(final DiscoveryHandlerDTO discoveryHandlerDTO, f Set cacheKey = getCacheKey(discoveryHandlerDTO.getDiscoveryId()); if (Objects.nonNull(cacheKey) && cacheKey.contains(key)) { LOG.info("shenyu discovery has watcher key = {}", key); + super.addDiscoverySyncDataListener(discoveryHandlerDTO, proxySelectorDTO); return; } - shenyuDiscoveryService.watch(key, getDiscoveryDataChangedEventListener(discoveryHandlerDTO, proxySelectorDTO)); + LOG.info("shenyu discovery id {} watch key = {}", discoveryHandlerDTO.getId(), key); + final DataChangedEventListener discoveryDataChangedEventListener = getDiscoveryDataChangedEventListener(discoveryHandlerDTO, proxySelectorDTO); + shenyuDiscoveryService.watchInstances(key, (selectKey, selectValue, event) -> { + LOG.info("shenyu discovery receive watch discovery id {} key = {}, value = {}, event = {}", discoveryHandlerDTO.getId(), selectKey, selectValue, event); + if (event.equals(ChangedEventListener.Event.ADDED)) { + discoveryDataChangedEventListener.onChange(new DiscoveryDataChangedEvent(selectKey, selectValue, DiscoveryDataChangedEvent.Event.ADDED)); + } else if (event.equals(ChangedEventListener.Event.UPDATED)) { + discoveryDataChangedEventListener.onChange(new DiscoveryDataChangedEvent(selectKey, selectValue, DiscoveryDataChangedEvent.Event.UPDATED)); + } else if (event.equals(ChangedEventListener.Event.DELETED)) { + discoveryDataChangedEventListener.onChange(new DiscoveryDataChangedEvent(selectKey, selectValue, DiscoveryDataChangedEvent.Event.DELETED)); + } else { + discoveryDataChangedEventListener.onChange(new DiscoveryDataChangedEvent(selectKey, selectValue, DiscoveryDataChangedEvent.Event.IGNORED)); + } + }); cacheKey.add(key); + super.addChangedEventListener(discoveryHandlerDTO.getDiscoveryId(), discoveryDataChangedEventListener); DataChangedEvent dataChangedEvent = new DataChangedEvent(ConfigGroupEnum.PROXY_SELECTOR, DataEventTypeEnum.CREATE, Collections.singletonList(DiscoveryTransfer.INSTANCE.mapToData(proxySelectorDTO))); publishEvent(dataChangedEvent); diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/discovery/AbstractDiscoveryProcessor.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/discovery/AbstractDiscoveryProcessor.java index 2013e4037726..41d7f4b23492 100644 --- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/discovery/AbstractDiscoveryProcessor.java +++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/discovery/AbstractDiscoveryProcessor.java @@ -18,6 +18,7 @@ package org.apache.shenyu.admin.discovery; import org.apache.commons.lang3.StringUtils; +import org.apache.shenyu.admin.discovery.listener.DataChangedEventListener; import org.apache.shenyu.admin.discovery.parse.CustomDiscoveryUpstreamParser; import org.apache.shenyu.admin.listener.DataChangedEvent; import org.apache.shenyu.admin.mapper.DiscoveryUpstreamMapper; @@ -33,9 +34,9 @@ import org.apache.shenyu.common.enums.DataEventTypeEnum; import org.apache.shenyu.common.utils.GsonUtils; import org.apache.shenyu.common.utils.UUIDUtils; -import org.apache.shenyu.discovery.api.ShenyuDiscoveryService; -import org.apache.shenyu.discovery.api.config.DiscoveryConfig; -import org.apache.shenyu.discovery.api.listener.DataChangedEventListener; +import org.apache.shenyu.registry.api.ShenyuInstanceRegisterRepository; +import org.apache.shenyu.registry.api.config.RegisterConfig; +import org.apache.shenyu.registry.api.entity.InstanceEntity; import org.apache.shenyu.spi.ExtensionLoader; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -43,16 +44,17 @@ import org.springframework.context.ApplicationEventPublisherAware; import java.sql.Timestamp; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Optional; +import java.util.Properties; import java.util.Set; -import java.util.ArrayList; import java.util.concurrent.ConcurrentHashMap; import java.util.stream.Collectors; -import java.util.Properties; -import java.util.HashSet; -import java.util.Collections; public abstract class AbstractDiscoveryProcessor implements DiscoveryProcessor, ApplicationEventPublisherAware { @@ -60,10 +62,12 @@ public abstract class AbstractDiscoveryProcessor implements DiscoveryProcessor, protected static final Logger LOG = LoggerFactory.getLogger(DefaultDiscoveryProcessor.class); - private final Map discoveryServiceCache; + private final Map discoveryServiceCache; private final Map> dataChangedEventListenerCache; + private final Map dataChangedEventListenerMap = new HashMap<>(); + private ApplicationEventPublisher eventPublisher; private final DiscoveryUpstreamMapper discoveryUpstreamMapper; @@ -88,11 +92,11 @@ public void createDiscovery(final DiscoveryDO discoveryDO) { String type = discoveryDO.getType(); String props = discoveryDO.getProps(); Properties properties = GsonUtils.getGson().fromJson(props, Properties.class); - DiscoveryConfig discoveryConfig = new DiscoveryConfig(); - discoveryConfig.setType(type); + RegisterConfig discoveryConfig = new RegisterConfig(); + discoveryConfig.setRegisterType(type); discoveryConfig.setProps(properties); - discoveryConfig.setServerList(discoveryDO.getServerList()); - ShenyuDiscoveryService discoveryService = ExtensionLoader.getExtensionLoader(ShenyuDiscoveryService.class).getJoin(type); + discoveryConfig.setServerLists(discoveryDO.getServerList()); + ShenyuInstanceRegisterRepository discoveryService = ExtensionLoader.getExtensionLoader(ShenyuInstanceRegisterRepository.class).getJoin(type); discoveryService.init(discoveryConfig); discoveryServiceCache.put(discoveryDO.getId(), discoveryService); dataChangedEventListenerCache.put(discoveryDO.getId(), new HashSet<>()); @@ -106,12 +110,12 @@ public void createDiscovery(final DiscoveryDO discoveryDO) { */ @Override public void removeDiscovery(final DiscoveryDO discoveryDO) { - ShenyuDiscoveryService shenyuDiscoveryService = discoveryServiceCache.remove(discoveryDO.getId()); + ShenyuInstanceRegisterRepository shenyuDiscoveryService = discoveryServiceCache.remove(discoveryDO.getId()); if (shenyuDiscoveryService == null) { return; } if (discoveryServiceCache.values().stream().noneMatch(p -> p.equals(shenyuDiscoveryService))) { - shenyuDiscoveryService.shutdown(); + shenyuDiscoveryService.close(); LOG.info("shenyu discovery shutdown [{}] discovery", discoveryDO.getName()); } } @@ -123,11 +127,11 @@ public void removeDiscovery(final DiscoveryDO discoveryDO) { */ @Override public void removeProxySelector(final DiscoveryHandlerDTO discoveryHandlerDTO, final ProxySelectorDTO proxySelectorDTO) { - ShenyuDiscoveryService shenyuDiscoveryService = discoveryServiceCache.get(discoveryHandlerDTO.getDiscoveryId()); + ShenyuInstanceRegisterRepository shenyuDiscoveryService = discoveryServiceCache.get(discoveryHandlerDTO.getDiscoveryId()); String key = buildProxySelectorKey(discoveryHandlerDTO.getListenerNode()); Optional.ofNullable(dataChangedEventListenerCache.get(discoveryHandlerDTO.getDiscoveryId())).ifPresent(cacheKey -> { cacheKey.remove(key); - shenyuDiscoveryService.unwatch(key); + shenyuDiscoveryService.unWatchInstances(key); DataChangedEvent dataChangedEvent = new DataChangedEvent(ConfigGroupEnum.PROXY_SELECTOR, DataEventTypeEnum.DELETE, Collections.singletonList(DiscoveryTransfer.INSTANCE.mapToData(proxySelectorDTO))); eventPublisher.publishEvent(dataChangedEvent); @@ -151,10 +155,21 @@ public void changeUpstream(final ProxySelectorDTO proxySelectorDTO, final List childData = shenyuDiscoveryService.getRegisterData(buildProxySelectorKey(discoveryHandlerDTO.getListenerNode())); - List discoveryUpstreamDataList = childData.stream().map(s -> GsonUtils.getGson().fromJson(s, DiscoveryUpstreamData.class)) - .collect(Collectors.toList()); + ShenyuInstanceRegisterRepository shenyuDiscoveryService = discoveryServiceCache.get(discoveryId); + final List instanceEntities = shenyuDiscoveryService.selectInstances(buildProxySelectorKey(discoveryHandlerDTO.getListenerNode())); + List discoveryUpstreamDataList = instanceEntities.stream().map(instanceEntity -> { + final DiscoveryUpstreamData discoveryUpstreamData = new DiscoveryUpstreamData(); + String uri = String.format("%s:%s", instanceEntity.getHost(), instanceEntity.getPort()); + discoveryUpstreamData.setUrl(uri); + discoveryUpstreamData.setWeight(instanceEntity.getWeight()); + discoveryUpstreamData.setStatus(instanceEntity.getStatus()); + discoveryUpstreamData.setProtocol("http://"); + if (discoveryUpstreamData.getNamespaceId() == null) { + discoveryUpstreamData.setNamespaceId(proxySelectorDTO.getNamespaceId()); + } + discoveryUpstreamData.setDiscoveryHandlerId(proxySelectorDTO.getId()); + return discoveryUpstreamData; + }).collect(Collectors.toList()); Set urlList = discoveryUpstreamDataList.stream().map(DiscoveryUpstreamData::getUrl).collect(Collectors.toSet()); List discoveryUpstreamDOS = discoveryUpstreamMapper.selectByDiscoveryHandlerId(discoveryHandlerDTO.getId()); Set dbUrlList = discoveryUpstreamDOS.stream().map(DiscoveryUpstreamDO::getUrl).collect(Collectors.toSet()); @@ -205,15 +220,36 @@ protected String buildProxySelectorKey(final String listenerNode) { * @param proxySelectorDTO proxySelectorDTO * @return DataChangedEventListener */ - public DataChangedEventListener getDiscoveryDataChangedEventListener(final DiscoveryHandlerDTO discoveryHandlerDTO, final ProxySelectorDTO proxySelectorDTO) { + public DataChangedEventListener getDiscoveryDataChangedEventListener(final DiscoveryHandlerDTO discoveryHandlerDTO, + final ProxySelectorDTO proxySelectorDTO) { final Map customMap = GsonUtils.getInstance().toObjectMap(discoveryHandlerDTO.getHandler(), String.class); DiscoverySyncData discoverySyncData = new DiscoverySyncData(); discoverySyncData.setPluginName(proxySelectorDTO.getPluginName()); discoverySyncData.setSelectorName(proxySelectorDTO.getName()); discoverySyncData.setSelectorId(proxySelectorDTO.getId()); discoverySyncData.setNamespaceId(proxySelectorDTO.getNamespaceId()); + discoverySyncData.setDiscoveryHandlerId(discoveryHandlerDTO.getId()); return new DiscoveryDataChangedEventSyncListener(eventPublisher, discoveryUpstreamMapper, - new CustomDiscoveryUpstreamParser(customMap), discoveryHandlerDTO.getId(), discoverySyncData); + new CustomDiscoveryUpstreamParser(customMap), discoverySyncData, discoveryHandlerDTO.getDiscoveryId()); + } + + /** + * addDiscoverySyncDataListener. + * + * @param discoveryHandlerDTO discoveryHandlerDTO + * @param proxySelectorDTO proxySelectorDTO + */ + public void addDiscoverySyncDataListener(final DiscoveryHandlerDTO discoveryHandlerDTO, final ProxySelectorDTO proxySelectorDTO) { + final DataChangedEventListener changedEventListener = this.getChangedEventListener(discoveryHandlerDTO.getDiscoveryId()); + if (changedEventListener != null) { + DiscoverySyncData discoverySyncData = new DiscoverySyncData(); + discoverySyncData.setPluginName(proxySelectorDTO.getPluginName()); + discoverySyncData.setSelectorName(proxySelectorDTO.getName()); + discoverySyncData.setSelectorId(proxySelectorDTO.getId()); + discoverySyncData.setNamespaceId(proxySelectorDTO.getNamespaceId()); + discoverySyncData.setDiscoveryHandlerId(discoveryHandlerDTO.getId()); + changedEventListener.addListener(discoverySyncData); + } } @Override @@ -227,7 +263,7 @@ public void setApplicationEventPublisher(final ApplicationEventPublisher eventPu * @param discoveryId discoveryId * @return ShenyuDiscoveryService */ - public ShenyuDiscoveryService getShenyuDiscoveryService(final String discoveryId) { + public ShenyuInstanceRegisterRepository getShenyuDiscoveryService(final String discoveryId) { return discoveryServiceCache.get(discoveryId); } @@ -241,6 +277,26 @@ public Set getCacheKey(final String discoveryId) { return dataChangedEventListenerCache.get(discoveryId); } + /** + * addChangedEventListener. + * + * @param discoveryId discoveryId + * @param dataChangedEventListener dataChangedEventListener + */ + public void addChangedEventListener(final String discoveryId, final DataChangedEventListener dataChangedEventListener) { + this.dataChangedEventListenerMap.put(discoveryId, dataChangedEventListener); + } + + /** + * getChangedEventListener. + * + * @param discoveryId discoveryId + * @return {@link DataChangedEventListener} + */ + public DataChangedEventListener getChangedEventListener(final String discoveryId) { + return this.dataChangedEventListenerMap.get(discoveryId); + } + /** * publishEvent. * diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/discovery/DefaultDiscoveryProcessor.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/discovery/DefaultDiscoveryProcessor.java index 87a9c75feb7e..533f116989f8 100644 --- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/discovery/DefaultDiscoveryProcessor.java +++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/discovery/DefaultDiscoveryProcessor.java @@ -17,6 +17,8 @@ package org.apache.shenyu.admin.discovery; +import org.apache.shenyu.admin.discovery.listener.DataChangedEventListener; +import org.apache.shenyu.admin.discovery.listener.DiscoveryDataChangedEvent; import org.apache.shenyu.admin.exception.ShenyuAdminException; import org.apache.shenyu.admin.listener.DataChangedEvent; import org.apache.shenyu.admin.mapper.DiscoveryUpstreamMapper; @@ -25,7 +27,8 @@ import org.apache.shenyu.admin.transfer.DiscoveryTransfer; import org.apache.shenyu.common.enums.ConfigGroupEnum; import org.apache.shenyu.common.enums.DataEventTypeEnum; -import org.apache.shenyu.discovery.api.ShenyuDiscoveryService; +import org.apache.shenyu.registry.api.ShenyuInstanceRegisterRepository; +import org.apache.shenyu.registry.api.event.ChangedEventListener; import java.util.Collections; import java.util.Objects; @@ -47,21 +50,35 @@ public DefaultDiscoveryProcessor(final DiscoveryUpstreamMapper discoveryUpstream @Override public void createProxySelector(final DiscoveryHandlerDTO discoveryHandlerDTO, final ProxySelectorDTO proxySelectorDTO) { - ShenyuDiscoveryService shenyuDiscoveryService = getShenyuDiscoveryService(discoveryHandlerDTO.getDiscoveryId()); + ShenyuInstanceRegisterRepository shenyuInstanceRegisterRepository = getShenyuDiscoveryService(discoveryHandlerDTO.getDiscoveryId()); String key = buildProxySelectorKey(discoveryHandlerDTO.getListenerNode()); - if (Objects.isNull(shenyuDiscoveryService)) { + if (Objects.isNull(shenyuInstanceRegisterRepository)) { throw new ShenyuAdminException(String.format("before start ProxySelector you need init DiscoveryId=%s", discoveryHandlerDTO.getDiscoveryId())); } - if (!shenyuDiscoveryService.exists(key)) { + + if (!shenyuInstanceRegisterRepository.serviceExists(key)) { throw new ShenyuAdminException(String.format("shenyu discovery start watcher need you has this key %s in Discovery", key)); } Set cacheKey = getCacheKey(discoveryHandlerDTO.getDiscoveryId()); if (Objects.nonNull(cacheKey) && cacheKey.contains(key)) { LOG.info("shenyu discovery has watcher key = {}", key); + super.addDiscoverySyncDataListener(discoveryHandlerDTO, proxySelectorDTO); return; } - shenyuDiscoveryService.watch(key, getDiscoveryDataChangedEventListener(discoveryHandlerDTO, proxySelectorDTO)); + final DataChangedEventListener discoveryDataChangedEventListener = getDiscoveryDataChangedEventListener(discoveryHandlerDTO, proxySelectorDTO); + shenyuInstanceRegisterRepository.watchInstances(key, (selectKey, selectValue, event) -> { + if (event.equals(ChangedEventListener.Event.ADDED)) { + discoveryDataChangedEventListener.onChange(new DiscoveryDataChangedEvent(selectKey, selectValue, DiscoveryDataChangedEvent.Event.ADDED)); + } else if (event.equals(ChangedEventListener.Event.UPDATED)) { + discoveryDataChangedEventListener.onChange(new DiscoveryDataChangedEvent(selectKey, selectValue, DiscoveryDataChangedEvent.Event.UPDATED)); + } else if (event.equals(ChangedEventListener.Event.DELETED)) { + discoveryDataChangedEventListener.onChange(new DiscoveryDataChangedEvent(selectKey, selectValue, DiscoveryDataChangedEvent.Event.DELETED)); + } else { + discoveryDataChangedEventListener.onChange(new DiscoveryDataChangedEvent(selectKey, selectValue, DiscoveryDataChangedEvent.Event.IGNORED)); + } + }); cacheKey.add(key); + super.addChangedEventListener(discoveryHandlerDTO.getDiscoveryId(), discoveryDataChangedEventListener); DataChangedEvent dataChangedEvent = new DataChangedEvent(ConfigGroupEnum.PROXY_SELECTOR, DataEventTypeEnum.CREATE, Collections.singletonList(DiscoveryTransfer.INSTANCE.mapToData(proxySelectorDTO))); publishEvent(dataChangedEvent); diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/discovery/DiscoveryDataChangedEventSyncListener.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/discovery/DiscoveryDataChangedEventSyncListener.java index c37cbbb52bb8..a1c8b2f5c5ca 100644 --- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/discovery/DiscoveryDataChangedEventSyncListener.java +++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/discovery/DiscoveryDataChangedEventSyncListener.java @@ -19,6 +19,8 @@ import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; +import org.apache.shenyu.admin.discovery.listener.DataChangedEventListener; +import org.apache.shenyu.admin.discovery.listener.DiscoveryDataChangedEvent; import org.apache.shenyu.admin.discovery.parse.KeyValueParser; import org.apache.shenyu.admin.listener.DataChangedEvent; import org.apache.shenyu.admin.mapper.DiscoveryUpstreamMapper; @@ -29,8 +31,6 @@ import org.apache.shenyu.common.enums.ConfigGroupEnum; import org.apache.shenyu.common.enums.DataEventTypeEnum; import org.apache.shenyu.common.utils.UUIDUtils; -import org.apache.shenyu.discovery.api.listener.DiscoveryDataChangedEvent; -import org.apache.shenyu.discovery.api.listener.DataChangedEventListener; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.context.ApplicationEventPublisher; @@ -38,6 +38,7 @@ import org.springframework.transaction.annotation.Transactional; import java.sql.Timestamp; +import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Objects; @@ -58,20 +59,21 @@ public class DiscoveryDataChangedEventSyncListener implements DataChangedEventLi private final DiscoveryUpstreamMapper discoveryUpstreamMapper; - private final String discoveryHandlerId; + private final List discoverySyncDataList; - private final DiscoverySyncData contextInfo; + private final String discoveryId; public DiscoveryDataChangedEventSyncListener(final ApplicationEventPublisher eventPublisher, final DiscoveryUpstreamMapper discoveryUpstreamMapper, final KeyValueParser keyValueParser, - final String discoveryHandlerId, - final DiscoverySyncData contextInfo) { + final DiscoverySyncData contextInfo, + final String discoveryId) { + this.discoverySyncDataList = new ArrayList<>(); this.eventPublisher = eventPublisher; this.keyValueParser = keyValueParser; + this.discoveryId = discoveryId; this.discoveryUpstreamMapper = discoveryUpstreamMapper; - this.discoveryHandlerId = discoveryHandlerId; - this.contextInfo = contextInfo; + discoverySyncDataList.add(contextInfo); } @Override @@ -81,12 +83,22 @@ public void onChange(final DiscoveryDataChangedEvent event) { if (DiscoveryDataChangedEvent.Event.IGNORED.equals(currentEvent)) { return; } - DiscoverySyncData discoverySyncData = buildProxySelectorData(event.getValue()); - final List upstreamDataList = discoverySyncData.getUpstreamDataList(); + discoverySyncDataList.forEach(discoverySyncData -> { + LOG.info("DiscoveryDataChangedEventSyncListener watch discoveryId {} discoveryHandlerId {} selectorId {} event {}", discoveryId, + discoverySyncData.getDiscoveryHandlerId(), + discoverySyncData.getSelectorId(), event); + syncData0(event, discoverySyncData, currentEvent); + }); + } + + private void syncData0(final DiscoveryDataChangedEvent event, final DiscoverySyncData discoverySyncData, final DiscoveryDataChangedEvent.Event currentEvent) { + final DiscoverySyncData syncData = buildProxySelectorData(discoverySyncData, event.getValue()); + final List upstreamDataList = syncData.getUpstreamDataList(); if (CollectionUtils.isEmpty(upstreamDataList)) { - LOG.warn("shenyu proxySelectorData#discoveryUpstreamList is empty"); + LOG.warn("Discover EventSync proxySelectorData discoveryUpstreamList is empty syncData {}", syncData); return; } + final String discoveryHandlerId = discoverySyncData.getDiscoveryHandlerId(); switch (currentEvent) { case ADDED: upstreamDataList.forEach(d -> { @@ -97,10 +109,10 @@ public void onChange(final DiscoveryDataChangedEvent event) { d.setDateCreated(new Timestamp(System.currentTimeMillis())); d.setDateUpdated(new Timestamp(System.currentTimeMillis())); discoveryUpstreamMapper.insert(DiscoveryTransfer.INSTANCE.mapToDo(d)); - LOG.info("shenyu [DiscoveryDataChangedEventSyncListener] ADDED Upstream {}", d.getUrl()); + LOG.info("[DiscoveryDataChangedEventSyncListener] ADDED Upstream {}", d.getUrl()); } } catch (DuplicateKeyException ex) { - LOG.info("shenyu [DiscoveryDataChangedEventSyncListener] Upstream {} exist", d.getUrl()); + LOG.info("[DiscoveryDataChangedEventSyncListener] Upstream {} exist", d.getUrl()); } }); break; @@ -108,33 +120,25 @@ public void onChange(final DiscoveryDataChangedEvent event) { upstreamDataList.stream().map(DiscoveryTransfer.INSTANCE::mapToDo).forEach(discoveryUpstreamDO -> { discoveryUpstreamDO.setDiscoveryHandlerId(discoveryHandlerId); int effect = discoveryUpstreamMapper.updateDiscoveryHandlerIdAndUrl(discoveryUpstreamDO); - LOG.info("shenyu [DiscoveryDataChangedEventSyncListener] UPDATE Upstream {}, effect = {} ", discoveryUpstreamDO.getUrl(), effect); + LOG.info("[DiscoveryDataChangedEventSyncListener] UPDATE Upstream {}, effect = {} ", discoveryUpstreamDO.getUrl(), effect); }); break; case DELETED: if (CollectionUtils.isNotEmpty(upstreamDataList)) { upstreamDataList.forEach(up -> { discoveryUpstreamMapper.deleteByUrl(discoveryHandlerId, up.getUrl()); - LOG.info("shenyu [DiscoveryDataChangedEventSyncListener] DELETE Upstream {}", up.getUrl()); + LOG.info("[DiscoveryDataChangedEventSyncListener] DELETE Upstream {}", up.getUrl()); }); } break; default: - throw new IllegalStateException("shenyu DiscoveryDataChangedEventSyncListener find IllegalState"); + throw new IllegalStateException("DiscoveryDataChangedEventSyncListener find IllegalState"); } - fillFullyDiscoverySyncData(discoverySyncData); - DataChangedEvent dataChangedEvent = new DataChangedEvent(ConfigGroupEnum.DISCOVER_UPSTREAM, DataEventTypeEnum.UPDATE, Collections.singletonList(discoverySyncData)); + DataChangedEvent dataChangedEvent = new DataChangedEvent(ConfigGroupEnum.DISCOVER_UPSTREAM, DataEventTypeEnum.UPDATE, Collections.singletonList(syncData)); eventPublisher.publishEvent(dataChangedEvent); } - private void fillFullyDiscoverySyncData(final DiscoverySyncData discoverySyncData) { - List discoveryUpstreamDOS = discoveryUpstreamMapper.selectByProxySelectorId(discoverySyncData.getSelectorId()); - discoveryUpstreamDOS.addAll(discoveryUpstreamMapper.selectBySelectorId(discoverySyncData.getSelectorId())); - List collect = discoveryUpstreamDOS.stream().map(DiscoveryTransfer.INSTANCE::mapToData).collect(Collectors.toList()); - discoverySyncData.setUpstreamDataList(collect); - } - - private DiscoverySyncData buildProxySelectorData(final String value) { + private DiscoverySyncData buildProxySelectorData(final DiscoverySyncData discoverySyncData, final String value) { List discoveryUpstreamDTOS = keyValueParser.parseValue(value); discoveryUpstreamDTOS.forEach(discoveryUpstreamData -> { if (StringUtils.isBlank(discoveryUpstreamData.getNamespaceId())) { @@ -142,23 +146,32 @@ private DiscoverySyncData buildProxySelectorData(final String value) { } }); discoveryUpstreamDTOS = discoveryUpstreamDTOS.stream() - .filter(upstreamData -> contextInfo.getNamespaceId().equals(upstreamData.getNamespaceId())) + .filter(upstreamData -> discoverySyncData.getNamespaceId().equals(upstreamData.getNamespaceId())) .collect(Collectors.toList()); discoveryUpstreamDTOS.forEach(discoveryUpstreamData -> { - discoveryUpstreamData.setDiscoveryHandlerId(discoveryHandlerId); + discoveryUpstreamData.setDiscoveryHandlerId(discoverySyncData.getDiscoveryHandlerId()); if (StringUtils.isBlank(discoveryUpstreamData.getProtocol())) { - discoveryUpstreamData.setProtocol(discoverySupportProtocol(contextInfo.getPluginName())); + discoveryUpstreamData.setProtocol(discoverySupportProtocol(discoverySyncData.getPluginName())); } }); DiscoverySyncData data = new DiscoverySyncData(); data.setUpstreamDataList(discoveryUpstreamDTOS); - data.setSelectorId(contextInfo.getSelectorId()); - data.setSelectorName(contextInfo.getSelectorName()); - data.setPluginName(contextInfo.getPluginName()); - data.setNamespaceId(contextInfo.getNamespaceId()); + data.setSelectorId(discoverySyncData.getSelectorId()); + data.setSelectorName(discoverySyncData.getSelectorName()); + data.setPluginName(discoverySyncData.getPluginName()); + data.setNamespaceId(discoverySyncData.getNamespaceId()); return data; } + @Override + public void addListener(final DiscoverySyncData discoverySyncData) { + if (discoverySyncDataList.stream().noneMatch(data -> data.getSelectorId().equals(discoverySyncData.getSelectorId()) + && data.getDiscoveryHandlerId().equals(discoverySyncData.getDiscoveryHandlerId()))) { + discoverySyncDataList.add(discoverySyncData); + LOG.info("[DiscoveryDataChangedEventSyncListener] add discoverySyncData {}", discoverySyncData); + } + } + private String discoverySupportProtocol(final String pluginName) { String pluginNameLower = pluginName.toLowerCase(); switch (pluginNameLower) { diff --git a/shenyu-discovery/shenyu-discovery-api/src/main/java/org/apache/shenyu/discovery/api/listener/DataChangedEventListener.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/discovery/listener/DataChangedEventListener.java similarity index 79% rename from shenyu-discovery/shenyu-discovery-api/src/main/java/org/apache/shenyu/discovery/api/listener/DataChangedEventListener.java rename to shenyu-admin/src/main/java/org/apache/shenyu/admin/discovery/listener/DataChangedEventListener.java index 9e7c97e72068..ffeab471a341 100644 --- a/shenyu-discovery/shenyu-discovery-api/src/main/java/org/apache/shenyu/discovery/api/listener/DataChangedEventListener.java +++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/discovery/listener/DataChangedEventListener.java @@ -15,17 +15,26 @@ * limitations under the License. */ -package org.apache.shenyu.discovery.api.listener; +package org.apache.shenyu.admin.discovery.listener; + +import org.apache.shenyu.common.dto.DiscoverySyncData; /** * Data changed listener. */ public interface DataChangedEventListener { - + /** * when data changed, fire this event. - * + * * @param event data changed event */ void onChange(DiscoveryDataChangedEvent event); -} + + /** + * addListener. + * + * @param discoverySyncData discoverySyncData + */ + void addListener(DiscoverySyncData discoverySyncData); +} \ No newline at end of file diff --git a/shenyu-discovery/shenyu-discovery-api/src/main/java/org/apache/shenyu/discovery/api/listener/DiscoveryDataChangedEvent.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/discovery/listener/DiscoveryDataChangedEvent.java similarity index 95% rename from shenyu-discovery/shenyu-discovery-api/src/main/java/org/apache/shenyu/discovery/api/listener/DiscoveryDataChangedEvent.java rename to shenyu-admin/src/main/java/org/apache/shenyu/admin/discovery/listener/DiscoveryDataChangedEvent.java index 414034590675..0755c1dc66e4 100644 --- a/shenyu-discovery/shenyu-discovery-api/src/main/java/org/apache/shenyu/discovery/api/listener/DiscoveryDataChangedEvent.java +++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/discovery/listener/DiscoveryDataChangedEvent.java @@ -15,19 +15,19 @@ * limitations under the License. */ -package org.apache.shenyu.discovery.api.listener; +package org.apache.shenyu.admin.discovery.listener; /** * Data changed event. */ public final class DiscoveryDataChangedEvent { - + private final String key; - + private final String value; - + private final Event event; - + /** * Instantiates a new Data changed event. * @@ -40,7 +40,7 @@ public DiscoveryDataChangedEvent(final String key, final String value, final Eve this.value = value; this.event = event; } - + /** * Gets key. * @@ -49,7 +49,7 @@ public DiscoveryDataChangedEvent(final String key, final String value, final Eve public String getKey() { return key; } - + /** * Gets value. * @@ -58,7 +58,7 @@ public String getKey() { public String getValue() { return value; } - + /** * Gets event. * @@ -67,12 +67,12 @@ public String getValue() { public Event getEvent() { return event; } - + /** * Data changed event. */ public enum Event { - + /** * Added event. */ diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/disruptor/subscriber/DiscoveryConfigRegisterExecutorSubscriber.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/disruptor/subscriber/DiscoveryConfigRegisterExecutorSubscriber.java index 82a78e1634cb..d21f3d864ef2 100644 --- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/disruptor/subscriber/DiscoveryConfigRegisterExecutorSubscriber.java +++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/disruptor/subscriber/DiscoveryConfigRegisterExecutorSubscriber.java @@ -22,6 +22,8 @@ import org.apache.shenyu.register.common.dto.DiscoveryConfigRegisterDTO; import org.apache.shenyu.register.common.subsriber.ExecutorTypeSubscriber; import org.apache.shenyu.register.common.type.DataType; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.Collection; import java.util.concurrent.ScheduledExecutorService; @@ -30,6 +32,8 @@ public class DiscoveryConfigRegisterExecutorSubscriber implements ExecutorTypeSubscriber { + private static final Logger log = LoggerFactory.getLogger(DiscoveryConfigRegisterExecutorSubscriber.class); + private final DiscoveryService discoveryService; private final ScheduledExecutorService executorService; @@ -46,7 +50,13 @@ public DiscoveryConfigRegisterExecutorSubscriber(final DiscoveryService discover @Override public void executor(final Collection discoveryConfigRegisterDTOS) { - executorService.schedule(() -> discoveryConfigRegisterDTOS.forEach(discoveryService::registerDiscoveryConfig), 2, TimeUnit.SECONDS); + executorService.schedule(() -> { + try { + discoveryConfigRegisterDTOS.forEach(discoveryService::registerDiscoveryConfig); + } catch (Exception e) { + log.error("discovery config register error ", e); + } + }, 2, TimeUnit.SECONDS); } @Override diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/mapper/DiscoveryMapper.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/mapper/DiscoveryMapper.java index d0f7c63c3d33..48c26d55779e 100644 --- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/mapper/DiscoveryMapper.java +++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/mapper/DiscoveryMapper.java @@ -74,13 +74,25 @@ public interface DiscoveryMapper extends ExistProvider { /** * select discovery by plugin name and level. * - * @param pluginName plugin name - * @param level level - * @param namespaceId namespaceId + * @param pluginName plugin name + * @param level level + * @param namespaceId namespaceId * @return {@linkplain DiscoveryDO} */ DiscoveryDO selectByPluginNameAndLevelAndNamespaceId(@Param("pluginName") String pluginName, @Param("level") String level, @Param("namespaceId") String namespaceId); + /** + * select discovery by plugin name and level. + * + * @param pluginName plugin name + * @param level level + * @param namespaceId namespaceId + * @param discoveryType discoveryType + * @return {@linkplain DiscoveryDO} + */ + DiscoveryDO selectByPluginNameAndLevelAndNamespaceIdAndType(@Param("pluginName") String pluginName, @Param("level") String level, @Param("namespaceId") String namespaceId, + @Param("discoveryType") String discoveryType); + /** * insert discovery. * diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/mapper/DiscoveryRelMapper.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/mapper/DiscoveryRelMapper.java index a3efb34e4115..51d82795188f 100644 --- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/mapper/DiscoveryRelMapper.java +++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/mapper/DiscoveryRelMapper.java @@ -107,4 +107,5 @@ public interface DiscoveryRelMapper { * @return rows */ int deleteByDiscoveryHandlerId(@Param("discoveryHandlerId") String discoveryHandlerId); + } diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/converter/AbstractSelectorHandleConverter.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/converter/AbstractSelectorHandleConverter.java index 01c57c1cdd6f..d8aa597641f0 100644 --- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/converter/AbstractSelectorHandleConverter.java +++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/converter/AbstractSelectorHandleConverter.java @@ -69,7 +69,7 @@ public String handler(final String handle, final List aliveList) */ @Override public List updateStatusAndFilter(final List existList, final List aliveList) { - if (Objects.isNull(aliveList)) { + if (Objects.isNull(aliveList) || Objects.isNull(existList)) { return Lists.newArrayList(); } long currentTimeMillis = System.currentTimeMillis(); diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/converter/SpringCloudSelectorHandleConverter.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/converter/SpringCloudSelectorHandleConverter.java deleted file mode 100644 index 68f4bf0a6a3c..000000000000 --- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/converter/SpringCloudSelectorHandleConverter.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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.admin.service.converter; - -import org.apache.shenyu.admin.utils.CommonUpstreamUtils; -import org.apache.shenyu.common.dto.convert.selector.CommonUpstream; -import org.apache.shenyu.common.dto.convert.selector.DivideUpstream; -import org.apache.shenyu.common.dto.convert.selector.SpringCloudSelectorHandle; -import org.apache.shenyu.common.enums.PluginEnum; -import org.apache.shenyu.common.utils.GsonUtils; -import org.springframework.stereotype.Component; - -import java.util.List; - -/** - * The type Spring cloud selector handle converter. - */ -@Component -public class SpringCloudSelectorHandleConverter extends AbstractSelectorHandleConverter implements SelectorHandleConverter { - - @Override - public List convertUpstream(final String handle) { - return CommonUpstreamUtils.convertCommonUpstreamList(convert(handle).getDivideUpstreams()); - } - - @Override - public String pluginName() { - return PluginEnum.SPRING_CLOUD.getName(); - } - - @Override - protected Object doHandle(final String handle, final List aliveList) { - SpringCloudSelectorHandle selectorHandle = convert(handle); - List existList = updateStatusAndFilter(selectorHandle.getDivideUpstreams(), aliveList); - aliveList.stream().filter(alive -> existList.stream().noneMatch(valid -> valid.getUpstreamUrl().equals(alive.getUpstreamUrl()))) - .forEach(alive -> existList.add(CommonUpstreamUtils.buildDefaultAliveDivideUpstream(alive.getUpstreamUrl()))); - existList.removeIf(e -> aliveList.stream().noneMatch(alive -> alive.getUpstreamUrl().equals(e.getUpstreamUrl()))); - selectorHandle.setDivideUpstreams(existList); - return selectorHandle; - } - - private SpringCloudSelectorHandle convert(final String handle) { - return GsonUtils.getInstance().fromJson(handle, SpringCloudSelectorHandle.class); - } -} diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/DiscoveryServiceImpl.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/DiscoveryServiceImpl.java index 24cc2a7019b8..7dd796251ac0 100644 --- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/DiscoveryServiceImpl.java +++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/DiscoveryServiceImpl.java @@ -146,8 +146,8 @@ private void bindingDiscovery(final DiscoveryConfigRegisterDTO discoveryConfigRe proxySelectorDTO.setId(selectorDO.getId()); proxySelectorDTO.setPluginName(discoveryConfigRegisterDTO.getPluginName()); proxySelectorDTO.setNamespaceId(selectorDO.getNamespaceId()); - DiscoveryDO discoveryDO = discoveryMapper.selectByPluginNameAndLevelAndNamespaceId(discoveryConfigRegisterDTO.getPluginName(), - DiscoveryLevel.PLUGIN.getCode(), discoveryConfigRegisterDTO.getNamespaceId()); + DiscoveryDO discoveryDO = discoveryMapper.selectByPluginNameAndLevelAndNamespaceIdAndType(discoveryConfigRegisterDTO.getPluginName(), + DiscoveryLevel.PLUGIN.getCode(), discoveryConfigRegisterDTO.getNamespaceId(), discoveryConfigRegisterDTO.getDiscoveryType()); if (discoveryDO == null) { Timestamp currentTime = new Timestamp(System.currentTimeMillis()); discoveryDO = DiscoveryDO.builder() diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/register/ShenyuClientRegisterSpringCloudServiceImpl.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/register/ShenyuClientRegisterSpringCloudServiceImpl.java deleted file mode 100644 index 7d36b268142c..000000000000 --- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/register/ShenyuClientRegisterSpringCloudServiceImpl.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * 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.admin.service.register; - -import org.apache.commons.collections4.CollectionUtils; -import org.apache.shenyu.admin.model.entity.MetaDataDO; -import org.apache.shenyu.admin.model.entity.SelectorDO; -import org.apache.shenyu.admin.service.MetaDataService; -import org.apache.shenyu.admin.service.converter.SpringCloudSelectorHandleConverter; -import org.apache.shenyu.admin.utils.CommonUpstreamUtils; -import org.apache.shenyu.common.dto.convert.rule.impl.SpringCloudRuleHandle; -import org.apache.shenyu.common.dto.convert.selector.DivideUpstream; -import org.apache.shenyu.common.dto.convert.selector.SpringCloudSelectorHandle; -import org.apache.shenyu.common.enums.RpcTypeEnum; -import org.apache.shenyu.common.utils.GsonUtils; -import org.apache.shenyu.register.common.dto.MetaDataRegisterDTO; -import org.apache.shenyu.register.common.dto.URIRegisterDTO; -import org.apache.shenyu.register.common.enums.EventType; -import org.springframework.stereotype.Service; - -import jakarta.annotation.Resource; -import java.util.List; -import java.util.concurrent.CopyOnWriteArrayList; -import java.util.stream.Collectors; - -/** - * spring cloud service register. - */ -@Service("springCloud") -public class ShenyuClientRegisterSpringCloudServiceImpl extends AbstractContextPathRegisterService { - - @Resource - private SpringCloudSelectorHandleConverter springCloudSelectorHandleConverter; - - @Override - public String rpcType() { - return RpcTypeEnum.SPRING_CLOUD.getName(); - } - - @Override - protected String selectorHandler(final MetaDataRegisterDTO metaDataDTO) { - return GsonUtils.getInstance().toJson(SpringCloudSelectorHandle.builder().serviceId(metaDataDTO.getAppName()).build()); - } - - @Override - protected String ruleHandler() { - return new SpringCloudRuleHandle().toJson(); - } - - @Override - protected void registerMetadata(final MetaDataRegisterDTO metaDataDTO) { - MetaDataService metaDataService = getMetaDataService(); - MetaDataDO metaDataDO = metaDataService.findByPathAndNamespaceId(metaDataDTO.getPath(), metaDataDTO.getNamespaceId()); - metaDataService.saveOrUpdateMetaData(metaDataDO, metaDataDTO); - } - - @Override - protected String buildHandle(final List uriList, final SelectorDO selectorDO) { - List addList = buildDivideUpstreamList(uriList); - List canAddList = new CopyOnWriteArrayList<>(); - boolean isEventDeleted = uriList.size() == 1 && EventType.DELETED.equals(uriList.get(0).getEventType()); - if (isEventDeleted) { - addList.get(0).setStatus(false); - } - - SpringCloudSelectorHandle springCloudSelectorHandle = GsonUtils.getInstance().fromJson(selectorDO.getHandle(), SpringCloudSelectorHandle.class); - List existList = springCloudSelectorHandle.getDivideUpstreams(); - if (CollectionUtils.isEmpty(existList)) { - canAddList = addList; - } else { - List diffList = addList.stream().filter(upstream -> !existList.contains(upstream)).collect(Collectors.toList()); - if (CollectionUtils.isNotEmpty(diffList)) { - canAddList.addAll(diffList); - existList.addAll(diffList); - } - List diffStatusList = addList.stream().filter(upstream -> !upstream.isStatus() - || existList.stream().anyMatch(e -> e.equals(upstream) && e.isStatus() != upstream.isStatus())).collect(Collectors.toList()); - if (CollectionUtils.isNotEmpty(diffStatusList)) { - canAddList.addAll(diffStatusList); - } - } - - if (doSubmit(selectorDO.getId(), canAddList)) { - return null; - } - springCloudSelectorHandle.setDivideUpstreams(CollectionUtils.isEmpty(existList) ? canAddList : existList); - return GsonUtils.getInstance().toJson(springCloudSelectorHandle); - } - - private List buildDivideUpstreamList(final List uriList) { - return uriList.stream() - .map(dto -> CommonUpstreamUtils.buildDefaultDivideUpstream(dto.getHost(), dto.getPort(), dto.getNamespaceId())) - .collect(Collectors.toCollection(CopyOnWriteArrayList::new)); - } - -} diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/utils/SelectorUtil.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/utils/SelectorUtil.java index becbf90b5cc7..21d8890561a6 100644 --- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/utils/SelectorUtil.java +++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/utils/SelectorUtil.java @@ -33,7 +33,6 @@ import java.util.Collections; import java.util.List; -import java.util.Objects; /** * ResourceUtil. @@ -54,11 +53,6 @@ private SelectorUtil() { * @return default is empty list. */ public static List buildDivideUpstream(final SelectorDO selectorDO, final String pluginName) { - if (PluginEnum.SPRING_CLOUD.getName().equals(pluginName) && Objects.nonNull(selectorDO.getHandle())) { - return GsonUtils.getInstance() - .fromJson(selectorDO.getHandle(), SpringCloudSelectorHandle.class) - .getDivideUpstreams(); - } if (PluginEnum.DIVIDE.getName().equals(pluginName) && StringUtils.isNotBlank(selectorDO.getHandle())) { return GsonUtils.getInstance() .fromList(selectorDO.getHandle(), DivideUpstream.class); diff --git a/shenyu-admin/src/main/resources/mappers/discovery-sqlmap.xml b/shenyu-admin/src/main/resources/mappers/discovery-sqlmap.xml index 3e0148aaacd8..a1f8b3479953 100644 --- a/shenyu-admin/src/main/resources/mappers/discovery-sqlmap.xml +++ b/shenyu-admin/src/main/resources/mappers/discovery-sqlmap.xml @@ -64,6 +64,14 @@ WHERE plugin_name = #{pluginName, jdbcType=VARCHAR} AND level = #{level, jdbcType=VARCHAR} AND namespace_id = #{namespaceId, jdbcType=VARCHAR} + +