• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java RoundRobinRule类的典型用法和代码示例

java 1次浏览

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

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

示例1: testFixedServerList

点赞 3

import com.netflix.loadbalancer.RoundRobinRule; //导入依赖的package包/类
@Test
public void testFixedServerList() throws Exception {
    List<RibbonServer> servers = new ArrayList<>();
    servers.add(new RibbonServer("localhost", 9090));
    servers.add(new RibbonServer("localhost", 9091));

    ServerList<RibbonServer> list = new RibbonServiceCallStaticServerListStrategy(servers);

    ZoneAwareLoadBalancer<RibbonServer> lb = LoadBalancerBuilder.<RibbonServer>newBuilder()
        .withDynamicServerList(list)
        .withRule(new RoundRobinRule()).buildDynamicServerListLoadBalancer();

    Server server = lb.chooseServer();
    assertEquals("localhost", server.getHost());
    assertEquals(9091, server.getPort());

    server = lb.chooseServer();
    assertEquals("localhost", server.getHost());
    assertEquals(9090, server.getPort());
}
 

开发者ID:HydAu,
项目名称:Camel,
代码行数:21,
代码来源:RibbonServerListTest.java

示例2: testBuildWithArchaiusProperties

点赞 3

import com.netflix.loadbalancer.RoundRobinRule; //导入依赖的package包/类
@Test
public void testBuildWithArchaiusProperties() {
    Configuration config = ConfigurationManager.getConfigInstance();
    config.setProperty("client1.niws.client." + Keys.DeploymentContextBasedVipAddresses, "dummy:7001");
    config.setProperty("client1.niws.client." + Keys.InitializeNFLoadBalancer, "true");
    config.setProperty("client1.niws.client." + Keys.NFLoadBalancerClassName, DynamicServerListLoadBalancer.class.getName());
    config.setProperty("client1.niws.client." + Keys.NFLoadBalancerRuleClassName, RoundRobinRule.class.getName());
    config.setProperty("client1.niws.client." + Keys.NIWSServerListClassName, DiscoveryEnabledNIWSServerList.class.getName());
    config.setProperty("client1.niws.client." + Keys.NIWSServerListFilterClassName, ZoneAffinityServerListFilter.class.getName());
    config.setProperty("client1.niws.client." + Keys.ServerListUpdaterClassName, PollingServerListUpdater.class.getName());
    IClientConfig clientConfig = IClientConfig.Builder.newBuilder(NiwsClientConfig.class, "client1").build();
    ILoadBalancer lb = LoadBalancerBuilder.newBuilder().withClientConfig(clientConfig).buildLoadBalancerFromConfigWithReflection();
    assertNotNull(lb);
    assertEquals(DynamicServerListLoadBalancer.class.getName(), lb.getClass().getName());
    DynamicServerListLoadBalancer<Server> dynamicLB = (DynamicServerListLoadBalancer<Server>) lb;
    assertTrue(dynamicLB.getServerListUpdater() instanceof PollingServerListUpdater);
    assertTrue(dynamicLB.getFilter() instanceof ZoneAffinityServerListFilter);
    assertTrue(dynamicLB.getRule() instanceof RoundRobinRule);
    assertTrue(dynamicLB.getPing() instanceof DummyPing);
    assertEquals(Lists.newArrayList(expected), lb.getAllServers());
}
 

开发者ID:Netflix,
项目名称:ribbon,
代码行数:22,
代码来源:LBBuilderTest.java

示例3: createLoadBalancerRule

点赞 2

import com.netflix.loadbalancer.RoundRobinRule; //导入依赖的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

示例4: testRuleName

点赞 2

import com.netflix.loadbalancer.RoundRobinRule; //导入依赖的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

示例5: testRuleClassName

点赞 2

import com.netflix.loadbalancer.RoundRobinRule; //导入依赖的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

示例6: setUp

点赞 2

import com.netflix.loadbalancer.RoundRobinRule; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    Server server1 = new Server("host1", 4711);
    Server server2 = new Server("host2", 4712);

    List<Server> servers = Arrays.asList(server1, server2);
    loadBalancer = LoadBalancerBuilder.newBuilder()
            .withRule(new RoundRobinRule())
            .buildFixedServerListLoadBalancer(servers);
    filter = new RibbonClientRequestFilter(loadBalancer);
}
 

开发者ID:lreimer,
项目名称:cloud-native-javaee,
代码行数:12,
代码来源:RibbonClientRequestFilterTest.java

示例7: SessionStickinessRule

点赞 2

import com.netflix.loadbalancer.RoundRobinRule; //导入依赖的package包/类
public SessionStickinessRule() {
  triggerRule = new RoundRobinRule();
}
 

开发者ID:apache,
项目名称:incubator-servicecomb-java-chassis,
代码行数:4,
代码来源:SessionStickinessRule.java

示例8: roundRobin

点赞 2

import com.netflix.loadbalancer.RoundRobinRule; //导入依赖的package包/类
@Produces
@Default
@Dependent
public IRule roundRobin() {
    return new RoundRobinRule();
}
 

开发者ID:lreimer,
项目名称:cloud-native-javaee,
代码行数:7,
代码来源:RuleProducer.java

示例9: getRoundRobinRule

点赞 2

import com.netflix.loadbalancer.RoundRobinRule; //导入依赖的package包/类
private RoundRobinRule getRoundRobinRule() {
	return new RoundRobinRule(this);
}
 

开发者ID:spring-cloud,
项目名称:spring-cloud-zookeeper,
代码行数:4,
代码来源:DependenciesBasedLoadBalancer.java

示例10: ruleOverridesToRandom

点赞 2

import com.netflix.loadbalancer.RoundRobinRule; //导入依赖的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

示例11: ribbonRule

点赞 2

import com.netflix.loadbalancer.RoundRobinRule; //导入依赖的package包/类
@Bean
public IRule ribbonRule() {
	return new RoundRobinRule();
}
 

开发者ID:spring-cloud,
项目名称:spring-cloud-netflix,
代码行数:5,
代码来源:RibbonClientPreprocessorOverridesIntegrationTests.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)