Search in sources :

Example 1 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 2 with DefaultEurekaClientConfig

use of com.netflix.discovery.DefaultEurekaClientConfig in project eureka by Netflix.

the class ResponseCacheTest method setUp.

@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    // create a new registry that is sync'ed up with the default registry in the AbstractTester,
    // but disable transparent fetch to the remote for gets
    EurekaServerConfig serverConfig = spy(new DefaultEurekaServerConfig());
    doReturn(true).when(serverConfig).disableTransparentFallbackToOtherRegion();
    testRegistry = new PeerAwareInstanceRegistryImpl(serverConfig, new DefaultEurekaClientConfig(), new DefaultServerCodecs(serverConfig), client);
    testRegistry.init(serverContext.getPeerEurekaNodes());
    testRegistry.syncUp();
}
Also used : DefaultEurekaClientConfig(com.netflix.discovery.DefaultEurekaClientConfig) DefaultEurekaServerConfig(com.netflix.eureka.DefaultEurekaServerConfig) DefaultEurekaServerConfig(com.netflix.eureka.DefaultEurekaServerConfig) EurekaServerConfig(com.netflix.eureka.EurekaServerConfig) DefaultServerCodecs(com.netflix.eureka.resources.DefaultServerCodecs) Before(org.junit.Before)

Example 3 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 4 with DefaultEurekaClientConfig

use of com.netflix.discovery.DefaultEurekaClientConfig in project eureka by Netflix.

the class DiscoveryClientResource method setupInjector.

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

Example 5 with DefaultEurekaClientConfig

use of com.netflix.discovery.DefaultEurekaClientConfig in project eureka by Netflix.

the class DiscoveryClientResource method createEurekaClientConfig.

private EurekaClientConfig createEurekaClientConfig() throws Exception {
    // Cluster connectivity
    URI serviceURI;
    if (portResolverCallable != null) {
        serviceURI = new URI("http://localhost:" + portResolverCallable.call() + "/eureka/v2/");
    } else if (eurekaHttpServer != null) {
        serviceURI = eurekaHttpServer.getServiceURI();
    } else {
        throw new IllegalStateException("Either port or EurekaHttpServer must be configured");
    }
    if (userName != null) {
        serviceURI = UriBuilder.fromUri(serviceURI).userInfo(userName + ':' + password).build();
    }
    bindProperty(EUREKA_TEST_NAMESPACE + "serviceUrl.default", serviceURI.toString());
    if (remoteRegions != null && !remoteRegions.isEmpty()) {
        StringBuilder regions = new StringBuilder();
        for (String region : remoteRegions) {
            regions.append(',').append(region);
        }
        bindProperty(EUREKA_TEST_NAMESPACE + "fetchRemoteRegionsRegistry", regions.substring(1));
    }
    // Registration
    bindProperty(EUREKA_TEST_NAMESPACE + "registration.enabled", Boolean.toString(registrationEnabled));
    bindProperty(EUREKA_TEST_NAMESPACE + "appinfo.initial.replicate.time", Integer.toString(0));
    bindProperty(EUREKA_TEST_NAMESPACE + "appinfo.replicate.interval", Integer.toString(1));
    // Registry fetch
    bindProperty(EUREKA_TEST_NAMESPACE + "shouldFetchRegistry", Boolean.toString(registryFetchEnabled));
    bindProperty(EUREKA_TEST_NAMESPACE + "client.refresh.interval", Integer.toString(1));
    if (vipFetch != null) {
        bindProperty(EUREKA_TEST_NAMESPACE + "registryRefreshSingleVipAddress", vipFetch);
    }
    return new DefaultEurekaClientConfig(EUREKA_TEST_NAMESPACE);
}
Also used : DefaultEurekaClientConfig(com.netflix.discovery.DefaultEurekaClientConfig) URI(java.net.URI)

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