Search in sources :

Example 1 with EurekaConfigBasedInstanceInfoProvider

use of com.netflix.appinfo.providers.EurekaConfigBasedInstanceInfoProvider in project spring-cloud-netflix by spring-cloud.

the class RestTemplateEurekaHttpClientTest method setup.

@Before
public void setup() {
    eurekaHttpClient = new RestTemplateTransportClientFactory().newClient(new DefaultEndpoint(serviceUrl));
    EurekaInstanceConfigBean config = new EurekaInstanceConfigBean(inetUtils);
    String appname = "customapp";
    config.setIpAddress("127.0.0.1");
    config.setHostname("localhost");
    config.setAppname(appname);
    config.setVirtualHostName(appname);
    config.setSecureVirtualHostName(appname);
    config.setNonSecurePort(4444);
    config.setSecurePort(8443);
    config.setInstanceId("127.0.0.1:customapp:4444");
    info = new EurekaConfigBasedInstanceInfoProvider(config).get();
}
Also used : DefaultEndpoint(com.netflix.discovery.shared.resolver.DefaultEndpoint) EurekaInstanceConfigBean(org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean) EurekaConfigBasedInstanceInfoProvider(com.netflix.appinfo.providers.EurekaConfigBasedInstanceInfoProvider) Before(org.junit.Before)

Example 2 with EurekaConfigBasedInstanceInfoProvider

use of com.netflix.appinfo.providers.EurekaConfigBasedInstanceInfoProvider in project hazelcast-eureka by hazelcast.

the class EurekaOneDiscoveryStrategy method initializeApplicationInfoManager.

private ApplicationInfoManager initializeApplicationInfoManager(DiscoveryNode localNode) {
    EurekaInstanceConfig instanceConfig = buildInstanceConfig(localNode);
    InstanceInfo instanceInfo = new EurekaConfigBasedInstanceInfoProvider(instanceConfig).get();
    ApplicationInfoManager manager = new ApplicationInfoManager(instanceConfig, instanceInfo);
    statusChangeStrategy.update(manager, InstanceInfo.InstanceStatus.STARTING);
    return manager;
}
Also used : EurekaInstanceConfig(com.netflix.appinfo.EurekaInstanceConfig) EurekaConfigBasedInstanceInfoProvider(com.netflix.appinfo.providers.EurekaConfigBasedInstanceInfoProvider) InstanceInfo(com.netflix.appinfo.InstanceInfo) ApplicationInfoManager(com.netflix.appinfo.ApplicationInfoManager)

Example 3 with EurekaConfigBasedInstanceInfoProvider

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

Example 4 with EurekaConfigBasedInstanceInfoProvider

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

use of com.netflix.appinfo.providers.EurekaConfigBasedInstanceInfoProvider in project nutzboot by nutzam.

the class EurekaClientStarter method getApplicationInfoManager.

@IocBean(name = "applicationInfoManager")
public ApplicationInfoManager getApplicationInfoManager(EurekaInstanceConfig eurekaInstanceConfig) {
    InstanceInfo instanceInfo = new EurekaConfigBasedInstanceInfoProvider(eurekaInstanceConfig).get();
    ApplicationInfoManager applicationInfoManager = new ApplicationInfoManager(eurekaInstanceConfig, instanceInfo);
    applicationInfoManager.setInstanceStatus(InstanceInfo.InstanceStatus.STARTING);
    return applicationInfoManager;
}
Also used : EurekaConfigBasedInstanceInfoProvider(com.netflix.appinfo.providers.EurekaConfigBasedInstanceInfoProvider) InstanceInfo(com.netflix.appinfo.InstanceInfo) ApplicationInfoManager(com.netflix.appinfo.ApplicationInfoManager) IocBean(org.nutz.ioc.loader.annotation.IocBean)

Aggregations

EurekaConfigBasedInstanceInfoProvider (com.netflix.appinfo.providers.EurekaConfigBasedInstanceInfoProvider)6 ApplicationInfoManager (com.netflix.appinfo.ApplicationInfoManager)5 InstanceInfo (com.netflix.appinfo.InstanceInfo)4 EurekaInstanceConfig (com.netflix.appinfo.EurekaInstanceConfig)2 CloudInstanceConfig (com.netflix.appinfo.CloudInstanceConfig)1 MyDataCenterInstanceConfig (com.netflix.appinfo.MyDataCenterInstanceConfig)1 DefaultEurekaClientConfig (com.netflix.discovery.DefaultEurekaClientConfig)1 DiscoveryClient (com.netflix.discovery.DiscoveryClient)1 EurekaClientConfig (com.netflix.discovery.EurekaClientConfig)1 DefaultEndpoint (com.netflix.discovery.shared.resolver.DefaultEndpoint)1 AwsBinderDelegate (com.netflix.eureka.aws.AwsBinderDelegate)1 PeerEurekaNodes (com.netflix.eureka.cluster.PeerEurekaNodes)1 AwsInstanceRegistry (com.netflix.eureka.registry.AwsInstanceRegistry)1 PeerAwareInstanceRegistry (com.netflix.eureka.registry.PeerAwareInstanceRegistry)1 PeerAwareInstanceRegistryImpl (com.netflix.eureka.registry.PeerAwareInstanceRegistryImpl)1 DefaultServerCodecs (com.netflix.eureka.resources.DefaultServerCodecs)1 ServerCodecs (com.netflix.eureka.resources.ServerCodecs)1 Before (org.junit.Before)1 IocBean (org.nutz.ioc.loader.annotation.IocBean)1 EurekaInstanceConfigBean (org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean)1