• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java RandomRule类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.netflix.loadbalancer.RandomRule的典型用法代码示例。如果您正苦于以下问题:Java RandomRule类的具体用法?Java RandomRule怎么用?Java RandomRule使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



RandomRule类属于com.netflix.loadbalancer包,在下文中一共展示了RandomRule类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: ruleOverridesToRandom

import com.netflix.loadbalancer.RandomRule; //导入依赖的package包/类
@Test
public void ruleOverridesToRandom() throws Exception {
	RandomRule.class.cast(getLoadBalancer("foo").getRule());
	RoundRobinRule.class.cast(getLoadBalancer("bar").getRule());
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:6,代码来源:RibbonClientPreprocessorOverridesIntegrationTests.java


示例2: createLoadBalancerRule

import com.netflix.loadbalancer.RandomRule; //导入依赖的package包/类
@Override
public IRule createLoadBalancerRule(String ruleName) {
  if (RULE_RoundRobin.equals(ruleName)) {
    return new RoundRobinRule();
  } else if (RULE_Random.equals(ruleName)) {
    return new RandomRule();
  } else if (RULE_WeightedResponse.equals(ruleName)) {
    return new WeightedResponseTimeRule();
  } else if (RULE_SessionStickiness.equals(ruleName)) {
    return new SessionStickinessRule();
  } else {
    throw new IllegalStateException("unexpected code to reach here, value is " + ruleName);
  }
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:15,代码来源:RuleNameExtentionsFactory.java


示例3: testRuleName

import com.netflix.loadbalancer.RandomRule; //导入依赖的package包/类
@Test
public void testRuleName() {
  System.setProperty("cse.loadbalance.mytest1.strategy.name", "RoundRobin");
  System.setProperty("cse.loadbalance.mytest2.strategy.name", "Random");
  System.setProperty("cse.loadbalance.mytest3.strategy.name", "WeightedResponse");
  System.setProperty("cse.loadbalance.mytest4.strategy.name", "SessionStickiness");

  BeansHolder holder = new BeansHolder();
  List<ExtensionsFactory> extensionsFactories = new ArrayList<>();
  extensionsFactories.add(new RuleClassNameExtentionsFactory());
  extensionsFactories.add(new RuleNameExtentionsFactory());
  extensionsFactories.add(new DefaultRetryExtensionsFactory());
  Deencapsulation.setField(holder, "extentionsFactories", extensionsFactories);
  holder.init();

  Assert.assertEquals(RoundRobinRule.class.getName(),
      ExtensionsManager.createLoadBalancerRule("mytest1").getClass().getName());
  Assert.assertEquals(RandomRule.class.getName(),
      ExtensionsManager.createLoadBalancerRule("mytest2").getClass().getName());
  Assert.assertEquals(WeightedResponseTimeRule.class.getName(),
      ExtensionsManager.createLoadBalancerRule("mytest3").getClass().getName());
  Assert.assertEquals(SessionStickinessRule.class.getName(),
      ExtensionsManager.createLoadBalancerRule("mytest4").getClass().getName());

  System.getProperties().remove("cse.loadbalance.mytest1.strategy.name");
  System.getProperties().remove("cse.loadbalance.mytest2.strategy.name");
  System.getProperties().remove("cse.loadbalance.mytest3.strategy.name");
  System.getProperties().remove("cse.loadbalance.mytest4.strategy.name");
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:30,代码来源:TestExtensionsManager.java


示例4: testRuleClassName

import com.netflix.loadbalancer.RandomRule; //导入依赖的package包/类
@Test
public void testRuleClassName() {
  System.setProperty("cse.loadbalance.mytest1.NFLoadBalancerRuleClassName",
      "com.netflix.loadbalancer.RoundRobinRule");
  System.setProperty("cse.loadbalance.mytest2.NFLoadBalancerRuleClassName",
      "com.netflix.loadbalancer.WeightedResponseTimeRule");
  System.setProperty("cse.loadbalance.mytest3.NFLoadBalancerRuleClassName", "com.netflix.loadbalancer.RandomRule");
  System.setProperty("cse.loadbalance.mytest4.NFLoadBalancerRuleClassName",
      "org.apache.servicecomb.loadbalance.SessionStickinessRule");

  BeansHolder holder = new BeansHolder();
  List<ExtensionsFactory> extensionsFactories = new ArrayList<>();
  extensionsFactories.add(new RuleClassNameExtentionsFactory());
  extensionsFactories.add(new RuleNameExtentionsFactory());
  extensionsFactories.add(new DefaultRetryExtensionsFactory());
  Deencapsulation.setField(holder, "extentionsFactories", extensionsFactories);
  holder.init();

  Assert.assertEquals(RoundRobinRule.class.getName(),
      ExtensionsManager.createLoadBalancerRule("mytest1").getClass().getName());
  Assert.assertEquals(WeightedResponseTimeRule.class.getName(),
      ExtensionsManager.createLoadBalancerRule("mytest2").getClass().getName());
  Assert.assertEquals(RandomRule.class.getName(),
      ExtensionsManager.createLoadBalancerRule("mytest3").getClass().getName());
  Assert.assertEquals(SessionStickinessRule.class.getName(),
      ExtensionsManager.createLoadBalancerRule("mytest4").getClass().getName());

  System.getProperties().remove("cse.loadbalance.mytest1.NFLoadBalancerRuleClassName");
  System.getProperties().remove("cse.loadbalance.mytest2.NFLoadBalancerRuleClassName");
  System.getProperties().remove("cse.loadbalance.mytest3.NFLoadBalancerRuleClassName");
  System.getProperties().remove("cse.loadbalance.mytest4.NFLoadBalancerRuleClassName");

  Assert.assertEquals(DefaultLoadBalancerRetryHandler.class.getName(),
      ExtensionsManager.createRetryHandler("mytest1").getClass().getName());
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:36,代码来源:TestExtensionsManager.java


示例5: ribbonRule

import com.netflix.loadbalancer.RandomRule; //导入依赖的package包/类
/**
     * 负载均衡策略
     * @return
     */
    @Bean
    public IRule ribbonRule() {
//        return new BestAvailableRule(); //选择一个最小的并发请求的server
//        return new WeightedResponseTimeRule(); //根据相应时间分配一个weight,相应时间越长,weight越小,被选中的可能性越低。
//        return new RetryRule(); //对选定的负载均衡策略机上重试机制。
//        return new RoundRobinRule(); //roundRobin方式轮询选择server
        return new RandomRule(); //随机选择一个server
//        return new ZoneAvoidanceRule(); //复合判断server所在区域的性能和server的可用性选择server
//        return new AvailabilityFilteringRule();
    }
 
开发者ID:hutou-workhouse,项目名称:miscroServiceHello,代码行数:15,代码来源:HelloConfiguration.java


示例6: ribbonRule

import com.netflix.loadbalancer.RandomRule; //导入依赖的package包/类
@Bean
public IRule ribbonRule() {
  // 负载均衡规则,改为随机
  return new RandomRule();
}
 
开发者ID:itmuch,项目名称:spring-cloud-docker-microservice-book-code,代码行数:6,代码来源:RibbonConfiguration.java


示例7: ribbonRule

import com.netflix.loadbalancer.RandomRule; //导入依赖的package包/类
@Bean
public IRule ribbonRule() {
    return new RandomRule();
}
 
开发者ID:kenly333,项目名称:service-hive,代码行数:5,代码来源:HRClientHystrixApplication.java


示例8: getRandomRule

import com.netflix.loadbalancer.RandomRule; //导入依赖的package包/类
private IRule getRandomRule() {
	RandomRule randomRule = new RandomRule();
	randomRule.setLoadBalancer(this);
	return randomRule;
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-zookeeper,代码行数:6,代码来源:DependenciesBasedLoadBalancer.java


示例9: ruleOverridesToRandom

import com.netflix.loadbalancer.RandomRule; //导入依赖的package包/类
@Test
public void ruleOverridesToRandom() throws Exception {
	assumeNotTravis();
	RandomRule.class.cast(getLoadBalancer("foo2").getRule());
	ZoneAvoidanceRule.class.cast(getLoadBalancer("bar").getRule());
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:7,代码来源:RibbonClientPreprocessorPropertiesOverridesIntegrationTests.java


示例10: ribbonRule

import com.netflix.loadbalancer.RandomRule; //导入依赖的package包/类
@Bean
public IRule ribbonRule() {
	return new RandomRule();
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:5,代码来源:RibbonClientPreprocessorOverridesIntegrationTests.java



注:本文中的com.netflix.loadbalancer.RandomRule类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java AlipayTradeOrderSettleModel类代码示例发布时间:2022-05-22
下一篇:
Java ManifestParser类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap