gpt4 book ai didi

com.netflix.loadbalancer.ZoneAvoidanceRule类的使用及代码示例

转载 作者:知者 更新时间:2024-03-14 06:13:31 30 4
gpt4 key购买 nike

本文整理了Java中com.netflix.loadbalancer.ZoneAvoidanceRule类的一些代码示例,展示了ZoneAvoidanceRule类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZoneAvoidanceRule类的具体详情如下:
包路径:com.netflix.loadbalancer.ZoneAvoidanceRule
类名称:ZoneAvoidanceRule

ZoneAvoidanceRule介绍

[英]A rule that uses the a CompositePredicate to filter servers based on zone and availability. The primary predicate is composed of a ZoneAvoidancePredicate and AvailabilityPredicate, with the fallbacks to AvailabilityPredicateand an "always true" predicate returned from AbstractServerPredicate#alwaysTrue()
[中]一种使用CompositeProdicate根据区域和可用性筛选服务器的规则。主谓词由ZoneAvoidancePredicate和AvailabilityPredicate组成,其中AvailabilityPredicate的回退和AbstractServerPredicate#alwaysTrue()返回的“始终为真”谓词

代码示例

代码示例来源:origin: codingapi/tx-lcn

private Server getServer(Object key) {
  String localKey = String.format("%s:%s:%s", registration.getServiceId(), registration.getHost(), registration.getPort());
  List<String> appList = sleuthParamListener.beforeBalance(localKey);
  Server balanceServer = null;
  List<Server> servers = getLoadBalancer().getAllServers();
  log.debug("load balanced rule servers: {}", servers);
  for (Server server : servers) {
    for (String appKey : appList) {
      String serverKey = String.format("%s:%s", server.getMetaInfo().getAppName(), server.getHostPort());
      if (serverKey.equals(appKey)) {
        balanceServer = server;
      }
    }
  }
  if (balanceServer == null) {
    Server server = super.choose(key);
    sleuthParamListener.afterNewBalance(String.format("%s:%s", server.getMetaInfo().getAppName(), server.getHostPort()));
    return server;
  } else {
    return balanceServer;
  }
}

代码示例来源:origin: SpringCloud/spring-cloud-gray

