Skip to content

Commit

Permalink
fix issue apache#274: monitor的cluster一定是failsafe的,而且无法修改 (apache#3523)
Browse files Browse the repository at this point in the history
* fix issue apache#274: monitor的cluster一定是failsafe的,而且无法修改

* remove unused import
  • Loading branch information
beiwei30 authored and chickenlj committed Feb 26, 2019
1 parent 6034ceb commit 4aaa542
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/
package org.apache.dubbo.monitor.dubbo;

import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.utils.StringUtils;
import org.apache.dubbo.monitor.Monitor;
Expand All @@ -26,6 +25,10 @@
import org.apache.dubbo.rpc.Protocol;
import org.apache.dubbo.rpc.ProxyFactory;

import static org.apache.dubbo.common.Constants.CHECK_KEY;
import static org.apache.dubbo.common.Constants.PROTOCOL_KEY;
import static org.apache.dubbo.common.Constants.REFERENCE_FILTER_KEY;

/**
* DefaultMonitorFactory
*/
Expand All @@ -45,21 +48,20 @@ public void setProxyFactory(ProxyFactory proxyFactory) {

@Override
protected Monitor createMonitor(URL url) {
url = url.setProtocol(url.getParameter(Constants.PROTOCOL_KEY, "dubbo"));
url = url.setProtocol(url.getParameter(PROTOCOL_KEY, "dubbo"));
if (StringUtils.isEmpty(url.getPath())) {
url = url.setPath(MonitorService.class.getName());
}
String filter = url.getParameter(Constants.REFERENCE_FILTER_KEY);
String filter = url.getParameter(REFERENCE_FILTER_KEY);
if (StringUtils.isEmpty(filter)) {
filter = "";
} else {
filter = filter + ",";
}
url = url.addParameters(Constants.CLUSTER_KEY, "failsafe", Constants.CHECK_KEY, String.valueOf(false),
Constants.REFERENCE_FILTER_KEY, filter + "-monitor");
url = url.addParameters(CHECK_KEY, String.valueOf(false), REFERENCE_FILTER_KEY, filter + "-monitor");
Invoker<MonitorService> monitorInvoker = protocol.refer(MonitorService.class, url);
MonitorService monitorService = proxyFactory.getProxy(monitorInvoker);
return new DubboMonitor(monitorInvoker, monitorService);
}

}
}

0 comments on commit 4aaa542

Please sign in to comment.