diff --git a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/support/FailbackClusterInvoker.java b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/support/FailbackClusterInvoker.java index 17b50fff69c..3cc22a8439b 100644 --- a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/support/FailbackClusterInvoker.java +++ b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/support/FailbackClusterInvoker.java @@ -18,12 +18,13 @@ import com.alibaba.dubbo.common.logger.Logger; import com.alibaba.dubbo.common.logger.LoggerFactory; -import com.alibaba.dubbo.common.utils.NamedThreadFactory; +import com.alibaba.dubbo.common.threadlocal.NamedInternalThreadFactory; import com.alibaba.dubbo.rpc.Invocation; import com.alibaba.dubbo.rpc.Invoker; import com.alibaba.dubbo.rpc.Result; import com.alibaba.dubbo.rpc.RpcException; import com.alibaba.dubbo.rpc.RpcResult; +import com.alibaba.dubbo.rpc.RpcContext; import com.alibaba.dubbo.rpc.cluster.Directory; import com.alibaba.dubbo.rpc.cluster.LoadBalance; @@ -50,7 +51,13 @@ public class FailbackClusterInvoker extends AbstractClusterInvoker { private static final long RETRY_FAILED_PERIOD = 5 * 1000; - private final ScheduledExecutorService scheduledExecutorService = Executors.newScheduledThreadPool(2, new NamedThreadFactory("failback-cluster-timer", true)); + /** + * Use {@link NamedInternalThreadFactory} to produce {@link com.alibaba.dubbo.common.threadlocal.InternalThread} + * which with the use of {@link com.alibaba.dubbo.common.threadlocal.InternalThreadLocal} in {@link RpcContext}. + */ + private final ScheduledExecutorService scheduledExecutorService = Executors.newScheduledThreadPool(2, + new NamedInternalThreadFactory("failback-cluster-timer", true)); + private final ConcurrentMap> failed = new ConcurrentHashMap>(); private volatile ScheduledFuture retryFuture; diff --git a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/support/ForkingClusterInvoker.java b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/support/ForkingClusterInvoker.java index dd6b90120f1..7d9a58d824b 100644 --- a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/support/ForkingClusterInvoker.java +++ b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/support/ForkingClusterInvoker.java @@ -17,7 +17,7 @@ package com.alibaba.dubbo.rpc.cluster.support; import com.alibaba.dubbo.common.Constants; -import com.alibaba.dubbo.common.utils.NamedThreadFactory; +import com.alibaba.dubbo.common.threadlocal.NamedInternalThreadFactory; import com.alibaba.dubbo.rpc.Invocation; import com.alibaba.dubbo.rpc.Invoker; import com.alibaba.dubbo.rpc.Result; @@ -43,7 +43,12 @@ */ public class ForkingClusterInvoker extends AbstractClusterInvoker { - private final ExecutorService executor = Executors.newCachedThreadPool(new NamedThreadFactory("forking-cluster-timer", true)); + /** + * Use {@link NamedInternalThreadFactory} to produce {@link com.alibaba.dubbo.common.threadlocal.InternalThread} + * which with the use of {@link com.alibaba.dubbo.common.threadlocal.InternalThreadLocal} in {@link RpcContext}. + */ + private final ExecutorService executor = Executors.newCachedThreadPool( + new NamedInternalThreadFactory("forking-cluster-timer", true)); public ForkingClusterInvoker(Directory directory) { super(directory);