当前位置: 首页 > news >正文

网站开发的基本技术网页设计与制作实例教程第2版答案

网站开发的基本技术,网页设计与制作实例教程第2版答案,网络平台推广,百度地图嵌入公司网站redisson版本3.16.6 1.什么是看门狗 Redisson提供的分布式锁是支持锁自动续期的#xff0c;也就是说#xff0c;如果线程仍旧没有执行完#xff0c;那么redisson会自动给redis中的目标key延长超时时间#xff0c;这在Redisson中称之为 Watch Dog 机制。默认情况下#x…redisson版本3.16.6 1.什么是看门狗 Redisson提供的分布式锁是支持锁自动续期的也就是说如果线程仍旧没有执行完那么redisson会自动给redis中的目标key延长超时时间这在Redisson中称之为 Watch Dog 机制。默认情况下看门狗的检查锁的超时时间是30秒钟也可以通过修改Config.lockWatchdogTimeout来另行指定。 2.什么情况会续期 什么情况会续期总结一句话不传入leaseTime锁自动释放时间使用默认值-1 tryLock可传入参数有三个 lockName需要锁住的内容关键字 waitTime 获取锁最大等待时间没有传-1 leaseTime锁自动释放时间没有传-1 boolean tryLock 重载了三个方法分别如下 boolean tryLock(String lockName);boolean tryLock(String lockName, long waitTime) throws InterruptedException;boolean tryLock(String lockName, long waitTime, long leaseTime) throws InterruptedException; 从实现上看使用才传参不用千万别主动写入-1会对入参有校验。可以实现续期的情况只能使用前两个构造器不能使用主动传入leaseTime的构造器。为什么这么说呢源码如下 方法都会调用tryLock获取锁tryLock方法中调用tryAcquire方法 public boolean tryLock(long waitTime, long leaseTime, TimeUnit unit) throws InterruptedException {long time unit.toMillis(waitTime);long current System.currentTimeMillis();long threadId Thread.currentThread().getId();Long ttl tryAcquire(waitTime, leaseTime, unit, threadId);// lock acquiredif (ttl null) {return true;}....省略 tryAcquire方法会调用tryAcquireAsync源码如下 private T RFutureLong tryAcquireAsync(long waitTime, long leaseTime, TimeUnit unit, long threadId) {RFutureLong ttlRemainingFuture;if (leaseTime ! -1) {ttlRemainingFuture tryLockInnerAsync(waitTime, leaseTime, unit, threadId, RedisCommands.EVAL_LONG);} else {ttlRemainingFuture tryLockInnerAsync(waitTime, internalLockLeaseTime,TimeUnit.MILLISECONDS, threadId, RedisCommands.EVAL_LONG);}ttlRemainingFuture.onComplete((ttlRemaining, e) - {if (e ! null) {return;}// lock acquiredif (ttlRemaining null) {if (leaseTime ! -1) {internalLockLeaseTime unit.toMillis(leaseTime);} else {scheduleExpirationRenewal(threadId);}}});return ttlRemainingFuture; } 从源码上看只有当leaseTime为-1时scheduleExpirationRenewal这个方法才会生效这个方法会进行续期。 3.续期源码分析 启一个task任务进行锁的自动续期 scheduleExpirationRenewal()-renewExpiration() private void renewExpiration() {ExpirationEntry ee EXPIRATION_RENEWAL_MAP.get(getEntryName());if (ee null) {return;}// 启一个定时任务Timeout task commandExecutor.getConnectionManager().newTimeout(new TimerTask() {Overridepublic void run(Timeout timeout) throws Exception {ExpirationEntry ent EXPIRATION_RENEWAL_MAP.get(getEntryName());if (ent null) {return;}Long threadId ent.getFirstThreadId();if (threadId null) {return;}// 核心续期代码执行lua脚本RFutureBoolean future renewExpirationAsync(threadId);future.onComplete((res, e) - {if (e ! null) {log.error(Cant update lock getRawName() expiration, e);EXPIRATION_RENEWAL_MAP.remove(getEntryName());return;}if (res) {// renewExpirationAsync执行成功进行递归调用调用自己就可以实现不停的续期// 第一次执行这个函数设置task任务10s后执行task任务刷新有效期又重新设置一个task任务10s后执行renewExpiration();} else {cancelExpirationRenewal(null);}});}// 定时任务是lockWatchdogTimeout的1/3时间去执行就是每10s执行一次,renewExpirationAsync进行续期}, internalLockLeaseTime / 3, TimeUnit.MILLISECONDS);ee.setTimeout(task); }
http://www.hkea.cn/news/14589722/

相关文章:

  • 西安公司网站费用做游戏视频网站要批证吗
  • 了解公司的网站购物网站建设成本
  • 安徽池州建设厅网站保定满城网站建设
  • 网站建设服务目标商丘手机网站建设
  • 邯郸哪里做网站好番禺24小时核酸检测
  • 万能搜索网站云南省城乡住房建设厅官方网站
  • 企业网站的购买方式这么登入wordpress
  • 福州开发公司乌海网站seo
  • 用python做电商网站厦门网站网站建设
  • 杨家平网站建设百度自动驾驶技术
  • 兴文县建设工程网站3000行业关键词
  • 网站的百度地图怎么做的如何做网站建设业务员
  • ps企业网站模板免费下载广告公司品牌策划
  • 包头建设安全协会网站企业宣传册模板排版
  • html黑什么主题WordPress如何做好网站seo优化
  • 网站开发需求分析中性能需求网站建设 设计
  • dede仿站黑龙江网站建设开发
  • 手机浏览微网站wordpress外汇
  • 贵州建设学校网站湖北响应式网页建设哪家有
  • 做网站优化给业务员提成拍摄公司宣传片报价
  • 直接进入网站的代码腾讯云网站制作教程
  • 毕业设计做网站哪种好android开发视频
  • 一个网站建设的成本怎么做网站的内链
  • 网站维护与推广四川鸿业建设集团公司网站
  • 国外红人营销网站地域性旅游网站建设系统结构
  • 做网站域名要自己注册吗天津建设工程信息网络
  • 零基础做网站教程网页版传奇开服
  • 购物网站建设市场调查论文白酒企业网站源码
  • 学校资源网站的建设方案招商网站建设解决方案
  • 汕头做网站优化哪家好郑州市有做网站的吗