This is an automated email from the ASF dual-hosted git repository.
xiaoyu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-shenyu.git
The following commit(s) were added to refs/heads/master by this push:
new 5bae6f7 [type: feature] support dubbo gray relase. (#2056)
5bae6f7 is described below
commit 5bae6f7d0fcc479f3a8990c443c83fec0f57528f
Author: Kevin Clair <[email protected]>
AuthorDate: Thu Sep 23 18:48:17 2021 +0800
[type: feature] support dubbo gray relase. (#2056)
* dubbo gray release.
* Fix checkstyle.
* Delete code.
* delete init sql.
* support group and version gray.
* Add sql script.
* Fix check style.
* Fix integrated-http-test error.
* Replace with constants.
* update code, use BeanHolder.
* Add sql script.
* Add pg sql support.
---
.../admin/service/impl/SelectorServiceImpl.java | 14 +-
.../impl/ShenyuClientRegisterServiceImpl.java | 4 +-
.../AbstractShenyuClientRegisterServiceImpl.java | 58 +++---
.../ShenyuClientRegisterDubboServiceImpl.java | 11 +-
.../ShenyuClientRegisterGrpcServiceImpl.java | 2 +-
.../ShenyuClientRegisterMotanServiceImpl.java | 2 +-
.../ShenyuClientRegisterSofaServiceImpl.java | 2 +-
...ShenyuClientRegisterSpringCloudServiceImpl.java | 4 +-
.../ShenyuClientRegisterSpringMVCServiceImpl.java | 4 +-
.../ShenyuClientRegisterTarsServiceImpl.java | 2 +-
.../shenyu/admin/utils/DivideUpstreamUtils.java | 4 +-
.../src/main/resources/sql-script/h2/schema.sql | 21 +-
.../src/main/resources/sql-script/mysql/schema.sql | 21 +-
.../src/main/resources/sql-script/pg/schema.sql | 19 +-
.../service/ShenyuClientRegisterServiceTest.java | 2 +-
.../apache/shenyu/common/constant/Constants.java | 15 ++
.../shenyu/common/dto/convert/DivideUpstream.java | 11 +-
.../shenyu/common/dto/convert/rule/RuleHandle.java | 5 +-
.../common/dto/convert/rule/RuleHandleFactory.java | 15 +-
.../convert/rule/impl/ContextMappingHandle.java | 2 +-
.../rule/impl/CryptorRequestRuleHandle.java | 2 +-
.../rule/impl/CryptorResponseRuleHandle.java | 2 +-
.../dto/convert/rule/impl/DivideRuleHandle.java | 2 +-
.../dto/convert/rule/impl/DubboRuleHandle.java | 62 +++---
.../rule/impl/ModifyResponseRuleHandle.java | 2 +-
.../dto/convert/rule/impl/ParamMappingHandle.java | 2 +-
.../dto/convert/rule/impl/SofaRuleHandle.java | 2 +-
.../convert/rule/impl/SpringCloudRuleHandle.java | 2 +-
.../dto/convert/rule/impl/WebSocketRuleHandle.java | 2 +-
.../dto/convert/selector/DubboSelectorHandle.java | 225 +++++++++++++++++++--
.../dto/convert/rule/RuleHandleFactoryTest.java | 10 +-
.../rule/impl/ContextMappingHandleTest.java | 2 +-
.../rule/impl/ModifyResponseRuleHandleTest.java | 2 +-
.../convert/rule/impl/ParamMappingHandleTest.java | 2 +-
.../pom.xml | 2 +
.../annotation/impl/DubboTestServiceImpl.java | 5 +
.../shenyu/loadbalancer/entity/Upstream.java | 109 ++++++++--
shenyu-plugin/shenyu-plugin-apache-dubbo/pom.xml | 5 +
.../plugin/apache/dubbo/ApacheDubboPlugin.java | 4 +
.../apache/dubbo/cache/ApplicationConfigCache.java | 4 +-
.../handler/ApacheDubboPluginDataHandler.java | 73 ++++++-
.../dubbo/proxy/ApacheDubboGrayLoadBalance.java | 85 ++++++++
.../dubbo/org.apache.dubbo.rpc.cluster.LoadBalance | 27 +--
.../plugin/apache/dubbo/ApacheDubboPluginTest.java | 2 -
.../shenyu/plugin/divide/DividePluginTest.java | 2 +-
.../plugin/websocket/WebSocketPluginTest.java | 2 +-
46 files changed, 674 insertions(+), 183 deletions(-)
diff --git
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/SelectorServiceImpl.java
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/SelectorServiceImpl.java
index 241cc9a..64b8f3f 100644
---
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/SelectorServiceImpl.java
+++
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/SelectorServiceImpl.java
@@ -239,8 +239,7 @@ public class SelectorServiceImpl implements SelectorService
{
@Override
public SelectorData buildByName(final String name) {
- SelectorDO selectorDO = selectorMapper.selectByName(name);
- return buildSelectorData(selectorDO);
+ return buildSelectorData(selectorMapper.selectByName(name));
}
/**
@@ -284,9 +283,8 @@ public class SelectorServiceImpl implements SelectorService
{
}
SelectorDO selectorDO = selectorMapper.selectByName(contextPath);
String selectorId;
- String uri = String.join(":", dto.getHost(),
String.valueOf(dto.getPort()));
if (Objects.isNull(selectorDO)) {
- selectorId = registerPluginSelector(contextPath, uri, rpcType);
+ selectorId = registerPluginSelector(contextPath, dto, rpcType);
} else {
selectorId = selectorDO.getId();
//update upstream
@@ -300,8 +298,8 @@ public class SelectorServiceImpl implements SelectorService
{
handleAdd =
GsonUtils.getInstance().toJson(Collections.singletonList(addDivideUpstream));
} else {
List<DivideUpstream> exist =
GsonUtils.getInstance().fromList(handle, DivideUpstream.class);
- for (DivideUpstream upstream : exist) {
- if
(upstream.getUpstreamUrl().equals(addDivideUpstream.getUpstreamUrl())) {
+ for (DivideUpstream each : exist) {
+ if
(each.getUpstreamUrl().equals(addDivideUpstream.getUpstreamUrl())) {
return selectorId;
}
}
@@ -362,10 +360,10 @@ public class SelectorServiceImpl implements
SelectorService {
}
}
- private String registerPluginSelector(final String contextPath, final
String uri, final String rpcType) {
+ private String registerPluginSelector(final String contextPath, final
MetaDataRegisterDTO metaDataRegisterDTO, final String rpcType) {
SelectorDTO selectorDTO = registerSelector(contextPath,
pluginMapper.selectByName(rpcType).getId());
//is divide
- DivideUpstream divideUpstream = buildDivideUpstream(uri);
+ DivideUpstream divideUpstream =
DivideUpstreamUtils.buildDivideUpstream(metaDataRegisterDTO);
String handler =
GsonUtils.getInstance().toJson(Collections.singletonList(divideUpstream));
selectorDTO.setHandle(handler);
upstreamCheckService.submit(selectorDTO.getName(), divideUpstream);
diff --git
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/ShenyuClientRegisterServiceImpl.java
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/ShenyuClientRegisterServiceImpl.java
index 0abf68f..f78965d 100644
---
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/ShenyuClientRegisterServiceImpl.java
+++
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/ShenyuClientRegisterServiceImpl.java
@@ -477,9 +477,9 @@ public class ShenyuClientRegisterServiceImpl implements
ShenyuClientRegisterServ
private void registerRule(final String selectorId, final String path,
final String pluginName, final String ruleName) {
RuleHandle ruleHandle;
if (pluginName.equals(PluginEnum.CONTEXT_PATH.getName())) {
- ruleHandle = RuleHandleFactory.ruleHandle(pluginName,
buildContextPath(path));
+ ruleHandle = RuleHandleFactory.ruleHandle(pluginName,
buildContextPath(path), "");
} else {
- ruleHandle = RuleHandleFactory.ruleHandle(pluginName, path);
+ ruleHandle = RuleHandleFactory.ruleHandle(pluginName, path, "");
}
RuleDTO ruleDTO = RuleDTO.builder()
.selectorId(selectorId)
diff --git
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/register/AbstractShenyuClientRegisterServiceImpl.java
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/register/AbstractShenyuClientRegisterServiceImpl.java
index 57e8f13..eb621c1 100644
---
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/register/AbstractShenyuClientRegisterServiceImpl.java
+++
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/register/AbstractShenyuClientRegisterServiceImpl.java
@@ -29,7 +29,6 @@ import
org.apache.shenyu.common.dto.convert.rule.RuleHandleFactory;
import org.apache.shenyu.common.enums.MatchModeEnum;
import org.apache.shenyu.common.enums.OperatorEnum;
import org.apache.shenyu.common.enums.ParamTypeEnum;
-import org.apache.shenyu.common.enums.PluginEnum;
import org.apache.shenyu.common.enums.SelectorTypeEnum;
import org.apache.shenyu.register.common.dto.MetaDataRegisterDTO;
@@ -79,30 +78,15 @@ public abstract class
AbstractShenyuClientRegisterServiceImpl implements ShenyuC
return selectorDTO;
}
- protected RuleDTO registerRule(final String selectorId, final String path,
final String pluginName, final String ruleName) {
- RuleHandle ruleHandle =
pluginName.equals(PluginEnum.CONTEXT_PATH.getName())
- ? RuleHandleFactory.ruleHandle(pluginName,
buildContextPath(path)) : RuleHandleFactory.ruleHandle(pluginName, path);
- RuleDTO ruleDTO = RuleDTO.builder()
- .selectorId(selectorId)
- .name(ruleName)
- .matchMode(MatchModeEnum.AND.getCode())
- .enabled(Boolean.TRUE)
- .loged(Boolean.TRUE)
- .sort(1)
- .handle(ruleHandle.toJson())
- .build();
- RuleConditionDTO ruleConditionDTO = RuleConditionDTO.builder()
- .paramType(ParamTypeEnum.URI.getName())
- .paramName("/")
- .paramValue(path)
- .build();
- if (path.indexOf("*") > 1) {
- ruleConditionDTO.setOperator(OperatorEnum.MATCH.getAlias());
- } else {
- ruleConditionDTO.setOperator(OperatorEnum.EQ.getAlias());
- }
- ruleDTO.setRuleConditions(Collections.singletonList(ruleConditionDTO));
- return ruleDTO;
+ protected RuleDTO registerRule(final String selectorId, final
MetaDataRegisterDTO metaDataDTO, final String pluginName) {
+ String path = metaDataDTO.getPath();
+ RuleHandle ruleHandle = RuleHandleFactory.ruleHandle(pluginName, path,
metaDataDTO.getRpcExt());
+ return getRuleDTO(selectorId, path, ruleHandle,
metaDataDTO.getRuleName());
+ }
+
+ protected RuleDTO registerContextPathRule(final String selectorId, final
String path, final String pluginName, final String ruleName) {
+ RuleHandle ruleHandle = RuleHandleFactory.ruleHandle(pluginName,
buildContextPath(path), "");
+ return getRuleDTO(selectorId, path, ruleHandle, ruleName);
}
protected List<SelectorConditionDTO>
buildDefaultSelectorConditionDTO(final String contextPath) {
@@ -144,4 +128,28 @@ public abstract class
AbstractShenyuClientRegisterServiceImpl implements ShenyuC
&&
(!existMetaDataDO.getMethodName().equals(dto.getMethodName())
||
!existMetaDataDO.getServiceName().equals(dto.getServiceName()));
}
+
+ private RuleDTO getRuleDTO(final String selectorId, final String path,
final RuleHandle ruleHandle, final String ruleName) {
+ RuleDTO ruleDTO = RuleDTO.builder()
+ .selectorId(selectorId)
+ .name(ruleName)
+ .matchMode(MatchModeEnum.AND.getCode())
+ .enabled(Boolean.TRUE)
+ .loged(Boolean.TRUE)
+ .sort(1)
+ .handle(ruleHandle.toJson())
+ .build();
+ RuleConditionDTO ruleConditionDTO = RuleConditionDTO.builder()
+ .paramType(ParamTypeEnum.URI.getName())
+ .paramName("/")
+ .paramValue(path)
+ .build();
+ if (path.indexOf("*") > 1) {
+ ruleConditionDTO.setOperator(OperatorEnum.MATCH.getAlias());
+ } else {
+ ruleConditionDTO.setOperator(OperatorEnum.EQ.getAlias());
+ }
+ ruleDTO.setRuleConditions(Collections.singletonList(ruleConditionDTO));
+ return ruleDTO;
+ }
}
diff --git
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/register/ShenyuClientRegisterDubboServiceImpl.java
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/register/ShenyuClientRegisterDubboServiceImpl.java
index 1e5f980..cb0457e 100644
---
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/register/ShenyuClientRegisterDubboServiceImpl.java
+++
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/register/ShenyuClientRegisterDubboServiceImpl.java
@@ -18,7 +18,6 @@
package org.apache.shenyu.admin.service.register;
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.PluginService;
import org.apache.shenyu.admin.service.RuleService;
@@ -29,8 +28,6 @@ import
org.apache.shenyu.register.common.dto.MetaDataRegisterDTO;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
-import java.util.Objects;
-
/**
* dubbo service register.
*/
@@ -72,16 +69,12 @@ public class ShenyuClientRegisterDubboServiceImpl extends
AbstractShenyuClientRe
@Override
public String handlerSelector(final MetaDataRegisterDTO metaDataDTO) {
- SelectorDO selectorDO =
selectorService.findByName(metaDataDTO.getContextPath());
- if (Objects.nonNull(selectorDO)) {
- return selectorDO.getId();
- }
- return
selectorService.register(registerSelector(metaDataDTO.getContextPath(),
pluginService.selectIdByName(metaDataDTO.getRpcType())));
+ return selectorService.handlerSelectorNeedUpstreamCheck(metaDataDTO,
PluginEnum.DUBBO.getName());
}
@Override
public void handlerRule(final String selectorId, final MetaDataRegisterDTO
metaDataDTO, final MetaDataDO exist) {
- ruleService.register(registerRule(selectorId, metaDataDTO.getPath(),
PluginEnum.DUBBO.getName(), metaDataDTO.getRuleName()),
+ ruleService.register(registerRule(selectorId, metaDataDTO,
PluginEnum.DUBBO.getName()),
metaDataDTO.getPath(), false);
}
}
diff --git
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/register/ShenyuClientRegisterGrpcServiceImpl.java
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/register/ShenyuClientRegisterGrpcServiceImpl.java
index 7cd55f0..3c72302 100644
---
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/register/ShenyuClientRegisterGrpcServiceImpl.java
+++
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/register/ShenyuClientRegisterGrpcServiceImpl.java
@@ -71,7 +71,7 @@ public class ShenyuClientRegisterGrpcServiceImpl extends
AbstractShenyuClientReg
@Override
public void handlerRule(final String selectorId, final MetaDataRegisterDTO
metaDataDTO, final MetaDataDO exist) {
- ruleService.register(registerRule(selectorId, metaDataDTO.getPath(),
PluginEnum.GRPC.getName(), metaDataDTO.getRuleName()),
+ ruleService.register(registerRule(selectorId, metaDataDTO,
PluginEnum.GRPC.getName()),
metaDataDTO.getPath(),
Objects.isNull(exist));
}
diff --git
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/register/ShenyuClientRegisterMotanServiceImpl.java
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/register/ShenyuClientRegisterMotanServiceImpl.java
index 4b0b69a..eaffbc9 100644
---
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/register/ShenyuClientRegisterMotanServiceImpl.java
+++
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/register/ShenyuClientRegisterMotanServiceImpl.java
@@ -71,7 +71,7 @@ public class ShenyuClientRegisterMotanServiceImpl extends
AbstractShenyuClientRe
@Override
public void handlerRule(final String selectorId, final MetaDataRegisterDTO
metaDataDTO, final MetaDataDO exist) {
- ruleService.register(registerRule(selectorId, metaDataDTO.getPath(),
PluginEnum.MOTAN.getName(), metaDataDTO.getRuleName()),
+ ruleService.register(registerRule(selectorId, metaDataDTO,
PluginEnum.MOTAN.getName()),
metaDataDTO.getPath(),
Objects.isNull(exist));
}
diff --git
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/register/ShenyuClientRegisterSofaServiceImpl.java
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/register/ShenyuClientRegisterSofaServiceImpl.java
index 7f86a9a..454461c 100644
---
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/register/ShenyuClientRegisterSofaServiceImpl.java
+++
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/register/ShenyuClientRegisterSofaServiceImpl.java
@@ -88,7 +88,7 @@ public class ShenyuClientRegisterSofaServiceImpl extends
AbstractShenyuClientReg
@Override
public void handlerRule(final String selectorId, final MetaDataRegisterDTO
metaDataDTO, final MetaDataDO exist) {
- ruleService.register(registerRule(selectorId, metaDataDTO.getPath(),
PluginEnum.SOFA.getName(), metaDataDTO.getRuleName()),
+ ruleService.register(registerRule(selectorId, metaDataDTO,
PluginEnum.SOFA.getName()),
metaDataDTO.getPath(),
Objects.isNull(exist));
}
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
index de81286..37865e3 100644
---
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
@@ -175,7 +175,7 @@ public class ShenyuClientRegisterSpringCloudServiceImpl
extends AbstractShenyuCl
@Override
public void handlerRule(final String selectorId, final MetaDataRegisterDTO
dto, final MetaDataDO exist) {
- ruleService.register(registerRule(selectorId, dto.getPath(),
PluginEnum.SPRING_CLOUD.getName(), dto.getRuleName()),
+ ruleService.register(registerRule(selectorId, dto,
PluginEnum.SPRING_CLOUD.getName()),
dto.getRuleName(),
false);
}
@@ -185,7 +185,7 @@ public class ShenyuClientRegisterSpringCloudServiceImpl
extends AbstractShenyuCl
SelectorDO selectorDO = selectorService.findByName(name);
if (Objects.isNull(selectorDO)) {
String contextPathSelectorId =
registerContextPathSelector(contextPath, name);
- ruleService.register(registerRule(contextPathSelectorId,
contextPath + "/**", PluginEnum.CONTEXT_PATH.getName(), name),
+
ruleService.register(registerContextPathRule(contextPathSelectorId, contextPath
+ "/**", PluginEnum.CONTEXT_PATH.getName(), name),
name,
false);
}
diff --git
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/register/ShenyuClientRegisterSpringMVCServiceImpl.java
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/register/ShenyuClientRegisterSpringMVCServiceImpl.java
index 5ab4b94..046560a 100644
---
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/register/ShenyuClientRegisterSpringMVCServiceImpl.java
+++
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/register/ShenyuClientRegisterSpringMVCServiceImpl.java
@@ -115,7 +115,7 @@ public class ShenyuClientRegisterSpringMVCServiceImpl
extends AbstractShenyuClie
@Override
public void handlerRule(final String selectorId, final MetaDataRegisterDTO
dto, final MetaDataDO exist) {
- ruleService.register(registerRule(selectorId, dto.getPath(),
PluginEnum.DIVIDE.getName(), dto.getRuleName()),
+ ruleService.register(registerRule(selectorId, dto,
PluginEnum.DIVIDE.getName()),
dto.getRuleName(),
false);
}
@@ -125,7 +125,7 @@ public class ShenyuClientRegisterSpringMVCServiceImpl
extends AbstractShenyuClie
SelectorDO selectorDO = selectorService.findByName(name);
if (Objects.isNull(selectorDO)) {
String contextPathSelectorId =
registerContextPathSelector(contextPath, name);
- ruleService.register(registerRule(contextPathSelectorId,
contextPath + "/**", PluginEnum.CONTEXT_PATH.getName(), name),
+
ruleService.register(registerContextPathRule(contextPathSelectorId, contextPath
+ "/**", PluginEnum.CONTEXT_PATH.getName(), name),
name,
false);
}
diff --git
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/register/ShenyuClientRegisterTarsServiceImpl.java
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/register/ShenyuClientRegisterTarsServiceImpl.java
index 90a290b..f6306bb 100644
---
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/register/ShenyuClientRegisterTarsServiceImpl.java
+++
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/register/ShenyuClientRegisterTarsServiceImpl.java
@@ -75,6 +75,6 @@ public class ShenyuClientRegisterTarsServiceImpl extends
AbstractShenyuClientReg
@Override
public void handlerRule(final String selectorId, final MetaDataRegisterDTO
metaDataDTO, final MetaDataDO exist) {
- ruleService.register(registerRule(selectorId, metaDataDTO.getPath(),
PluginEnum.TARS.getName(), metaDataDTO.getRuleName()), metaDataDTO.getPath(),
Objects.isNull(exist));
+ ruleService.register(registerRule(selectorId, metaDataDTO,
PluginEnum.TARS.getName()), metaDataDTO.getPath(), Objects.isNull(exist));
}
}
diff --git
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/utils/DivideUpstreamUtils.java
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/utils/DivideUpstreamUtils.java
index e259e08..39f822b 100644
---
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/utils/DivideUpstreamUtils.java
+++
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/utils/DivideUpstreamUtils.java
@@ -29,7 +29,7 @@ public class DivideUpstreamUtils {
/**
- * buildDivideUpstream.
+ * build divide upstream.
*
* @param metaDataRegisterDTO metaDataRegisterDTO
* @return divideUpstream divideUpstream
@@ -39,7 +39,7 @@ public class DivideUpstreamUtils {
}
/**
- * buildUrl.
+ * build url.
*
* @param metaDataRegisterDTO metaDataRegisterDTO
* @return String String
diff --git a/shenyu-admin/src/main/resources/sql-script/h2/schema.sql
b/shenyu-admin/src/main/resources/sql-script/h2/schema.sql
index 2960956..c742153 100644
--- a/shenyu-admin/src/main/resources/sql-script/h2/schema.sql
+++ b/shenyu-admin/src/main/resources/sql-script/h2/schema.sql
@@ -311,13 +311,18 @@ INSERT IGNORE INTO `shenyu_dict` (`id`,
`type`,`dict_code`, `dict_name`, `dict_v
INSERT IGNORE INTO shenyu_dict (`id`, `type`, `dict_code`, `dict_name`,
`dict_value`, `desc`, `sort`, `enabled`, `date_created`, `date_updated`) VALUES
('12', 'mode', 'MODE', 'cluster', 'cluster', 'cluster', 0, 1, '2020-12-25
00:00:00', '2020-12-25 00:00:00');
INSERT IGNORE INTO shenyu_dict (`id`, `type`, `dict_code`, `dict_name`,
`dict_value`, `desc`, `sort`, `enabled`, `date_created`, `date_updated`) VALUES
('13', 'mode', 'MODE', 'sentinel', 'sentinel', 'sentinel', 1, 1, '2020-12-25
00:00:00', '2020-12-25 00:00:00');
INSERT IGNORE INTO shenyu_dict (`id`, `type`, `dict_code`, `dict_name`,
`dict_value`, `desc`, `sort`, `enabled`, `date_created`, `date_updated`) VALUES
('14', 'mode', 'MODE', 'standalone', 'standalone', 'standalone', 2, 1,
'2020-12-25 00:00:00', '2020-12-25 00:00:00');
+
+/*insert dict for dubbo plugin*/
+INSERT IGNORE INTO shenyu_dict (`id`, `type`, `dict_code`, `dict_name`,
`dict_value`, `desc`, `sort`, `enabled`, `date_created`, `date_updated`) VALUES
('54', 'gray', 'GRAY_STATUS', 'close', 'false', 'close', '1', '1', '2021-03-08
14:21:58', '2021-03-08 14:21:58');
+INSERT IGNORE INTO shenyu_dict (`id`, `type`, `dict_code`, `dict_name`,
`dict_value`, `desc`, `sort`, `enabled`, `date_created`, `date_updated`) VALUES
('55', 'gray', 'GRAY_STATUS', 'open', 'true', 'open', '0', '1', '2021-03-08
14:21:32', '2021-03-08 14:21:32');
+
/*plugin*/
INSERT IGNORE INTO `plugin` (`id`, `name`, `role`, `sort`, `enabled`,
`date_created`, `date_updated`) VALUES ('1','sign','authentication', 20, '0',
'2018-06-14 10:17:35', '2018-06-14 10:17:35');
INSERT IGNORE INTO `plugin` (`id`, `name`, `role`, `sort`,`config`,`enabled`,
`date_created`, `date_updated`) VALUES ('2','waf', 'authentication',
50,'{"model":"black"}','0', '2018-06-23 10:26:30', '2018-06-13 15:43:10');
INSERT IGNORE INTO `plugin` (`id`, `name`, `role`, `sort`, `enabled`,
`date_created`, `date_updated`) VALUES ('3','rewrite', 'http process', 90,'0',
'2018-06-23 10:26:34', '2018-06-25 13:59:31');
INSERT IGNORE INTO `plugin` (`id`, `name`, `role`, `sort`, `config`,`enabled`,
`date_created`, `date_updated`) VALUES ('4','rate_limiter','fault tolerance',
60,'{"master":"mymaster","mode":"standalone","url":"192.168.1.1:6379","password":"abc"}',
'0', '2018-06-23 10:26:37', '2018-06-13 15:34:48');
INSERT IGNORE INTO `plugin` (`id`, `name`, `role`, `sort`, `config`,`enabled`,
`date_created`, `date_updated`) VALUES ('5','divide', 'proxy',
200,'{"multiSelectorHandle":"1","multiRuleHandle":"0"}','1', '2018-06-25
10:19:10', '2018-06-13 13:56:04');
-INSERT IGNORE INTO `plugin` (`id`, `name`, `role`, `sort`, `config`,`enabled`,
`date_created`, `date_updated`) VALUES ('6','dubbo','proxy',
310,'{"register":"zookeeper://localhost:2181"}', '0', '2018-06-23 10:26:41',
'2018-06-11 10:11:47');
+INSERT IGNORE INTO `plugin` (`id`, `name`, `role`, `sort`, `config`,`enabled`,
`date_created`, `date_updated`) VALUES ('6','dubbo','proxy',
310,'{"register":"zookeeper://localhost:2181","multiSelectorHandle":"1"}', '0',
'2018-06-23 10:26:41', '2018-06-11 10:11:47');
INSERT IGNORE INTO `plugin` (`id`, `name`, `role`, `sort`, `config`,`enabled`,
`date_created`, `date_updated`) VALUES ('7','monitor', 'monitor',
170,'{"metricsName":"prometheus","host":"localhost","port":"9190","async":"true"}','0',
'2018-06-25 13:47:57', '2018-06-25 13:47:57');
INSERT IGNORE INTO `plugin` (`id`, `name`, `role`, `sort`, `enabled`,
`date_created`, `date_updated`) VALUES ('8','springCloud','proxy', 200, '0',
'2018-06-25 13:47:57', '2018-06-25 13:47:57');
INSERT IGNORE INTO `plugin` (`id`, `name`, `role`, `sort`, `enabled`,
`date_created`, `date_updated`) VALUES ('9','hystrix', 'fault tolerance',
130,'0', '2020-01-15 10:19:10', '2020-01-15 10:19:10');
@@ -474,6 +479,20 @@ INSERT IGNORE INTO plugin_handle
(`id`,`plugin_id`,`field`,`label`,`data_type`,`
INSERT IGNORE INTO plugin_handle
(`id`,`plugin_id`,`field`,`label`,`data_type`,`type`,`sort`,`ext_obj`,`date_created`,`date_updated`)
VALUES ('1008', '26', 'retry', 'retryCount', 1, 2, 1, null, '2021-08-27
21:31:00', '2021-08-27 10:32:51');
INSERT IGNORE INTO plugin_handle
(`id`,`plugin_id`,`field`,`label`,`data_type`,`type`,`sort`,`ext_obj`,`date_created`,`date_updated`)
VALUES ('1009', '26', 'timeout', 'timeout', 1, 2, 2,
'{"defaultValue":"3000","rule":""}', '2021-08-27 21:13:50', '2021-08-27
10:32:51');
+/*insert plugin_handle data for dubbo*/
+INSERT IGNORE INTO plugin_handle (`id`, `plugin_id`, `field`, `label`,
`data_type`, `type`, `sort`, `ext_obj`, `date_created`, `date_updated`) VALUES
('119', '6', 'gray', 'gray', '3', '1', '9',
'{\"required\":\"0\",\"defaultValue\":\"false\",\"placeholder\":\"gray\",\"rule\":\"\"}',
'2021-03-06 21:29:16', '2021-09-23 14:45:16');
+INSERT IGNORE INTO plugin_handle (`id`, `plugin_id`, `field`, `label`,
`data_type`, `type`, `sort`, `ext_obj`, `date_created`, `date_updated`) VALUES
('120', '6', 'group', 'group', '2', '1', '3',
'{\"required\":\"0\",\"placeholder\":\"group\",\"rule\":\"\"}', '2021-03-06
21:25:55', '2021-09-23 14:43:19');
+INSERT IGNORE INTO plugin_handle (`id`, `plugin_id`, `field`, `label`,
`data_type`, `type`, `sort`, `ext_obj`, `date_created`, `date_updated`) VALUES
('122', '6', 'loadbalance', 'loadbalance', '2', '2', '0',
'{\"required\":\"0\",\"placeholder\":\"loadbalance\",\"rule\":\"\"}',
'2021-09-20 20:36:10', '2021-09-20 21:25:12');
+INSERT IGNORE INTO plugin_handle (`id`, `plugin_id`, `field`, `label`,
`data_type`, `type`, `sort`, `ext_obj`, `date_created`, `date_updated`) VALUES
('111', '6', 'multiSelectorHandle', 'multiSelectorHandle', '3', '3', '0', NULL,
'2021-03-08 13:18:44', '2021-03-09 10:32:51');
+INSERT IGNORE INTO plugin_handle (`id`, `plugin_id`, `field`, `label`,
`data_type`, `type`, `sort`, `ext_obj`, `date_created`, `date_updated`) VALUES
('115', '6', 'protocol', 'protocol', '2', '1', '2',
'{\"required\":\"0\",\"defaultValue\":\"\",\"placeholder\":\"http://\",\"rule\":\"\"}',
'2021-03-06 21:25:37', '2021-03-09 10:32:51');
+INSERT IGNORE INTO plugin_handle (`id`, `plugin_id`, `field`, `label`,
`data_type`, `type`, `sort`, `ext_obj`, `date_created`, `date_updated`) VALUES
('113', '6', 'status', 'status', '3', '1', '8',
'{\"defaultValue\":\"true\",\"rule\":\"\"}', '2021-03-06 21:29:16', '2021-09-23
14:45:14');
+INSERT IGNORE INTO plugin_handle (`id`, `plugin_id`, `field`, `label`,
`data_type`, `type`, `sort`, `ext_obj`, `date_created`, `date_updated`) VALUES
('114', '6', 'timestamp', 'startupTime', '1', '1', '7',
'{\"defaultValue\":\"0\",\"placeholder\":\"startup timestamp\",\"rule\":\"\"}',
'2021-03-06 21:27:11', '2021-09-23 14:45:10');
+INSERT IGNORE INTO plugin_handle (`id`, `plugin_id`, `field`, `label`,
`data_type`, `type`, `sort`, `ext_obj`, `date_created`, `date_updated`) VALUES
('112', '6', 'upstreamHost', 'host', '2', '1', '0', NULL, '2021-03-06
21:23:41', '2021-03-09 10:32:51');
+INSERT IGNORE INTO plugin_handle (`id`, `plugin_id`, `field`, `label`,
`data_type`, `type`, `sort`, `ext_obj`, `date_created`, `date_updated`) VALUES
('116', '6', 'upstreamUrl', 'ip:port', '2', '1', '1',
'{\"required\":\"1\",\"placeholder\":\"\",\"rule\":\"\"}', '2021-03-06
21:25:55', '2021-03-09 10:32:51');
+INSERT IGNORE INTO plugin_handle (`id`, `plugin_id`, `field`, `label`,
`data_type`, `type`, `sort`, `ext_obj`, `date_created`, `date_updated`) VALUES
('121', '6', 'version', 'version', '2', '1', '4',
'{\"required\":\"0\",\"placeholder\":\"version\",\"rule\":\"\"}', '2021-03-06
21:25:55', '2021-09-23 14:43:39');
+INSERT IGNORE INTO plugin_handle (`id`, `plugin_id`, `field`, `label`,
`data_type`, `type`, `sort`, `ext_obj`, `date_created`, `date_updated`) VALUES
('117', '6', 'warmup', 'warmupTime', '1', '1', '6',
'{\"defaultValue\":\"0\",\"placeholder\":\"warmup time (ms)\",\"rule\":\"\"}',
'2021-03-06 21:27:34', '2021-09-23 14:45:08');
+INSERT IGNORE INTO plugin_handle (`id`, `plugin_id`, `field`, `label`,
`data_type`, `type`, `sort`, `ext_obj`, `date_created`, `date_updated`) VALUES
('118', '6', 'weight', 'weight', '1', '1', '5',
'{\"defaultValue\":\"50\",\"rule\":\"\"}', '2021-03-06 21:26:35', '2021-09-23
14:45:03');
+
/** insert resource for resource */
INSERT IGNORE INTO `resource` (`id`, `parent_id`, `title`, `name`, `url`,
`component`, `resource_type`, `sort`, `icon`, `is_leaf`, `is_route`, `perms`,
`status`, `date_created`, `date_updated`)
VALUES('1346775491550474240','','SHENYU.MENU.PLUGIN.LIST','plug','/plug','PluginList','0','0','dashboard','0','0','','1','2021-01-06
05:07:54','2021-01-07 18:34:11');
INSERT IGNORE INTO `resource` (`id`, `parent_id`, `title`, `name`, `url`,
`component`, `resource_type`, `sort`, `icon`, `is_leaf`, `is_route`, `perms`,
`status`, `date_created`, `date_updated`)
VALUES('1357956838021890048','','SHENYU.MENU.CONFIG.MANAGMENT','config','/config','config','0','1','api','0','0','','1','2021-02-06
15:38:34','2021-02-06 15:47:25');
diff --git a/shenyu-admin/src/main/resources/sql-script/mysql/schema.sql
b/shenyu-admin/src/main/resources/sql-script/mysql/schema.sql
index 338b5a9..3b757a4 100644
--- a/shenyu-admin/src/main/resources/sql-script/mysql/schema.sql
+++ b/shenyu-admin/src/main/resources/sql-script/mysql/schema.sql
@@ -315,13 +315,17 @@ INSERT IGNORE INTO shenyu_dict (`id`, `type`,
`dict_code`, `dict_name`, `dict_va
INSERT IGNORE INTO shenyu_dict (`id`, `type`, `dict_code`, `dict_name`,
`dict_value`, `desc`, `sort`, `enabled`, `date_created`, `date_updated`) VALUES
('13', 'mode', 'MODE', 'sentinel', 'sentinel', 'sentinel', 1, 1, '2020-12-25
00:00:00', '2020-12-25 00:00:00');
INSERT IGNORE INTO shenyu_dict (`id`, `type`, `dict_code`, `dict_name`,
`dict_value`, `desc`, `sort`, `enabled`, `date_created`, `date_updated`) VALUES
('14', 'mode', 'MODE', 'standalone', 'standalone', 'standalone', 2, 1,
'2020-12-25 00:00:00', '2020-12-25 00:00:00');
+/*insert dict for dubbo plugin*/
+INSERT IGNORE INTO shenyu_dict (`id`, `type`, `dict_code`, `dict_name`,
`dict_value`, `desc`, `sort`, `enabled`, `date_created`, `date_updated`) VALUES
('54', 'gray', 'GRAY_STATUS', 'close', 'false', 'close', '1', '1', '2021-03-08
14:21:58', '2021-03-08 14:21:58');
+INSERT IGNORE INTO shenyu_dict (`id`, `type`, `dict_code`, `dict_name`,
`dict_value`, `desc`, `sort`, `enabled`, `date_created`, `date_updated`) VALUES
('55', 'gray', 'GRAY_STATUS', 'open', 'true', 'open', '0', '1', '2021-03-08
14:21:32', '2021-03-08 14:21:32');
+
/*plugin*/
INSERT IGNORE INTO `plugin` (`id`, `name`, `role`, `sort`, `enabled`,
`date_created`, `date_updated`) VALUES ('1','sign','authentication', 20, '0',
'2018-06-14 10:17:35', '2018-06-14 10:17:35');
INSERT IGNORE INTO `plugin` (`id`, `name`, `role`, `sort`,`config`,`enabled`,
`date_created`, `date_updated`) VALUES ('2','waf', 'authentication',
50,'{"model":"black"}','0', '2018-06-23 10:26:30', '2018-06-13 15:43:10');
INSERT IGNORE INTO `plugin` (`id`, `name`, `role`, `sort`, `enabled`,
`date_created`, `date_updated`) VALUES ('3','rewrite', 'http process', 90,'0',
'2018-06-23 10:26:34', '2018-06-25 13:59:31');
INSERT IGNORE INTO `plugin` (`id`, `name`, `role`, `sort`, `config`,`enabled`,
`date_created`, `date_updated`) VALUES ('4','rate_limiter','fault tolerance',
60,'{"master":"mymaster","mode":"standalone","url":"192.168.1.1:6379","password":"abc"}',
'0', '2018-06-23 10:26:37', '2018-06-13 15:34:48');
INSERT IGNORE INTO `plugin` (`id`, `name`, `role`, `sort`, `config`,`enabled`,
`date_created`, `date_updated`) VALUES ('5','divide', 'proxy',
200,'{"multiSelectorHandle":"1","multiRuleHandle":"0"}','1', '2018-06-25
10:19:10', '2018-06-13 13:56:04');
-INSERT IGNORE INTO `plugin` (`id`, `name`, `role`, `sort`, `config`,`enabled`,
`date_created`, `date_updated`) VALUES ('6','dubbo','proxy',
310,'{"register":"zookeeper://localhost:2181"}', '0', '2018-06-23 10:26:41',
'2018-06-11 10:11:47');
+INSERT IGNORE INTO `plugin` (`id`, `name`, `role`, `sort`, `config`,`enabled`,
`date_created`, `date_updated`) VALUES ('6','dubbo','proxy',
310,'{"register":"zookeeper://localhost:2181","multiSelectorHandle":"1"}', '0',
'2018-06-23 10:26:41', '2018-06-11 10:11:47');
INSERT IGNORE INTO `plugin` (`id`, `name`, `role`, `sort`, `config`,`enabled`,
`date_created`, `date_updated`) VALUES ('7','monitor', 'monitor',
170,'{"metricsName":"prometheus","host":"localhost","port":"9190","async":"true"}','0',
'2018-06-25 13:47:57', '2018-06-25 13:47:57');
INSERT IGNORE INTO `plugin` (`id`, `name`, `role`, `sort`, `enabled`,
`date_created`, `date_updated`) VALUES ('8','springCloud','proxy', 200, '0',
'2018-06-25 13:47:57', '2018-06-25 13:47:57');
INSERT IGNORE INTO `plugin` (`id`, `name`, `role`, `sort`, `enabled`,
`date_created`, `date_updated`) VALUES ('9','hystrix', 'fault tolerance',
130,'0', '2020-01-15 10:19:10', '2020-01-15 10:19:10');
@@ -466,6 +470,20 @@ INSERT IGNORE INTO plugin_handle
(`id`,`plugin_id`,`field`,`label`,`data_type`,`
INSERT IGNORE INTO plugin_handle
(`id`,`plugin_id`,`field`,`label`,`data_type`,`type`,`sort`,`ext_obj`,`date_created`,`date_updated`)
VALUES ('109', '25', 'key', 'key', 2, 2, 3, NULL, '2021-08-13 15:14:07',
'2021-08-13 15:14:36');
INSERT IGNORE INTO plugin_handle
(`id`,`plugin_id`,`field`,`label`,`data_type`,`type`,`sort`,`ext_obj`,`date_created`,`date_updated`)
VALUES ('110', '25', 'fieldNames', 'fieldNames', 2, 2, 4, NULL, '2021-08-13
15:16:30', '2021-08-13 15:16:45');
+/*insert plugin_handle data for dubbo*/
+INSERT IGNORE INTO plugin_handle (`id`, `plugin_id`, `field`, `label`,
`data_type`, `type`, `sort`, `ext_obj`, `date_created`, `date_updated`) VALUES
('119', '6', 'gray', 'gray', '3', '1', '9',
'{\"required\":\"0\",\"defaultValue\":\"false\",\"placeholder\":\"gray\",\"rule\":\"\"}',
'2021-03-06 21:29:16', '2021-09-23 14:45:16');
+INSERT IGNORE INTO plugin_handle (`id`, `plugin_id`, `field`, `label`,
`data_type`, `type`, `sort`, `ext_obj`, `date_created`, `date_updated`) VALUES
('120', '6', 'group', 'group', '2', '1', '3',
'{\"required\":\"0\",\"placeholder\":\"group\",\"rule\":\"\"}', '2021-03-06
21:25:55', '2021-09-23 14:43:19');
+INSERT IGNORE INTO plugin_handle (`id`, `plugin_id`, `field`, `label`,
`data_type`, `type`, `sort`, `ext_obj`, `date_created`, `date_updated`) VALUES
('122', '6', 'loadbalance', 'loadbalance', '2', '2', '0',
'{\"required\":\"0\",\"placeholder\":\"loadbalance\",\"rule\":\"\"}',
'2021-09-20 20:36:10', '2021-09-20 21:25:12');
+INSERT IGNORE INTO plugin_handle (`id`, `plugin_id`, `field`, `label`,
`data_type`, `type`, `sort`, `ext_obj`, `date_created`, `date_updated`) VALUES
('111', '6', 'multiSelectorHandle', 'multiSelectorHandle', '3', '3', '0', NULL,
'2021-03-08 13:18:44', '2021-03-09 10:32:51');
+INSERT IGNORE INTO plugin_handle (`id`, `plugin_id`, `field`, `label`,
`data_type`, `type`, `sort`, `ext_obj`, `date_created`, `date_updated`) VALUES
('115', '6', 'protocol', 'protocol', '2', '1', '2',
'{\"required\":\"0\",\"defaultValue\":\"\",\"placeholder\":\"http://\",\"rule\":\"\"}',
'2021-03-06 21:25:37', '2021-03-09 10:32:51');
+INSERT IGNORE INTO plugin_handle (`id`, `plugin_id`, `field`, `label`,
`data_type`, `type`, `sort`, `ext_obj`, `date_created`, `date_updated`) VALUES
('113', '6', 'status', 'status', '3', '1', '8',
'{\"defaultValue\":\"true\",\"rule\":\"\"}', '2021-03-06 21:29:16', '2021-09-23
14:45:14');
+INSERT IGNORE INTO plugin_handle (`id`, `plugin_id`, `field`, `label`,
`data_type`, `type`, `sort`, `ext_obj`, `date_created`, `date_updated`) VALUES
('114', '6', 'timestamp', 'startupTime', '1', '1', '7',
'{\"defaultValue\":\"0\",\"placeholder\":\"startup timestamp\",\"rule\":\"\"}',
'2021-03-06 21:27:11', '2021-09-23 14:45:10');
+INSERT IGNORE INTO plugin_handle (`id`, `plugin_id`, `field`, `label`,
`data_type`, `type`, `sort`, `ext_obj`, `date_created`, `date_updated`) VALUES
('112', '6', 'upstreamHost', 'host', '2', '1', '0', NULL, '2021-03-06
21:23:41', '2021-03-09 10:32:51');
+INSERT IGNORE INTO plugin_handle (`id`, `plugin_id`, `field`, `label`,
`data_type`, `type`, `sort`, `ext_obj`, `date_created`, `date_updated`) VALUES
('116', '6', 'upstreamUrl', 'ip:port', '2', '1', '1',
'{\"required\":\"1\",\"placeholder\":\"\",\"rule\":\"\"}', '2021-03-06
21:25:55', '2021-03-09 10:32:51');
+INSERT IGNORE INTO plugin_handle (`id`, `plugin_id`, `field`, `label`,
`data_type`, `type`, `sort`, `ext_obj`, `date_created`, `date_updated`) VALUES
('121', '6', 'version', 'version', '2', '1', '4',
'{\"required\":\"0\",\"placeholder\":\"version\",\"rule\":\"\"}', '2021-03-06
21:25:55', '2021-09-23 14:43:39');
+INSERT IGNORE INTO plugin_handle (`id`, `plugin_id`, `field`, `label`,
`data_type`, `type`, `sort`, `ext_obj`, `date_created`, `date_updated`) VALUES
('117', '6', 'warmup', 'warmupTime', '1', '1', '6',
'{\"defaultValue\":\"0\",\"placeholder\":\"warmup time (ms)\",\"rule\":\"\"}',
'2021-03-06 21:27:34', '2021-09-23 14:45:08');
+INSERT IGNORE INTO plugin_handle (`id`, `plugin_id`, `field`, `label`,
`data_type`, `type`, `sort`, `ext_obj`, `date_created`, `date_updated`) VALUES
('118', '6', 'weight', 'weight', '1', '1', '5',
'{\"defaultValue\":\"50\",\"rule\":\"\"}', '2021-03-06 21:26:35', '2021-09-23
14:45:03');
+
/*insert plugin_handle data for websocket*/
INSERT IGNORE INTO plugin_handle
(`id`,`plugin_id`,`field`,`label`,`data_type`,`type`,`sort`,`ext_obj`,`date_created`,`date_updated`)
VALUES ('1000', '26', 'host', 'host', 2, 1, 0, null, '2021-08-27 21:23:41',
'2021-08-27 10:32:51');
INSERT IGNORE INTO plugin_handle
(`id`,`plugin_id`,`field`,`label`,`data_type`,`type`,`sort`,`ext_obj`,`date_created`,`date_updated`)
VALUES ('1001', '26', 'protocol', 'protocol', 2, 1, 2,
'{"required":"0","defaultValue":"","placeholder":"ws://","rule":""}',
'2021-08-27 21:25:37', '2021-08-27 10:32:51');
@@ -478,7 +496,6 @@ INSERT IGNORE INTO plugin_handle
(`id`,`plugin_id`,`field`,`label`,`data_type`,`
INSERT IGNORE INTO plugin_handle
(`id`,`plugin_id`,`field`,`label`,`data_type`,`type`,`sort`,`ext_obj`,`date_created`,`date_updated`)
VALUES ('1008', '26', 'retry', 'retryCount', 1, 2, 1, null, '2021-08-27
21:31:00', '2021-08-27 10:32:51');
INSERT IGNORE INTO plugin_handle
(`id`,`plugin_id`,`field`,`label`,`data_type`,`type`,`sort`,`ext_obj`,`date_created`,`date_updated`)
VALUES ('1009', '26', 'timeout', 'timeout', 1, 2, 2,
'{"defaultValue":"3000","rule":""}', '2021-08-27 21:13:50', '2021-08-27
10:32:51');
-
/** insert resource for resource */
INSERT IGNORE INTO `resource` (`id`, `parent_id`, `title`, `name`, `url`,
`component`, `resource_type`, `sort`, `icon`, `is_leaf`, `is_route`, `perms`,
`status`, `date_created`, `date_updated`)
VALUES('1346775491550474240','','SHENYU.MENU.PLUGIN.LIST','plug','/plug','PluginList','0','0','dashboard','0','0','','1','2021-01-06
05:07:54','2021-01-07 18:34:11');
INSERT IGNORE INTO `resource` (`id`, `parent_id`, `title`, `name`, `url`,
`component`, `resource_type`, `sort`, `icon`, `is_leaf`, `is_route`, `perms`,
`status`, `date_created`, `date_updated`)
VALUES('1357956838021890048','','SHENYU.MENU.CONFIG.MANAGMENT','config','/config','config','0','1','api','0','0','','1','2021-02-06
15:38:34','2021-02-06 15:47:25');
diff --git a/shenyu-admin/src/main/resources/sql-script/pg/schema.sql
b/shenyu-admin/src/main/resources/sql-script/pg/schema.sql
index 8ec9a7c..ed14fee 100644
--- a/shenyu-admin/src/main/resources/sql-script/pg/schema.sql
+++ b/shenyu-admin/src/main/resources/sql-script/pg/schema.sql
@@ -674,7 +674,7 @@ ELSE
PERFORM public.dblink_exec('init_conn', 'INSERT INTO "plugin" VALUES
(''' || '3' || ''', ''' || 'rewrite' || ''', NULL, ''' || 'http process' ||
''', 90, 0, ''' || '2018-06-23 10:26:34' || ''', ''' || '2018-06-25 13:59:31'
|| ''');');
PERFORM public.dblink_exec('init_conn', 'INSERT INTO "plugin" VALUES
(''' || '4' || ''', ''' || 'rate_limiter' || ''', ''' ||
'{"master":"mymaster","mode":"standalone","url":"192.168.1.1:6379","password":"abc"}'
|| ''', ''' || 'fault tolerance' || ''', 60, 0, ''' || '2018-06-23 10:26:37'
|| ''', ''' || '2018-06-13 15:34:48' || ''');');
PERFORM public.dblink_exec('init_conn', 'INSERT INTO "plugin" VALUES
(''' || '5' || ''', ''' || 'divide' || ''', ''' ||
'{"multiSelectorHandle":"1","multiRuleHandle":"0"}' || ''', ''' || 'proxy' ||
''', 200, 1, ''' || '2018-06-25 10:19:10' || ''', ''' || '2018-06-13 13:56:04'
|| ''');');
- PERFORM public.dblink_exec('init_conn', 'INSERT INTO "plugin" VALUES
(''' || '6' || ''', ''' || 'dubbo' || ''', ''' ||
'{"register":"zookeeper://localhost:2181"}' || ''', ''' || 'proxy' || ''', 310,
0, ''' || '2018-06-23 10:26:41' || ''', ''' || '2018-06-11 10:11:47' || ''');');
+ PERFORM public.dblink_exec('init_conn', 'INSERT INTO "plugin" VALUES
(''' || '6' || ''', ''' || 'dubbo' || ''', ''' ||
'{"register":"zookeeper://localhost:2181","multiSelectorHandle":"1"}' || ''',
''' || 'proxy' || ''', 310, 0, ''' || '2018-06-23 10:26:41' || ''', ''' ||
'2018-06-11 10:11:47' || ''');');
PERFORM public.dblink_exec('init_conn', 'INSERT INTO "plugin" VALUES
(''' || '7' || ''', ''' || 'monitor' || ''', ''' ||
'{"metricsName":"prometheus","host":"localhost","port":"9190","async":"true"}'
|| ''', ''' || 'monitor' || ''', 170, 0, ''' || '2018-06-25 13:47:57' || ''',
''' || '2018-06-25 13:47:57' || ''');');
PERFORM public.dblink_exec('init_conn', 'INSERT INTO "plugin" VALUES
(''' || '8' || ''', ''' || 'springCloud' || ''', NULL, ''' || 'proxy' || ''',
200, 0, ''' || '2018-06-25 13:47:57' || ''', ''' || '2018-06-25 13:47:57' ||
''');');
PERFORM public.dblink_exec('init_conn', 'INSERT INTO "plugin" VALUES
(''' || '9' || ''', ''' || 'hystrix' || ''', NULL, ''' || 'fault tolerance' ||
''', 130, 0, ''' || '2020-01-15 10:19:10' || ''', ''' || '2020-01-15 10:19:10'
|| ''');');
@@ -828,7 +828,20 @@ ELSE
PERFORM public.dblink_exec('init_conn', 'INSERT INTO "plugin_handle"
VALUES (''' || '9' || ''', ''' || '2' || ''', ''' || 'permission' || ''', '''
|| 'permission' || ''', 3, 2, 1, NULL, ''' || '2020-11-22 12:04:10' || ''', '''
|| '2020-11-22 12:04:10' || ''');');
PERFORM public.dblink_exec('init_conn', 'INSERT INTO "plugin_handle"
VALUES (''' || '90' || ''', ''' || '19' || ''', ''' || 'filterPath' || ''', '''
|| 'filterPath' || ''', 2, 3, 1, NULL, ''' || '2021-06-12 19:17:10' || ''', '''
|| '2021-06-12 19:17:10' || ''');');
PERFORM public.dblink_exec('init_conn', 'INSERT INTO "plugin_handle"
VALUES (''' || '99' || ''', ''' || '12' || ''', ''' ||
'automaticTransitionFromOpenToHalfOpenEnabled' || ''', ''' ||
'automaticHalfOpen' || ''', 3, 2, 1, ''' ||
'{"required":"1","defaultValue":"true","rule":""}' || ''', ''' || '2021-07-18
22:52:20' || ''', ''' || '2021-07-18 22:59:57' || ''');');
-
+
+ PERFORM public.dblink_exec('init_conn', 'INSERT INTO "plugin_handle"
VALUES (''' || '119' || ''', ''' || '6' || ''', ''' || 'gray' || ''', ''' ||
'gray' || ''', 3, 1, 9, ''' ||
'{"required":"0","defaultValue":"false","placeholder":"gray","rule":""}' ||
''', ''' || '2021-07-18 22:52:20' || ''', ''' || '2021-07-18 22:59:57' ||
''');');
+ PERFORM public.dblink_exec('init_conn', 'INSERT INTO "plugin_handle"
VALUES (''' || '120' || ''', ''' || '6' || ''', ''' || 'group' || ''', ''' ||
'group' || ''', 2, 1, 3, ''' ||
'{"required":"0","placeholder":"group","rule":""}' || ''', ''' || '2021-07-18
22:52:20' || ''', ''' || '2021-07-18 22:59:57' || ''');');
+ PERFORM public.dblink_exec('init_conn', 'INSERT INTO "plugin_handle"
VALUES (''' || '122' || ''', ''' || '6' || ''', ''' || 'loadbalance' || ''',
''' || 'loadbalance' || ''', 2, 2, 0, ''' ||
'{"required":"0","placeholder":"loadbalance","rule":""}' || ''', ''' ||
'2021-07-18 22:52:20' || ''', ''' || '2021-07-18 22:59:57' || ''');');
+ PERFORM public.dblink_exec('init_conn', 'INSERT INTO "plugin_handle"
VALUES (''' || '111' || ''', ''' || '6' || ''', ''' || 'multiSelectorHandle' ||
''', ''' || 'multiSelectorHandle' || ''', 3, 3, 0, NULL, ''' || '2021-07-18
22:52:20' || ''', ''' || '2021-07-18 22:59:57' || ''');');
+ PERFORM public.dblink_exec('init_conn', 'INSERT INTO "plugin_handle"
VALUES (''' || '115' || ''', ''' || '6' || ''', ''' || 'protocol' || ''', '''
|| 'protocol' || ''', 2, 1, 2, ''' ||
'{"required":"0","defaultValue":"","placeholder":"http://","rule":""}' || ''',
''' || '2021-07-18 22:52:20' || ''', ''' || '2021-07-18 22:59:57' || ''');');
+ PERFORM public.dblink_exec('init_conn', 'INSERT INTO "plugin_handle"
VALUES (''' || '113' || ''', ''' || '6' || ''', ''' || 'status' || ''', ''' ||
'status' || ''', 3, 1, 8, ''' || '{"defaultValue":"true","rule":""}' || ''',
''' || '2021-07-18 22:52:20' || ''', ''' || '2021-07-18 22:59:57' || ''');');
+ PERFORM public.dblink_exec('init_conn', 'INSERT INTO "plugin_handle"
VALUES (''' || '114' || ''', ''' || '6' || ''', ''' || 'timestamp' || ''', '''
|| 'startupTime' || ''', 1, 1, 7, ''' ||
'{"defaultValue":"0","placeholder":"startup timestamp","rule":""}' || ''', '''
|| '2021-07-18 22:52:20' || ''', ''' || '2021-07-18 22:59:57' || ''');');
+ PERFORM public.dblink_exec('init_conn', 'INSERT INTO "plugin_handle"
VALUES (''' || '112' || ''', ''' || '6' || ''', ''' || 'upstreamHost' || ''',
''' || 'host' || ''', 2, 1, 0, NULL, ''' || '2021-07-18 22:52:20' || ''', '''
|| '2021-07-18 22:59:57' || ''');');
+ PERFORM public.dblink_exec('init_conn', 'INSERT INTO "plugin_handle"
VALUES (''' || '116' || ''', ''' || '6' || ''', ''' || 'upstreamUrl' || ''',
''' || 'ip:port' || ''', 2, 1, 1, ''' ||
'{"required":"1","placeholder":"","rule":""}' || ''', ''' || '2021-07-18
22:52:20' || ''', ''' || '2021-07-18 22:59:57' || ''');');
+ PERFORM public.dblink_exec('init_conn', 'INSERT INTO "plugin_handle"
VALUES (''' || '121' || ''', ''' || '6' || ''', ''' || 'version' || ''', ''' ||
'version' || ''', 2, 1, 4, ''' ||
'{"required":"0","placeholder":"version","rule":""}' || ''', ''' || '2021-07-18
22:52:20' || ''', ''' || '2021-07-18 22:59:57' || ''');');
+ PERFORM public.dblink_exec('init_conn', 'INSERT INTO "plugin_handle"
VALUES (''' || '117' || ''', ''' || '6' || ''', ''' || 'warmup' || ''', ''' ||
'warmupTime' || ''', 1, 1, 6, ''' || '{"defaultValue":"0","placeholder":"warmup
time (ms)","rule":""}' || ''', ''' || '2021-07-18 22:52:20' || ''', ''' ||
'2021-07-18 22:59:57' || ''');');
+ PERFORM public.dblink_exec('init_conn', 'INSERT INTO "plugin_handle"
VALUES (''' || '118' || ''', ''' || '6' || ''', ''' || 'weight' || ''', ''' ||
'weight' || ''', 1, 1, 5, ''' || '{"defaultValue":"50","rule":""}' || ''', '''
|| '2021-07-18 22:52:20' || ''', ''' || '2021-07-18 22:59:57' || ''');');
+
PERFORM public.dblink_exec('init_conn', 'COMMIT');
END IF;
@@ -1488,6 +1501,8 @@ ELSE
PERFORM public.dblink_exec('init_conn', 'INSERT INTO "shenyu_dict"
VALUES (''' || '7' || ''', ''' || 'flowRuleControlBehavior' || ''', ''' ||
'CONTROL_BEHAVIOR_WARM_UP' || ''', ''' || 'warm up' || ''', ''' || '1' || ''',
''' || 'control behavior-warm up' || ''', 1, 1, ''' || '2020-11-20 15:47:05' ||
''', ''' || '2020-11-20 15:47:05' || ''');');
PERFORM public.dblink_exec('init_conn', 'INSERT INTO "shenyu_dict"
VALUES (''' || '8' || ''', ''' || 'flowRuleControlBehavior' || ''', ''' ||
'CONTROL_BEHAVIOR_RATE_LIMITER' || ''', ''' || 'constant speed queuing' || ''',
''' || '2' || ''', ''' || 'control behavior-uniform speed queuing' || ''', 2,
1, ''' || '2020-11-20 15:49:45' || ''', ''' || '2020-11-20 15:49:45' || ''');');
PERFORM public.dblink_exec('init_conn', 'INSERT INTO "shenyu_dict"
VALUES (''' || '9' || ''', ''' || 'flowRuleControlBehavior' || ''', ''' ||
'CONTROL_BEHAVIOR_WARM_UP_RATE_LIMITER' || ''', ''' || 'preheating uniformly
queued' || ''', ''' || '3' || ''', ''' || 'control behavior-preheating
uniformly queued' || ''', 3, 1, ''' || '2020-11-20 15:51:25' || ''', ''' ||
'2020-11-20 15:51:37' || ''');');
+ PERFORM public.dblink_exec('init_conn', 'INSERT INTO "shenyu_dict"
VALUES (''' || '22' || ''', ''' || 'gray' || ''', ''' || 'GRAY_STATUS' || ''',
''' || 'close' || ''', ''' || 'false' || ''', ''' || 'close' || ''', 1, 1, '''
|| '2021-03-08 14:21:58' || ''', ''' || '2021-03-08 14:21:58' || ''');');
+ PERFORM public.dblink_exec('init_conn', 'INSERT INTO "shenyu_dict"
VALUES (''' || '23' || ''', ''' || 'gray' || ''', ''' || 'GRAY_STATUS' || ''',
''' || 'open' || ''', ''' || 'true' || ''', ''' || 'open' || ''', 0, 1, ''' ||
'2021-03-08 14:21:32' || ''', ''' || '2021-03-08 14:21:32' || ''');');
PERFORM public.dblink_exec('init_conn', 'COMMIT');
END IF;
diff --git
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/service/ShenyuClientRegisterServiceTest.java
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/service/ShenyuClientRegisterServiceTest.java
index c3e9f8c..72aa6a9 100644
---
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/service/ShenyuClientRegisterServiceTest.java
+++
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/service/ShenyuClientRegisterServiceTest.java
@@ -521,7 +521,7 @@ public final class ShenyuClientRegisterServiceTest {
metaDataDTO.setServiceName("serviceName3");
metaDataDTO.setMethodName("methodName3");
metaDataDTO.setParameterTypes("parameterTypes3");
- metaDataDTO.setRpcExt("rpcExt3");
+ metaDataDTO.setRpcExt("{\"loadbalance\":\"random\"}");
metaDataDTO.setEnabled(false);
return metaDataDTO;
}
diff --git
a/shenyu-common/src/main/java/org/apache/shenyu/common/constant/Constants.java
b/shenyu-common/src/main/java/org/apache/shenyu/common/constant/Constants.java
index 64399fb..ed3f681 100644
---
a/shenyu-common/src/main/java/org/apache/shenyu/common/constant/Constants.java
+++
b/shenyu-common/src/main/java/org/apache/shenyu/common/constant/Constants.java
@@ -419,6 +419,21 @@ public interface Constants {
String CONTEXT_PATH_NAME_PREFIX = "/context-path";
/**
+ * dubbo gray release selector id.
+ */
+ String DUBBO_SELECTOR_ID = "dubboSelectorId";
+
+ /**
+ * dubbo gray release rule id.
+ */
+ String DUBBO_RULE_ID = "dubboRuleId";
+
+ /**
+ * dubbo remote address.
+ */
+ String DUBBO_REMOTE_ADDRESS = "dubboRemoteAddress";
+
+ /**
* String q.
*/
default void findConstants() {
diff --git
a/shenyu-common/src/main/java/org/apache/shenyu/common/dto/convert/DivideUpstream.java
b/shenyu-common/src/main/java/org/apache/shenyu/common/dto/convert/DivideUpstream.java
index be62e16..0c2359e 100644
---
a/shenyu-common/src/main/java/org/apache/shenyu/common/dto/convert/DivideUpstream.java
+++
b/shenyu-common/src/main/java/org/apache/shenyu/common/dto/convert/DivideUpstream.java
@@ -62,12 +62,19 @@ public class DivideUpstream implements Serializable {
*/
private int warmup;
- // health parameters
-
+ /**
+ * health status.
+ */
private boolean healthy;
+ /**
+ * the last healthy time.
+ */
private long lastHealthTimestamp;
+ /**
+ * the last unhealthy time.
+ */
private long lastUnhealthyTimestamp;
/**
diff --git
a/shenyu-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/RuleHandle.java
b/shenyu-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/RuleHandle.java
index 109b08b..bed9a2a 100644
---
a/shenyu-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/RuleHandle.java
+++
b/shenyu-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/RuleHandle.java
@@ -28,10 +28,11 @@ public interface RuleHandle extends Serializable {
/**
* It will be call when RuleHandleFactory to generate a RuleHandle object.
- * @param path path.
+ * @param path path.
+ * @param rpcExt rpc ext.
* @return it's self.
*/
- RuleHandle createDefault(String path);
+ RuleHandle createDefault(String path, String rpcExt);
/**
* Format this object to json string.
diff --git
a/shenyu-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/RuleHandleFactory.java
b/shenyu-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/RuleHandleFactory.java
index 5ba008c..e2f8b0c 100644
---
a/shenyu-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/RuleHandleFactory.java
+++
b/shenyu-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/RuleHandleFactory.java
@@ -53,18 +53,19 @@ public final class RuleHandleFactory {
/**
* Get a RuleHandle object with given rpc type and path.
- * @param name name.
- * @param path path.
- * @return RuleHandle object.
+ * @param pluginName plugin's name.
+ * @param path path.
+ * @param rpcExt rpc ext.
+ * @return RuleHandle object.
*/
- public static RuleHandle ruleHandle(final String name, final String path) {
- Class<? extends RuleHandle> clazz =
RPC_TYPE_TO_RULE_HANDLE_CLASS.getOrDefault(name, DEFAULT_RULE_HANDLE);
+ public static RuleHandle ruleHandle(final String pluginName, final String
path, final String rpcExt) {
+ Class<? extends RuleHandle> clazz =
RPC_TYPE_TO_RULE_HANDLE_CLASS.getOrDefault(pluginName, DEFAULT_RULE_HANDLE);
try {
- return clazz.newInstance().createDefault(path);
+ return clazz.newInstance().createDefault(path, rpcExt);
} catch (InstantiationException | IllegalAccessException e) {
throw new ShenyuException(
String.format("Init RuleHandle failed with plugin name:
%s, rule class: %s, exception: %s",
- name,
+ pluginName,
clazz.getSimpleName(),
e.getMessage()));
}
diff --git
a/shenyu-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/impl/ContextMappingHandle.java
b/shenyu-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/impl/ContextMappingHandle.java
index 4747582..73565fc 100644
---
a/shenyu-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/impl/ContextMappingHandle.java
+++
b/shenyu-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/impl/ContextMappingHandle.java
@@ -98,7 +98,7 @@ public class ContextMappingHandle implements RuleHandle {
}
@Override
- public RuleHandle createDefault(final String path) {
+ public RuleHandle createDefault(final String path, final String rpcExt) {
this.contextPath = path;
return this;
}
diff --git
a/shenyu-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/impl/CryptorRequestRuleHandle.java
b/shenyu-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/impl/CryptorRequestRuleHandle.java
index ae53f80..a9f8e81 100644
---
a/shenyu-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/impl/CryptorRequestRuleHandle.java
+++
b/shenyu-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/impl/CryptorRequestRuleHandle.java
@@ -94,7 +94,7 @@ public class CryptorRequestRuleHandle implements RuleHandle {
}
@Override
- public RuleHandle createDefault(final String path) {
+ public RuleHandle createDefault(final String path, final String rpcExt) {
return this;
}
diff --git
a/shenyu-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/impl/CryptorResponseRuleHandle.java
b/shenyu-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/impl/CryptorResponseRuleHandle.java
index d5f24dc..e0f7cb9 100644
---
a/shenyu-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/impl/CryptorResponseRuleHandle.java
+++
b/shenyu-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/impl/CryptorResponseRuleHandle.java
@@ -88,7 +88,7 @@ public class CryptorResponseRuleHandle implements RuleHandle {
}
@Override
- public RuleHandle createDefault(final String path) {
+ public RuleHandle createDefault(final String path, final String rpcExt) {
return this;
}
diff --git
a/shenyu-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/impl/DivideRuleHandle.java
b/shenyu-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/impl/DivideRuleHandle.java
index 31d669d..6d1c355 100644
---
a/shenyu-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/impl/DivideRuleHandle.java
+++
b/shenyu-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/impl/DivideRuleHandle.java
@@ -183,7 +183,7 @@ public class DivideRuleHandle implements RuleHandle {
}
@Override
- public RuleHandle createDefault(final String path) {
+ public RuleHandle createDefault(final String path, final String rpcExt) {
this.loadBalance = RuleHandleConstants.DEFAULT_LOAD_BALANCE.getName();
this.retry = RuleHandleConstants.DEFAULT_RETRY;
return this;
diff --git
a/shenyu-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/impl/DubboRuleHandle.java
b/shenyu-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/impl/DubboRuleHandle.java
index b24f4e4..eb031c9 100644
---
a/shenyu-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/impl/DubboRuleHandle.java
+++
b/shenyu-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/impl/DubboRuleHandle.java
@@ -17,10 +17,12 @@
package org.apache.shenyu.common.dto.convert.rule.impl;
+import org.apache.commons.lang3.StringUtils;
import org.apache.shenyu.common.constant.Constants;
import org.apache.shenyu.common.constant.RuleHandleConstants;
import org.apache.shenyu.common.dto.convert.rule.RuleHandle;
import org.apache.shenyu.common.enums.LoadBalanceEnum;
+import org.apache.shenyu.common.utils.GsonUtils;
import java.util.Objects;
@@ -47,10 +49,10 @@ public class DubboRuleHandle implements RuleHandle {
private Integer retries;
/**
- * the loadBalance.
+ * the loadbalance.
* {@linkplain LoadBalanceEnum}
*/
- private String loadBalance;
+ private String loadbalance;
/**
* timeout is required.
@@ -112,21 +114,21 @@ public class DubboRuleHandle implements RuleHandle {
}
/**
- * get loadBalance.
+ * Gets the value of loadbalance.
*
- * @return loadBalance
+ * @return the value of loadbalance
*/
- public String getLoadBalance() {
- return loadBalance;
+ public String getLoadbalance() {
+ return loadbalance;
}
/**
- * set loadBalance.
+ * Sets the loadbalance.
*
- * @param loadBalance loadBalance
+ * @param loadbalance loadbalance
*/
- public void setLoadBalance(final String loadBalance) {
- this.loadBalance = loadBalance;
+ public void setLoadbalance(final String loadbalance) {
+ this.loadbalance = loadbalance;
}
/**
@@ -152,42 +154,40 @@ public class DubboRuleHandle implements RuleHandle {
if (this == o) {
return true;
}
- if (o == null || getClass() != o.getClass()) {
+ if (!(o instanceof DubboRuleHandle)) {
return false;
}
DubboRuleHandle that = (DubboRuleHandle) o;
- return timeout == that.timeout && Objects.equals(version,
that.version) && Objects.equals(group, that.group)
- && Objects.equals(retries, that.retries) &&
Objects.equals(loadBalance, that.loadBalance);
+ return timeout == that.timeout
+ && Objects.equals(version, that.version)
+ && Objects.equals(group, that.group)
+ && Objects.equals(retries, that.retries)
+ && Objects.equals(loadbalance, that.loadbalance);
}
@Override
public int hashCode() {
- return Objects.hash(version, group, retries, loadBalance, timeout);
+ return Objects.hash(version, group, retries, loadbalance, timeout);
}
@Override
public String toString() {
return "DubboRuleHandle{"
- + "version='"
- + version
- + '\''
- + ", group='"
- + group
- + '\''
- + ", retries="
- + retries
- + ", loadBalance='"
- + loadBalance
- + '\''
- + ", timeout="
- + timeout
+ + "version='" + version + '\''
+ + ", group='" + group + '\''
+ + ", retries=" + retries
+ + ", loadbalance='" + loadbalance + '\''
+ + ", timeout=" + timeout
+ '}';
}
@Override
- public RuleHandle createDefault(final String path) {
- this.loadBalance = RuleHandleConstants.DEFAULT_LOAD_BALANCE.getName();
- this.retries = RuleHandleConstants.DEFAULT_RETRIES;
- return this;
+ public RuleHandle createDefault(final String path, final String rpcExt) {
+ if (StringUtils.isBlank(rpcExt)) {
+ this.loadbalance =
RuleHandleConstants.DEFAULT_LOAD_BALANCE.getName();
+ this.retries = RuleHandleConstants.DEFAULT_RETRIES;
+ return this;
+ }
+ return GsonUtils.getInstance().fromJson(rpcExt, DubboRuleHandle.class);
}
}
diff --git
a/shenyu-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/impl/ModifyResponseRuleHandle.java
b/shenyu-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/impl/ModifyResponseRuleHandle.java
index f727916..ef8dc22 100644
---
a/shenyu-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/impl/ModifyResponseRuleHandle.java
+++
b/shenyu-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/impl/ModifyResponseRuleHandle.java
@@ -269,7 +269,7 @@ public class ModifyResponseRuleHandle implements RuleHandle
{
}
@Override
- public RuleHandle createDefault(final String path) {
+ public RuleHandle createDefault(final String path, final String rpcExt) {
this.statusCode = HttpStatus.OK.value();
return this;
}
diff --git
a/shenyu-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/impl/ParamMappingHandle.java
b/shenyu-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/impl/ParamMappingHandle.java
index 092caee..9f9513f 100644
---
a/shenyu-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/impl/ParamMappingHandle.java
+++
b/shenyu-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/impl/ParamMappingHandle.java
@@ -119,7 +119,7 @@ public class ParamMappingHandle implements RuleHandle {
}
@Override
- public RuleHandle createDefault(final String path) {
+ public RuleHandle createDefault(final String path, final String rpcExt) {
return this;
}
diff --git
a/shenyu-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/impl/SofaRuleHandle.java
b/shenyu-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/impl/SofaRuleHandle.java
index 0fd024a..7583044 100644
---
a/shenyu-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/impl/SofaRuleHandle.java
+++
b/shenyu-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/impl/SofaRuleHandle.java
@@ -133,7 +133,7 @@ public class SofaRuleHandle implements RuleHandle {
}
@Override
- public RuleHandle createDefault(final String path) {
+ public RuleHandle createDefault(final String path, final String rpcExt) {
this.retries = RuleHandleConstants.DEFAULT_RETRIES;
this.loadBalance = RuleHandleConstants.DEFAULT_LOAD_BALANCE.getName();
return this;
diff --git
a/shenyu-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/impl/SpringCloudRuleHandle.java
b/shenyu-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/impl/SpringCloudRuleHandle.java
index 1e70509..f7a3b9c 100644
---
a/shenyu-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/impl/SpringCloudRuleHandle.java
+++
b/shenyu-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/impl/SpringCloudRuleHandle.java
@@ -129,7 +129,7 @@ public class SpringCloudRuleHandle implements RuleHandle {
}
@Override
- public RuleHandle createDefault(final String path) {
+ public RuleHandle createDefault(final String path, final String rpcExt) {
this.path = path;
return this;
}
diff --git
a/shenyu-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/impl/WebSocketRuleHandle.java
b/shenyu-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/impl/WebSocketRuleHandle.java
index 276faee..8190c12 100644
---
a/shenyu-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/impl/WebSocketRuleHandle.java
+++
b/shenyu-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/impl/WebSocketRuleHandle.java
@@ -131,7 +131,7 @@ public class WebSocketRuleHandle implements RuleHandle {
}
@Override
- public RuleHandle createDefault(final String path) {
+ public RuleHandle createDefault(final String path, final String rpcExt) {
this.loadBalance = RuleHandleConstants.DEFAULT_LOAD_BALANCE.getName();
this.retry = RuleHandleConstants.DEFAULT_RETRY;
this.timeout = Constants.TIME_OUT;
diff --git
a/shenyu-common/src/main/java/org/apache/shenyu/common/dto/convert/selector/DubboSelectorHandle.java
b/shenyu-common/src/main/java/org/apache/shenyu/common/dto/convert/selector/DubboSelectorHandle.java
index 2838603..f98d37d 100644
---
a/shenyu-common/src/main/java/org/apache/shenyu/common/dto/convert/selector/DubboSelectorHandle.java
+++
b/shenyu-common/src/main/java/org/apache/shenyu/common/dto/convert/selector/DubboSelectorHandle.java
@@ -48,6 +48,46 @@ public class DubboSelectorHandle implements Serializable {
private int port;
/**
+ * upstreamUrl.
+ */
+ private String upstreamUrl;
+
+ /**
+ * gray status.
+ */
+ private Boolean gray;
+
+ /**
+ * group.
+ */
+ private String group;
+
+ /**
+ * version.
+ */
+ private String version;
+
+ /**
+ * weight.
+ */
+ private int weight;
+
+ /**
+ * false close/ true open.
+ */
+ private boolean status = true;
+
+ /**
+ * startup time.
+ */
+ private long timestamp;
+
+ /**
+ * warmup.
+ */
+ private int warmup;
+
+ /**
* get registry.
*
* @return registry
@@ -119,38 +159,193 @@ public class DubboSelectorHandle implements Serializable
{
this.port = port;
}
+ /**
+ * Gets the value of gray.
+ *
+ * @return the value of gray
+ */
+ public Boolean isGray() {
+ return gray;
+ }
+
+ /**
+ * Sets the gray.
+ *
+ * @param gray gray
+ */
+ public void setGray(final Boolean gray) {
+ this.gray = gray;
+ }
+
+ /**
+ * Gets the value of upstreamUrl.
+ *
+ * @return the value of upstreamUrl
+ */
+ public String getUpstreamUrl() {
+ return upstreamUrl;
+ }
+
+ /**
+ * Sets the upstreamUrl.
+ *
+ * @param upstreamUrl upstreamUrl
+ */
+ public void setUpstreamUrl(final String upstreamUrl) {
+ this.upstreamUrl = upstreamUrl;
+ }
+
+ /**
+ * Gets the value of weight.
+ *
+ * @return the value of weight
+ */
+ public int getWeight() {
+ return weight;
+ }
+
+ /**
+ * Sets the weight.
+ *
+ * @param weight weight
+ */
+ public void setWeight(final int weight) {
+ this.weight = weight;
+ }
+
+ /**
+ * Gets the value of status.
+ *
+ * @return the value of status
+ */
+ public boolean isStatus() {
+ return status;
+ }
+
+ /**
+ * Sets the status.
+ *
+ * @param status status
+ */
+ public void setStatus(final boolean status) {
+ this.status = status;
+ }
+
+ /**
+ * Gets the value of timestamp.
+ *
+ * @return the value of timestamp
+ */
+ public long getTimestamp() {
+ return timestamp;
+ }
+
+ /**
+ * Sets the timestamp.
+ *
+ * @param timestamp timestamp
+ */
+ public void setTimestamp(final long timestamp) {
+ this.timestamp = timestamp;
+ }
+
+ /**
+ * Gets the value of warmup.
+ *
+ * @return the value of warmup
+ */
+ public int getWarmup() {
+ return warmup;
+ }
+
+ /**
+ * Sets the warmup.
+ *
+ * @param warmup warmup
+ */
+ public void setWarmup(final int warmup) {
+ this.warmup = warmup;
+ }
+
+ /**
+ * Gets the value of group.
+ *
+ * @return the value of group
+ */
+ public String getGroup() {
+ return group;
+ }
+
+ /**
+ * Sets the group.
+ *
+ * @param group group
+ */
+ public void setGroup(final String group) {
+ this.group = group;
+ }
+
+ /**
+ * Gets the value of version.
+ *
+ * @return the value of version
+ */
+ public String getVersion() {
+ return version;
+ }
+
+ /**
+ * Sets the version.
+ *
+ * @param version version
+ */
+ public void setVersion(final String version) {
+ this.version = version;
+ }
+
@Override
public boolean equals(final Object o) {
if (this == o) {
return true;
}
- if (o == null || getClass() != o.getClass()) {
+ if (!(o instanceof DubboSelectorHandle)) {
return false;
}
DubboSelectorHandle that = (DubboSelectorHandle) o;
- return port == that.port && Objects.equals(registry, that.registry)
- && Objects.equals(appName, that.appName) &&
Objects.equals(protocol, that.protocol);
+ return port == that.port
+ && weight == that.weight
+ && status == that.status
+ && timestamp == that.timestamp
+ && warmup == that.warmup
+ && Objects.equals(registry, that.registry)
+ && Objects.equals(appName, that.appName)
+ && Objects.equals(protocol, that.protocol)
+ && Objects.equals(upstreamUrl, that.upstreamUrl)
+ && Objects.equals(gray, that.gray)
+ && Objects.equals(group, that.group)
+ && Objects.equals(version, that.version);
}
@Override
public int hashCode() {
- return Objects.hash(registry, appName, protocol, port);
+ return Objects.hash(registry, appName, protocol, port, upstreamUrl,
gray, weight, status, timestamp, warmup, group, version);
}
@Override
public String toString() {
return "DubboSelectorHandle{"
- + "registry='"
- + registry
- + '\''
- + ", appName='"
- + appName
- + '\''
- + ", protocol='"
- + protocol
- + '\''
- + ", port="
- + port
+ + "registry='" + registry
+ + ", appName='" + appName
+ + ", protocol='" + protocol
+ + ", port=" + port
+ + ", upstreamUrl='" + upstreamUrl
+ + ", gray=" + gray
+ + ", weight=" + weight
+ + ", status=" + status
+ + ", timestamp=" + timestamp
+ + ", warmup=" + warmup
+ + ", group='" + group
+ + ", version='" + version
+ '}';
}
}
diff --git
a/shenyu-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/RuleHandleFactoryTest.java
b/shenyu-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/RuleHandleFactoryTest.java
index c33d0e4..d89591f 100644
---
a/shenyu-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/RuleHandleFactoryTest.java
+++
b/shenyu-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/RuleHandleFactoryTest.java
@@ -35,23 +35,23 @@ public final class RuleHandleFactoryTest {
@Test
public void testRuleHandleCorrectType() {
- RuleHandle handle =
RuleHandleFactory.ruleHandle(PluginEnum.DUBBO.getName(), "");
+ RuleHandle handle =
RuleHandleFactory.ruleHandle(PluginEnum.DUBBO.getName(), "",
"{\"loadbalance\":\"random\"}");
assertThat(handle, notNullValue());
assertThat(handle instanceof DubboRuleHandle, is(true));
- handle = RuleHandleFactory.ruleHandle(PluginEnum.SOFA.getName(), "");
+ handle = RuleHandleFactory.ruleHandle(PluginEnum.SOFA.getName(), "",
"");
assertThat(handle, notNullValue());
assertThat(handle instanceof SofaRuleHandle, is(true));
- handle = RuleHandleFactory.ruleHandle(PluginEnum.DIVIDE.getName(), "");
+ handle = RuleHandleFactory.ruleHandle(PluginEnum.DIVIDE.getName(), "",
"");
assertThat(handle, notNullValue());
assertThat(handle instanceof DivideRuleHandle, is(true));
- handle = RuleHandleFactory.ruleHandle(PluginEnum.GRPC.getName(), "");
+ handle = RuleHandleFactory.ruleHandle(PluginEnum.GRPC.getName(), "",
"");
assertThat(handle, notNullValue());
assertThat(handle instanceof SpringCloudRuleHandle, is(true));
- handle =
RuleHandleFactory.ruleHandle(PluginEnum.SPRING_CLOUD.getName(), "");
+ handle =
RuleHandleFactory.ruleHandle(PluginEnum.SPRING_CLOUD.getName(), "", "");
assertThat(handle, notNullValue());
assertThat(handle instanceof SpringCloudRuleHandle, is(true));
}
diff --git
a/shenyu-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/impl/ContextMappingHandleTest.java
b/shenyu-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/impl/ContextMappingHandleTest.java
index aec6345..c707026 100644
---
a/shenyu-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/impl/ContextMappingHandleTest.java
+++
b/shenyu-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/impl/ContextMappingHandleTest.java
@@ -35,7 +35,7 @@ public class ContextMappingHandleTest {
@Test
public void testCreateDefault() {
ContextMappingHandle contextMappingHandle = new ContextMappingHandle();
- RuleHandle aDefault = contextMappingHandle.createDefault(PATH);
+ RuleHandle aDefault = contextMappingHandle.createDefault(PATH, "");
assertNotNull(aDefault);
assertEquals(aDefault, contextMappingHandle);
assertEquals(contextMappingHandle.getContextPath(), PATH);
diff --git
a/shenyu-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/impl/ModifyResponseRuleHandleTest.java
b/shenyu-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/impl/ModifyResponseRuleHandleTest.java
index 8f0b900..f19658c 100644
---
a/shenyu-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/impl/ModifyResponseRuleHandleTest.java
+++
b/shenyu-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/impl/ModifyResponseRuleHandleTest.java
@@ -36,7 +36,7 @@ public class ModifyResponseRuleHandleTest {
@Test
public void testCreateDefault() {
ModifyResponseRuleHandle modifyResponseRuleHandle = new
ModifyResponseRuleHandle();
- RuleHandle aDefault = modifyResponseRuleHandle.createDefault(PATH);
+ RuleHandle aDefault = modifyResponseRuleHandle.createDefault(PATH, "");
assertNotNull(aDefault);
assertEquals(aDefault, modifyResponseRuleHandle);
assertEquals(HttpStatus.OK.value(),
modifyResponseRuleHandle.getStatusCode());
diff --git
a/shenyu-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/impl/ParamMappingHandleTest.java
b/shenyu-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/impl/ParamMappingHandleTest.java
index b61a607..0397f6f 100644
---
a/shenyu-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/impl/ParamMappingHandleTest.java
+++
b/shenyu-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/impl/ParamMappingHandleTest.java
@@ -37,7 +37,7 @@ public class ParamMappingHandleTest {
@Test
public void testCreateDefault() {
ParamMappingHandle paramMappingHandle = new ParamMappingHandle();
- RuleHandle aDefault = paramMappingHandle.createDefault(PATH);
+ RuleHandle aDefault = paramMappingHandle.createDefault(PATH, "");
assertNotNull(aDefault);
assertEquals(aDefault, paramMappingHandle);
}
diff --git
a/shenyu-examples/shenyu-examples-dubbo/shenyu-examples-apache-dubbo-service-annotation/pom.xml
b/shenyu-examples/shenyu-examples-dubbo/shenyu-examples-apache-dubbo-service-annotation/pom.xml
index ab6c13c..8984be6 100644
---
a/shenyu-examples/shenyu-examples-dubbo/shenyu-examples-apache-dubbo-service-annotation/pom.xml
+++
b/shenyu-examples/shenyu-examples-dubbo/shenyu-examples-apache-dubbo-service-annotation/pom.xml
@@ -87,11 +87,13 @@
<artifactId>curator-client</artifactId>
<version>${curator.version}</version>
</dependency>
+
<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-framework</artifactId>
<version>${curator.version}</version>
</dependency>
+
<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-recipes</artifactId>
diff --git
a/shenyu-examples/shenyu-examples-dubbo/shenyu-examples-apache-dubbo-service-annotation/src/main/java/org/apache/shenyu/examples/apache/dubbo/service/annotation/impl/DubboTestServiceImpl.java
b/shenyu-examples/shenyu-examples-dubbo/shenyu-examples-apache-dubbo-service-annotation/src/main/java/org/apache/shenyu/examples/apache/dubbo/service/annotation/impl/DubboTestServiceImpl.java
index 45adaae..c6c2938 100644
---
a/shenyu-examples/shenyu-examples-dubbo/shenyu-examples-apache-dubbo-service-annotation/src/main/java/org/apache/shenyu/examples/apache/dubbo/service/annotation/impl/DubboTestServiceImpl.java
+++
b/shenyu-examples/shenyu-examples-dubbo/shenyu-examples-apache-dubbo-service-annotation/src/main/java/org/apache/shenyu/examples/apache/dubbo/service/annotation/impl/DubboTestServiceImpl.java
@@ -21,6 +21,8 @@ import
org.apache.shenyu.client.dubbo.common.annotation.ShenyuDubboClient;
import org.apache.shenyu.examples.dubbo.api.entity.DubboTest;
import org.apache.shenyu.examples.dubbo.api.entity.ListResp;
import org.apache.shenyu.examples.dubbo.api.service.DubboTestService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.util.Arrays;
import java.util.Random;
@@ -31,12 +33,15 @@ import java.util.Random;
@Service
public class DubboTestServiceImpl implements DubboTestService {
+ private static final Logger logger =
LoggerFactory.getLogger(DubboTestServiceImpl.class);
+
@Override
@ShenyuDubboClient(path = "/findById", desc = "Query by Id")
public DubboTest findById(final String id) {
DubboTest dubboTest = new DubboTest();
dubboTest.setId(id);
dubboTest.setName("hello world shenyu Apache, findById");
+
logger.info("==========================================接口被调用===================================");
return dubboTest;
}
diff --git
a/shenyu-loadbalancer/src/main/java/org/apache/shenyu/loadbalancer/entity/Upstream.java
b/shenyu-loadbalancer/src/main/java/org/apache/shenyu/loadbalancer/entity/Upstream.java
index a3501cb..1d7b58d 100644
---
a/shenyu-loadbalancer/src/main/java/org/apache/shenyu/loadbalancer/entity/Upstream.java
+++
b/shenyu-loadbalancer/src/main/java/org/apache/shenyu/loadbalancer/entity/Upstream.java
@@ -54,12 +54,31 @@ public final class Upstream {
*/
private int warmup;
+ /**
+ * healthy.
+ */
private boolean healthy;
+ /**
+ * lastHealthTimestamp.
+ */
private long lastHealthTimestamp;
+ /**
+ * lastUnhealthyTimestamp.
+ */
private long lastUnhealthyTimestamp;
+ /**
+ * group.
+ */
+ private String group;
+
+ /**
+ * version.
+ */
+ private String version;
+
private Upstream(final Builder builder) {
this.protocol = builder.protocol;
this.url = builder.url;
@@ -67,6 +86,8 @@ public final class Upstream {
this.status = builder.status;
this.timestamp = builder.timestamp;
this.warmup = builder.warmup;
+ this.group = builder.group;
+ this.version = builder.version;
}
/**
@@ -196,6 +217,42 @@ public final class Upstream {
}
/**
+ * Gets group.
+ *
+ * @return the group
+ */
+ public String getGroup() {
+ return group;
+ }
+
+ /**
+ * Sets group.
+ *
+ * @param group the group
+ */
+ public void setGroup(final String group) {
+ this.group = group;
+ }
+
+ /**
+ * Gets version.
+ *
+ * @return the version
+ */
+ public String getVersion() {
+ return version;
+ }
+
+ /**
+ * Sets version.
+ *
+ * @param version the version
+ */
+ public void setVersion(final String version) {
+ this.version = version;
+ }
+
+ /**
* class builder.
*
* @return Builder builder
@@ -224,18 +281,14 @@ public final class Upstream {
@Override
public String toString() {
return "Upstream{"
- + "protocol='"
- + protocol
- + ", url='"
- + url
- + ", weight="
- + weight
- + ", status="
- + status
- + ", timestamp="
- + timestamp
- + ", warmup="
- + warmup
+ + "protocol='" + protocol
+ + ", url='" + url
+ + ", weight=" + weight
+ + ", status=" + status
+ + ", timestamp=" + timestamp
+ + ", warmup=" + warmup
+ + ", group='" + group
+ + ", version='" + version
+ '}';
}
@@ -275,6 +328,16 @@ public final class Upstream {
private int warmup = 10 * 60 * 1000;
/**
+ * group.
+ */
+ private String group;
+
+ /**
+ * version.
+ */
+ private String version;
+
+ /**
* no args constructor.
*/
private Builder() {
@@ -354,5 +417,27 @@ public final class Upstream {
this.warmup = warmup;
return this;
}
+
+ /**
+ * build group.
+ *
+ * @param group group
+ * @return this builder
+ */
+ public Builder group(final String group) {
+ this.group = group;
+ return this;
+ }
+
+ /**
+ * build version.
+ *
+ * @param version version
+ * @return this builder
+ */
+ public Builder version(final String version) {
+ this.version = version;
+ return this;
+ }
}
}
diff --git a/shenyu-plugin/shenyu-plugin-apache-dubbo/pom.xml
b/shenyu-plugin/shenyu-plugin-apache-dubbo/pom.xml
index 0930c6c..d3b5077 100644
--- a/shenyu-plugin/shenyu-plugin-apache-dubbo/pom.xml
+++ b/shenyu-plugin/shenyu-plugin-apache-dubbo/pom.xml
@@ -51,5 +51,10 @@
<artifactId>reactor-test</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.shenyu</groupId>
+ <artifactId>shenyu-loadbalancer</artifactId>
+ <version>${project.version}</version>
+ </dependency>
</dependencies>
</project>
\ No newline at end of file
diff --git
a/shenyu-plugin/shenyu-plugin-apache-dubbo/src/main/java/org/apache/shenyu/plugin/apache/dubbo/ApacheDubboPlugin.java
b/shenyu-plugin/shenyu-plugin-apache-dubbo/src/main/java/org/apache/shenyu/plugin/apache/dubbo/ApacheDubboPlugin.java
index 0cddc3a..3e6f60f 100644
---
a/shenyu-plugin/shenyu-plugin-apache-dubbo/src/main/java/org/apache/shenyu/plugin/apache/dubbo/ApacheDubboPlugin.java
+++
b/shenyu-plugin/shenyu-plugin-apache-dubbo/src/main/java/org/apache/shenyu/plugin/apache/dubbo/ApacheDubboPlugin.java
@@ -18,6 +18,7 @@
package org.apache.shenyu.plugin.apache.dubbo;
import org.apache.commons.lang3.StringUtils;
+import org.apache.dubbo.rpc.RpcContext;
import org.apache.shenyu.common.constant.Constants;
import org.apache.shenyu.common.dto.MetaData;
import org.apache.shenyu.common.dto.RuleData;
@@ -74,6 +75,9 @@ public class ApacheDubboPlugin extends AbstractShenyuPlugin {
Object error =
ShenyuResultWrap.error(ShenyuResultEnum.DUBBO_HAVE_BODY_PARAM.getCode(),
ShenyuResultEnum.DUBBO_HAVE_BODY_PARAM.getMsg(), null);
return WebFluxResultUtils.result(exchange, error);
}
+ RpcContext.getContext().setAttachment(Constants.DUBBO_SELECTOR_ID,
selector.getId());
+ RpcContext.getContext().setAttachment(Constants.DUBBO_RULE_ID,
rule.getId());
+ RpcContext.getContext().setAttachment(Constants.DUBBO_REMOTE_ADDRESS,
Objects.requireNonNull(exchange.getRequest().getRemoteAddress()).getAddress().getHostAddress());
final Mono<Object> result = dubboProxyService.genericInvoker(param,
metaData, exchange);
return result.then(chain.execute(exchange));
}
diff --git
a/shenyu-plugin/shenyu-plugin-apache-dubbo/src/main/java/org/apache/shenyu/plugin/apache/dubbo/cache/ApplicationConfigCache.java
b/shenyu-plugin/shenyu-plugin-apache-dubbo/src/main/java/org/apache/shenyu/plugin/apache/dubbo/cache/ApplicationConfigCache.java
index b2644fc..dbb8937 100644
---
a/shenyu-plugin/shenyu-plugin-apache-dubbo/src/main/java/org/apache/shenyu/plugin/apache/dubbo/cache/ApplicationConfigCache.java
+++
b/shenyu-plugin/shenyu-plugin-apache-dubbo/src/main/java/org/apache/shenyu/plugin/apache/dubbo/cache/ApplicationConfigCache.java
@@ -155,6 +155,7 @@ public final class ApplicationConfigCache {
reference.setRegistry(registryConfig);
reference.setInterface(metaData.getServiceName());
reference.setProtocol("dubbo");
+ reference.setLoadbalance("gray");
String rpcExt = metaData.getRpcExt();
DubboParamExtInfo dubboParamExtInfo =
GsonUtils.getInstance().fromJson(rpcExt, DubboParamExtInfo.class);
if (Objects.nonNull(dubboParamExtInfo)) {
@@ -164,9 +165,6 @@ public final class ApplicationConfigCache {
if (StringUtils.isNoneBlank(dubboParamExtInfo.getGroup())) {
reference.setGroup(dubboParamExtInfo.getGroup());
}
- if (StringUtils.isNoneBlank(dubboParamExtInfo.getLoadbalance())) {
- reference.setLoadbalance(dubboParamExtInfo.getLoadbalance());
- }
if (StringUtils.isNoneBlank(dubboParamExtInfo.getUrl())) {
reference.setUrl(dubboParamExtInfo.getUrl());
}
diff --git
a/shenyu-plugin/shenyu-plugin-apache-dubbo/src/main/java/org/apache/shenyu/plugin/apache/dubbo/handler/ApacheDubboPluginDataHandler.java
b/shenyu-plugin/shenyu-plugin-apache-dubbo/src/main/java/org/apache/shenyu/plugin/apache/dubbo/handler/ApacheDubboPluginDataHandler.java
index ed704f3..0e47d57 100644
---
a/shenyu-plugin/shenyu-plugin-apache-dubbo/src/main/java/org/apache/shenyu/plugin/apache/dubbo/handler/ApacheDubboPluginDataHandler.java
+++
b/shenyu-plugin/shenyu-plugin-apache-dubbo/src/main/java/org/apache/shenyu/plugin/apache/dubbo/handler/ApacheDubboPluginDataHandler.java
@@ -17,21 +17,39 @@
package org.apache.shenyu.plugin.apache.dubbo.handler;
-import java.util.Objects;
-
-import org.apache.shenyu.plugin.apache.dubbo.cache.ApplicationConfigCache;
+import org.apache.commons.lang3.StringUtils;
import org.apache.shenyu.common.config.DubboRegisterConfig;
import org.apache.shenyu.common.dto.PluginData;
+import org.apache.shenyu.common.dto.RuleData;
+import org.apache.shenyu.common.dto.SelectorData;
+import org.apache.shenyu.common.dto.convert.rule.impl.DubboRuleHandle;
+import org.apache.shenyu.common.dto.convert.selector.DubboSelectorHandle;
import org.apache.shenyu.common.enums.PluginEnum;
+import org.apache.shenyu.common.utils.CollectionUtils;
import org.apache.shenyu.common.utils.GsonUtils;
-import org.apache.shenyu.plugin.base.handler.PluginDataHandler;
import org.apache.shenyu.common.utils.Singleton;
+import org.apache.shenyu.loadbalancer.cache.UpstreamCacheManager;
+import org.apache.shenyu.loadbalancer.entity.Upstream;
+import org.apache.shenyu.plugin.apache.dubbo.cache.ApplicationConfigCache;
+import org.apache.shenyu.plugin.base.cache.RuleHandleCache;
+import org.apache.shenyu.plugin.base.handler.PluginDataHandler;
+import org.apache.shenyu.plugin.base.utils.BeanHolder;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
+import java.util.function.Supplier;
+import java.util.stream.Collectors;
/**
* The type Apache dubbo plugin data handler.
*/
public class ApacheDubboPluginDataHandler implements PluginDataHandler {
+ public static final Supplier<RuleHandleCache<String, DubboRuleHandle>>
RULE_CACHED_HANDLE = new BeanHolder<>(RuleHandleCache::new);
+
+ public static final Supplier<RuleHandleCache<String,
List<DubboSelectorHandle>>> SELECTOR_CACHED_HANDLE = new
BeanHolder<>(RuleHandleCache::new);
+
@Override
public void handlerPlugin(final PluginData pluginData) {
if (null != pluginData && pluginData.getEnabled()) {
@@ -50,7 +68,54 @@ public class ApacheDubboPluginDataHandler implements
PluginDataHandler {
}
@Override
+ public void handlerSelector(final SelectorData selectorData) {
+ List<DubboSelectorHandle> dubboSelectorHandles =
GsonUtils.getInstance().fromList(selectorData.getHandle(),
DubboSelectorHandle.class);
+ if (CollectionUtils.isEmpty(dubboSelectorHandles)) {
+ return;
+ }
+ List<DubboSelectorHandle> graySelectorHandle = new ArrayList<>();
+ for (DubboSelectorHandle each : dubboSelectorHandles) {
+ if (StringUtils.isNotBlank(each.getUpstreamUrl()) &&
Objects.nonNull(each.isGray()) && each.isGray()) {
+ graySelectorHandle.add(each);
+ }
+ }
+ if (CollectionUtils.isNotEmpty(graySelectorHandle)) {
+ SELECTOR_CACHED_HANDLE.get().cachedHandle(selectorData.getId(),
graySelectorHandle);
+ UpstreamCacheManager.getInstance().submit(selectorData.getId(),
convertUpstreamList(graySelectorHandle));
+ }
+ }
+
+ @Override
+ public void removeSelector(final SelectorData selectorData) {
+ SELECTOR_CACHED_HANDLE.get().removeHandle(selectorData.getId());
+ UpstreamCacheManager.getInstance().removeByKey(selectorData.getId());
+ }
+
+ @Override
+ public void handlerRule(final RuleData ruleData) {
+ RULE_CACHED_HANDLE.get().cachedHandle(ruleData.getId(),
GsonUtils.getInstance().fromJson(ruleData.getHandle(), DubboRuleHandle.class));
+ }
+
+ @Override
+ public void removeRule(final RuleData ruleData) {
+ RULE_CACHED_HANDLE.get().removeHandle(ruleData.getId());
+ }
+
+ @Override
public String pluginNamed() {
return PluginEnum.DUBBO.getName();
}
+
+ private List<Upstream> convertUpstreamList(final List<DubboSelectorHandle>
handleList) {
+ return handleList.stream().map(u -> Upstream.builder()
+ .protocol(u.getProtocol())
+ .url(u.getUpstreamUrl())
+ .weight(u.getWeight())
+ .status(u.isStatus())
+ .timestamp(u.getTimestamp())
+ .warmup(u.getWarmup())
+ .group(u.getGroup())
+ .version(u.getVersion())
+ .build()).collect(Collectors.toList());
+ }
}
diff --git
a/shenyu-plugin/shenyu-plugin-apache-dubbo/src/main/java/org/apache/shenyu/plugin/apache/dubbo/proxy/ApacheDubboGrayLoadBalance.java
b/shenyu-plugin/shenyu-plugin-apache-dubbo/src/main/java/org/apache/shenyu/plugin/apache/dubbo/proxy/ApacheDubboGrayLoadBalance.java
new file mode 100644
index 0000000..e9d8869
--- /dev/null
+++
b/shenyu-plugin/shenyu-plugin-apache-dubbo/src/main/java/org/apache/shenyu/plugin/apache/dubbo/proxy/ApacheDubboGrayLoadBalance.java
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shenyu.plugin.apache.dubbo.proxy;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.dubbo.common.URL;
+import org.apache.dubbo.common.constants.CommonConstants;
+import org.apache.dubbo.common.extension.ExtensionLoader;
+import org.apache.dubbo.rpc.Invocation;
+import org.apache.dubbo.rpc.Invoker;
+import org.apache.dubbo.rpc.RpcException;
+import org.apache.dubbo.rpc.cluster.LoadBalance;
+import org.apache.shenyu.common.constant.Constants;
+import org.apache.shenyu.common.dto.convert.rule.impl.DubboRuleHandle;
+import org.apache.shenyu.common.dto.convert.selector.DubboSelectorHandle;
+import org.apache.shenyu.common.utils.CollectionUtils;
+import org.apache.shenyu.loadbalancer.cache.UpstreamCacheManager;
+import org.apache.shenyu.loadbalancer.entity.Upstream;
+import org.apache.shenyu.loadbalancer.factory.LoadBalancerFactory;
+import
org.apache.shenyu.plugin.apache.dubbo.handler.ApacheDubboPluginDataHandler;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * ApacheDubboGrayLoadBalance.
+ */
+public class ApacheDubboGrayLoadBalance implements LoadBalance {
+
+ @Override
+ public <T> Invoker<T> select(final List<Invoker<T>> invokers, final URL
url, final Invocation invocation) throws RpcException {
+ String shenyuSelectorId =
invocation.getAttachment(Constants.DUBBO_SELECTOR_ID);
+ String shenyuRuleId =
invocation.getAttachment(Constants.DUBBO_RULE_ID);
+ String remoteAddressIp =
invocation.getAttachment(Constants.DUBBO_REMOTE_ADDRESS);
+ List<DubboSelectorHandle> dubboSelectorHandles =
ApacheDubboPluginDataHandler.SELECTOR_CACHED_HANDLE.get().obtainHandle(shenyuSelectorId);
+ DubboRuleHandle dubboRuleHandle =
ApacheDubboPluginDataHandler.RULE_CACHED_HANDLE.get().obtainHandle(shenyuRuleId);
+ // if gray list is not empty,just use load balance to choose one.
+ if (CollectionUtils.isNotEmpty(dubboSelectorHandles)) {
+ Upstream upstream =
LoadBalancerFactory.selector(UpstreamCacheManager.getInstance().findUpstreamListBySelectorId(shenyuSelectorId),
dubboRuleHandle.getLoadbalance(), remoteAddressIp);
+ if (StringUtils.isBlank(upstream.getUrl()) &&
StringUtils.isBlank(upstream.getGroup()) &&
StringUtils.isBlank(upstream.getVersion())) {
+ return
ExtensionLoader.getExtensionLoader(LoadBalance.class).getExtension(dubboRuleHandle.getLoadbalance()).select(invokers,
url, invocation);
+ }
+ // url is the first level, then is group, the version is the
lowest.
+ final List<Invoker<T>> invokerListAfterShenyuGrayFilter =
invokers.stream().filter(each -> {
+ if (StringUtils.isNotBlank(upstream.getUrl())) {
+ URL eachUrl = each.getUrl();
+ return eachUrl.getAddress().equals(upstream.getUrl());
+ }
+ return true;
+ }).filter(each -> {
+ if (StringUtils.isNotBlank(upstream.getGroup())) {
+ final URL eachUrl = each.getUrl();
+ return
upstream.getGroup().equals(eachUrl.getParameter(CommonConstants.GROUP_KEY));
+ }
+ return true;
+ }).filter(each -> {
+ if (StringUtils.isNotBlank(upstream.getVersion())) {
+ final URL eachUrl = each.getUrl();
+ return
upstream.getVersion().equals(eachUrl.getParameter(CommonConstants.VERSION_KEY));
+ }
+ return true;
+ }).collect(Collectors.toList());
+ if (CollectionUtils.isEmpty(invokerListAfterShenyuGrayFilter)) {
+ return null;
+ }
+ return
ExtensionLoader.getExtensionLoader(LoadBalance.class).getExtension(dubboRuleHandle.getLoadbalance()).select(invokerListAfterShenyuGrayFilter,
url, invocation);
+ }
+ return
ExtensionLoader.getExtensionLoader(LoadBalance.class).getExtension(dubboRuleHandle.getLoadbalance()).select(invokers,
url, invocation);
+ }
+}
diff --git
a/shenyu-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/RuleHandle.java
b/shenyu-plugin/shenyu-plugin-apache-dubbo/src/main/resources/META-INF/dubbo/org.apache.dubbo.rpc.cluster.LoadBalance
similarity index 57%
copy from
shenyu-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/RuleHandle.java
copy to
shenyu-plugin/shenyu-plugin-apache-dubbo/src/main/resources/META-INF/dubbo/org.apache.dubbo.rpc.cluster.LoadBalance
index 109b08b..210bf69 100644
---
a/shenyu-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/RuleHandle.java
+++
b/shenyu-plugin/shenyu-plugin-apache-dubbo/src/main/resources/META-INF/dubbo/org.apache.dubbo.rpc.cluster.LoadBalance
@@ -15,29 +15,4 @@
* limitations under the License.
*/
-package org.apache.shenyu.common.dto.convert.rule;
-
-import org.apache.shenyu.common.utils.GsonUtils;
-
-import java.io.Serializable;
-
-/**
- * The RuleHandle interface.
- */
-public interface RuleHandle extends Serializable {
-
- /**
- * It will be call when RuleHandleFactory to generate a RuleHandle object.
- * @param path path.
- * @return it's self.
- */
- RuleHandle createDefault(String path);
-
- /**
- * Format this object to json string.
- * @return json string.
- */
- default String toJson() {
- return GsonUtils.getGson().toJson(this);
- }
-}
+gray=org.apache.shenyu.plugin.apache.dubbo.proxy.ApacheDubboGrayLoadBalance
\ No newline at end of file
diff --git
a/shenyu-plugin/shenyu-plugin-apache-dubbo/src/test/java/org/apache/shenyu/plugin/apache/dubbo/ApacheDubboPluginTest.java
b/shenyu-plugin/shenyu-plugin-apache-dubbo/src/test/java/org/apache/shenyu/plugin/apache/dubbo/ApacheDubboPluginTest.java
index 94169f9..80f0345 100644
---
a/shenyu-plugin/shenyu-plugin-apache-dubbo/src/test/java/org/apache/shenyu/plugin/apache/dubbo/ApacheDubboPluginTest.java
+++
b/shenyu-plugin/shenyu-plugin-apache-dubbo/src/test/java/org/apache/shenyu/plugin/apache/dubbo/ApacheDubboPluginTest.java
@@ -34,7 +34,6 @@ import org.mockito.junit.MockitoJUnitRunner;
import org.springframework.mock.http.server.reactive.MockServerHttpRequest;
import org.springframework.mock.web.server.MockServerWebExchange;
import org.springframework.web.server.ServerWebExchange;
-import reactor.core.publisher.Mono;
import reactor.test.StepVerifier;
import static org.junit.Assert.assertEquals;
@@ -77,7 +76,6 @@ public final class ApacheDubboPluginTest {
exchange.getAttributes().put(Constants.CONTEXT, context);
exchange.getAttributes().put(Constants.PARAM_TRANSFORM, "{key:value}");
exchange.getAttributes().put(Constants.META_DATA, metaData);
- when(chain.execute(exchange)).thenReturn(Mono.empty());
SelectorData selectorData = mock(SelectorData.class);
RuleData data = mock(RuleData.class);
StepVerifier.create(apacheDubboPlugin.doExecute(exchange, chain,
selectorData, data)).expectSubscription().verifyComplete();
diff --git
a/shenyu-plugin/shenyu-plugin-divide/src/test/java/org/apache/shenyu/plugin/divide/DividePluginTest.java
b/shenyu-plugin/shenyu-plugin-divide/src/test/java/org/apache/shenyu/plugin/divide/DividePluginTest.java
index b7e3a2d..d92e15d 100644
---
a/shenyu-plugin/shenyu-plugin-divide/src/test/java/org/apache/shenyu/plugin/divide/DividePluginTest.java
+++
b/shenyu-plugin/shenyu-plugin-divide/src/test/java/org/apache/shenyu/plugin/divide/DividePluginTest.java
@@ -157,7 +157,7 @@ public final class DividePluginTest {
private void initMockInfo() {
ShenyuContext context = mock(ShenyuContext.class);
context.setRpcType(RpcTypeEnum.HTTP.getName());
- DivideRuleHandle handle = (DivideRuleHandle)
RuleHandleFactory.ruleHandle(PluginEnum.DIVIDE.getName(), "");
+ DivideRuleHandle handle = (DivideRuleHandle)
RuleHandleFactory.ruleHandle(PluginEnum.DIVIDE.getName(), "", "");
when(selectorData.getId()).thenReturn("mock");
when(selectorData.getHandle()).thenReturn(GsonUtils.getGson().toJson(divideUpstreamList));
when(ruleData.getHandle()).thenReturn(GsonUtils.getGson().toJson(handle));
diff --git
a/shenyu-plugin/shenyu-plugin-websocket/src/test/java/org/apache/shenyu/plugin/websocket/WebSocketPluginTest.java
b/shenyu-plugin/shenyu-plugin-websocket/src/test/java/org/apache/shenyu/plugin/websocket/WebSocketPluginTest.java
index ecd43c9..eaccffa 100644
---
a/shenyu-plugin/shenyu-plugin-websocket/src/test/java/org/apache/shenyu/plugin/websocket/WebSocketPluginTest.java
+++
b/shenyu-plugin/shenyu-plugin-websocket/src/test/java/org/apache/shenyu/plugin/websocket/WebSocketPluginTest.java
@@ -149,7 +149,7 @@ public class WebSocketPluginTest {
private void initMockInfo() {
ShenyuContext context = mock(ShenyuContext.class);
context.setRpcType(RpcTypeEnum.HTTP.getName());
- DivideRuleHandle handle = (DivideRuleHandle)
RuleHandleFactory.ruleHandle(PluginEnum.DIVIDE.getName(), "");
+ DivideRuleHandle handle = (DivideRuleHandle)
RuleHandleFactory.ruleHandle(PluginEnum.DIVIDE.getName(), "", "");
when(selectorData.getId()).thenReturn("mock");
when(selectorData.getHandle()).thenReturn(GsonUtils.getGson().toJson(divideUpstreamList));
when(ruleData.getHandle()).thenReturn(GsonUtils.getGson().toJson(handle));