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

中国网站建设公司排行湘潭做网站 活动磐石网络

中国网站建设公司排行,湘潭做网站 活动磐石网络,wordpress文章数据库表,在线logo设计生成器1.设计 1.1 背景 系统启动后#xff0c;所有任务都在被执行#xff0c;如果这时某个节点宕机#xff0c;那它负责的任务就不能执行了#xff0c;这对有稳定性要求的任务是不能接受的#xff0c;所以系统要实现rebalance的功能。 1.2 设计 下面是Job分配与执行的业务点…1.设计 1.1 背景 系统启动后所有任务都在被执行如果这时某个节点宕机那它负责的任务就不能执行了这对有稳定性要求的任务是不能接受的所以系统要实现rebalance的功能。 1.2 设计 下面是Job分配与执行的业务点重分配就是在 follower下线、controller下线、节点新上线进行重分配。理清楚接下来实现就是水到渠成了 2. 实现 2.1 RebalanceJobType 定义了重平衡job的类型 public enum RebalanceJobType {FOLLOWER_OFFLINE(0), CONTROLLER_OFFLINE(1), NODE_ONLINE(2);private int code;RebalanceJobType(int code) {this.code code;}public boolean isFollowerOffline() {return this.code FOLLOWER_OFFLINE.code;}public boolean isControllerOffline() {return this.code CONTROLLER_OFFLINE.code;}public boolean isNodeOnline() {return this.code NODE_ONLINE.code;}} 2.2 AverageJobAllotStrategy 添加了 rebalanceJob的方法只有Controller才能调用对不同的重平衡情况进行分别处理 private MapLong, ListDttaskJob getDttaskJobMap() {ListDttaskJob allDttaskJob getAllDttaskJob();return average(allDttaskJob); }Override public void rebalanceJob(RebalanceJobContext rebalanceJobContext) {if (rebalanceJobContext.getType().isFollowerOffline()|| rebalanceJobContext.getType().isControllerOffline()) {long offlineServerId rebalanceJobContext.getServerId();log.info({}节点{}下线-重平衡job{},rebalanceJobContext.getType().isFollowerOffline() ? follower : controller,offlineServerId,rebalanceJobContext);ListDttaskJob dttaskJobs getByDttaskId(offlineServerId);ListNodeInfo nodeInfoList ServerInfo.getNodeInfoList();MapLong, ListDttaskJob allotMap new HashMap();int i 0;int nodeCount nodeInfoList.size();while (i dttaskJobs.size()) {DttaskJob dttaskJob dttaskJobs.get(i);NodeInfo nodeInfo nodeInfoList.get(i % nodeCount);i;ListDttaskJob dttaskJobList allotMap.getOrDefault(nodeInfo.getServerId(), new ArrayList());dttaskJobList.add(dttaskJob);allotMap.put(nodeInfo.getServerId(), dttaskJobList);}executeDttaskJob(new ExecuteDttaskJobContext(allotMap, true));} else if (rebalanceJobContext.getType().isNodeOnline()) {log.info(节点上线-重平衡job{}, rebalanceJobContext);long onlineServerId rebalanceJobContext.getServerId();MapLong, ListDttaskJob dttaskJobMap BeanUseHelper.entityHelpService().queryDttaskJob();MapLong, ListDttaskJob allotDttaskJobMap getDttaskJobMap();MapLong, ListDttaskJob stopDttaskJobMapOfOldNodes new HashMap();MapLong, ListDttaskJob startDttaskJobMapOfNewNodes new HashMap();ListDttaskJob startDttaskJobs new ArrayList();dttaskJobMap.forEach((serverId, dttaskJobList) - {int size dttaskJobList.size();int newSize allotDttaskJobMap.get(serverId).size();if (size newSize) {ListDttaskJob dttaskJobs dttaskJobList.subList(0, size - newSize);stopDttaskJobMapOfOldNodes.put(serverId, dttaskJobs);startDttaskJobs.addAll(dttaskJobs);}});startDttaskJobMapOfNewNodes.put(onlineServerId, startDttaskJobs);executeDttaskJob(new ExecuteDttaskJobContext(stopDttaskJobMapOfOldNodes, false));executeDttaskJob(new ExecuteDttaskJobContext(startDttaskJobMapOfNewNodes, true));} } 2.3 ServerClientChannelHandler 对节点下线进行重平衡处理 2.4 NodeOnlineMessageService 3. 测试 启动三个节点节点完成选举每个节点执行2个任务 3号节点下线 1 2 节点各分配了一个任务继续执行 3号节点上线 新上线的3号节点重新得到2个任务1 2节点各停止一个任务 至此节点上下线的任务重平衡完成
http://www.sadfv.cn/news/234725/

相关文章:

  • 网站内页做友链鞍山58招聘
  • 江苏专业网站建设wordpress 图标上传
  • 科技英语上海网站se0优化
  • 网站开发设计报告书外包小程序价格
  • 个人备案做别的网站自己做店铺网站
  • 全国网站建设公司排名枣庄科技馆里度周末
  • 公司网站建设图片素材怎么找做变形记图网站
  • 织梦网站更换域名成立公司怎么做网站
  • 网站优化软件推荐追设计网站
  • 网站建设佰金手指科杰六外贸网站制作公司哪家好
  • 安徽网站开发推荐苏州网站制作方法
  • 网站建设难点和重点中国购物网站排名
  • 郑州模板建站定制网站怎么修改wordpress站点代码
  • 佛山网站推广排名网站app开发费用
  • ssh做电商 网站网址查询入口
  • 苏华建设集团网站沈阳网站模板
  • 做科普网站网站加入购物车的代码
  • 服装业网站建设的策划简要列举网站常见类型
  • 江门网站建设服务网站建设 网站内容 采集
  • 搜索 贵州省住房和城乡建设厅网站保险网站模板
  • 建设制作外贸网站的公司简介天长网络推广
  • 域名如何绑定网站设计精美的网站
  • 做市场调查的网站免费做黑彩网站能赚钱吗
  • 网站模板下载简单的那种找个人做网站的
  • 移动网站建设是什么营销型网站建设价格
  • 阳江市做网站特产网站建设规划书
  • 甘肃省建设工程造价信息网站深圳建设人力资源网
  • 国家职业资格证书网站门户网站用什么后台系统好
  • 武夷山市网站建设深圳华强北营业时间
  • 南宁做网站公司自媒体创业计划书word