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

2018网站建设涉及创新的网站建设排行榜

2018网站建设涉及,创新的网站建设排行榜,cms wordpress 企业,校园门户网站 建设方案failureRateInterval时间内如果addEx(错误)达到 maxFailuresPerInterval 次数#xff0c;则fused方法返回true,表示触发熔断#xff0c;进入冷却期coolingInterval#xff0c;冷却期内fused方法返回true#xff0c;冷却期过后进入下一个错误统计周期。 scala语言完成 imp…failureRateInterval时间内如果addEx(错误)达到 maxFailuresPerInterval 次数则fused方法返回true,表示触发熔断进入冷却期coolingInterval冷却期内fused方法返回true冷却期过后进入下一个错误统计周期。 scala语言完成 import scala.collection.mutable case class Excp(ts: Long, throwable: Throwable)trait ExceptionStrategy { }case class FailureRateExit(maxFailuresPerInterval: Int, failureRateInterval: Int, coolingInterval: Int) extends ExceptionStrategy {val LOG: Logger org.slf4j.LoggerFactory.getLogger(this.getClass)private val exceptionQueue: mutable.Queue[Excp] mutable.Queue.empty// exceptionQueue Excp(0L, new RuntimeException())private var lastFuseTs: Long 0Ldef fused(): Boolean {val curr System.currentTimeMillis()if ((curr - lastFuseTs) / 1000 coolingInterval) {LOG.info(sfusing cooling, fist error ts:${exceptionQueue.head.ts}, last error ts:${exceptionQueue.last.ts})exceptionQueue.clear()return true}cleanup(curr)val trigger exceptionQueue.size maxFailuresPerInterval exceptionQueue.head.ts - exceptionQueue.last.ts failureRateIntervalif (trigger) {lastFuseTs currLOG.info(sfusing triggered, fist error ts:${exceptionQueue.head.ts}, last error ts:${exceptionQueue.last.ts}, total errors:${exceptionQueue.size})}trigger}def addEx(ex: Exception): Unit {val curr System.currentTimeMillis()exceptionQueue Excp(curr, ex)cleanup(curr)}private def cleanup(curr: Long System.currentTimeMillis()): Unit {exceptionQueue.dequeueAll(e (curr - e.ts) / 1000 failureRateInterval)exceptionQueue.dequeueAll(e exceptionQueue.size maxFailuresPerInterval * 2 e ! exceptionQueue.last e ! exceptionQueue.head)} }测试代码 import org.scalatest.funsuite.AnyFunSuite import scala.util.Randomclass StrategyTest extends AnyFunSuite {test(fail-rate) {val f FailureRateExit(3, 10, 15)while (true) {f.addEx(new RuntimeException())println(f.fused())Thread.sleep(Random.nextInt(8 * 1000))}} }测试结果 false false false false 13:52:03.519 [ScalaTest-run-running-StrategyTest] [INFO ] FailureRateExit:30 --- fusing triggered, fist error ts:1734414718275, last error ts:1734414723512, total errors:3 true 13:52:10.202 [ScalaTest-run-running-StrategyTest] [INFO ] FailureRateExit:22 --- fusing cooling, fist error ts:1734414722743, last error ts:1734414730202 true 13:52:18.120 [ScalaTest-run-running-StrategyTest] [INFO ] FailureRateExit:22 --- fusing cooling, fist error ts:1734414738120, last error ts:1734414738120 true false false false false false false 13:52:55.780 [ScalaTest-run-running-StrategyTest] [INFO ] FailureRateExit:30 --- fusing triggered, fist error ts:1734414768116, last error ts:1734414775780, total errors:3 true 13:53:00.976 [ScalaTest-run-running-StrategyTest] [INFO ] FailureRateExit:22 --- fusing cooling, fist error ts:1734414775249, last error ts:1734414780976 true 13:53:03.931 [ScalaTest-run-running-StrategyTest] [INFO ] FailureRateExit:22 --- fusing cooling, fist error ts:1734414783931, last error ts:1734414783931 true 13:53:07.628 [ScalaTest-run-running-StrategyTest] [INFO ] FailureRateExit:22 --- fusing cooling, fist error ts:1734414787628, last error ts:1734414787628 true false false false 13:53:28.360 [ScalaTest-run-running-StrategyTest] [INFO ] FailureRateExit:30 --- fusing triggered, fist error ts:1734414800129, last error ts:1734414808359, total errors:3 true 13:53:35.734 [ScalaTest-run-running-StrategyTest] [INFO ] FailureRateExit:22 --- fusing cooling, fist error ts:1734414808359, last error ts:1734414815734 true 13:53:42.517 [ScalaTest-run-running-StrategyTest] [INFO ] FailureRateExit:22 --- fusing cooling, fist error ts:1734414822514, last error ts:1734414822514 true false false 13:53:49.223 [ScalaTest-run-running-StrategyTest] [INFO ] FailureRateExit:30 --- fusing triggered, fist error ts:1734414824804, last error ts:1734414829223, total errors:3 true 13:53:50.351 [ScalaTest-run-running-StrategyTest] [INFO ] FailureRateExit:22 --- fusing cooling, fist error ts:1734414824804, last error ts:1734414830351 true 13:53:57.470 [ScalaTest-run-running-StrategyTest] [INFO ] FailureRateExit:22 --- fusing cooling, fist error ts:1734414837470, last error ts:1734414837470 true 13:54:04.618 [ScalaTest-run-running-StrategyTest] [INFO ] FailureRateExit:22 --- fusing cooling, fist error ts:1734414844618, last error ts:1734414844618 true false false使用方式伪代码 private val strategy: FailureRateExit FailureRateExit(failureRateInterval, maxFailuresPerInterval, failCoolingInterval)try {if(!strategy.fused){// 执行正常逻辑}else{// 忽略}} catch {case ex: Exception // 添加异常到熔断器strategy.addEx(ex)}
http://www.w-s-a.com/news/480122/

