Search in sources :

Example 6 with ApplicationInfoManager

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

the class DiscoveryClientResource method setupDiscoveryClient.

public static EurekaClient setupDiscoveryClient(InstanceInfo clientInstanceInfo) {
    DefaultEurekaClientConfig config = new DefaultEurekaClientConfig();
    // setup config in advance, used in initialize converter
    ApplicationInfoManager applicationInfoManager = new ApplicationInfoManager(new MyDataCenterInstanceConfig(), clientInstanceInfo);
    DiscoveryManager.getInstance().setEurekaClientConfig(config);
    EurekaClient client = new DiscoveryClient(applicationInfoManager, config);
    return client;
}
Also used : DefaultEurekaClientConfig(com.netflix.discovery.DefaultEurekaClientConfig) MyDataCenterInstanceConfig(com.netflix.appinfo.MyDataCenterInstanceConfig) EurekaClient(com.netflix.discovery.EurekaClient) DiscoveryClient(com.netflix.discovery.DiscoveryClient) ApplicationInfoManager(com.netflix.appinfo.ApplicationInfoManager)

Example 7 with ApplicationInfoManager

use of com.netflix.appinfo.ApplicationInfoManager 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 8 with ApplicationInfoManager

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

the class RateLimitingFilterTest method setUp.

@Before
public void setUp() throws Exception {
    RateLimitingFilter.reset();
    ConfigurationManager.getConfigInstance().setProperty("eureka.rateLimiter.privilegedClients", PYTHON_CLIENT);
    ConfigurationManager.getConfigInstance().setProperty("eureka.rateLimiter.enabled", true);
    ConfigurationManager.getConfigInstance().setProperty("eureka.rateLimiter.burstSize", 2);
    ConfigurationManager.getConfigInstance().setProperty("eureka.rateLimiter.registryFetchAverageRate", 1);
    ConfigurationManager.getConfigInstance().setProperty("eureka.rateLimiter.fullFetchAverageRate", 1);
    ConfigurationManager.getConfigInstance().setProperty("eureka.rateLimiter.throttleStandardClients", false);
    ApplicationInfoManager applicationInfoManager = new ApplicationInfoManager(new MyDataCenterInstanceConfig());
    DefaultEurekaServerConfig config = new DefaultEurekaServerConfig();
    EurekaServerContext mockServer = mock(EurekaServerContext.class);
    when(mockServer.getServerConfig()).thenReturn(config);
    filter = new RateLimitingFilter(mockServer);
}
Also used : MyDataCenterInstanceConfig(com.netflix.appinfo.MyDataCenterInstanceConfig) ApplicationInfoManager(com.netflix.appinfo.ApplicationInfoManager) Before(org.junit.Before)

Example 9 with ApplicationInfoManager

use of com.netflix.appinfo.ApplicationInfoManager 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 10 with ApplicationInfoManager

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

the class ExampleEurekaService method initializeApplicationInfoManager.

private static synchronized ApplicationInfoManager initializeApplicationInfoManager(EurekaInstanceConfig instanceConfig) {
    if (applicationInfoManager == null) {
        InstanceInfo instanceInfo = new EurekaConfigBasedInstanceInfoProvider(instanceConfig).get();
        applicationInfoManager = new ApplicationInfoManager(instanceConfig, instanceInfo);
    }
    return applicationInfoManager;
}
Also used : EurekaConfigBasedInstanceInfoProvider(com.netflix.appinfo.providers.EurekaConfigBasedInstanceInfoProvider) InstanceInfo(com.netflix.appinfo.InstanceInfo) ApplicationInfoManager(com.netflix.appinfo.ApplicationInfoManager)

Aggregations

ApplicationInfoManager (com.netflix.appinfo.ApplicationInfoManager)16 MyDataCenterInstanceConfig (com.netflix.appinfo.MyDataCenterInstanceConfig)10 InstanceInfo (com.netflix.appinfo.InstanceInfo)9 DefaultEurekaClientConfig (com.netflix.discovery.DefaultEurekaClientConfig)6 DiscoveryClient (com.netflix.discovery.DiscoveryClient)6 EurekaInstanceConfig (com.netflix.appinfo.EurekaInstanceConfig)5 EurekaClient (com.netflix.discovery.EurekaClient)5 EurekaClientConfig (com.netflix.discovery.EurekaClientConfig)4 Before (org.junit.Before)4 EurekaConfigBasedInstanceInfoProvider (com.netflix.appinfo.providers.EurekaConfigBasedInstanceInfoProvider)3 PeerAwareInstanceRegistry (com.netflix.eureka.registry.PeerAwareInstanceRegistry)3 Test (org.junit.Test)3 AmazonInfo (com.netflix.appinfo.AmazonInfo)2 DataCenterInfo (com.netflix.appinfo.DataCenterInfo)2 Archaius2VipAddressResolver (com.netflix.appinfo.providers.Archaius2VipAddressResolver)2 VipAddressResolver (com.netflix.appinfo.providers.VipAddressResolver)2 EurekaServerConfig (com.netflix.eureka.EurekaServerConfig)2 PeerEurekaNodes (com.netflix.eureka.cluster.PeerEurekaNodes)2 DefaultServerCodecs (com.netflix.eureka.resources.DefaultServerCodecs)2 ServerCodecs (com.netflix.eureka.resources.ServerCodecs)2