首页>代码>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();
	}
}
最近下载更多
xiaoyuer2  LV8 2022年11月20日
mudingc木钉  LV30 2021年6月16日
wujb315  LV1 2021年1月21日
baynight  LV2 2020年7月22日
qian123go  LV17 2020年6月10日
chyy001  LV5 2020年4月21日
xgaccp  LV8 2020年4月7日
nj1penny  LV2 2020年4月3日
860595563  LV15 2020年3月26日
tiansitong  LV14 2020年3月23日
最近浏览更多
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日
暂无贡献等级
李明翰  LV4 2022年6月16日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友