dubbo RPC调用超时处理--DefaultFuture

一、每次发起一次RPC调用,就创建一个Future对象,并将对象放入集合中

//存放channel对象
private static final Map<Long, Channel> CHANNELS = new ConcurrentHashMap<Long, Channel>();
//存放Future对象
private static final Map<Long, DefaultFuture> FUTURES = new ConcurrentHashMap<Long, DefaultFuture>();


private final Lock lock = new ReentrantLock();
private final Condition done = lock.newCondition();



//开始循环扫描线程
static {
        Thread th = new Thread(new RemotingInvocationTimeoutScan(),         
                                    "DubboResponseTimeoutScanTimer");
        th.setDaemon(true);
        th.start();
}


//创建Future对象
public DefaultFuture(Channel channel, Request request, int timeout) {
        this.channel = channel;
        this.request = request;
        this.id = request.getId();
        this.timeout = timeout > 0 ? timeout : channel.getUrl().getPositiveParameter(Constants.TIMEOUT_KEY, Constants.DEFAULT_TIMEOUT);
        // put into w
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值