当前位置: 首页 > 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.pierceye.com/news/670749/

相关文章:

  • 优秀甜品网站最有前景的十大行业
  • 手册设计南宁seo网站排名优化公司
  • 国外做科普视频的网站郑州做营销型网站的公司
  • 雄安网站设计制作即时灵感网站
  • 自己怎么优化网站排名wordpress 自动超链接
  • 建设工程安全监督备案网站wordpress最简易主题
  • 集客营销软件官方网站如何开发微信微网站
  • 青岛谁优化网站做的好微营销工具
  • 怎么才能建立一个网站卖东西php做网站用html做吗
  • 西安公司网站设计费用免费外国网站浏览器
  • 如何加快网站打开速度浦东新区建设机械网站
  • 求网站制作焦作网站建设的公司
  • 用python做网站不常见久久建筑网外墙岩棉保温板施工工艺
  • 做刷票的网站广告牌的样式大全
  • 手机登录网站怎么建设网站风格和功能设计方案
  • 网站报价天津网站在哪里建设
  • 湖北专业网站建设维修电话福清网站商城建设
  • 网站建设模块怎么使用线上注册公司流程和费用
  • 营销型网站设计内容wordpress加速优化插件
  • 设计坞网站官方下载4399网页游戏入口
  • 太原百度网站建设如何联系网站管理员
  • 海东高端网站建设公司视频网站 费用
  • 可以帮别人备案网站吗手机建网站公司
  • 四川建设厅网上查询网站信用网站系统建设方案
  • 克隆网站后台做系统用哪个网站好
  • html5 手机网站页面实例wordpress 路由404
  • 百度地图嵌入公司网站wordpress如何去掉分类里面的大字
  • 山东住房与城乡建设网站够完美网站建设
  • 班级网站建设首页报告如何查询一个网站是否备案
  • 艺术设计类网站石家庄公司的网站设计