in appactive-java-client/client-bridge/client-bridge-rpc-apache-dubbo/client-bridge-rpc-apache-dubbo2/src/main/java/io/appactive/rpc/apache/dubbo2/provider/ProviderProtectFilter.java [84:118]
private Result processUnitCondition(Invocation invocation) {
ProviderModel providerModel = ModelUtil.getProviderModel(invocation);
ServiceMetadata serviceMetadata = providerModel.getServiceMetadata();
// 单元化保护
try {
Map<String, Object> attachments = serviceMetadata.getAttachments();
String resourceActiveType = (String)attachments.get(RPCConstant.URL_RESOURCE_ACTIVE_LABEL_KEY);
if (resourceActiveType == null) {
// 1. 普通服务不处理
return normalResourceProtect(invocation,serviceMetadata);
}
if (resourceActiveType.equals(ResourceActiveType.CENTER_RESOURCE_TYPE)) {
return centerResourceProtect(invocation, serviceMetadata);
}
if (resourceActiveType.equals(ResourceActiveType.UNIT_RESOURCE_TYPE)) {
return unitResourceProtect(invocation,providerModel);
}
return normalResourceProtect(invocation,serviceMetadata);
} catch (Throwable t) {
String serviceUniqueName = serviceMetadata.getServiceKey();
String methodName = invocation.getMethodName();
String clientIp = RpcContext.getContext().getRemoteHost();
String errorMsg = MessageFormat.format(
"[Dubbo-Provider-{0}] ERROR, The request for [{1}] [{2}] from [{3}] ,currentUnit [{4}],error:{5}",
CURRENT_IP, serviceUniqueName, methodName, clientIp,
machineUnitRuleService.getCurrentUnit(),
t.getMessage());
return errorResult(invocation, errorMsg, t);
}
}