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

网站规划明细表网站友情链接自动上链

网站规划明细表,网站友情链接自动上链,重庆一般做一个网站需要多少钱,不建网站网络营销怎么做目录 1. sentinel使用场景 2. sentinel组成 3. sentinel dashboard搭建 4. sentinel客户端详细使用 4.1 引入依赖 4.2 application.properties增加dashboard注册地址 4.3 手动增加限流配置类 4.4 rest接口及service类 4.5 通过dashboard动态配置限流规则 1. sentinel使…目录 1. sentinel使用场景 2.  sentinel组成 3. sentinel dashboard搭建 4. sentinel客户端详细使用 4.1 引入依赖 4.2 application.properties增加dashboard注册地址 4.3 手动增加限流配置类 4.4 rest接口及service类 4.5 通过dashboard动态配置限流规则 1. sentinel使用场景 限流、熔断、监控、动态规则配置 2.  sentinel组成 由两部分组成 第一个是dashboard监控仪表盘单独的jar官网下载后启动可监控所有服务、动态发现服务、配置限流策略、熔断等 第二个是sentinel的客户端核心包供微服务引用注册到dashboard仪表盘引入相关pom及设置相关配置即可 3. sentinel dashboard搭建 启动命令 java -Dserver.port8400 -Dcsp.sentinel.dashboard.serverlocalhost:8400 -Dproject.namehj-sentinel -Dsentinel.dashboard.auth.usernamesentinel -Dsentinel.dashboard.auth.passwordsentinel -jar sentinel-dashboard-1.8.6.jar 启动成功地址栏输入localhost:8400, 如图 4. sentinel客户端详细使用 4.1 引入依赖 dependencygroupIdcom.alibaba.cloud/groupIdartifactIdspring-cloud-starter-alibaba-sentinel/artifactIdversion2.2.5.RELEASE/version /dependency 4.2 application.properties增加dashboard注册地址 spring.cloud.sentinel.transport.dashboardlocalhost:8400 4.3 手动增加限流配置类 package hj.example.sampleprovider.sample.config;import com.alibaba.csp.sentinel.slots.block.RuleConstant; import com.alibaba.csp.sentinel.slots.block.flow.FlowRule; import com.alibaba.csp.sentinel.slots.block.flow.FlowRuleManager; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration;import java.util.ArrayList; import java.util.List;/*** Description: sentinel 限流规则配置类**/ Configuration public class SentinelRulesConfig {Beanpublic void initFlowQpsRules() {ListFlowRule rules new ArrayList();FlowRule flowRule new FlowRule();flowRule.setResource(sentinelTest);flowRule.setGrade(RuleConstant.FLOW_GRADE_QPS);flowRule.setCount(1);flowRule.setLimitApp(default);flowRule.setClusterMode(false);flowRule.setControlBehavior(RuleConstant.CONTROL_BEHAVIOR_DEFAULT);rules.add(flowRule);FlowRule flowRule1 new FlowRule();flowRule1.setResource(sayHello);flowRule1.setGrade(RuleConstant.FLOW_GRADE_QPS);flowRule1.setCount(1);flowRule1.setLimitApp(default);flowRule1.setClusterMode(false);flowRule1.setControlBehavior(RuleConstant.CONTROL_BEHAVIOR_DEFAULT);rules.add(flowRule1);FlowRuleManager.loadRules(rules);} }4.4 rest接口及service类 其中sentinelTest为rest接口限流sayHello为方法限流 package hj.example.sampleprovider.sample.controller;import com.alibaba.csp.sentinel.Entry; import com.alibaba.csp.sentinel.SphU; import com.alibaba.csp.sentinel.annotation.SentinelResource; import com.alibaba.csp.sentinel.slots.block.BlockException; import com.alibaba.csp.sentinel.slots.block.RuleConstant; import com.alibaba.csp.sentinel.slots.block.flow.FlowRule; import com.alibaba.csp.sentinel.slots.block.flow.FlowRuleManager; import com.alibaba.fastjson.JSONObject; import hj.example.sampleprovider.sample.HelloServiceImpl; import hj.example.sampleprovider.sample.config.SentinelRulesConfig; import org.apache.commons.lang.time.DateFormatUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController;import java.util.ArrayList; import java.util.Date; import java.util.List;/*** Description: TODO**/ RestController public class SentinelTestController {Autowiredprivate HelloServiceImpl helloService;RequestMapping(/testClean/{id})public ResponseEntityObject testClean(PathVariable(id) String id) {String resultStr String.format(test clean id: %s [%s], id, DateFormatUtils.format(new Date(), yyyy-MM-dd HH:mm:ss ssss));return new ResponseEntity(resultStr , HttpStatus.OK);}RequestMapping(/testSentinelDynamicDashboard)public ResponseEntityObject testSentinelDynamicDashboard() {String resultStr String.format(testSentinelDynamicDashboard [%s], DateFormatUtils.format(new Date(), yyyy-MM-dd HH:mm:ss sss));return new ResponseEntity(resultStr, HttpStatus.OK);}RequestMapping(/sayHello)public ResponseEntityObject sayHelloTest() {String helloStr helloService.sayHello(sayHelloTest);return new ResponseEntity(helloStr, HttpStatus.OK);}SentinelResource(value sentinelTest, blockHandler sentinelTestHandler)RequestMapping(/sentinelTest)public ResponseEntityObject sentinelTest() {System.out.println( sentinelTest : DateFormatUtils.format(new Date(), yyyy-MM-dd HH:mm:ss sss));return new ResponseEntity(sentinelTest , HttpStatus.OK);}public ResponseEntityObject sentinelTestHandler(BlockException e) {System.out.println(被限流了);return new ResponseEntity(sentinelTestHandler 被限流了: JSONObject.toJSONString(e), HttpStatus.OK);} }package hj.example.sampleprovider.sample;import com.alibaba.csp.sentinel.Entry; import com.alibaba.csp.sentinel.SphU; import com.alibaba.csp.sentinel.annotation.SentinelResource; import com.alibaba.csp.sentinel.slots.block.BlockException; import com.alibaba.fastjson.JSON; import hj.example.sample.IHelloService; import org.apache.commons.lang.time.DateFormatUtils; import org.apache.dubbo.config.annotation.DubboService; import org.springframework.beans.factory.annotation.Value; import test.SentinelTest;import javax.xml.bind.ValidationException; import java.util.Date;DubboService public class HelloServiceImpl implements IHelloService {Value(${dubbo.application.name})private String serviceName;SentinelResource(value sayHello, blockHandler sayHelloBlockHandler)public String sayHello(String name) {System.out.printf([%s]: Hello, %s%n, serviceName, name);return String.format([%s]: Hello, %s, serviceName, name);}public String sayHelloBlockHandler(String name, BlockException e) throws ValidationException {System.out.println(sayHello 被限流了。name: name ,被限流了 JSON.toJSONString(e));return sayHello 被限流了。name: name ,被限流了 JSON.toJSONString(e);}public void sentinelTestMethod() {try(Entry entry SphU.entry(sentinelTestMethod)) {System.out.println(hello sentinel : DateFormatUtils.format(new Date(), yyyy-MM-dd HH:mm:ss sss));}catch (BlockException e) {e.printStackTrace();}}public void sentinelTestHandler(BlockException e) throws ValidationException {e.printStackTrace();throw new ValidationException(e.getMessage());} }4.5 通过dashboard动态配置限流规则
http://www.w-s-a.com/news/71024/

