本文整理汇总了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;
}
}
示例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));
}
示例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;
}
示例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());
}
示例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);
}
示例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;
}
示例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;
}
示例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());
}
示例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;
}
示例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;
}
示例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());
}
示例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;
}
示例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