Search in sources :

Example 6 with DefaultEurekaClientConfig

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));
}
Also used : DefaultEurekaClientConfig(com.netflix.discovery.DefaultEurekaClientConfig) DefaultEurekaServerConfig(com.netflix.eureka.DefaultEurekaServerConfig) MyDataCenterInstanceConfig(com.netflix.appinfo.MyDataCenterInstanceConfig) AwsAsgUtil(com.netflix.eureka.aws.AwsAsgUtil) DefaultEurekaServerConfig(com.netflix.eureka.DefaultEurekaServerConfig) EurekaServerConfig(com.netflix.eureka.EurekaServerConfig) DiscoveryClient(com.netflix.discovery.DiscoveryClient) AmazonInfo(com.netflix.appinfo.AmazonInfo) InstanceInfo(com.netflix.appinfo.InstanceInfo) ApplicationInfoManager(com.netflix.appinfo.ApplicationInfoManager) PeerAwareInstanceRegistry(com.netflix.eureka.registry.PeerAwareInstanceRegistry) Before(org.junit.Before)

Example 7 with DefaultEurekaClientConfig

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();
    }
}
Also used : DefaultEurekaClientConfig(com.netflix.discovery.DefaultEurekaClientConfig) MyDataCenterInstanceConfig(com.netflix.appinfo.MyDataCenterInstanceConfig) EurekaClient(com.netflix.discovery.EurekaClient) DynamicPropertyFactory(com.netflix.config.DynamicPropertyFactory) ApplicationInfoManager(com.netflix.appinfo.ApplicationInfoManager)

Example 8 with DefaultEurekaClientConfig

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);
}
Also used : DefaultEurekaClientConfig(com.netflix.discovery.DefaultEurekaClientConfig) EurekaInstanceConfig(com.netflix.appinfo.EurekaInstanceConfig)

Example 9 with DefaultEurekaClientConfig

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;
}
Also used : DefaultEurekaClientConfig(com.netflix.discovery.DefaultEurekaClientConfig) DiscoveryManager(com.netflix.discovery.DiscoveryManager) EurekaInstanceConfig(com.netflix.appinfo.EurekaInstanceConfig) Bean(org.springframework.context.annotation.Bean)

Example 10 with DefaultEurekaClientConfig

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();
}
Also used : DefaultEurekaClientConfig(com.netflix.discovery.DefaultEurekaClientConfig) MyDataCenterInstanceConfig(com.netflix.appinfo.MyDataCenterInstanceConfig) DiscoveryClient(com.netflix.discovery.DiscoveryClient) DefaultServerCodecs(com.netflix.eureka.resources.DefaultServerCodecs) InstanceInfo(com.netflix.appinfo.InstanceInfo) ApplicationInfoManager(com.netflix.appinfo.ApplicationInfoManager) DefaultServerCodecs(com.netflix.eureka.resources.DefaultServerCodecs) ServerCodecs(com.netflix.eureka.resources.ServerCodecs) Before(org.junit.Before)

Aggregations

DefaultEurekaClientConfig (com.netflix.discovery.DefaultEurekaClientConfig)12 MyDataCenterInstanceConfig (com.netflix.appinfo.MyDataCenterInstanceConfig)7 ApplicationInfoManager (com.netflix.appinfo.ApplicationInfoManager)6 DiscoveryClient (com.netflix.discovery.DiscoveryClient)5 EurekaClient (com.netflix.discovery.EurekaClient)4 EurekaInstanceConfig (com.netflix.appinfo.EurekaInstanceConfig)3 DefaultServerCodecs (com.netflix.eureka.resources.DefaultServerCodecs)3 Before (org.junit.Before)3 InstanceInfo (com.netflix.appinfo.InstanceInfo)2 DefaultEurekaServerConfig (com.netflix.eureka.DefaultEurekaServerConfig)2 EurekaServerConfig (com.netflix.eureka.EurekaServerConfig)2 PeerAwareInstanceRegistry (com.netflix.eureka.registry.PeerAwareInstanceRegistry)2 ServerCodecs (com.netflix.eureka.resources.ServerCodecs)2 Injector (com.google.inject.Injector)1 AmazonInfo (com.netflix.appinfo.AmazonInfo)1 CloudInstanceConfig (com.netflix.appinfo.CloudInstanceConfig)1 EurekaConfigBasedInstanceInfoProvider (com.netflix.appinfo.providers.EurekaConfigBasedInstanceInfoProvider)1 DynamicPropertyFactory (com.netflix.config.DynamicPropertyFactory)1 DiscoveryManager (com.netflix.discovery.DiscoveryManager)1 EurekaClientConfig (com.netflix.discovery.EurekaClientConfig)1