Search in sources :

Example 11 with MyDataCenterInstanceConfig

use of com.netflix.appinfo.MyDataCenterInstanceConfig in project eureka by Netflix.

the class ExampleEurekaClient method main.

public static void main(String[] args) {
    ExampleEurekaClient sampleClient = new ExampleEurekaClient();
    // create the client
    ApplicationInfoManager applicationInfoManager = initializeApplicationInfoManager(new MyDataCenterInstanceConfig());
    EurekaClient client = initializeEurekaClient(applicationInfoManager, new DefaultEurekaClientConfig());
    // use the client
    sampleClient.sendRequestToServiceUsingEureka(client);
    // shutdown the client
    eurekaClient.shutdown();
}
Also used : DefaultEurekaClientConfig(com.netflix.discovery.DefaultEurekaClientConfig) MyDataCenterInstanceConfig(com.netflix.appinfo.MyDataCenterInstanceConfig) EurekaClient(com.netflix.discovery.EurekaClient) ApplicationInfoManager(com.netflix.appinfo.ApplicationInfoManager)

Example 12 with MyDataCenterInstanceConfig

use of com.netflix.appinfo.MyDataCenterInstanceConfig in project eureka by Netflix.

the class DiscoveryClientResource method createApplicationManager.

private ApplicationInfoManager createApplicationManager() {
    if (applicationManager == null) {
        EurekaInstanceConfig instanceConfig = new MyDataCenterInstanceConfig(EUREKA_TEST_NAMESPACE) {

            @Override
            public String getAppname() {
                return "discoveryClientTest";
            }

            @Override
            public int getLeaseRenewalIntervalInSeconds() {
                return 1;
            }
        };
        applicationManager = new ApplicationInfoManager(instanceConfig);
    }
    return applicationManager;
}
Also used : EurekaInstanceConfig(com.netflix.appinfo.EurekaInstanceConfig) MyDataCenterInstanceConfig(com.netflix.appinfo.MyDataCenterInstanceConfig) ApplicationInfoManager(com.netflix.appinfo.ApplicationInfoManager)

Example 13 with MyDataCenterInstanceConfig

use of com.netflix.appinfo.MyDataCenterInstanceConfig in project riposte by Nike-Inc.

the class EurekaHandler method createEurekaInstanceConfig.

protected EurekaInstanceConfig createEurekaInstanceConfig() {
    EurekaInstanceConfig eurekaInstanceConfig;
    String datacenterType = datacenterTypePropertySupplier.get();
    DataCenterInfo.Name dcType = DataCenterInfo.Name.MyOwn;
    if (null != datacenterType) {
        try {
            dcType = DataCenterInfo.Name.valueOf(datacenterType);
        } catch (IllegalArgumentException e) {
            logger.warn(String.format("Illegal value %s for eureka datacenter provided in property %s. " + "Ignoring the same and defaulting to %s", datacenterType, EUREKA_DATACENTER_TYPE_PROP_NAME, dcType));
        }
    }
    switch(dcType) {
        case Amazon:
        case // Intentional fall-through
        Netflix:
            eurekaInstanceConfig = createCloudInstanceConfig(eurekaNamespace);
            break;
        default:
            // Every other value is just custom data center.
            eurekaInstanceConfig = new MyDataCenterInstanceConfig(eurekaNamespace);
            break;
    }
    return eurekaInstanceConfig;
}
Also used : EurekaInstanceConfig(com.netflix.appinfo.EurekaInstanceConfig) MyDataCenterInstanceConfig(com.netflix.appinfo.MyDataCenterInstanceConfig) DataCenterInfo(com.netflix.appinfo.DataCenterInfo)

Aggregations

MyDataCenterInstanceConfig (com.netflix.appinfo.MyDataCenterInstanceConfig)13 ApplicationInfoManager (com.netflix.appinfo.ApplicationInfoManager)10 DefaultEurekaClientConfig (com.netflix.discovery.DefaultEurekaClientConfig)7 DiscoveryClient (com.netflix.discovery.DiscoveryClient)5 Before (org.junit.Before)5 InstanceInfo (com.netflix.appinfo.InstanceInfo)4 EurekaClient (com.netflix.discovery.EurekaClient)4 DataCenterInfo (com.netflix.appinfo.DataCenterInfo)3 EurekaInstanceConfig (com.netflix.appinfo.EurekaInstanceConfig)3 PeerAwareInstanceRegistry (com.netflix.eureka.registry.PeerAwareInstanceRegistry)2 DefaultServerCodecs (com.netflix.eureka.resources.DefaultServerCodecs)2 ServerCodecs (com.netflix.eureka.resources.ServerCodecs)2 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 EurekaClientConfig (com.netflix.discovery.EurekaClientConfig)1 DefaultEurekaServerConfig (com.netflix.eureka.DefaultEurekaServerConfig)1 EurekaServerConfig (com.netflix.eureka.EurekaServerConfig)1 AwsAsgUtil (com.netflix.eureka.aws.AwsAsgUtil)1