本文整理汇总了Java中org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean类的典型用法代码示例。如果您正苦于以下问题:Java EurekaInstanceConfigBean类的具体用法?Java EurekaInstanceConfigBean怎么用?Java EurekaInstanceConfigBean使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EurekaInstanceConfigBean类属于org.springframework.cloud.netflix.eureka包,在下文中一共展示了EurekaInstanceConfigBean类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: setup
import org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean; //导入依赖的package包/类
@Before
public void setup() {
eurekaHttpClient = new RestTemplateTransportClientFactory()
.newClient(new DefaultEndpoint(serviceUrl));
EurekaInstanceConfigBean config = new EurekaInstanceConfigBean(inetUtils);
String appname = "customapp";
config.setIpAddress("127.0.0.1");
config.setHostname("localhost");
config.setAppname(appname);
config.setVirtualHostName(appname);
config.setSecureVirtualHostName(appname);
config.setNonSecurePort(4444);
config.setSecurePort(8443);
config.setInstanceId("127.0.0.1:customapp:4444");
info = new EurekaConfigBasedInstanceInfoProvider(config).get();
}
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:20,代码来源:RestTemplateEurekaHttpClientTest.java
示例2: get
import org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean; //导入依赖的package包/类
@Override
public ManagementMetadata get(EurekaInstanceConfigBean instance, int serverPort,
String serverContextPath, String managementContextPath,
Integer managementPort) {
if (isRandom(managementPort)) {
return null;
}
if (managementPort == null && isRandom(serverPort)) {
return null;
}
String healthCheckUrl = getHealthCheckUrl(instance, serverPort, serverContextPath,
managementContextPath, managementPort);
String statusPageUrl = getStatusPageUrl(instance, serverPort, serverContextPath,
managementContextPath, managementPort);
return new ManagementMetadata(healthCheckUrl, statusPageUrl, managementPort == null ? serverPort : managementPort);
}
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:18,代码来源:DefaultManagementMetadataProvider.java
示例3: basicConfigurationCreatedForLoadBalancer
import org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean; //导入依赖的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
示例4: testSetProp
import org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean; //导入依赖的package包/类
@Test
public void testSetProp() {
EurekaClientConfigBean client = new EurekaClientConfigBean();
EurekaInstanceConfigBean configBean = getEurekaInstanceConfigBean();
EurekaRibbonClientConfiguration preprocessor = new EurekaRibbonClientConfiguration(
client, "myService", configBean, false);
String serviceId = "myService";
String suffix = "mySuffix";
String value = "myValue";
DynamicStringProperty property = getProperty(getRibbonKey(serviceId, suffix));
assertEquals("property doesn't have default value", VALUE_NOT_SET,
property.get());
setRibbonProperty(serviceId, suffix, value);
assertEquals("property has wrong value", value, property.get());
setRibbonProperty(serviceId, suffix, value);
assertEquals("property has wrong value", value, property.get());
}
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:18,代码来源:EurekaRibbonClientConfigurationTests.java
示例5: eurekaClientNotShutdownInDeregister
import org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean; //导入依赖的package包/类
@Test
public void eurekaClientNotShutdownInDeregister() {
EurekaServiceRegistry registry = new EurekaServiceRegistry();
CloudEurekaClient eurekaClient = mock(CloudEurekaClient.class);
ApplicationInfoManager applicationInfoManager = mock(ApplicationInfoManager.class);
when(applicationInfoManager.getInfo()).thenReturn(mock(InstanceInfo.class));
EurekaRegistration registration = EurekaRegistration.builder(new EurekaInstanceConfigBean(new InetUtils(new InetUtilsProperties())))
.with(eurekaClient)
.with(applicationInfoManager)
.with(new EurekaClientConfigBean(), mock(ApplicationEventPublisher.class))
.build();
registry.deregister(registration);
verifyZeroInteractions(eurekaClient);
}
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:20,代码来源:EurekaServiceRegistryTests.java
示例6: register
import org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean; //导入依赖的package包/类
@RequestMapping(path = "/register", method = POST)
public String register() {
EurekaInstanceConfigBean config = new EurekaInstanceConfigBean(inetUtils);
String appname = "customapp";
config.setIpAddress("127.0.0.1");
config.setHostname("localhost");
config.setAppname(appname);
config.setVirtualHostName(appname);
config.setSecureVirtualHostName(appname);
config.setNonSecurePort(4444);
config.setInstanceId("127.0.0.1:customapp:4444");
this.registration = EurekaRegistration.builder(config)
.with(this.clientConfig, this.context)
.build();
this.serviceRegistry.register(this.registration);
return config.getInstanceId();
}
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:20,代码来源:EurekaSampleApplication.java
示例7: eurekaInstanceConfig
import org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean; //导入依赖的package包/类
@Bean
/**
* Dynamically assign the hosts IP address to this instances of the Eureka Client
*
* @param inetUtils Java Networks Utilities
* @return An instance of a EurekaInstanceConfigBean with dynamically configured IP address
*/
public EurekaInstanceConfigBean eurekaInstanceConfig(InetUtils inetUtils){
EurekaInstanceConfigBean config = new EurekaInstanceConfigBean(inetUtils);
String ip = null;
String urlPattern = "http://{0}:{1}{2}";
try {
// Get the IP address of the current host using Java Network Utils
ip = InetAddress.getLocalHost().getHostAddress();
} catch (UnknownHostException e) {
e.printStackTrace();
}
config.setIpAddress(ip);
config.setPreferIpAddress(true);
// Build the Status Page URL specific to this instances IP Address
String statusPageUrl = MessageFormat.format(urlPattern,
config.getIpAddress(),
port,
config.getStatusPageUrlPath());
config.setStatusPageUrl(statusPageUrl);
// Build the Health Page URL specific to this instances IP Address
String healthPageUrl = MessageFormat.format(urlPattern,
config.getIpAddress(),
port,
config.getHealthCheckUrlPath());
config.setHealthCheckUrl(healthPageUrl);
return config;
}
开发者ID:wb3-spring,项目名称:Trace-Server,代码行数:40,代码来源:WB3TraceServer.java
示例8: LoggingConfiguration
import org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean; //导入依赖的package包/类
public LoggingConfiguration(@Value("${spring.application.name}") String appName, @Value("${server.port}") String serverPort,
EurekaInstanceConfigBean eurekaInstanceConfigBean, JHipsterProperties jHipsterProperties, @Value("${info.project.version}") String version) {
this.appName = appName;
this.serverPort = serverPort;
this.eurekaInstanceConfigBean = eurekaInstanceConfigBean;
this.jHipsterProperties = jHipsterProperties;
this.version = version;
if (jHipsterProperties.getLogging().getLogstash().isEnabled()) {
addLogstashAppender(context);
addContextListener(context);
}
if (jHipsterProperties.getMetrics().getLogs().isEnabled()) {
setMetricsMarkerLogbackFilter(context);
}
}
开发者ID:kalnee,项目名称:trivor,代码行数:16,代码来源:LoggingConfiguration.java
示例9: getInstanceInfo
import org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean; //导入依赖的package包/类
public InstanceInfo getInstanceInfo(Application application) {
EurekaInstanceConfigBean instanceConfig = new EurekaInstanceConfigBean(inetUtils);
instanceConfig.setInstanceEnabledOnit(true);
instanceConfig.setAppname(application.getName());
instanceConfig.setVirtualHostName(application.getName());
instanceConfig.setInstanceId(application.getInstance_id());
instanceConfig.setHostname(application.getHostname());
instanceConfig.setNonSecurePort(application.getPort());
return new InstanceInfoFactory().create(instanceConfig);
}
开发者ID:spencergibb,项目名称:spring-cloud-netflix-eureka-lite,代码行数:12,代码来源:Eureka.java
示例10: getHealthCheckUrl
import org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean; //导入依赖的package包/类
private String getHealthCheckUrl(EurekaInstanceConfigBean instance, int serverPort, String serverContextPath,
String managementContextPath, Integer managementPort) {
String healthCheckUrlPath = instance.getHealthCheckUrlPath();
String healthCheckUrl = getUrl(instance, serverPort, serverContextPath, managementContextPath,
managementPort, healthCheckUrlPath);
log.debug("Constructed eureka meta-data healthcheckUrl: " + healthCheckUrl);
return healthCheckUrl;
}
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:9,代码来源:DefaultManagementMetadataProvider.java
示例11: getStatusPageUrl
import org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean; //导入依赖的package包/类
public String getStatusPageUrl(EurekaInstanceConfigBean instance, int serverPort, String serverContextPath,
String managementContextPath, Integer managementPort) {
String statusPageUrlPath = instance.getStatusPageUrlPath();
String statusPageUrl = getUrl(instance, serverPort, serverContextPath, managementContextPath,
managementPort, statusPageUrlPath);
log.debug("Constructed eureka meta-data statusPageUrl: " + statusPageUrl);
return statusPageUrl;
}
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:9,代码来源:DefaultManagementMetadataProvider.java
示例12: getUrl
import org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean; //导入依赖的package包/类
private String getUrl(EurekaInstanceConfigBean instance, int serverPort,
String serverContextPath, String managementContextPath,
Integer managementPort, String urlPath) {
managementContextPath = refineManagementContextPath(serverContextPath, managementContextPath, managementPort);
if (managementPort == null) {
managementPort = serverPort;
}
String scheme = instance.getSecurePortEnabled() ? "https" : "http";
return constructValidUrl(scheme, instance.getHostname(), managementPort, managementContextPath, urlPath);
}
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:11,代码来源:DefaultManagementMetadataProvider.java
示例13: testExplicitZone
import org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean; //导入依赖的package包/类
@Test
public void testExplicitZone() {
EurekaClientConfigBean client = new EurekaClientConfigBean();
EurekaInstanceConfigBean configBean = getEurekaInstanceConfigBean();
configBean.getMetadataMap().put("zone", "myZone");
EurekaRibbonClientConfiguration preprocessor = new EurekaRibbonClientConfiguration(
client, "myService", configBean, false);
preprocessor.preprocess();
assertEquals("myZone",
ConfigurationManager.getDeploymentContext().getValue(ContextKey.zone));
}
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:12,代码来源:EurekaRibbonClientConfigurationTests.java
示例14: testDefaultZone
import org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean; //导入依赖的package包/类
@Test
public void testDefaultZone() {
EurekaClientConfigBean client = new EurekaClientConfigBean();
EurekaInstanceConfigBean configBean = getEurekaInstanceConfigBean();
EurekaRibbonClientConfiguration preprocessor = new EurekaRibbonClientConfiguration(
client, "myService", configBean, false);
preprocessor.preprocess();
assertEquals("defaultZone",
ConfigurationManager.getDeploymentContext().getValue(ContextKey.zone));
}
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:11,代码来源:EurekaRibbonClientConfigurationTests.java
示例15: testApproximateZone
import org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean; //导入依赖的package包/类
@Test
public void testApproximateZone() {
EurekaClientConfigBean client = new EurekaClientConfigBean();
EurekaInstanceConfigBean configBean = getEurekaInstanceConfigBean();
configBean.setHostname("this.is.a.test.com");
EurekaRibbonClientConfiguration preprocessor = new EurekaRibbonClientConfiguration(
client, "myService", configBean, true);
preprocessor.preprocess();
assertEquals("is.a.test.com",
ConfigurationManager.getDeploymentContext().getValue(ContextKey.zone));
}
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:12,代码来源:EurekaRibbonClientConfigurationTests.java
示例16: eurekaClientGetStatus
import org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean; //导入依赖的package包/类
@Test
public void eurekaClientGetStatus() {
EurekaServiceRegistry registry = new EurekaServiceRegistry();
EurekaInstanceConfigBean config = new EurekaInstanceConfigBean(new InetUtils(new InetUtilsProperties()));
config.setAppname("myapp");
config.setInstanceId("1234");
CloudEurekaClient eurekaClient = mock(CloudEurekaClient.class);
InstanceInfo instanceInfo = InstanceInfo.Builder.newBuilder()
.setAppName("myapp")
.setInstanceId("1234")
.setStatus(DOWN)
.setOverriddenStatus(UNKNOWN)
.build();
when(eurekaClient.getInstanceInfo("myapp", "1234"))
.thenReturn(instanceInfo);
EurekaRegistration registration = EurekaRegistration.builder(config)
.with(eurekaClient)
.with(mock(ApplicationInfoManager.class))
.with(new EurekaClientConfigBean(), mock(ApplicationEventPublisher.class))
.build();
Object status = registry.getStatus(registration);
assertThat(status).isInstanceOf(Map.class);
Map<Object, Object> map = (Map<Object, Object>) status;
assertThat(map).hasSize(2)
.containsEntry("status", DOWN.toString())
.containsEntry("overriddenStatus", UNKNOWN.toString());
}
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:36,代码来源:EurekaServiceRegistryTests.java
示例17: eurekaClientGetStatusNoInstance
import org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean; //导入依赖的package包/类
@Test
public void eurekaClientGetStatusNoInstance() {
EurekaServiceRegistry registry = new EurekaServiceRegistry();
EurekaInstanceConfigBean config = new EurekaInstanceConfigBean(new InetUtils(new InetUtilsProperties()));
config.setAppname("myapp");
config.setInstanceId("1234");
CloudEurekaClient eurekaClient = mock(CloudEurekaClient.class);
when(eurekaClient.getInstanceInfo("myapp", "1234"))
.thenReturn(null);
EurekaRegistration registration = EurekaRegistration.builder(config)
.with(eurekaClient)
.with(mock(ApplicationInfoManager.class))
.with(new EurekaClientConfigBean(), mock(ApplicationEventPublisher.class))
.build();
Object status = registry.getStatus(registration);
assertThat(status).isInstanceOf(Map.class);
Map<Object, Object> map = (Map<Object, Object>) status;
assertThat(map).hasSize(1)
.containsEntry("status", UNKNOWN.toString());
}
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:29,代码来源:EurekaServiceRegistryTests.java
示例18: offByDefault
import org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean; //导入依赖的package包/类
@Test
public void offByDefault() {
new ApplicationContextRunner().withConfiguration(
AutoConfigurations.of(EurekaClientConfigServerAutoConfiguration.class))
.run(c -> {
assertEquals(0,
c.getBeanNamesForType(EurekaInstanceConfigBean.class).length);
});
}
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:10,代码来源:EurekaClientConfigServerAutoConfigurationTests.java
示例19: onWhenRequested
import org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean; //导入依赖的package包/类
@Test
public void onWhenRequested() {
new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(
EurekaClientConfigServerAutoConfiguration.class,
ConfigServerProperties.class, EurekaInstanceConfigBean.class))
.withPropertyValues("spring.cloud.config.server.prefix=/config")
.run(c -> {
assertEquals(1,
c.getBeanNamesForType(EurekaInstanceConfig.class).length);
EurekaInstanceConfig instance = c.getBean(EurekaInstanceConfig.class);
assertEquals("/config", instance.getMetadataMap().get("configPath"));
});
}
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:15,代码来源:EurekaClientConfigServerAutoConfigurationTests.java
示例20: eurekaInstanceConfigBean
import org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean; //导入依赖的package包/类
@Bean
public EurekaInstanceConfigBean eurekaInstanceConfigBean() {
EurekaInstanceConfigBean config = new EurekaInstanceConfigBean(inetUtils);
String springAppName = this.env.getProperty("spring.application.name", "");
int port = this.sidecarProperties.getPort();
config.setNonSecurePort(port);
config.setInstanceId(getDefaultInstanceId(this.env));
if (StringUtils.hasText(springAppName)) {
config.setAppname(springAppName);
config.setVirtualHostName(springAppName);
config.setSecureVirtualHostName(springAppName);
}
String hostname = this.sidecarProperties.getHostname();
String ipAddress = this.sidecarProperties.getIpAddress();
if (!StringUtils.hasText(hostname) && StringUtils.hasText(this.hostname)) {
hostname = this.hostname;
}
if (StringUtils.hasText(hostname)) {
config.setHostname(hostname);
}
if (StringUtils.hasText(ipAddress)) {
config.setIpAddress(ipAddress);
}
String scheme = config.getSecurePortEnabled() ? "https" : "http";
config.setStatusPageUrl(scheme + "://" + config.getHostname() + ":"
+ this.managementPort + config.getStatusPageUrlPath());
config.setHealthCheckUrl(scheme + "://" + config.getHostname() + ":"
+ this.managementPort + config.getHealthCheckUrlPath());
config.setHomePageUrl(scheme + "://" + config.getHostname() + ":" + port
+ config.getHomePageUrlPath());
return config;
}
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:33,代码来源:SidecarConfiguration.java
注:本文中的org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论