相关文章:

  • 攀枝花市网站建设outlook企业邮箱注册申请
  • 企业网站建设报价单免费劳务网站建设
  • 天津平台网站建设方案国际新闻最新消息今天乌克兰与俄罗斯
  • 食用油 网站 模板网页游戏网站在线玩
  • 做网站用的书新能源东莞网站建设技术支持
  • 漯河网站超市建设软件开发的五个阶段
  • 制作深圳网站建设阿里OSS做网站图库费用
  • 网页设计与网站建设 入门必练宜都网站seo
  • 网站设计沟通阆中网站网站建设
  • 缩短网址做钓鱼网站如何确保网站安全
  • 网店网站开发怎样用ps做企业网站
  • 南京门户网站建设做网站一般注册哪几类商标
  • 企业咨询管理服务wordpress seo tdk
  • 做网站前期创建文件夹flash 开发的网站
  • 天津网站制作培训搭建网站的工具
  • 江西网站建设价格低网上卖产品怎么推广
  • 做aelogo动效有什么好的网站建立网站站点的步骤
  • 无锡网站推广公司排名网站赚钱平台
  • 网站物理结构利用公共dns做网站解析
  • 苍南做网站微信建设网站哪家好
  • 华中农业大学基因编辑在线设计网站网站蓝色配色
  • 洛阳建设工程信息网站怎么在服务器建立网站
  • 陕西省建设部官方网站微信小程序怎么关闭这个功能
  • 唐河县住房和城乡建设局网站公司需要做网站
  • 体现网站特色免费个人域名网站
  • ps国外教程网站seo优化是什么职业
  • 什么是网站单页适合女生做的网站
  • 环境文化建设方案网站企业英语网站
  • 南通网站关键词推广响应式网站建设流程
  • 湖北响应式网站建设企业做漫画网站 漫画哪找