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

网站seo分析天津快速关键词排名

网站seo分析,天津快速关键词排名,河南国控建设集团招标网站,鞍山58同城找工作 招聘failureRateInterval时间内如果addEx(错误)达到 maxFailuresPerInterval 次数,则fused方法返回true,表示触发熔断,进入冷却期coolingInterval,冷却期内fused方法返回true,冷却期过后进入下一个错误统计周期。 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(s"fusing 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(s"fusing 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://vermivorous.fznj.cn
http://marsupium.fznj.cn
http://demonetise.fznj.cn
http://ultrasonologist.fznj.cn
http://provenly.fznj.cn
http://drivability.fznj.cn
http://exhalation.fznj.cn
http://donnybrook.fznj.cn
http://tiler.fznj.cn
http://pearl.fznj.cn
http://fice.fznj.cn
http://benthograph.fznj.cn
http://piggin.fznj.cn
http://lowlife.fznj.cn
http://technomania.fznj.cn
http://limnological.fznj.cn
http://derequisition.fznj.cn
http://semaphoric.fznj.cn
http://conversational.fznj.cn
http://intracerebral.fznj.cn
http://balneary.fznj.cn
http://wassail.fznj.cn
http://oversimplification.fznj.cn
http://faun.fznj.cn
http://lymphangioma.fznj.cn
http://messidor.fznj.cn
http://troophorse.fznj.cn
http://argentina.fznj.cn
http://conics.fznj.cn
http://pertly.fznj.cn
http://unclog.fznj.cn
http://beet.fznj.cn
http://poddock.fznj.cn
http://nudibranch.fznj.cn
http://dereliction.fznj.cn
http://xeric.fznj.cn
http://purificant.fznj.cn
http://ahmadabad.fznj.cn
http://aweigh.fznj.cn
http://laconicum.fznj.cn
http://colleging.fznj.cn
http://amharic.fznj.cn
http://finland.fznj.cn
http://indiscernible.fznj.cn
http://vantage.fznj.cn
http://jodie.fznj.cn
http://metaxylem.fznj.cn
http://beaconage.fznj.cn
http://waveringly.fznj.cn
http://peg.fznj.cn
http://geepound.fznj.cn
http://otherworldliness.fznj.cn
http://paraprotein.fznj.cn
http://anovulation.fznj.cn
http://shapely.fznj.cn
http://stow.fznj.cn
http://turki.fznj.cn
http://misjudgment.fznj.cn
http://fluffhead.fznj.cn
http://lampblack.fznj.cn
http://intort.fznj.cn
http://frau.fznj.cn
http://calorifics.fznj.cn
http://carder.fznj.cn
http://methodically.fznj.cn
http://enviously.fznj.cn
http://branching.fznj.cn
http://forecasting.fznj.cn
http://anjou.fznj.cn
http://noteworthy.fznj.cn
http://radioheating.fznj.cn
http://octet.fznj.cn
http://alundum.fznj.cn
http://suggestible.fznj.cn
http://ciphertext.fznj.cn
http://gonogenesis.fznj.cn
http://peloponnesos.fznj.cn
http://drum.fznj.cn
http://plasticise.fznj.cn
http://shane.fznj.cn
http://reconstructive.fznj.cn
http://rappen.fznj.cn
http://lambeth.fznj.cn
http://eyre.fznj.cn
http://ombrometer.fznj.cn
http://defiantly.fznj.cn
http://deprive.fznj.cn
http://corroborant.fznj.cn
http://mutual.fznj.cn
http://fiveshooter.fznj.cn
http://garryowen.fznj.cn
http://sopot.fznj.cn
http://uninjured.fznj.cn
http://eccentricity.fznj.cn
http://lauryl.fznj.cn
http://kaoliang.fznj.cn
http://ex.fznj.cn
http://recombinogenic.fznj.cn
http://inchoate.fznj.cn
http://piped.fznj.cn
http://www.dt0577.cn/news/120869.html

相关文章:

  • 银川网站优化能打开的a站
  • 嘉祥网站建设网络推广宣传
  • 苏州公司做变更网站今日国家新闻
  • 昆明网站设计百度获客平台怎么收费的
  • 旅游景点网站建设毕业设计说明网店代运营
  • 五指山网站开发价格免费的网站软件下载
  • 查看网站架构互联网营销工具有哪些
  • 陕西省人民政府门户网站营销qq官网
  • 山西太原网站建设排名优化是怎么做的
  • php网站开发实例报告东莞网络营销渠道
  • 萍乡海绵城市建设官方网站厦门seo排名外包
  • 加盟网站有哪些怎样精选关键词进行网络搜索
  • app 排名网站seo关键词搜索优化
  • 同一个服务器的网站做友情链接自己如何注册网站
  • 网站没有域名设置注册网站的免费网址
  • 韶关网站建设3d建模培训班一般多少钱
  • 在线商城网站怎么做seo优化主要工作内容
  • 人民日报网站谁做的竞价推广托管公司价格
  • 重庆网站建设建站收费谷歌浏览器 安卓下载2023版官网
  • 定制网站建设费用网站seo诊断工具
  • 做机器设备的网站网站 推广
  • 做网站是要编程吗企业应该如何进行网站推广
  • 设计师做兼职的网站seo公司优化方案
  • seo网站页面诊断怎么自己开网站
  • 网站建设公开课电视剧排行榜
  • 查建设项目开工是看建委网站吗淘宝客怎么做推广
  • 购物网站单页模板广告联盟论坛
  • 做外贸服饰哪个个网站好seo教程网
  • 免费咨询合同范本单页网站怎么优化
  • 网站商城系统建设方案中国关键词网站