use of com.netflix.discovery.DefaultEurekaClientConfig in project eureka by Netflix.
the class AwsAsgUtilTest method setUp.
@Before
public void setUp() throws Exception {
ConfigurationManager.getConfigInstance().setProperty("eureka.awsAccessId", "fakeId");
ConfigurationManager.getConfigInstance().setProperty("eureka.awsSecretKey", "fakeKey");
AmazonInfo dataCenterInfo = mock(AmazonInfo.class);
EurekaServerConfig serverConfig = new DefaultEurekaServerConfig();
InstanceInfo.Builder builder = InstanceInfo.Builder.newBuilder();
builder.setIPAddr("10.10.101.00");
builder.setHostName("fakeHost");
builder.setAppName("fake-" + UUID.randomUUID());
builder.setLeaseInfo(LeaseInfo.Builder.newBuilder().build());
builder.setDataCenterInfo(dataCenterInfo);
instanceInfo = builder.build();
applicationInfoManager = new ApplicationInfoManager(new MyDataCenterInstanceConfig(), instanceInfo);
DefaultEurekaClientConfig clientConfig = new DefaultEurekaClientConfig();
// setup config in advance, used in initialize converter
client = mock(DiscoveryClient.class);
registry = mock(PeerAwareInstanceRegistry.class);
awsAsgUtil = spy(new AwsAsgUtil(serverConfig, clientConfig, registry));
}
use of com.netflix.discovery.DefaultEurekaClientConfig in project eureka by Netflix.
the class ExampleEurekaService method main.
public static void main(String[] args) {
DynamicPropertyFactory configInstance = com.netflix.config.DynamicPropertyFactory.getInstance();
ApplicationInfoManager applicationInfoManager = initializeApplicationInfoManager(new MyDataCenterInstanceConfig());
EurekaClient eurekaClient = initializeEurekaClient(applicationInfoManager, new DefaultEurekaClientConfig());
ExampleServiceBase exampleServiceBase = new ExampleServiceBase(applicationInfoManager, eurekaClient, configInstance);
try {
exampleServiceBase.start();
} finally {
// the stop calls shutdown on eurekaClient
exampleServiceBase.stop();
}
}
use of com.netflix.discovery.DefaultEurekaClientConfig in project riposte by Nike-Inc.
the class EurekaHandler method register.
public void register() {
if (isEurekaDisabled()) {
logger.info("Eureka is disabled, skipping instance's eureka registration.");
return;
}
if (!registered.compareAndSet(false, true)) {
logger.info("Eureka handler already registered, skipping registration.");
return;
}
EurekaInstanceConfig eurekaInstanceConfig = createEurekaInstanceConfig();
initDiscoveryManager(eurekaInstanceConfig, new DefaultEurekaClientConfig(eurekaClientNamespace));
setEurekaInstanceStatus(InstanceInfo.InstanceStatus.UP);
}
use of com.netflix.discovery.DefaultEurekaClientConfig in project chassis by Kixeye.
the class EurekaConfiguration method eurekaDiscoveryManager.
/***
* Initializes Eureka Client Library (aka DiscoveryManager)
*
* @return discovery manager bean
*/
@Bean(destroyMethod = "shutdownComponent")
public DiscoveryManager eurekaDiscoveryManager(MetadataCollector metadataCollector) {
final DiscoveryManager bean = DiscoveryManager.getInstance();
if (!disableEureka) {
// set eureka.port via http.port if not already set
int httpPort = ConfigurationManager.getConfigInstance().getInt("http.port", -1);
int httpsPort = ConfigurationManager.getConfigInstance().getInt("https.port", -1);
int eurekaPort = ConfigurationManager.getConfigInstance().getInt("eureka.port", -1);
int eurekaSecurePort = ConfigurationManager.getConfigInstance().getInt("eureka.securePort", -1);
boolean httpPortEnabled = ConfigurationManager.getConfigInstance().getBoolean("http.enabled", false);
boolean httpsPortEnabled = ConfigurationManager.getConfigInstance().getBoolean("https.enabled", false);
if (httpPort != -1 && eurekaPort == -1) {
ConfigurationManager.getConfigInstance().setProperty("eureka.port", httpPort);
ConfigurationManager.getConfigInstance().setProperty("eureka.port.enabled", httpPortEnabled);
}
if (httpsPort != -1 && eurekaSecurePort == -1) {
ConfigurationManager.getConfigInstance().setProperty("eureka.securePort", httpsPort);
ConfigurationManager.getConfigInstance().setProperty("eureka.securePort.enabled", httpsPortEnabled);
}
// set eureka.name and eureka.vipAddress with @SpringApp name if not already set
String appName = ConfigurationManager.getConfigInstance().getString("app.name", null);
String eurekaName = ConfigurationManager.getConfigInstance().getString("eureka.name", null);
String eurekaVip = ConfigurationManager.getConfigInstance().getString("eureka.vipAddress", null);
String eurekaSecureVipAddress = ConfigurationManager.getConfigInstance().getString("eureka.secureVipAddress", null);
if (appName != null && eurekaName == null) {
ConfigurationManager.getConfigInstance().setProperty("eureka.name", appName);
}
if (appName != null && eurekaVip == null) {
ConfigurationManager.getConfigInstance().setProperty("eureka.vipAddress", appName);
}
if (appName != null && eurekaSecureVipAddress == null) {
ConfigurationManager.getConfigInstance().setProperty("eureka.secureVipAddress", appName);
}
// initialize DiscoveryManager if it hasn't already been done
if (ApplicationInfoManager.getInstance().getInfo() == null) {
EurekaInstanceConfig config;
switch(datacenter.toLowerCase()) {
case "amazon":
case "cloud":
config = new KixeyeCloudInstanceConfig(metadataCollector);
break;
default:
config = new KixeyeMyDataCenterInstanceConfig(metadataCollector);
break;
}
bean.initComponent(config, new DefaultEurekaClientConfig());
}
}
return bean;
}
use of com.netflix.discovery.DefaultEurekaClientConfig in project eureka by Netflix.
the class AbstractTester method setUp.
@Before
public void setUp() throws Exception {
ConfigurationManager.getConfigInstance().clearProperty("eureka.remoteRegion.global.appWhiteList");
ConfigurationManager.getConfigInstance().setProperty("eureka.responseCacheAutoExpirationInSeconds", "10");
ConfigurationManager.getConfigInstance().clearProperty("eureka.remoteRegion." + REMOTE_REGION_NAME + ".appWhiteList");
ConfigurationManager.getConfigInstance().setProperty("eureka.deltaRetentionTimerIntervalInMs", "600000");
ConfigurationManager.getConfigInstance().setProperty("eureka.remoteRegion.registryFetchIntervalInSeconds", "5");
populateRemoteRegistryAtStartup();
mockRemoteEurekaServer = newMockRemoteServer();
mockRemoteEurekaServer.start();
ConfigurationManager.getConfigInstance().setProperty("eureka.remoteRegionUrlsWithName", REMOTE_REGION_NAME + ";http://localhost:" + mockRemoteEurekaServer.getPort() + MockRemoteEurekaServer.EUREKA_API_BASE_PATH);
serverConfig = spy(new DefaultEurekaServerConfig());
InstanceInfo.Builder builder = InstanceInfo.Builder.newBuilder();
builder.setIPAddr("10.10.101.00");
builder.setHostName("Hosttt");
builder.setAppName("EurekaTestApp-" + UUID.randomUUID());
builder.setLeaseInfo(LeaseInfo.Builder.newBuilder().build());
builder.setDataCenterInfo(getDataCenterInfo());
ConfigurationManager.getConfigInstance().setProperty("eureka.serviceUrl.default", "http://localhost:" + mockRemoteEurekaServer.getPort() + MockRemoteEurekaServer.EUREKA_API_BASE_PATH);
DefaultEurekaClientConfig clientConfig = new DefaultEurekaClientConfig();
// setup config in advance, used in initialize converter
ApplicationInfoManager applicationInfoManager = new ApplicationInfoManager(new MyDataCenterInstanceConfig(), builder.build());
client = new DiscoveryClient(applicationInfoManager, clientConfig);
ServerCodecs serverCodecs = new DefaultServerCodecs(serverConfig);
registry = makePeerAwareInstanceRegistry(serverConfig, clientConfig, serverCodecs, client);
serverContext = new DefaultEurekaServerContext(serverConfig, serverCodecs, registry, mock(PeerEurekaNodes.class), applicationInfoManager);
serverContext.initialize();
}
Aggregations