当前位置: 首页>>代码示例>>Java>>正文


Java ServerList类代码示例

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


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

示例1: testFixedServerList

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

import com.netflix.loadbalancer.ServerList; //导入依赖的package包/类
protected DomainExtractingServerList getDomainExtractingServerList(
		DefaultClientConfigImpl config, boolean approximateZoneFromHostname) {
	DiscoveryEnabledServer server = mock(DiscoveryEnabledServer.class);
	@SuppressWarnings("unchecked")
	ServerList<DiscoveryEnabledServer> originalServerList = mock(ServerList.class);
	InstanceInfo instanceInfo = mock(InstanceInfo.class);
	given(server.getInstanceInfo()).willReturn(instanceInfo);
	given(server.getHost()).willReturn(HOST_NAME);
	given(instanceInfo.getMetadata()).willReturn(this.metadata);
	given(instanceInfo.getHostName()).willReturn(HOST_NAME);
	given(instanceInfo.getIPAddr()).willReturn(IP_ADDR);
	given(instanceInfo.getPort()).willReturn(PORT);
	given(originalServerList.getInitialListOfServers()).willReturn(
			Arrays.asList(server));
	return new DomainExtractingServerList(originalServerList, config,
			approximateZoneFromHostname);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:18,代码来源:DomainExtractingServerListTests.java

示例3: testBuildWithDiscoveryEnabledNIWSServerList

import com.netflix.loadbalancer.ServerList; //导入依赖的package包/类
@Test
public void testBuildWithDiscoveryEnabledNIWSServerList() {
    IRule rule = new AvailabilityFilteringRule();
    ServerList<DiscoveryEnabledServer> list = new DiscoveryEnabledNIWSServerList("dummy:7001");
    ServerListFilter<DiscoveryEnabledServer> filter = new ZoneAffinityServerListFilter<DiscoveryEnabledServer>();
    ZoneAwareLoadBalancer<DiscoveryEnabledServer> lb = LoadBalancerBuilder.<DiscoveryEnabledServer>newBuilder()
            .withDynamicServerList(list)
            .withRule(rule)
            .withServerListFilter(filter)
            .buildDynamicServerListLoadBalancer();
    assertNotNull(lb);
    assertEquals(Lists.newArrayList(expected), lb.getAllServers());
    assertSame(filter, lb.getFilter());
    assertSame(list, lb.getServerListImpl());
    Server server = lb.chooseServer();
    // make sure load balancer does not recreate the server instance
    assertTrue(server instanceof DiscoveryEnabledServer);
}
 
开发者ID:Netflix,项目名称:ribbon,代码行数:19,代码来源:LBBuilderTest.java

示例4: testBuildWithDiscoveryEnabledNIWSServerListAndUpdater

import com.netflix.loadbalancer.ServerList; //导入依赖的package包/类
@Test
public void testBuildWithDiscoveryEnabledNIWSServerListAndUpdater() {
    IRule rule = new AvailabilityFilteringRule();
    ServerList<DiscoveryEnabledServer> list = new DiscoveryEnabledNIWSServerList("dummy:7001");
    ServerListFilter<DiscoveryEnabledServer> filter = new ZoneAffinityServerListFilter<DiscoveryEnabledServer>();
    ServerListUpdater updater = new PollingServerListUpdater();
    ZoneAwareLoadBalancer<DiscoveryEnabledServer> lb = LoadBalancerBuilder.<DiscoveryEnabledServer>newBuilder()
            .withDynamicServerList(list)
            .withRule(rule)
            .withServerListFilter(filter)
            .withServerListUpdater(updater)
            .buildDynamicServerListLoadBalancerWithUpdater();
    assertNotNull(lb);
    assertEquals(Lists.newArrayList(expected), lb.getAllServers());
    assertSame(filter, lb.getFilter());
    assertSame(list, lb.getServerListImpl());
    assertSame(updater, lb.getServerListUpdater());
    Server server = lb.chooseServer();
    // make sure load balancer does not recreate the server instance
    assertTrue(server instanceof DiscoveryEnabledServer);
}
 
开发者ID:Netflix,项目名称:ribbon,代码行数:22,代码来源:LBBuilderTest.java

示例5: ribbonServerList

import com.netflix.loadbalancer.ServerList; //导入依赖的package包/类
@Bean
public ServerList<Server> ribbonServerList(
    IClientConfig config) {
  ServiceCombServerList serverList = new ServiceCombServerList();
  serverList.initWithNiwsConfig(config);
  return serverList;
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:8,代码来源:CseRibbonClientConfiguration.java

示例6: loadBalancer

import com.netflix.loadbalancer.ServerList; //导入依赖的package包/类
/**
 * The load balancer definition.
 *
 * @param config            the client config.
 * @param serverList        the server list.
 * @param serverListFilter  the server list filter.
 * @param rule              the load balancing rule.
 * @param ping              the ping strategy.
 * @param serverListUpdater the server list updater.
 * @return The Dynamic Server List Load Balancer.
 */
@Bean
@ConditionalOnMissingBean
public ILoadBalancer loadBalancer(IClientConfig config,
                                  ServerList<Server> serverList,
                                  ServerListFilter<Server> serverListFilter,
                                  IRule rule, IPing ping,
                                  ServerListUpdater serverListUpdater) {
    log.debug("dynamic server list load balancer enabled.");
    return new DynamicServerListLoadBalancer<>(config, rule, ping, serverList,
            serverListFilter, serverListUpdater);
}
 
开发者ID:enadim,项目名称:spring-cloud-ribbon-extensions,代码行数:23,代码来源:RuleBaseConfig.java

示例7: serverList

import com.netflix.loadbalancer.ServerList; //导入依赖的package包/类
@Bean
public ServerList<Server> serverList() {
    return new ServerList<Server>() {
        @Override
        public List<Server> getInitialListOfServers() {
            return servers();
        }

        @Override
        public List<Server> getUpdatedListOfServers() {
            return servers();
        }
    };
}
 
开发者ID:enadim,项目名称:spring-cloud-ribbon-extensions,代码行数:15,代码来源:AbstractSupportTest.java

示例8: ribbonServerList

import com.netflix.loadbalancer.ServerList; //导入依赖的package包/类
@Bean
@ConditionalOnMissingBean
public ServerList<?> ribbonServerList() {
    MarathonServerList serverList = new MarathonServerList(client, properties);
    serverList.initWithNiwsConfig(clientConfig);
    return serverList;
}
 
开发者ID:aatarasoff,项目名称:spring-cloud-marathon,代码行数:8,代码来源:MarathonRibbonClientConfiguration.java

示例9: ribbonServerList

import com.netflix.loadbalancer.ServerList; //导入依赖的package包/类
@Bean
@ConditionalOnMissingBean
public ServerList<?> ribbonServerList(KubernetesClient client, IClientConfig config) {
    KubernetesServerList serverList = new KubernetesServerList(client);
    serverList.initWithNiwsConfig(config);
    return serverList;
}
 
开发者ID:fabric8io,项目名称:spring-cloud-kubernetes,代码行数:8,代码来源:KubernetesRibbonClientConfiguration.java

示例10: ribbonServerList

import com.netflix.loadbalancer.ServerList; //导入依赖的package包/类
@Bean
ServerList<Server> ribbonServerList() {
  String hostname;
  int port;
  try {
    hostname = new URI(quoteServerURL).getHost();
    port = new URI(quoteServerURL).getPort();
  } catch (URISyntaxException e) {
    hostname = DEFAULT_QUOTE_SERVER_HOST;
    port = DEFAULT_QUOTE_SERVER_PORT;
    e.printStackTrace();
  }
  return new StaticServerList<>(new Server(hostname, port));
}
 
开发者ID:singram,项目名称:openzipkin-demo,代码行数:15,代码来源:Application.java

示例11: ribbonServerList

import com.netflix.loadbalancer.ServerList; //导入依赖的package包/类
@Bean
@ConditionalOnMissingBean
public ServerList<?> ribbonServerList(IClientConfig config) {
	// TODO: this is a common thing between impl, maybe ServerListFactory?
	LatticeServerList serverList = new LatticeServerList(props, receptorService,
			serviceId);
	return serverList;
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-lattice,代码行数:9,代码来源:LatticeRibbonClientConfiguration.java

示例12: ribbonServerList

import com.netflix.loadbalancer.ServerList; //导入依赖的package包/类
@Bean
public ServerList<?> ribbonServerList() {
    Map<String, String> metadata = new HashMap<>();
    metadata.put("version", "1.0");
    metadata.put("variant", "A");
    InstanceInfo instanceInfo = InstanceInfo.Builder.newBuilder()
            .setAppName("local")
            .setHostName("localhost")
            .setPort(8761)
            .setMetadata(metadata)
            .build();
    return new StaticServerList<>(Arrays.asList(new DiscoveryEnabledServer(instanceInfo, false)));
}
 
开发者ID:jmnarloch,项目名称:ribbon-discovery-filter-spring-cloud-starter,代码行数:14,代码来源:RibbonDiscoveryFilterTest.java

示例13: ribbonLoadBalancer

import com.netflix.loadbalancer.ServerList; //导入依赖的package包/类
@Bean
@ConditionalOnMissingBean
public ILoadBalancer ribbonLoadBalancer(IClientConfig config,
										ServerList<Server> serverList, ServerListFilter<Server> serverListFilter,
										IRule rule, IPing ping) {
	ZoneAwareLoadBalancer<Server> balancer = LoadBalancerBuilder.newBuilder()
			.withClientConfig(config).withRule(rule).withPing(ping)
			.withServerListFilter(serverListFilter).withDynamicServerList(serverList)
			.buildDynamicServerListLoadBalancer();
	return new DemoLoadBalancer(balancer);
}
 
开发者ID:spencergibb,项目名称:ribbondemo,代码行数:12,代码来源:RibbonDemoRibbonConfig.java

示例14: ribbonServerListFromDependencies

import com.netflix.loadbalancer.ServerList; //导入依赖的package包/类
@Bean
@ConditionalOnMissingBean
@ConditionalOnDependenciesPassed
public ServerList<?> ribbonServerListFromDependencies(IClientConfig config,
		ZookeeperDependencies zookeeperDependencies,
		ServiceDiscovery<ZookeeperInstance> serviceDiscovery) {
	ZookeeperServerList serverList = new ZookeeperServerList(serviceDiscovery);
	serverList.initFromDependencies(config, zookeeperDependencies);
	log.debug(String.format("Server list for Ribbon's dependencies based load balancing is [%s]", serverList));
	return serverList;
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-zookeeper,代码行数:12,代码来源:ZookeeperRibbonClientConfiguration.java

示例15: dependenciesBasedLoadBalancer

import com.netflix.loadbalancer.ServerList; //导入依赖的package包/类
@Bean
@ConditionalOnMissingBean
@ConditionalOnDependenciesPassed
@ConditionalOnProperty(value = "spring.cloud.zookeeper.dependency.ribbon.loadbalancer", matchIfMissing = true)
public ILoadBalancer dependenciesBasedLoadBalancer(ZookeeperDependencies zookeeperDependencies,
		ServerList<?> serverList, IClientConfig config, IPing iPing) {
	return new DependenciesBasedLoadBalancer(zookeeperDependencies, serverList, config, iPing);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-zookeeper,代码行数:9,代码来源:ZookeeperRibbonClientConfiguration.java


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