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


Java DiscoveryEnabledServer类代码示例

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


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


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