com.netflix.appinfo.MyDataCenterInstanceConfig Java Examples
The following examples show how to use
com.netflix.appinfo.MyDataCenterInstanceConfig.
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: EurekaHandlerTest.java From riposte with Apache License 2.0 | 6 votes |
@DataProvider(value = { "null", "MyOwn", "not-a-real-datacenter-type" }) @Test public void createEurekaInstanceConfig_returns_MyDataCenterInstanceConfig_when_datacenterType_is_null_or_MyOwn_or_invalid( String datacenterType ) { // given doReturn(datacenterType).when(datacenterTypePropertySupplierMock).get(); // when EurekaInstanceConfig instanceConfig = handlerSpy.createEurekaInstanceConfig(); // then assertThat(instanceConfig).isInstanceOf(MyDataCenterInstanceConfig.class); assertThat(Whitebox.getInternalState(instanceConfig, "namespace")).isEqualTo(handlerSpy.eurekaClientNamespace); }
Example #2
Source File: EurekaRegistry.java From oneplatform with Apache License 2.0 | 5 votes |
private void initEurekaClient(Properties properties) throws Exception{ properties.setProperty("eureka.metadataMap.nodeId", NodeNameHolder.getNodeId()); ConfigurationManager.loadProperties(properties); //ConfigurationManager.loadPropertiesFromResources("eureka.properties"); //DynamicPropertyFactory configInstance = com.netflix.config.DynamicPropertyFactory.getInstance(); MyDataCenterInstanceConfig instanceConfig = new MyDataCenterInstanceConfig(){ @Override public String getHostName(boolean refresh) { String hostName = super.getHostName(refresh); if(ResourceUtils.getBoolean("eureka.preferIpAddress")){ hostName = IpUtils.getLocalIpAddr(); } return hostName; } @Override public String getIpAddress() { return IpUtils.getLocalIpAddr(); } }; InstanceInfo instanceInfo = new EurekaConfigBasedInstanceInfoProvider(instanceConfig).get(); applicationInfoManager = new ApplicationInfoManager(instanceConfig, instanceInfo); DefaultEurekaClientConfig clientConfig = new DefaultEurekaClientConfig(); eurekaClient = new DiscoveryClient(applicationInfoManager, clientConfig); instanceId = instanceInfo.getInstanceId(); }