Search in sources :

Example 1 with MyDataCenterInstanceConfig

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

the class DiscoveryClientRegisterUpdateTest method setUp.

@Before
public void setUp() throws Exception {
    mockLocalEurekaServer = new MockRemoteEurekaServer();
    mockLocalEurekaServer.start();
    ConfigurationManager.getConfigInstance().setProperty("eureka.name", "EurekaTestApp-" + UUID.randomUUID());
    ConfigurationManager.getConfigInstance().setProperty("eureka.registration.enabled", "true");
    ConfigurationManager.getConfigInstance().setProperty("eureka.appinfo.replicate.interval", 2);
    ConfigurationManager.getConfigInstance().setProperty("eureka.shouldFetchRegistry", "false");
    ConfigurationManager.getConfigInstance().setProperty("eureka.serviceUrl.default", "http://localhost:" + mockLocalEurekaServer.getPort() + MockRemoteEurekaServer.EUREKA_API_BASE_PATH);
    applicationInfoManager = new TestApplicationInfoManager();
    applicationInfoManager.initComponent(new MyDataCenterInstanceConfig());
    client = new DiscoveryClient(applicationInfoManager, new DefaultEurekaClientConfig());
}
Also used : MyDataCenterInstanceConfig(com.netflix.appinfo.MyDataCenterInstanceConfig) Before(org.junit.Before)

Example 2 with MyDataCenterInstanceConfig

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

the class DiscoveryClientDisableRegistryTest method setUp.

@Before
public void setUp() throws Exception {
    mockLocalEurekaServer = new MockRemoteEurekaServer();
    mockLocalEurekaServer.start();
    ConfigurationManager.getConfigInstance().setProperty("eureka.registration.enabled", "false");
    ConfigurationManager.getConfigInstance().setProperty("eureka.shouldFetchRegistry", "false");
    ConfigurationManager.getConfigInstance().setProperty("eureka.serviceUrl.default", "http://localhost:" + mockLocalEurekaServer.getPort() + 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());
    client = new DiscoveryClient(applicationInfoManager, new DefaultEurekaClientConfig());
}
Also used : MyDataCenterInstanceConfig(com.netflix.appinfo.MyDataCenterInstanceConfig) DataCenterInfo(com.netflix.appinfo.DataCenterInfo) InstanceInfo(com.netflix.appinfo.InstanceInfo) ApplicationInfoManager(com.netflix.appinfo.ApplicationInfoManager) Before(org.junit.Before)

Example 3 with MyDataCenterInstanceConfig

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

the class EurekaBootStrap method initEurekaServerContext.

/**
     * init hook for server context. Override for custom logic.
     */
protected void initEurekaServerContext() throws Exception {
    EurekaServerConfig eurekaServerConfig = new DefaultEurekaServerConfig();
    // For backward compatibility
    JsonXStream.getInstance().registerConverter(new V1AwareInstanceInfoConverter(), XStream.PRIORITY_VERY_HIGH);
    XmlXStream.getInstance().registerConverter(new V1AwareInstanceInfoConverter(), XStream.PRIORITY_VERY_HIGH);
    logger.info("Initializing the eureka client...");
    logger.info(eurekaServerConfig.getJsonCodecName());
    ServerCodecs serverCodecs = new DefaultServerCodecs(eurekaServerConfig);
    ApplicationInfoManager applicationInfoManager = null;
    if (eurekaClient == null) {
        EurekaInstanceConfig instanceConfig = isCloud(ConfigurationManager.getDeploymentContext()) ? new CloudInstanceConfig() : new MyDataCenterInstanceConfig();
        applicationInfoManager = new ApplicationInfoManager(instanceConfig, new EurekaConfigBasedInstanceInfoProvider(instanceConfig).get());
        EurekaClientConfig eurekaClientConfig = new DefaultEurekaClientConfig();
        eurekaClient = new DiscoveryClient(applicationInfoManager, eurekaClientConfig);
    } else {
        applicationInfoManager = eurekaClient.getApplicationInfoManager();
    }
    PeerAwareInstanceRegistry registry;
    if (isAws(applicationInfoManager.getInfo())) {
        registry = new AwsInstanceRegistry(eurekaServerConfig, eurekaClient.getEurekaClientConfig(), serverCodecs, eurekaClient);
        awsBinder = new AwsBinderDelegate(eurekaServerConfig, eurekaClient.getEurekaClientConfig(), registry, applicationInfoManager);
        awsBinder.start();
    } else {
        registry = new PeerAwareInstanceRegistryImpl(eurekaServerConfig, eurekaClient.getEurekaClientConfig(), serverCodecs, eurekaClient);
    }
    PeerEurekaNodes peerEurekaNodes = getPeerEurekaNodes(registry, eurekaServerConfig, eurekaClient.getEurekaClientConfig(), serverCodecs, applicationInfoManager);
    serverContext = new DefaultEurekaServerContext(eurekaServerConfig, serverCodecs, registry, peerEurekaNodes, applicationInfoManager);
    EurekaServerContextHolder.initialize(serverContext);
    serverContext.initialize();
    logger.info("Initialized server context");
    // Copy registry from neighboring eureka node
    int registryCount = registry.syncUp();
    registry.openForTraffic(applicationInfoManager, registryCount);
    // Register all monitoring statistics.
    EurekaMonitors.registerAllStats();
}
Also used : DefaultEurekaClientConfig(com.netflix.discovery.DefaultEurekaClientConfig) PeerAwareInstanceRegistryImpl(com.netflix.eureka.registry.PeerAwareInstanceRegistryImpl) CloudInstanceConfig(com.netflix.appinfo.CloudInstanceConfig) DefaultEurekaClientConfig(com.netflix.discovery.DefaultEurekaClientConfig) EurekaClientConfig(com.netflix.discovery.EurekaClientConfig) EurekaInstanceConfig(com.netflix.appinfo.EurekaInstanceConfig) EurekaConfigBasedInstanceInfoProvider(com.netflix.appinfo.providers.EurekaConfigBasedInstanceInfoProvider) DefaultServerCodecs(com.netflix.eureka.resources.DefaultServerCodecs) DefaultServerCodecs(com.netflix.eureka.resources.DefaultServerCodecs) ServerCodecs(com.netflix.eureka.resources.ServerCodecs) PeerAwareInstanceRegistry(com.netflix.eureka.registry.PeerAwareInstanceRegistry) PeerEurekaNodes(com.netflix.eureka.cluster.PeerEurekaNodes) AwsBinderDelegate(com.netflix.eureka.aws.AwsBinderDelegate) MyDataCenterInstanceConfig(com.netflix.appinfo.MyDataCenterInstanceConfig) DiscoveryClient(com.netflix.discovery.DiscoveryClient) AwsInstanceRegistry(com.netflix.eureka.registry.AwsInstanceRegistry) ApplicationInfoManager(com.netflix.appinfo.ApplicationInfoManager)

Example 4 with MyDataCenterInstanceConfig

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

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

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