相关文章:

  • 网站的ftp地址是什么江苏做网站
  • 宁波网站建设制作公司哪家好潍坊建公司网站
  • 云端网站建设php7 wordpress速度
  • 建站的公司中小企业网站建设报告
  • 上海高档网站建设网站设计入门
  • 德尔普网站建设做网站线
  • 宁波网站搭建定制非模板网站建设电子商务公司名称大全简单大气
  • 巴中哪里做网站推销网站的方法
  • wordpress建站动画网站宣传的手段有哪些?(写出五种以上)
  • 做么网站有黄医疗机构网站备案
  • 企业年金是1比3还是1比4北京厦门网站优化
  • 政务信息网站建设工作方案云南建设工程质量监督网站
  • 如何做一份企业网站免费的短视频素材库
  • 云脑网络科技网站建设咸阳软件开发
  • seo对网站优化网站更换程序
  • 网站建设放什么科目中小学生在线做试卷的网站6
  • 网站建设推广公司排名绥化建设局网站
  • 凡科做的网站为什么打不开苏州行业网站建设
  • 南昌定制网站开发费用微信小商店官网入口
  • 深圳网站建设费用找人做的网站怎么看ftp
  • 做网站cookie传值dedecms网站后台
  • 温州网站推广网站建设要学会什么
  • c 网站开发框架品牌策划方案范文
  • 儿童摄影作品网站多元网络兰州网站建设
  • 电脑上不了建设厅网站常德网站建设费用
  • 做单页免费模板网站最新办公室装修风格效果图
  • 中国铁路建设投资公司网站熊学军想开网站建设公司
  • 优化一个网站多少钱网站开发北京
  • html教学关键词优化价格
  • 黄冈论坛网站有哪些给wordpress首页添加公告栏