com.netflix.discovery.shared.transport.EurekaHttpClient Java Examples
The following examples show how to use
com.netflix.discovery.shared.transport.EurekaHttpClient.
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: CloudEurekaClient.java From spring-cloud-netflix with Apache License 2.0 | 6 votes |
EurekaHttpClient getEurekaHttpClient() { if (this.eurekaHttpClient.get() == null) { try { Object eurekaTransport = this.eurekaTransportField.get(this); Field registrationClientField = ReflectionUtils .findField(eurekaTransport.getClass(), "registrationClient"); ReflectionUtils.makeAccessible(registrationClientField); this.eurekaHttpClient.compareAndSet(null, (EurekaHttpClient) registrationClientField.get(eurekaTransport)); } catch (IllegalAccessException e) { log.error("error getting EurekaHttpClient", e); } } return this.eurekaHttpClient.get(); }
Example #2
Source File: EurekaConfigServerBootstrapConfigurationTests.java From spring-cloud-netflix with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") @Bean public EurekaHttpClient mockEurekaHttpClient() { InstanceInfo instanceInfo = InstanceInfo.Builder.newBuilder() .setAppName("configserver").build(); List<InstanceInfo> instanceInfos = Collections.singletonList(instanceInfo); Applications applications = mock(Applications.class); when(applications.getInstancesByVirtualHostName("configserver")) .thenReturn(instanceInfos); EurekaHttpResponse<Applications> response = mock(EurekaHttpResponse.class); when(response.getStatusCode()).thenReturn(200); when(response.getEntity()).thenReturn(applications); EurekaHttpClient client = mock(EurekaHttpClient.class); when(client.getApplications("us-east-1")).thenReturn(response); return client; }
Example #3
Source File: EurekaServerHolder.java From nacos-sync with Apache License 2.0 | 5 votes |
@Override EurekaNamingService createServer(String clusterId, Supplier<String> serverAddressSupplier, String namespace) throws Exception { RestTemplateTransportClientFactory restTemplateTransportClientFactory = new RestTemplateTransportClientFactory(); EurekaEndpoint eurekaEndpoint = new DefaultEndpoint(serverAddressSupplier.get()); EurekaHttpClient eurekaHttpClient = restTemplateTransportClientFactory.newClient(eurekaEndpoint); return new EurekaNamingService(eurekaHttpClient); }
Example #4
Source File: EurekaBeatReactor.java From nacos-sync with Apache License 2.0 | 5 votes |
public EurekaBeatReactor(EurekaHttpClient eurekaHttpClient) { this.eurekaHttpClient = eurekaHttpClient; executorService = new ScheduledThreadPoolExecutor(30, r -> { Thread thread = new Thread(r); thread.setDaemon(true); thread.setName("com.alibaba.nacossync.eureka.beat.sender"); return thread; }); executorService.schedule(new BeatProcessor(), 0, TimeUnit.SECONDS); }
Example #5
Source File: ArmeriaEurekaClientTest.java From armeria with Apache License 2.0 | 5 votes |
@Override protected EurekaHttpClient getEurekaClientWithBasicAuthentication(String userName, String password) { final WebClient webClient = WebClient.builder(toH1C(getHttpServer().getServiceURI())) .auth(BasicToken.of(userName, password)) .build(); return new EurekaHttpClientWrapper(webClient); }
Example #6
Source File: WebClientTransportClientFactory.java From spring-cloud-netflix with Apache License 2.0 | 5 votes |
@Override public EurekaHttpClient newClient(EurekaEndpoint serviceUrl) { WebClient.Builder builder = of(serviceUrl.getServiceUrl()); this.setExchangeStrategies(builder); this.skipHttp400Error(builder); return new WebClientEurekaHttpClient(builder.build()); }
Example #7
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 #8
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 #9
Source File: EurekaConfigServerBootstrapConfiguration.java From spring-cloud-netflix with Apache License 2.0 | 5 votes |
@Bean public ConfigServerInstanceProvider.Function eurekaConfigServerInstanceProvider( EurekaHttpClient client, EurekaClientConfig config) { return serviceId -> { if (log.isDebugEnabled()) { log.debug("eurekaConfigServerInstanceProvider finding instances for " + serviceId); } EurekaHttpResponse<Applications> response = client .getApplications(config.getRegion()); List<ServiceInstance> instances = new ArrayList<>(); if (!isSuccessful(response) || response.getEntity() == null) { return instances; } Applications applications = response.getEntity(); applications.shuffleInstances(config.shouldFilterOnlyUpInstances()); List<InstanceInfo> infos = applications .getInstancesByVirtualHostName(serviceId); for (InstanceInfo info : infos) { instances.add(new EurekaServiceInstance(info)); } if (log.isDebugEnabled()) { log.debug("eurekaConfigServerInstanceProvider found " + infos.size() + " instance(s) for " + serviceId + ", " + instances); } return instances; }; }
Example #10
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 #11
Source File: EurekaNamingService.java From nacos-sync with Apache License 2.0 | 4 votes |
public EurekaNamingService(EurekaHttpClient eurekaHttpClient) { this.eurekaHttpClient = eurekaHttpClient; beatReactor = new EurekaBeatReactor(eurekaHttpClient); }
Example #12
Source File: ArmeriaEurekaClientTest.java From armeria with Apache License 2.0 | 4 votes |
@Override protected EurekaHttpClient getEurekaHttpClient(URI serviceURI) { return new EurekaHttpClientWrapper(WebClient.of(toH1C(serviceURI))); }
Example #13
Source File: RestTemplateTransportClientFactory.java From spring-cloud-netflix with Apache License 2.0 | 4 votes |
@Override public EurekaHttpClient newClient(EurekaEndpoint serviceUrl) { return new RestTemplateEurekaHttpClient(restTemplate(serviceUrl.getServiceUrl()), serviceUrl.getServiceUrl()); }