This is an automated email from the ASF dual-hosted git repository.

carryxyh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-dubbo.git


The following commit(s) were added to refs/heads/master by this push:
     new 7d3c6bc  Optimization code (#3054)
7d3c6bc is described below

commit 7d3c6bc0aa379d05013172f11e38c0b301049b41
Author: 野菱 <[email protected]>
AuthorDate: Tue Dec 25 13:59:47 2018 +0800

    Optimization code (#3054)
    
    Only change FailbackClusterInvoker$RetryTimerTask, code Optimization,only 
save lastInvoker.
---
 .../dubbo/rpc/cluster/support/FailbackClusterInvoker.java     | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git 
a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/support/FailbackClusterInvoker.java
 
b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/support/FailbackClusterInvoker.java
index 1594557..dd68d7e 100644
--- 
a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/support/FailbackClusterInvoker.java
+++ 
b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/support/FailbackClusterInvoker.java
@@ -32,7 +32,7 @@ import org.apache.dubbo.rpc.RpcResult;
 import org.apache.dubbo.rpc.cluster.Directory;
 import org.apache.dubbo.rpc.cluster.LoadBalance;
 
-import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
 import java.util.concurrent.TimeUnit;
 
@@ -118,9 +118,9 @@ public class FailbackClusterInvoker<T> extends 
AbstractClusterInvoker<T> {
         private final Invocation invocation;
         private final LoadBalance loadbalance;
         private final List<Invoker<T>> invokers;
-        private final List<Invoker<T>> lastInvokers = new ArrayList<>();
         private final int retries;
         private final long tick;
+        private Invoker<T> lastInvoker;
         private int retryTimes = 0;
 
         RetryTimerTask(LoadBalance loadbalance, Invocation invocation, 
List<Invoker<T>> invokers, Invoker<T> lastInvoker, int retries, long tick) {
@@ -129,15 +129,14 @@ public class FailbackClusterInvoker<T> extends 
AbstractClusterInvoker<T> {
             this.invokers = invokers;
             this.retries = retries;
             this.tick = tick;
-            lastInvokers.add(lastInvoker);
+            this.lastInvoker=lastInvoker;
         }
 
         @Override
         public void run(Timeout timeout) {
             try {
-                Invoker<T> retryInvoker = select(loadbalance, invocation, 
invokers, lastInvokers);
-                lastInvokers.clear();
-                lastInvokers.add(retryInvoker);
+                Invoker<T> retryInvoker = select(loadbalance, invocation, 
invokers, Collections.singletonList(lastInvoker));
+                lastInvoker = retryInvoker;
                 retryInvoker.invoke(invocation);
             } catch (Throwable e) {
                 logger.error("Failed retry to invoke method " + 
invocation.getMethodName() + ", waiting again.", e);

Reply via email to