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

公司建的站加油违法吗电商网站图片

公司建的站加油违法吗,电商网站图片,wordpress 上传文件中文乱码,硚口区建设局网站目录 1.什么是Ribbo❤️❤️❤️ 2.eureka自带Ribbon ❤️❤️❤️ 3. RestTemplate❤️❤️❤️ 4.IRule❤️❤️❤️ 5.负载均衡算法❤️❤️❤️ 1.什么是Ribbo 1.Spring Cloud Ribbon是基于Netflix Ribbon实现的一套客户端,负载均衡的工具。2.主要功能是提供客户端的软件… 目录 1.什么是Ribbo❤️❤️❤️ 2.eureka自带Ribbon ❤️❤️❤️ 3. RestTemplate❤️❤️❤️ 4.IRule❤️❤️❤️ 5.负载均衡算法❤️❤️❤️ 1.什么是Ribbo 1.Spring Cloud Ribbon是基于Netflix Ribbon实现的一套客户端,负载均衡的工具。2.主要功能是提供客户端的软件负载均衡算法和服务调用。3.Ribbon客户端组件提供一系列完善的配置项如连接超时重试等。4.在配置文件中列出Load Balancer 简称LB后面所有的机器Ribbon会自动的帮助你基于某种规则如简单轮询,随机连接等去连接这些机器。 2.eureka自带Ribbon  之前没引入Ribbon为啥也能负载均衡 因为我们引入eureka时eureka自动引入了ribbon 3. RestTemplate restTemplate有两种方式 1.restTempalte.getForObject2.restTemplate.getForEntity GetMapping(/payment/get/{id})public CommonResultPayment getPayment(PathVariable(id) Integer id) {log.info(进入查询功能成功);return restTemplate.getForObject(PAYMENT_URL /payment/selectById/ id, CommonResult.class);}GetMapping(/payment/get2/{id})public CommonResultPayment getPayment2(PathVariable(id) Integer id) {log.info(进入查询功能成功);ResponseEntityCommonResult entity restTemplate.getForEntity(PAYMENT_URL /payment/selectById/ id, CommonResult.class);if (entity.getStatusCode().is2xxSuccessful()){log.info(entity.getStatusCode()\tentity.getHeaders());return entity.getBody();}else {return new CommonResult(404,查询失败~);}} 4.IRule 4.1轮询策略 1.RoundRobinRule      --------轮询2.RandomRule            ---------随机3.RetryRule                 ---------重试  (先轮询如果失败在执行时间内重试 4.2如何替换  1.创建配置类 注意创建的配置类不能被ComponentSacn所扫描不能与主启动类同包 2.创建IRule对象  使用Bean创建对象根据要求返回具体实现类 Configuration public class MySelfRule {Beanpublic IRule myRule(){return new RandomRule();//定义为随机} } 3.添加RibbonClient name属性表示要访问服务的名称。必须与Eureka中的名称一致包括大小写 configuration属性表示要访问的自定义IRUle配置类 SpringBootApplication EnableDiscoveryClient RibbonClient(name COULD-PAYMENT-SERVICE,configuration MySelfRule.class) public class OrderMain80 {public static void main(String[] args) {SpringApplication.run(OrderMain80.class);} } 5.负载均衡算法 5.1原理 算法rest接口第几次请求数 % 服务器集群总数量 实际调用服务器位置下标每次服务重启动后rest接口计数从1开始。  例如 ListServiceInstance instances discoveryClient.getInstances(CLOUD-PAYMENT-SERVICE); 获取实例 List [0] instances 127.0.0.1:8002 List [1] instances 127.0.0.1:8001 8001和8002组成集群共两台机器 当总请求数为1时: 1%21对应下标位置为1 ,则获得服务地址为127.0.0.1:8001 当总请求数位2时: 2%20对应下标位置为0,则获得服务地址为127.0.0.1:8002 当总请求数位3时: 3%21对应下标位置为1 ,则获得服务地址为127.0.0.1:8001 当总请求数位4时: 4%20对应下标位置为0,则获得服务地址为127.0.0.1:8002 5.2手写轮询 自定义轮询算法 Component public class MyLb implements LoadBalance {private AtomicInteger atomicInteger new AtomicInteger(0);public final int getAndIncrement() {int current;int next;do {current this.atomicInteger.get();next current Integer.MAX_VALUE ? 0 : current 1;} while (!this.atomicInteger.compareAndSet(current, next));System.out.println(next: next);return next;}Overridepublic ServiceInstance instances(ListServiceInstance serviceInstance) {int index getAndIncrement() % serviceInstance.size();return serviceInstance.get(index);} }80服务使用自定义轮询 //自己的负载均衡算法Autowiredprivate LoadBalance loadBalance;Autowiredprivate DiscoveryClient discoveryClient;GetMapping(/payment/lb)public String getPaymentLb() {ListServiceInstance instances discoveryClient.getInstances(COULD-PAYMENT-SERVICE);if (instances null || instances.size() 0) {return null;}ServiceInstance serviceInstanceloadBalance.instances(instances);URI uri serviceInstance.getUri();return restTemplate.getForObject(uri/payment/lb,String.class);}
http://www.yayakq.cn/news/1004/

相关文章:

  • 白银区住房和城乡建设局网站郑州网红打卡地
  • 物业网站模板信息门户平台
  • 做推文网站长沙信息网
  • 公司网站建站公司厦门排名推广
  • 万荣网站seo广州网站商城建设
  • 山东建站商城怎么做网站流量竞品分析
  • 手机网站推荐导航页在印度做视频网站
  • 怎麽做网站河南智慧团建官网
  • 网站seo诊断湖南岚鸿诊断北京做网站建设多少钱
  • 网站免费建站的方法wordpress代码块
  • 企业型网站网址搜索不到的网站
  • 做电子书的网站很有名后来被关闭了网站怎么做宣传
  • 具有品牌的广州做网站中国十大电商做的好的网站
  • 洛阳建站wordpress 4.0 id不连续
  • 宁波市建设银行网站成立网站
  • 美橙云建站成都网站推广
  • 做奥数题网站网站版权信息的正确写法
  • 南海顺德网站建设费用公众号平台怎么做
  • 模板网站库腾讯云获取WordPress密码
  • 备案号网站下边如何做淘外网站推广
  • 开锁在百度上做网站要钱吗论坛网站建设规划书
  • 这样做自己公司的网站一键生成网站
  • 苏州集团网站制作设计手机版网站建设方案
  • 自主建站是什么意思九一人才网
  • 网站内容设置济宁做网站多少钱
  • 如何查询网站点击量网站内容检测
  • 北京网站建设流程济南网站建设 泉诺
  • 网站建设与维护功能意义软文推广特点
  • 站长工具seo综合查询张家界新娘源码论坛网站需要多大的空间
  • iis7.5 网站配置沈阳建设工程信息网官方网站