Search in sources :

Example 16 with DefaultEurekaClientConfig

use of com.netflix.discovery.DefaultEurekaClientConfig 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 17 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");
    ConfigurationManager.getConfigInstance().setProperty("eureka.renewalThresholdUpdateIntervalMs", "5000");
    ConfigurationManager.getConfigInstance().setProperty("eureka.evictionIntervalTimerInMs", "10000");
    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();
    registry.openForTraffic(applicationInfoManager, 1);
}
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)17 DiscoveryClient (com.netflix.discovery.DiscoveryClient)8 MyDataCenterInstanceConfig (com.netflix.appinfo.MyDataCenterInstanceConfig)7 ApplicationInfoManager (com.netflix.appinfo.ApplicationInfoManager)6 EurekaClient (com.netflix.discovery.EurekaClient)5 Before (org.junit.Before)4 EurekaInstanceConfig (com.netflix.appinfo.EurekaInstanceConfig)3 InstanceInfo (com.netflix.appinfo.InstanceInfo)3 DefaultServerCodecs (com.netflix.eureka.resources.DefaultServerCodecs)3 DiscoveryManager (com.netflix.discovery.DiscoveryManager)2 EurekaClientConfig (com.netflix.discovery.EurekaClientConfig)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