Search in sources :

Example 6 with MyDataCenterInstanceConfig

use of com.netflix.appinfo.MyDataCenterInstanceConfig 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 MyDataCenterInstanceConfig

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

use of com.netflix.appinfo.MyDataCenterInstanceConfig 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 9 with MyDataCenterInstanceConfig

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

the class BackUpRegistryTest method setUp.

public void setUp(boolean enableRemote) throws Exception {
    ConfigurationManager.getConfigInstance().setProperty("eureka.client.refresh.interval", CLIENT_REFRESH_RATE);
    ConfigurationManager.getConfigInstance().setProperty("eureka.registration.enabled", "false");
    if (enableRemote) {
        ConfigurationManager.getConfigInstance().setProperty("eureka.fetchRemoteRegionsRegistry", REMOTE_REGION);
    }
    ConfigurationManager.getConfigInstance().setProperty("eureka.myregion.availabilityZones", REMOTE_ZONE);
    ConfigurationManager.getConfigInstance().setProperty("eureka.backupregistry", MockBackupRegistry.class.getName());
    ConfigurationManager.getConfigInstance().setProperty("eureka.serviceUrl.default", "http://localhost:" + NOT_AVAILABLE_EUREKA_PORT + MockRemoteEurekaServer.EUREKA_API_BASE_PATH);
    InstanceInfo.Builder builder = InstanceInfo.Builder.newBuilder();
    builder.setIPAddr("10.10.101.00");
    builder.setHostName("Hosttt");
    builder.setAppName("EurekaTestApp-" + UUID.randomUUID());
    builder.setDataCenterInfo(new DataCenterInfo() {

        @Override
        public Name getName() {
            return Name.MyOwn;
        }
    });
    ApplicationInfoManager applicationInfoManager = new ApplicationInfoManager(new MyDataCenterInstanceConfig(), builder.build());
    backupRegistry = new MockBackupRegistry();
    setupBackupMock();
    client = new DiscoveryClient(applicationInfoManager, new DefaultEurekaClientConfig(), null, Providers.of((BackupRegistry) backupRegistry));
}
Also used : MyDataCenterInstanceConfig(com.netflix.appinfo.MyDataCenterInstanceConfig) DataCenterInfo(com.netflix.appinfo.DataCenterInfo) InstanceInfo(com.netflix.appinfo.InstanceInfo) ApplicationInfoManager(com.netflix.appinfo.ApplicationInfoManager)

Example 10 with MyDataCenterInstanceConfig

use of com.netflix.appinfo.MyDataCenterInstanceConfig 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

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