Search in sources :

Example 6 with EurekaInstanceConfigBean

use of org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean in project spring-cloud-netflix by spring-cloud.

the class EurekaRibbonClientConfigurationTests method testDefaultZone.

@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));
}
Also used : EurekaInstanceConfigBean(org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean) EurekaClientConfigBean(org.springframework.cloud.netflix.eureka.EurekaClientConfigBean) Test(org.junit.Test)

Example 7 with EurekaInstanceConfigBean

use of org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean in project spring-cloud-netflix by spring-cloud.

the class EurekaRibbonClientConfigurationTests method testApproximateZone.

@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));
}
Also used : EurekaInstanceConfigBean(org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean) EurekaClientConfigBean(org.springframework.cloud.netflix.eureka.EurekaClientConfigBean) Test(org.junit.Test)

Example 8 with EurekaInstanceConfigBean

use of org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean in project spring-cloud-netflix by spring-cloud.

the class RestTemplateEurekaHttpClientTest method setup.

@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();
}
Also used : DefaultEndpoint(com.netflix.discovery.shared.resolver.DefaultEndpoint) EurekaInstanceConfigBean(org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean) EurekaConfigBasedInstanceInfoProvider(com.netflix.appinfo.providers.EurekaConfigBasedInstanceInfoProvider) Before(org.junit.Before)

Example 9 with EurekaInstanceConfigBean

use of org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean in project spring-cloud-netflix by spring-cloud.

the class EurekaSampleApplication method register.

@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();
}
Also used : EurekaInstanceConfigBean(org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 10 with EurekaInstanceConfigBean

use of org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean in project spring-cloud-netflix by spring-cloud.

the class EurekaRibbonClientConfigurationTests method testExplicitZone.

@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));
}
Also used : EurekaInstanceConfigBean(org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean) EurekaClientConfigBean(org.springframework.cloud.netflix.eureka.EurekaClientConfigBean) Test(org.junit.Test)

Aggregations

EurekaInstanceConfigBean (org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean)10 Test (org.junit.Test)8 EurekaClientConfigBean (org.springframework.cloud.netflix.eureka.EurekaClientConfigBean)8 ApplicationInfoManager (com.netflix.appinfo.ApplicationInfoManager)3 InetUtils (org.springframework.cloud.commons.util.InetUtils)3 InetUtilsProperties (org.springframework.cloud.commons.util.InetUtilsProperties)3 CloudEurekaClient (org.springframework.cloud.netflix.eureka.CloudEurekaClient)3 InstanceInfo (com.netflix.appinfo.InstanceInfo)2 Map (java.util.Map)2 EurekaConfigBasedInstanceInfoProvider (com.netflix.appinfo.providers.EurekaConfigBasedInstanceInfoProvider)1 DynamicStringProperty (com.netflix.config.DynamicStringProperty)1 DefaultEndpoint (com.netflix.discovery.shared.resolver.DefaultEndpoint)1 ILoadBalancer (com.netflix.loadbalancer.ILoadBalancer)1 ZoneAwareLoadBalancer (com.netflix.loadbalancer.ZoneAwareLoadBalancer)1 DiscoveryEnabledServer (com.netflix.niws.loadbalancer.DiscoveryEnabledServer)1 Before (org.junit.Before)1 Ignore (org.junit.Ignore)1 SpringClientFactory (org.springframework.cloud.netflix.ribbon.SpringClientFactory)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1