[
https://issues.apache.org/jira/browse/SCB-706?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16544883#comment-16544883
]
ASF GitHub Bot commented on SCB-706:
------------------------------------
WillemJiang commented on a change in pull request #803: [SCB-706]change
filters to discovery filters and support invocation based filters
URL:
https://github.com/apache/incubator-servicecomb-java-chassis/pull/803#discussion_r202589761
##########
File path:
handlers/handler-loadbalance/src/main/java/org/apache/servicecomb/loadbalance/LoadbalanceHandler.java
##########
@@ -121,67 +114,40 @@ public void handle(Invocation invocation, AsyncResponse
asyncResp) throws Except
}
private void clearLoadBalancer() {
- for (LoadBalancer loadBalancer : loadBalancerMap.values()) {
- loadBalancer.shutdown();
+ for (LoadBalancerCreator creator : loadBalancerMap.values()) {
+ creator.shutdown();
}
loadBalancerMap.clear();
}
- protected void setIsolationFilter(LoadBalancer lb, String microserviceName) {
- final String filterName = IsolationServerListFilter.class.getName();
- IsolationServerListFilter isolationListFilter = new
IsolationServerListFilter();
- isolationListFilter.setMicroserviceName(microserviceName);
- isolationListFilter.setLoadBalancerStats(lb.getLoadBalancerStats());
- lb.putFilter(filterName, isolationListFilter);
- }
-
- protected void setTransactionControlFilter(LoadBalancer lb, String
microserviceName) {
- final String filterName = TransactionControlFilter.class.getName();
+ protected void setTransactionControlFilter(String microserviceName) {
String policyClsName =
Configuration.INSTANCE.getFlowsplitFilterPolicy(microserviceName);
- if (policyClsName.isEmpty()) {
- return;
- }
- try {
- Class<?> policyCls = Class.forName(policyClsName);
- if (!TransactionControlFilter.class.isAssignableFrom(policyCls)) {
- String errMsg = String.format(
- "Define instance filter %s in yaml, but not extends abstract class
TransactionControlFilter.",
- policyClsName);
- LOGGER.error(errMsg);
- throw new Error(errMsg);
- }
- TransactionControlFilter transactionControlFilter =
(TransactionControlFilter) policyCls.newInstance();
- transactionControlFilter.setLoadBalancerStats(lb.getLoadBalancerStats());
- transactionControlFilter.setMicroserviceName(microserviceName);
- lb.putFilter(filterName, transactionControlFilter);
- } catch (Throwable e) {
- String errMsg = "Fail to create instance of class: " + policyClsName;
- LOGGER.error(errMsg);
- throw new Error(errMsg, e);
+ if (!policyClsName.isEmpty()) {
+ LOGGER.error(Configuration.TRANSACTIONCONTROL_POLICY_KEY_PATTERN + " is
not supported anymore." +
+ "You can change this class to SPI, and filters will be loaded by
SPI.");
Review comment:
We need to provide a document for the user to upgrade the code the new SPI.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> refactor loadbalance filters logic to support invocation based filter
> ---------------------------------------------------------------------
>
> Key: SCB-706
> URL: https://issues.apache.org/jira/browse/SCB-706
> Project: Apache ServiceComb
> Issue Type: Improvement
> Reporter: liubao
> Assignee: liubao
> Priority: Major
>
> Why we do this?
> # When implement invocation based filter, e.g. darklaunch deployment, we
> need to filter servers based on invocation parameters. But now, we create a
> Loadbalaner instance for each service, and Robin filter interface can not
> pass Invocation to it. Before refactor, we doing this by ThreadLocal and
> cache Invocation, and use in filter implementation. This is error prone and
> users can't handle this complixity
> # We have other improvements, e.g. SCB-700, we can do server status check,
> and add a filter a choose from active servers. We need to consider filter
> orders and other feature, current implementation not satisfy this.
> # We want to make loadbalance code handy by remove some compatible fixes.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)