首页>代码>SpringBoot2整合Apache Zookeeper集群管理、负载均衡功能代码>/zookeeper-demo1/src/main/java/com/test/controller/IndexController.java
package com.test.controller; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; import com.test.distributed.ImLoadBalance; import com.test.distributed.ImWorker; /** * 节点测试 * @author 程就人生 * @date 2020年1月13日 */ @RestController public class IndexController { @Autowired private ImLoadBalance imLoadBalance; /** * 增加访问数量 * @return */ @GetMapping("/add") public Object addVisit(){ return ImWorker.getInst().incBalance(); } /** * 减少访问数量 * @return */ @GetMapping("/delete") public Object deleVisit(){ return ImWorker.getInst().decrBalance(); } /** * 获取访问量最少的节点 * @return * */ @GetMapping("/node") public Object getNodes(){ return imLoadBalance.getBestWorker(); } }


xianyu091012 LV5
2024年11月18日
fellowfun LV12
2023年9月1日
心如止水 LV17
2023年8月15日
yzshabzbbdvw LV4
2023年6月3日
lironggang LV38
2023年3月28日
zxc131313 LV12
2023年2月2日
bibibi234 LV1
2022年12月5日
xiaoyuer2 LV8
2022年11月20日
Hachi6 LV13
2022年9月19日
别胡思乱想啦
2022年6月18日
暂无贡献等级