use of com.netflix.appinfo.Ec2EurekaArchaius2InstanceConfig in project eureka by Netflix.
the class Ec2EurekaClientModuleTest method testDI.
@SuppressWarnings("deprecation")
@Test
public void testDI() {
InstanceInfo instanceInfo = injector.getInstance(InstanceInfo.class);
Assert.assertEquals(ApplicationInfoManager.getInstance().getInfo(), instanceInfo);
VipAddressResolver vipAddressResolver = injector.getInstance(VipAddressResolver.class);
Assert.assertTrue(vipAddressResolver instanceof Archaius2VipAddressResolver);
EurekaClient eurekaClient = injector.getInstance(EurekaClient.class);
DiscoveryClient discoveryClient = injector.getInstance(DiscoveryClient.class);
Assert.assertEquals(DiscoveryManager.getInstance().getEurekaClient(), eurekaClient);
Assert.assertEquals(DiscoveryManager.getInstance().getDiscoveryClient(), discoveryClient);
Assert.assertEquals(eurekaClient, discoveryClient);
EurekaClientConfig eurekaClientConfig = injector.getInstance(EurekaClientConfig.class);
Assert.assertEquals(DiscoveryManager.getInstance().getEurekaClientConfig(), eurekaClientConfig);
EurekaInstanceConfig eurekaInstanceConfig = injector.getInstance(EurekaInstanceConfig.class);
Assert.assertEquals(DiscoveryManager.getInstance().getEurekaInstanceConfig(), eurekaInstanceConfig);
Assert.assertTrue(eurekaInstanceConfig instanceof Ec2EurekaArchaius2InstanceConfig);
ApplicationInfoManager applicationInfoManager = injector.getInstance(ApplicationInfoManager.class);
InstanceInfo myInfo = applicationInfoManager.getInfo();
Assert.assertTrue(myInfo.getDataCenterInfo() instanceof AmazonInfo);
Assert.assertEquals(DataCenterInfo.Name.Amazon, myInfo.getDataCenterInfo().getName());
}
use of com.netflix.appinfo.Ec2EurekaArchaius2InstanceConfig in project eureka by Netflix.
the class CompositeInstanceConfigFactory method get.
@Override
public synchronized EurekaInstanceConfig get() {
if (eurekaInstanceConfig == null) {
// create the amazonInfoConfig before we can determine if we are in EC2, as we want to use the amazonInfoConfig for
// that determination. This is just the config however so is cheap to do and does not have side effects.
AmazonInfoConfig amazonInfoConfig = new Archaius2AmazonInfoConfig(configInstance, namespace);
if (isInEc2(amazonInfoConfig)) {
eurekaInstanceConfig = new Ec2EurekaArchaius2InstanceConfig(configInstance, amazonInfoConfig, namespace);
logger.info("Creating EC2 specific instance config");
} else {
eurekaInstanceConfig = new EurekaArchaius2InstanceConfig(configInstance, namespace);
logger.info("Creating generic instance config");
}
// TODO: Remove this when DiscoveryManager is finally no longer used
DiscoveryManager.getInstance().setEurekaInstanceConfig(eurekaInstanceConfig);
}
return eurekaInstanceConfig;
}
use of com.netflix.appinfo.Ec2EurekaArchaius2InstanceConfig in project eureka by Netflix.
the class CustomAmazonInfoProviderInstanceConfigFactory method get.
@Override
public EurekaInstanceConfig get() {
if (eurekaInstanceConfig == null) {
eurekaInstanceConfig = new Ec2EurekaArchaius2InstanceConfig(configInstance, amazonInfoProvider, getInstanceConfigNamespace());
// Copied from CompositeInstanceConfigFactory.get
DiscoveryManager.getInstance().setEurekaInstanceConfig(eurekaInstanceConfig);
}
return eurekaInstanceConfig;
}
Aggregations