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

北京海华城市建设学校网站中文网站建设合同

北京海华城市建设学校网站,中文网站建设合同,专业型网站和个人网站,济南企业网站设计一、IPing机制 IPing是一个主动探测服务节点存活的机制#xff0c;通过判断服务节点的当前状态#xff0c;设置节点的可用状态。只有当节点为可用时候才会作为负载均衡器的选取节点。 IPing有以下几种模式: DummyPing#xff1a;默认返回true#xff0c;即认为所有节点都…一、IPing机制 IPing是一个主动探测服务节点存活的机制通过判断服务节点的当前状态设置节点的可用状态。只有当节点为可用时候才会作为负载均衡器的选取节点。 IPing有以下几种模式: DummyPing默认返回true即认为所有节点都可用这也是单独使用Ribbon时的默认模式NIWSDiscoveryPing借助Eureka服务发现机制获取节点状态。节点状态是UP则认为是可用状态PingUrl主动向服务节点发起一次http调用对方有响应则认为节点是可用状态NoOpPing返回truePingConstant返回设置的常量值二、IPing配置 1application.yaml配置 #单个服务设置 [service-name]: ribbon: NFLoadBalancerPingClassName: com.netflix.loadbalancer.DummyPing 2代码配置 public class MicroRibbonConfig {Beanpublic IPing microIPing(){return new DummyPing();} }RibbonClient(name micro-service, configuration MicroRibbonConfig.class) public class RibbonClientConfig {} 三、IPing模式实现 1DummyPing public class DummyPing extends AbstractLoadBalancerPing {public DummyPing() {}public boolean isAlive(Server server) {return true;}Overridepublic void initWithNiwsConfig(IClientConfig clientConfig) {} }public abstract class AbstractLoadBalancerPing implements IPing, IClientConfigAware{AbstractLoadBalancer lb;Overridepublic boolean isAlive(Server server) {return true;}public void setLoadBalancer(AbstractLoadBalancer lb){this.lb lb;}public AbstractLoadBalancer getLoadBalancer(){return lb;}} 2PingUrl public class PingUrl implements IPing {private static final Logger LOGGER LoggerFactory.getLogger(PingUrl.class);String pingAppendString ;boolean isSecure false;String expectedContent null;/*** Send one ping only.** Well, send what you need to determine whether or not the* server is still alive. Should return within a reasonable* time.*/public PingUrl() {}public PingUrl(boolean isSecure, String pingAppendString) {this.isSecure isSecure;this.pingAppendString (pingAppendString ! null) ? pingAppendString : ;}public void setPingAppendString(String pingAppendString) {this.pingAppendString (pingAppendString ! null) ? pingAppendString : ;}public String getPingAppendString() {return pingAppendString;}public boolean isSecure() {return isSecure;}/*** Should the Secure protocol be used to Ping* param isSecure*/public void setSecure(boolean isSecure) {this.isSecure isSecure;}public String getExpectedContent() {return expectedContent;}/*** Is there a particular content you are hoping to see?* If so -set this here.* for e.g. the WCS server sets the content body to be true* Please be advised that this content should match the actual * content exactly for this to work. Else yo may get false status.* param expectedContent*/public void setExpectedContent(String expectedContent) {this.expectedContent expectedContent;}public boolean isAlive(Server server) {String urlStr ;if (isSecure){urlStr https://;}else{urlStr http://;}urlStr server.getId();urlStr getPingAppendString();boolean isAlive false;HttpClient httpClient new DefaultHttpClient();HttpUriRequest getRequest new HttpGet(urlStr);String contentnull;try {HttpResponse response httpClient.execute(getRequest);content EntityUtils.toString(response.getEntity());isAlive (response.getStatusLine().getStatusCode() 200);if (getExpectedContent()!null){LOGGER.debug(content: content);if (content null){isAlive false;}else{if (content.equals(getExpectedContent())){isAlive true;}else{isAlive false;}}}} catch (IOException e) {e.printStackTrace();}finally{// Release the connection.getRequest.abort();}return isAlive;}public static void main(String[] args){PingUrl p new PingUrl(false,/cs/hostRunning);p.setExpectedContent(true);Server s new Server(ec2-75-101-231-85.compute-1.amazonaws.com, 7101);boolean isAlive p.isAlive(s);System.out.println(isAlive: isAlive);} } 3PingConstant  public class PingConstant implements IPing {boolean constant true;public void setConstant(String constantStr) {constant (constantStr ! null) (constantStr.toLowerCase().equals(true));}public void setConstant(boolean constant) {this.constant constant;}public boolean getConstant() {return constant;}public boolean isAlive(Server server) {return constant;} }4NoOpPing public class NoOpPing implements IPing {Overridepublic boolean isAlive(Server server) {return true;}}
http://www.sadfv.cn/news/321594/

相关文章:

  • 如何建立自己的网站?wordpress自定义弹窗
  • 邢台企业网站制作公司网站建设微信商城多少钱
  • 网站降权原因网站推广怎么做 知乎
  • 网站后台和前台软件著作权
  • 小说网站系统怎么做12数据网站建设
  • 河南省国基建设集团有限公司网站googleseo是什么
  • 电影网站logo设计iis如何做网站管理器
  • 备案核验单网站负责人长沙网站备案
  • 成都免费建网站公司365建筑人才网
  • 电子商城网站源码建筑网络工程教程
  • 成都网站快照优化公司云信智联商丘网站建设
  • 网站建设与管理实训课程如何开发一个手机网站
  • 厦网站建设培训wordpress+HTML5游戏
  • dedecms中餐网站模板网站做404
  • 中国住房和城乡建设部网站首页金华网站建设方案报价
  • 国家网站备案wordpress英文文章格式
  • 用meteor框架做的微博网站服饰 公司 网站建设
  • 阜新门户网站建设联合加工网
  • 基于响应式设计的网站建设最近网站改版文章突然不收录
  • php网站开发是学什么的禅城网站建设代理
  • 做网站什么主题好做申请商标官网
  • 用数据库做学校网站织梦网站优化
  • 网站在线做照片梅州网站建
  • 网站怎么盈利网站外包如何报价
  • 苏州网站制作计划域名注册平台
  • 包装网站开发青岛李村网站设计公司
  • 开封网站建设优化衡水哪儿做网站便宜
  • 北京建设信息港网站客户评价 网站
  • 制作社交app的网站网站开发总结经验和教训
  • 网站建设怎么收费呀网页美工基础