return server.get();
  } else {
    return choose(super.getPredicate(), normalServers, key);
  return subDelegate.choose(key);
}else{
  return super.choose(key);

代码示例来源:origin: SpringCloud/spring-cloud-gray

public BambooZoneAvoidanceRule() {
  super();
  BambooApiVersionPredicate apiVersionPredicate = new BambooApiVersionPredicate(this);
  bambooCompositePredicate = CompositePredicate.withPredicates(super.getPredicate(),
      apiVersionPredicate).build();
}

代码示例来源:origin: org.springframework.cloud/spring-cloud-netflix-ribbon

@Bean
@ConditionalOnMissingBean
public IRule ribbonRule(IClientConfig config) {
  if (this.propertiesFactory.isSet(IRule.class, name)) {
    return this.propertiesFactory.get(IRule.class, config, name);
  }
  ZoneAvoidanceRule rule = new ZoneAvoidanceRule();
  rule.initWithNiwsConfig(config);
  return rule;
}

代码示例来源:origin: com.netflix.ribbon/ribbon-loadbalancer

try {
  LoadBalancerStats lbStats = getLoadBalancerStats();
  Map<String, ZoneSnapshot> zoneSnapshot = ZoneAvoidanceRule.createSnapshot(lbStats);
  logger.debug("Zone snapshots: {}", zoneSnapshot);
  if (triggeringLoad == null) {
        "ZoneAwareNIWSDiscoveryLoadBalancer." + this.getName() + ".avoidZoneWithBlackoutPercetage", 0.99999d);
  Set<String> availableZones = ZoneAvoidanceRule.getAvailableZones(zoneSnapshot, triggeringLoad.get(), triggeringBlackoutPercentage.get());
  logger.debug("Available zones: {}", availableZones);
  if (availableZones != null &&  availableZones.size() < zoneSnapshot.keySet().size()) {
    String zone = ZoneAvoidanceRule.randomChooseZone(zoneSnapshot, availableZones);
    logger.debug("Zone chosen: {}", zone);
    if (zone != null) {

代码示例来源:origin: com.netflix.ribbon/ribbon-loadbalancer

public static Set<String> getAvailableZones(LoadBalancerStats lbStats,
    double triggeringLoad, double triggeringBlackoutPercentage) {
  if (lbStats == null) {
    return null;
  }
  Map<String, ZoneSnapshot> snapshot = createSnapshot(lbStats);
  return getAvailableZones(snapshot, triggeringLoad,
      triggeringBlackoutPercentage);
}

代码示例来源:origin: SpringCloud/spring-cloud-gray

@Override
public void initWithNiwsConfig(IClientConfig clientConfig) {
  super.initWithNiwsConfig(clientConfig);
  if(subDelegate!=null){
    subDelegate.initWithNiwsConfig(clientConfig);
  }
}

代码示例来源:origin: com.netflix.ribbon/ribbon-loadbalancer

public ZoneAvoidanceRule() {
  super();
  ZoneAvoidancePredicate zonePredicate = new ZoneAvoidancePredicate(this);
  AvailabilityPredicate availabilityPredicate = new AvailabilityPredicate(this);
  compositePredicate = createCompositePredicate(zonePredicate, availabilityPredicate);
}

代码示例来源:origin: SpringCloud/spring-cloud-gray

@Override
public void setLoadBalancer(ILoadBalancer lb) {
  super.setLoadBalancer(lb);
  if(subDelegate!=null){
    subDelegate.setLoadBalancer(lb);
  }
}

代码示例来源:origin: com.netflix.ribbon/ribbon-loadbalancer

String zoneToAvoid = randomChooseZone(snapshot, worstZones);
if (zoneToAvoid != null) {
  availableZones.remove(zoneToAvoid);

代码示例来源:origin: saleson/fm-cloud

public BambooZoneAvoidanceRule() {
  super();
  BambooApiVersionPredicate apiVersionPredicate = new BambooApiVersionPredicate(this);
  bambooCompositePredicate = CompositePredicate.withPredicates(super.getPredicate(),
      apiVersionPredicate).build();
}

代码示例来源:origin: com.netflix.ribbon/ribbon-loadbalancer

Map<String, ZoneSnapshot> zoneSnapshot = ZoneAvoidanceRule.createSnapshot(lbStats);
if (!zoneSnapshot.keySet().contains(serverZone)) {
Set<String> availableZones = ZoneAvoidanceRule.getAvailableZones(zoneSnapshot, triggeringLoad.get(), triggeringBlackoutPercentage.get());
logger.debug("Available zones: {}", availableZones);
if (availableZones != null) {

代码示例来源:origin: com.netflix.ribbon/ribbon-loadbalancer

@Override
public void initWithNiwsConfig(IClientConfig clientConfig) {
  ZoneAvoidancePredicate zonePredicate = new ZoneAvoidancePredicate(this, clientConfig);
  AvailabilityPredicate availabilityPredicate = new AvailabilityPredicate(this, clientConfig);
  compositePredicate = createCompositePredicate(zonePredicate, availabilityPredicate);
}

代码示例来源:origin: SpringCloud/spring-cloud-gray

protected void init(){
  GrayDecisionPredicate apiVersionPredicate = new GrayDecisionPredicate(this);
  GrayClientProperties grayClientProperties = GrayClientAppContext.getGrayClientProperties();
  //如果与多版本一起使用
  if(grayClientProperties.getInstance().isUseMultiVersion()){
    subDelegate = new BambooZoneAvoidanceRule();
    grayCompositePredicate = CompositePredicate.withPredicates(subDelegate.getPredicate(),
        apiVersionPredicate).build();
  }else{
    grayCompositePredicate = CompositePredicate.withPredicates(super.getPredicate(),
        apiVersionPredicate).build();
  }
}

代码示例来源:origin: Nepxion/Discovery

@Override
  public Server choose(Object key) {
    WeightFilterEntity weightFilterEntity = weightRandomLoadBalance.getWeightFilterEntity();
    if (weightFilterEntity == null) {
      return super.choose(key);
    }

    if (!weightFilterEntity.hasWeight()) {
      return super.choose(key);
    }

    List<Server> eligibleServers = getPredicate().getEligibleServers(getLoadBalancer().getAllServers(), key);

    try {
      return weightRandomLoadBalance.choose(eligibleServers, weightFilterEntity);
    } catch (Exception e) {
      return super.choose(key);
    }
  }
}

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com