You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by GitBox <gi...@apache.org> on 2018/07/24 07:52:16 UTC
[GitHub] GuldanChen commented on a change in pull request #2024: Binding
attachment before a clusterInvoker invoke.
GuldanChen commented on a change in pull request #2024: Binding attachment before a clusterInvoker invoke.
URL: https://github.com/apache/incubator-dubbo/pull/2024#discussion_r204656227
##########
File path: dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/support/ForkingClusterInvoker.java
##########
@@ -57,50 +57,55 @@ public ForkingClusterInvoker(Directory<T> directory) {
@Override
@SuppressWarnings({"unchecked", "rawtypes"})
public Result doInvoke(final Invocation invocation, List<Invoker<T>> invokers, LoadBalance loadbalance) throws RpcException {
- checkInvokers(invokers, invocation);
- final List<Invoker<T>> selected;
- final int forks = getUrl().getParameter(Constants.FORKS_KEY, Constants.DEFAULT_FORKS);
- final int timeout = getUrl().getParameter(Constants.TIMEOUT_KEY, Constants.DEFAULT_TIMEOUT);
- if (forks <= 0 || forks >= invokers.size()) {
- selected = invokers;
- } else {
- selected = new ArrayList<Invoker<T>>();
- for (int i = 0; i < forks; i++) {
- // TODO. Add some comment here, refer chinese version for more details.
- Invoker<T> invoker = select(loadbalance, invocation, invokers, selected);
- if (!selected.contains(invoker)) {//Avoid add the same invoker several times.
- selected.add(invoker);
+ try {
+ checkInvokers(invokers, invocation);
+ final List<Invoker<T>> selected;
+ final int forks = getUrl().getParameter(Constants.FORKS_KEY, Constants.DEFAULT_FORKS);
+ final int timeout = getUrl().getParameter(Constants.TIMEOUT_KEY, Constants.DEFAULT_TIMEOUT);
+ if (forks <= 0 || forks >= invokers.size()) {
+ selected = invokers;
+ } else {
+ selected = new ArrayList<Invoker<T>>();
+ for (int i = 0; i < forks; i++) {
+ // TODO. Add some comment here, refer chinese version for more details.
+ Invoker<T> invoker = select(loadbalance, invocation, invokers, selected);
+ if (!selected.contains(invoker)) {//Avoid add the same invoker several times.
+ selected.add(invoker);
+ }
}
}
- }
- RpcContext.getContext().setInvokers((List) selected);
- final AtomicInteger count = new AtomicInteger();
- final BlockingQueue<Object> ref = new LinkedBlockingQueue<Object>();
- for (final Invoker<T> invoker : selected) {
- executor.execute(new Runnable() {
- @Override
- public void run() {
- try {
- Result result = invoker.invoke(invocation);
- ref.offer(result);
- } catch (Throwable e) {
- int value = count.incrementAndGet();
- if (value >= selected.size()) {
- ref.offer(e);
+ RpcContext.getContext().setInvokers((List) selected);
+ final AtomicInteger count = new AtomicInteger();
+ final BlockingQueue<Object> ref = new LinkedBlockingQueue<Object>();
Review comment:
GOOD JOB
----------------------------------------------------------------
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:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org