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

Java DiscoveryEnabledServer类代码示例

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

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



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

示例1: doApply

import com.netflix.niws.loadbalancer.DiscoveryEnabledServer; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
protected boolean doApply(DiscoveryEnabledServer server) {
    String metadataKey = current().get(dynamicEntryKey);
    Map<String, String> metadata = server.getInstanceInfo().getMetadata();
    if (metadataKey != null) {
        String expected = current().get(metadataKey);
        String actual = metadata.get(metadataKey);
        boolean accept = (expected == null && actual == null) || (expected != null && expected.equals(actual));
        log.trace("Expected [{}={}] vs {}:{}{} => {}",
                metadataKey,
                expected,
                server.getHostPort(),
                server.getMetaInfo().getAppName(),
                metadata,
                accept);
        return accept;
    } else {
        log.trace("[{}] not defined! : {}{} => %b",
                dynamicEntryKey,
                server.getHostPort(),
                metadata,
                matchIfMissing);
        return matchIfMissing;
    }
}
 
开发者ID:enadim,项目名称:spring-cloud-ribbon-extensions,代码行数:29,代码来源:DynamicMetadataMatcher.java


示例2: basicConfigurationCreatedForLoadBalancer

import com.netflix.niws.loadbalancer.DiscoveryEnabledServer; //导入依赖的package包/类
@Test
@Ignore
public void basicConfigurationCreatedForLoadBalancer() {
	EurekaClientConfigBean client = new EurekaClientConfigBean();
	EurekaInstanceConfigBean configBean = getEurekaInstanceConfigBean();
	client.getAvailabilityZones().put(client.getRegion(), "foo");
	SpringClientFactory clientFactory = new SpringClientFactory();
	EurekaRibbonClientConfiguration clientPreprocessor = new EurekaRibbonClientConfiguration(
			client, "service", configBean, false);
	clientPreprocessor.preprocess();
	ILoadBalancer balancer = clientFactory.getLoadBalancer("service");
	assertNotNull(balancer);
	@SuppressWarnings("unchecked")
	ZoneAwareLoadBalancer<DiscoveryEnabledServer> aware = (ZoneAwareLoadBalancer<DiscoveryEnabledServer>) balancer;
	assertTrue(aware.getServerListImpl() instanceof DomainExtractingServerList);
	assertEquals("foo",
			ConfigurationManager.getDeploymentContext().getValue(ContextKey.zone));
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:19,代码来源:EurekaRibbonClientConfigurationTests.java


示例3: doApply

import com.netflix.niws.loadbalancer.DiscoveryEnabledServer; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
protected boolean doApply(DiscoveryEnabledServer server) {
    String expected = current().get(metadataKey);
    Map<String, String> metadata = server.getInstanceInfo().getMetadata();
    String actual = metadata.get(metadataKey);
    boolean accept = (expected == null && actual == null) || (expected != null && expected.equals(actual));
    log.trace("Expected [{}] vs {}:{}{} => {}",
            metadataKey,
            expected,
            server.getHostPort(),
            server.getMetaInfo().getAppName(),
            metadata,
            accept);
    return accept;
}
 
开发者ID:enadim,项目名称:spring-cloud-ribbon-extensions,代码行数:19,代码来源:SingleMetadataMatcher.java


示例4: DomainExtractingServer

import com.netflix.niws.loadbalancer.DiscoveryEnabledServer; //导入依赖的package包/类
public DomainExtractingServer(DiscoveryEnabledServer server, boolean useSecurePort,
		boolean useIpAddr, boolean approximateZoneFromHostname) {
	// host and port are set in super()
	super(server.getInstanceInfo(), useSecurePort, useIpAddr);
	if (server.getInstanceInfo().getMetadata().containsKey("zone")) {
		setZone(server.getInstanceInfo().getMetadata().get("zone"));
	}
	else if (approximateZoneFromHostname) {
		setZone(ZoneUtils.extractApproximateZone(server.getHost()));
	}
	else {
		setZone(server.getZone());
	}
	setId(extractId(server));
	setAlive(server.isAlive());
	setReadyToServe(server.isReadyToServe());
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:18,代码来源:DomainExtractingServerList.java


示例5: getDomainExtractingServerList

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


示例6: doApply

import com.netflix.niws.loadbalancer.DiscoveryEnabledServer; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
protected boolean doApply(DiscoveryEnabledServer server) {
    Set<Entry<String, String>> expected = current().entrySet();
    Map<String, String> actual = server.getInstanceInfo().getMetadata();
    boolean accept = actual.entrySet().containsAll(expected);
    log.trace("Expected {} vs {}:{}{} => {}",
            expected,
            server.getHostPort(),
            server.getMetaInfo().getAppName(),
            actual,
            accept);
    return accept;
}
 
开发者ID:enadim,项目名称:spring-cloud-ribbon-extensions,代码行数:17,代码来源:StrictMetadataMatcher.java


示例7: doApply

import com.netflix.niws.loadbalancer.DiscoveryEnabledServer; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
protected boolean doApply(DiscoveryEnabledServer server) {
    Map<String, String> metadata = server.getInstanceInfo().getMetadata();
    String actual = metadata.get(entryKey);
    boolean accept = entryValue.equals(actual);
    log.trace("Expected [{}={}] vs {}:{}{} => {}",
            entryKey,
            entryValue,
            server.getHostPort(),
            server.getMetaInfo().getAppName(),
            metadata,
            accept);
    return accept;
}
 
开发者ID:enadim,项目名称:spring-cloud-ribbon-extensions,代码行数:18,代码来源:SingleStaticMetadataMatcher.java


示例8: doApply

import com.netflix.niws.loadbalancer.DiscoveryEnabledServer; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
@SuppressFBWarnings("BC_UNCONFIRMED_CAST_OF_RETURN_VALUE")
protected boolean doApply(PredicateKey input) {
    return input.getServer() instanceof DiscoveryEnabledServer
            && doApply((DiscoveryEnabledServer) input.getServer());
}
 
开发者ID:enadim,项目名称:spring-cloud-ribbon-extensions,代码行数:10,代码来源:DiscoveryEnabledServerPredicate.java


示例9: doApply

import com.netflix.niws.loadbalancer.DiscoveryEnabledServer; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
protected boolean doApply(DiscoveryEnabledServer server) {
    String actual = server.getInstanceInfo().getInstanceId();
    boolean accept = expectedInstanceId.equals(actual);
    log.trace("Expected [{}] vs {}:{}[{}] => {}",
            expectedInstanceId,
            server.getHostPort(),
            server.getMetaInfo().getAppName(),
            actual,
            accept);
    return accept;
}
 
开发者ID:enadim,项目名称:spring-cloud-ribbon-extensions,代码行数:16,代码来源:InstanceIdMatcher.java


示例10: createServer

import com.netflix.niws.loadbalancer.DiscoveryEnabledServer; //导入依赖的package包/类
public DiscoveryEnabledServer createServer(String zone) {
    DiscoveryEnabledServer server = new DiscoveryEnabledServer(InstanceInfo.Builder.newBuilder()
            .setAppName(TestApplicationResource.SERVICE_ID)
            .setHostName("127.0.0.1")
            .setMetadata(new HashMap<>())
            .build(), false);
    server.setZone(zone);
    server.setAlive(true);
    server.setReadyToServe(true);
    return server;
}
 
开发者ID:enadim,项目名称:spring-cloud-ribbon-extensions,代码行数:12,代码来源:AbstractSupportTest.java


示例11: apply

import com.netflix.niws.loadbalancer.DiscoveryEnabledServer; //导入依赖的package包/类
/**
 * 执行断言,判断该服务实例是否满足条件。
 * @param input 服务实例。
 * @return
 */
@Override
public boolean apply(PredicateKey input) {
    return input != null
            && input.getServer() instanceof DiscoveryEnabledServer
            && apply((DiscoveryEnabledServer) input.getServer());
}
 
开发者ID:kenly333,项目名称:service-hive,代码行数:12,代码来源:MetadataAwarePredicate.java


示例12: apply

import com.netflix.niws.loadbalancer.DiscoveryEnabledServer; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public boolean apply(@Nullable PredicateKey input) {
    return input != null
            && input.getServer() instanceof DiscoveryEnabledServer
            && apply((DiscoveryEnabledServer) input.getServer());
}
 
开发者ID:jmnarloch,项目名称:ribbon-discovery-filter-spring-cloud-starter,代码行数:10,代码来源:DiscoveryEnabledPredicate.java


示例13: apply

import com.netflix.niws.loadbalancer.DiscoveryEnabledServer; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
protected boolean apply(DiscoveryEnabledServer server) {

    final RibbonFilterContext context = RibbonFilterContextHolder.getCurrentContext();
    final Set<Map.Entry<String, String>> attributes = Collections.unmodifiableSet(context.getAttributes().entrySet());
    final Map<String, String> metadata = server.getInstanceInfo().getMetadata();
    return metadata.entrySet().containsAll(attributes);
}
 
开发者ID:jmnarloch,项目名称:ribbon-discovery-filter-spring-cloud-starter,代码行数:12,代码来源:MetadataAwarePredicate.java


示例14: servers

import com.netflix.niws.loadbalancer.DiscoveryEnabledServer; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public static <T extends Server> List<T> servers(InstanceInfo... instanceInfos) {
    final List<T> result = new ArrayList<>();
    for (InstanceInfo info : instanceInfos) {
        result.add((T) new DiscoveryEnabledServer(info, false));
    }
    return result;
}
 
开发者ID:jmnarloch,项目名称:ribbon-discovery-filter-spring-cloud-starter,代码行数:9,代码来源:DiscoveryUtils.java


示例15: ribbonServerList

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


示例16: run

import com.netflix.niws.loadbalancer.DiscoveryEnabledServer; //导入依赖的package包/类
@Override
protected String run() throws Exception {

    IRule rule = new AvailabilityFilteringRule();
    ServerList<DiscoveryEnabledServer> list = new DiscoveryEnabledNIWSServerList(logWriterApplicationName);
    ServerListFilter<DiscoveryEnabledServer> filter = new ZoneAffinityServerListFilter<DiscoveryEnabledServer>();
    ZoneAwareLoadBalancer<DiscoveryEnabledServer> lb = LoadBalancerBuilder.<DiscoveryEnabledServer>newBuilder()
            .withDynamicServerList(list)
            .withRule(rule)
            .withServerListFilter(filter)
            .buildDynamicServerListLoadBalancer();
    Server server = lb.chooseServer();

    String url = "http://" + server.getHostPort() + "/log/latest";
    WebResource webResource = client
            .resource(url);

    ClientResponse response = webResource.accept("application/json")
            .get(ClientResponse.class);

    if (response.getStatus() != 200) {
        throw new RuntimeException("Failed : HTTP error code : "
                + response.getStatus() + " url " + url);
    }

    String output = response.getEntity(String.class);

    return "ceceived list of size: " + output;
}
 
开发者ID:guggens,项目名称:log-dropwizard-eureka-mongo-sample,代码行数:30,代码来源:LogReadCommand.java


示例17: run

import com.netflix.niws.loadbalancer.DiscoveryEnabledServer; //导入依赖的package包/类
@Override
protected String run() throws Exception {

    IRule rule = new AvailabilityFilteringRule();
    ServerList<DiscoveryEnabledServer> list = new DiscoveryEnabledNIWSServerList(logWriterApplicationName);
    ServerListFilter<DiscoveryEnabledServer> filter = new ZoneAffinityServerListFilter<DiscoveryEnabledServer>();
    ZoneAwareLoadBalancer<DiscoveryEnabledServer> lb = LoadBalancerBuilder.<DiscoveryEnabledServer>newBuilder()
            .withDynamicServerList(list)
            .withRule(rule)
            .withServerListFilter(filter)
            .buildDynamicServerListLoadBalancer();
    Server server = lb.chooseServer();

    int number = new Random().nextInt();
    String url = "http://" + server.getHostPort() + "/log?name=ProducedLog" + number;
    WebResource webResource = client
            .resource(url);

    ClientResponse response = webResource.accept("application/json")
            .get(ClientResponse.class);

    if (response.getStatus() != 200) {
        throw new RuntimeException("Failed : HTTP error code : "
                + response.getStatus() + " url " + url);
    }

    String output = response.getEntity(String.class);

    return "fired " + number + " to url:" + url + " with result " + output;
}
 
开发者ID:guggens,项目名称:log-dropwizard-eureka-mongo-sample,代码行数:31,代码来源:LogWriteCommand.java


示例18: isSecure

import com.netflix.niws.loadbalancer.DiscoveryEnabledServer; //导入依赖的package包/类
@Override
public boolean isSecure(Server server) {
	if (server instanceof DiscoveryEnabledServer) {
		DiscoveryEnabledServer discoveryServer = (DiscoveryEnabledServer) server;
		return discoveryServer.getInstanceInfo().isPortEnabled(InstanceInfo.PortType.SECURE);
	}
	return super.isSecure(server);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:9,代码来源:EurekaServerIntrospector.java


示例19: getMetadata

import com.netflix.niws.loadbalancer.DiscoveryEnabledServer; //导入依赖的package包/类
@Override
public Map<String, String> getMetadata(Server server) {
	if (server instanceof DiscoveryEnabledServer) {
		DiscoveryEnabledServer discoveryServer = (DiscoveryEnabledServer) server;
		return discoveryServer.getInstanceInfo().getMetadata();
	}
	return super.getMetadata(server);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:9,代码来源:EurekaServerIntrospector.java


示例20: setZones

import com.netflix.niws.loadbalancer.DiscoveryEnabledServer; //导入依赖的package包/类
private List<DiscoveryEnabledServer> setZones(List<DiscoveryEnabledServer> servers) {
	List<DiscoveryEnabledServer> result = new ArrayList<>();
	boolean isSecure = this.ribbon.isSecure(true);
	boolean shouldUseIpAddr = this.ribbon.isUseIPAddrForServer();
	for (DiscoveryEnabledServer server : servers) {
		result.add(new DomainExtractingServer(server, isSecure, shouldUseIpAddr,
				this.approximateZoneFromHostname));
	}
	return result;
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:11,代码来源:DomainExtractingServerList.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java InfrastructureProxy类代码示例发布时间:2022-05-22
下一篇:
Java GraphicsUtil类代码示例发布时间: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