org.springframework.cloud.netflix.eureka.EurekaClientConfigBean Java Examples
The following examples show how to use
org.springframework.cloud.netflix.eureka.EurekaClientConfigBean.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EurekaServiceRegistryTests.java From spring-cloud-netflix with Apache License 2.0 | 6 votes |
@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); verifyNoInteractions(eurekaClient); }
Example #2
Source File: StubRunnerSpringCloudEurekaAutoConfiguration.java From spring-cloud-contract with Apache License 2.0 | 5 votes |
@Bean(initMethod = "registerStubs") public StubsRegistrar stubsRegistrar(StubRunning stubRunning, ServiceRegistry<EurekaRegistration> serviceRegistry, ApplicationContext context, StubMapperProperties stubMapperProperties, InetUtils inetUtils, EurekaInstanceConfigBean eurekaInstanceConfigBean, EurekaClientConfigBean eurekaClientConfigBean) { return new EurekaStubsRegistrar(stubRunning, serviceRegistry, stubMapperProperties, inetUtils, eurekaInstanceConfigBean, eurekaClientConfigBean, context); }
Example #3
Source File: EurekaStubsRegistrar.java From spring-cloud-contract with Apache License 2.0 | 5 votes |
public EurekaStubsRegistrar(StubRunning stubRunning, ServiceRegistry<EurekaRegistration> serviceRegistry, StubMapperProperties stubMapperProperties, InetUtils inetUtils, EurekaInstanceConfigBean eurekaInstanceConfigBean, EurekaClientConfigBean eurekaClientConfigBean, ApplicationContext context) { this.stubRunning = stubRunning; this.stubMapperProperties = stubMapperProperties; this.serviceRegistry = serviceRegistry; this.inetUtils = inetUtils; this.eurekaInstanceConfigBean = eurekaInstanceConfigBean; this.eurekaClientConfigBean = eurekaClientConfigBean; this.context = context; }
Example #4
Source File: EurekaConfigServerBootstrapConfiguration.java From spring-cloud-netflix with Apache License 2.0 | 5 votes |
@Bean @ConditionalOnMissingBean(EurekaHttpClient.class) @ConditionalOnClass( name = "org.springframework.web.reactive.function.client.WebClient") @ConditionalOnProperty(prefix = "eureka.client", name = "webclient.enabled", havingValue = "true") public WebClientEurekaHttpClient configDiscoveryWebClientEurekaHttpClient( EurekaClientConfigBean config) { return (WebClientEurekaHttpClient) new WebClientTransportClientFactory() .newClient(new DefaultEndpoint(getEurekaUrl(config))); }
Example #5
Source File: EurekaConfigServerBootstrapConfiguration.java From spring-cloud-netflix with Apache License 2.0 | 5 votes |
@Bean @ConditionalOnMissingBean(EurekaHttpClient.class) @ConditionalOnProperty(prefix = "eureka.client", name = "webclient.enabled", matchIfMissing = true, havingValue = "false") public RestTemplateEurekaHttpClient configDiscoveryRestTemplateEurekaHttpClient( EurekaClientConfigBean config) { return (RestTemplateEurekaHttpClient) new RestTemplateTransportClientFactory() .newClient(new DefaultEndpoint(getEurekaUrl(config))); }
Example #6
Source File: EurekaServiceRegistryTests.java From spring-cloud-netflix with Apache License 2.0 | 5 votes |
@Test public void eurekaClientGetStatus() { EurekaServiceRegistry registry = new EurekaServiceRegistry(); EurekaInstanceConfigBean config = new EurekaInstanceConfigBean( new InetUtils(new InetUtilsProperties())); config.setAppname("myapp"); config.setInstanceId("1234"); InstanceInfo local = InstanceInfo.Builder.newBuilder().setAppName("myapp") .setInstanceId("1234").setStatus(DOWN).build(); InstanceInfo remote = InstanceInfo.Builder.newBuilder().setAppName("myapp") .setInstanceId("1234").setStatus(DOWN).setOverriddenStatus(OUT_OF_SERVICE) .build(); CloudEurekaClient eurekaClient = mock(CloudEurekaClient.class); when(eurekaClient.getInstanceInfo(local.getAppName(), local.getId())) .thenReturn(remote); ApplicationInfoManager applicationInfoManager = mock( ApplicationInfoManager.class); when(applicationInfoManager.getInfo()).thenReturn(local); EurekaRegistration registration = EurekaRegistration.builder(config) .with(eurekaClient).with(applicationInfoManager) .with(new EurekaClientConfigBean(), mock(ApplicationEventPublisher.class)) .build(); Object status = registry.getStatus(registration); assertThat(registration.getInstanceId()).isEqualTo("1234"); assertThat(status).isInstanceOf(Map.class); Map<Object, Object> map = (Map<Object, Object>) status; assertThat(map).hasSize(2).containsEntry("status", DOWN.toString()) .containsEntry("overriddenStatus", OUT_OF_SERVICE.toString()); }
Example #7
Source File: EurekaServiceRegistryTests.java From spring-cloud-netflix with Apache License 2.0 | 5 votes |
@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); ApplicationInfoManager applicationInfoManager = mock( ApplicationInfoManager.class); when(applicationInfoManager.getInfo()).thenReturn(mock(InstanceInfo.class)); EurekaRegistration registration = EurekaRegistration.builder(config) .with(eurekaClient).with(applicationInfoManager) .with(new EurekaClientConfigBean(), mock(ApplicationEventPublisher.class)) .build(); Object status = registry.getStatus(registration); assertThat(registration.getInstanceId()).isEqualTo("1234"); assertThat(status).isInstanceOf(Map.class); Map<Object, Object> map = (Map<Object, Object>) status; assertThat(map).hasSize(1).containsEntry("status", UNKNOWN.toString()); }
Example #8
Source File: EurekaReactiveDiscoveryClientTests.java From spring-cloud-netflix with Apache License 2.0 | 5 votes |
@Test public void verifyDefaultsWhenUsingEurekaClientConfigBean() { EurekaClientConfigBean configBean = new EurekaClientConfigBean(); configBean.setOrder(1); EurekaReactiveDiscoveryClient client = new EurekaReactiveDiscoveryClient( eurekaClient, configBean); assertThat(client.description()) .isEqualTo("Spring Cloud Eureka Reactive Discovery Client"); assertThat(client.getOrder()).isEqualTo(1); }
Example #9
Source File: EurekaConfigServerBootstrapConfigurationWebClientTests.java From spring-cloud-netflix with Apache License 2.0 | 5 votes |
@Test public void properBeansCreatedWhenEnabled() { new ApplicationContextRunner() .withConfiguration(AutoConfigurations .of(EurekaConfigServerBootstrapConfiguration.class)) .withPropertyValues("spring.cloud.config.discovery.enabled=true", "eureka.client.webclient.enabled=true") .run(context -> { assertThat(context).hasSingleBean(EurekaClientConfigBean.class); assertThat(context).hasSingleBean(WebClientEurekaHttpClient.class); assertThat(context) .hasSingleBean(ConfigServerInstanceProvider.Function.class); }); }
Example #10
Source File: EurekaConfigServerBootstrapConfigurationWebClientTests.java From spring-cloud-netflix with Apache License 2.0 | 5 votes |
@Test public void properBeansCreatedWhenEnabledWebClientDisabled() { new ApplicationContextRunner() .withConfiguration(AutoConfigurations .of(EurekaConfigServerBootstrapConfiguration.class)) .withPropertyValues("spring.cloud.config.discovery.enabled=true") .run(context -> { assertThat(context).hasSingleBean(EurekaClientConfigBean.class); assertThat(context).doesNotHaveBean(WebClientEurekaHttpClient.class); assertThat(context).hasSingleBean(RestTemplateEurekaHttpClient.class); assertThat(context) .hasSingleBean(ConfigServerInstanceProvider.Function.class); }); }
Example #11
Source File: EurekaConfigServerBootstrapConfigurationTests.java From spring-cloud-netflix with Apache License 2.0 | 5 votes |
@Test public void offByDefault() { new ApplicationContextRunner() .withConfiguration(AutoConfigurations .of(EurekaConfigServerBootstrapConfiguration.class)) .run(context -> { assertThat(context).doesNotHaveBean(EurekaClientConfigBean.class); assertThat(context).doesNotHaveBean(EurekaHttpClient.class); assertThat(context) .doesNotHaveBean(ConfigServerInstanceProvider.Function.class); }); }
Example #12
Source File: EurekaConfigServerBootstrapConfigurationTests.java From spring-cloud-netflix with Apache License 2.0 | 5 votes |
@Test public void properBeansCreatedWhenEnabled() { new ApplicationContextRunner() .withConfiguration(AutoConfigurations .of(EurekaConfigServerBootstrapConfiguration.class)) .withPropertyValues("spring.cloud.config.discovery.enabled=true") .run(context -> { assertThat(context).hasSingleBean(EurekaClientConfigBean.class); assertThat(context).hasSingleBean(RestTemplateEurekaHttpClient.class); assertThat(context) .hasSingleBean(ConfigServerInstanceProvider.Function.class); }); }
Example #13
Source File: MossServerDiscoveryAutoConfiguration.java From Moss with Apache License 2.0 | 4 votes |
@Bean(destroyMethod = "shutdown") public MultRegisterCenter initMultEureka(MultRegisterCenterService multRegisterCenterService, MultRegisterCenterServerMgmtConfig mgmtConfig) { Map<String, String> URL_MAP; MultRegisterCenter multRegisterCenter; log.info("start init MultRegisterCenter"); URL_MAP = multRegisterCenterService.getRegisterCenterList(); if (URL_MAP.isEmpty()) { multRegisterCenter = new MultRegisterCenter(new ConcurrentHashMap<String, EurekaClient>(), new ConcurrentHashMap<String, MossEurekaAutoServiceRegistration>(), new ConcurrentHashMap<EurekaClient, HeartbeatMonitor>()); return multRegisterCenter; } Map<String, EurekaClient> multEurekaMap = Maps.newConcurrentMap(); Map<String, MossEurekaAutoServiceRegistration> multRegistrationMap = Maps.newConcurrentMap(); Map<EurekaClient, HeartbeatMonitor> multHeartbeatMonitorMap = new ConcurrentHashMap<EurekaClient, HeartbeatMonitor>(); URL_MAP.entrySet().forEach(e -> { log.info("start init eureka server:{}", e.getKey() + "-" + e.getValue()); ManagementMetadataProvider managementMetadataProvider = mgmtConfig.serviceManagementMetadataProvider(); EurekaClientConfigBean configBean = mgmtConfig.eurekaClientConfigBean(env); configBean.getServiceUrl().clear(); configBean.getServiceUrl().put(EurekaClientConfigBean.DEFAULT_ZONE, e.getValue()); EurekaInstanceConfigBean instanceConfigBean = mgmtConfig.eurekaInstanceConfigBean(inetUtils, env, managementMetadataProvider); instanceConfigBean.setEnvironment(env); ApplicationInfoManager manager = mgmtConfig.eurekaApplicationInfoManager(instanceConfigBean); EurekaClient eurekaClient = mgmtConfig.eurekaClient(manager, configBean); EurekaRegistration registration = mgmtConfig.eurekaRegistration(eurekaClient, instanceConfigBean, manager, healthCheckHandler); MossEurekaAutoServiceRegistration autoServiceRegistration = mgmtConfig.eurekaAutoServiceRegistration(context, mgmtConfig.eurekaServiceRegistry(), registration, registration); multEurekaMap.put(e.getKey(), eurekaClient); multRegistrationMap.put(e.getKey(), autoServiceRegistration); multHeartbeatMonitorMap.put(eurekaClient, new HeartbeatMonitor()); log.info("init eureka server:{} end!", e.getKey() + "-" + e.getValue()); }); multRegisterCenter = new MultRegisterCenter(multEurekaMap, multRegistrationMap, multHeartbeatMonitorMap); log.info("init MultRegisterCenter End!"); return multRegisterCenter; }
Example #14
Source File: EurekaConfigServerBootstrapConfiguration.java From spring-cloud-netflix with Apache License 2.0 | 4 votes |
@Bean @ConditionalOnMissingBean(value = EurekaClientConfig.class, search = SearchStrategy.CURRENT) public EurekaClientConfigBean eurekaClientConfigBean() { return new EurekaClientConfigBean(); }
Example #15
Source File: EurekaConfigServerBootstrapConfiguration.java From spring-cloud-netflix with Apache License 2.0 | 4 votes |
private String getEurekaUrl(EurekaClientConfigBean config) { List<String> urls = EndpointUtils.getServiceUrlsFromConfig(config, EurekaClientConfigBean.DEFAULT_ZONE, true); return urls.get(0); }