com.netflix.appinfo.EurekaInstanceConfig Java Examples
The following examples show how to use
com.netflix.appinfo.EurekaInstanceConfig.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EurekaClientConfigServerAutoConfigurationTests.java From spring-cloud-netflix with Apache License 2.0 | 6 votes |
@Test public void notOverridingMetamapSettings() { new ApplicationContextRunner() .withConfiguration(AutoConfigurations.of( EurekaClientConfigServerAutoConfiguration.class, ConfigServerProperties.class, EurekaInstanceConfigBean.class)) .withPropertyValues("spring.cloud.config.server.prefix=/config") .withPropertyValues( "eureka.instance.metadataMap.configPath=/differentpath") .run(c -> { assertThat(c.getBeanNamesForType(EurekaInstanceConfig.class).length) .isEqualTo(1); EurekaInstanceConfig instance = c.getBean(EurekaInstanceConfig.class); assertThat(instance.getMetadataMap().get("configPath")) .isEqualTo("/differentpath"); }); }
Example #2
Source File: EurekaInstanceLocalInfoInitiralizer.java From spring-cloud-gray with Apache License 2.0 | 6 votes |
@Override public InstanceLocalInfo getInstanceLocalInfo() { if(instanceLocalInfo==null){ EurekaInstanceConfig eurekaInstanceConfig = applicationContext.getBean(EurekaInstanceConfig.class); String instanceId = eurekaInstanceConfig.getInstanceId(); int port = eurekaInstanceConfig.getNonSecurePort(); if(eurekaInstanceConfig.getSecurePortEnabled()){ port = eurekaInstanceConfig.getSecurePort(); } instanceLocalInfo = InstanceLocalInfo.builder() .instanceId(instanceId) .serviceId(eurekaInstanceConfig.getAppname()) .host(eurekaInstanceConfig.getHostName(false)) .port(port) .build(); } return instanceLocalInfo; }
Example #3
Source File: DiscoveryClientConfig.java From api-layer with Eclipse Public License 2.0 | 6 votes |
@Bean(destroyMethod = "shutdown") @RefreshScope public ApimlDiscoveryClient eurekaClient(ApplicationInfoManager manager, EurekaClientConfig config, EurekaInstanceConfig instance, @Autowired(required = false) HealthCheckHandler healthCheckHandler ) { ApplicationInfoManager appManager; if (AopUtils.isAopProxy(manager)) { appManager = ProxyUtils.getTargetObject(manager); } else { appManager = manager; } final ApimlDiscoveryClient discoveryClientClient = new ApimlDiscoveryClient(appManager, config, this.optionalArgs, this.context); discoveryClientClient.registerHealthCheck(healthCheckHandler); discoveryClientClient.registerEventListener(event -> { if (event instanceof CacheRefreshedEvent) { refreshableRouteLocators.forEach(RefreshableRouteLocator::refresh); zuulHandlerMapping.setDirty(true); } }); return discoveryClientClient; }
Example #4
Source File: DiscoveryClientTestConfig.java From api-layer with Eclipse Public License 2.0 | 6 votes |
@Bean(destroyMethod = "shutdown") @RefreshScope public ApimlDiscoveryClientStub eurekaClient(ApplicationInfoManager manager, EurekaClientConfig config, EurekaInstanceConfig instance, @Autowired(required = false) HealthCheckHandler healthCheckHandler, ApplicationRegistry applicationRegistry ) { ApplicationInfoManager appManager; if (AopUtils.isAopProxy(manager)) { appManager = ProxyUtils.getTargetObject(manager); } else { appManager = manager; } final ApimlDiscoveryClientStub discoveryClient = new ApimlDiscoveryClientStub(appManager, config, this.optionalArgs, this.context, applicationRegistry); discoveryClient.registerHealthCheck(healthCheckHandler); discoveryClient.registerEventListener(event -> { if (event instanceof CacheRefreshedEvent) { refreshableRouteLocators.forEach(RefreshableRouteLocator::refresh); zuulHandlerMapping.setDirty(true); } }); return discoveryClient; }
Example #5
Source File: EurekaHandler.java From riposte with Apache License 2.0 | 6 votes |
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); }
Example #6
Source File: EurekaHandlerTest.java From riposte with Apache License 2.0 | 6 votes |
@Before public void beforeMethod() { eurekaIsDisabledPropertySupplierMock = mock(Supplier.class); datacenterTypePropertySupplierMock = mock(Supplier.class); cloudInstanceConfigMock = mock(CloudInstanceConfig.class); doReturn(false).when(eurekaIsDisabledPropertySupplierMock).get(); doReturn(MyOwn.name()).when(datacenterTypePropertySupplierMock).get(); handlerSpy = spy(new EurekaHandler(eurekaIsDisabledPropertySupplierMock, datacenterTypePropertySupplierMock)); doNothing().when(handlerSpy).initDiscoveryManager(any(EurekaInstanceConfig.class), any(EurekaClientConfig.class)); doNothing().when(handlerSpy).shutdownDiscoveryManager(); doNothing().when(handlerSpy).setEurekaInstanceStatus(any(InstanceStatus.class)); doReturn(cloudInstanceConfigMock).when(handlerSpy).createCloudInstanceConfig(anyString()); }
Example #7
Source File: EurekaHandlerTest.java From riposte with Apache License 2.0 | 6 votes |
@Test public void register_uses_createEurekaInstanceConfig_then_calls_initDiscoveryManager_with_it_and_sets_instance_status_UP() { // given EurekaInstanceConfig instanceConfigMock = mock(EurekaInstanceConfig.class); doReturn(instanceConfigMock).when(handlerSpy).createEurekaInstanceConfig(); assertThat(handlerSpy.registered.get()).isFalse(); // when handlerSpy.register(); // then assertThat(handlerSpy.registered.get()).isTrue(); verify(handlerSpy).createEurekaInstanceConfig(); ArgumentCaptor<EurekaClientConfig> clientConfigCaptor = ArgumentCaptor.forClass(EurekaClientConfig.class); verify(handlerSpy).initDiscoveryManager(eq(instanceConfigMock), clientConfigCaptor.capture()); EurekaClientConfig clientConfigUsed = clientConfigCaptor.getValue(); assertThat(clientConfigUsed).isInstanceOf(DefaultEurekaClientConfig.class); assertThat(Whitebox.getInternalState(clientConfigUsed, "namespace")).isEqualTo(handlerSpy.eurekaClientNamespace); verify(handlerSpy).setEurekaInstanceStatus(InstanceStatus.UP); }
Example #8
Source File: EurekaHandlerTest.java From riposte with Apache License 2.0 | 6 votes |
@DataProvider(value = { "Amazon", "Netflix" }) @Test public void createEurekaInstanceConfig_returns_CloudInstanceConfig_when_datacenterType_is_amazon_or_netflix( String datacenterType ) { // given doReturn(datacenterType).when(datacenterTypePropertySupplierMock).get(); // when EurekaInstanceConfig instanceConfig = handlerSpy.createEurekaInstanceConfig(); // then verify(handlerSpy).createCloudInstanceConfig(handlerSpy.eurekaNamespace); assertThat(instanceConfig).isSameAs(cloudInstanceConfigMock); }
Example #9
Source File: EurekaHandlerTest.java From riposte with Apache License 2.0 | 6 votes |
@DataProvider(value = { "null", "MyOwn", "not-a-real-datacenter-type" }) @Test public void createEurekaInstanceConfig_returns_MyDataCenterInstanceConfig_when_datacenterType_is_null_or_MyOwn_or_invalid( String datacenterType ) { // given doReturn(datacenterType).when(datacenterTypePropertySupplierMock).get(); // when EurekaInstanceConfig instanceConfig = handlerSpy.createEurekaInstanceConfig(); // then assertThat(instanceConfig).isInstanceOf(MyDataCenterInstanceConfig.class); assertThat(Whitebox.getInternalState(instanceConfig, "namespace")).isEqualTo(handlerSpy.eurekaClientNamespace); }
Example #10
Source File: BrpcServiceRegistrationAutoConfiguration.java From brpc-java with Apache License 2.0 | 5 votes |
@Bean @ConditionalOnMissingBean(value = EurekaInstanceConfig.class, search = SearchStrategy.CURRENT) public EurekaInstanceConfigBean eurekaInstanceConfigBean( InetUtils inetUtils, ManagementMetadataProvider managementMetadataProvider) { EurekaInstanceConfigBean instance = new EurekaClientAutoConfiguration(env) .eurekaInstanceConfigBean(inetUtils, managementMetadataProvider); String brpcPort = env.getProperty(ENV_PORT_KEY); if (StringUtils.isNoneBlank(brpcPort)) { instance.getMetadataMap().put(META_DATA_PORT_KEY, brpcPort); } return instance; }
Example #11
Source File: EurekaClientConfigServerAutoConfigurationTests.java From spring-cloud-netflix with Apache License 2.0 | 5 votes |
@Test public void onWhenRequested() { new ApplicationContextRunner() .withConfiguration(AutoConfigurations.of( EurekaClientConfigServerAutoConfiguration.class, ConfigServerProperties.class, EurekaInstanceConfigBean.class)) .withPropertyValues("spring.cloud.config.server.prefix=/config") .run(c -> { assertThat(c.getBeanNamesForType(EurekaInstanceConfig.class).length) .isEqualTo(1); EurekaInstanceConfig instance = c.getBean(EurekaInstanceConfig.class); assertThat(instance.getMetadataMap().get("configPath")) .isEqualTo("/config"); }); }
Example #12
Source File: EurekaClientAutoConfiguration.java From spring-cloud-netflix with Apache License 2.0 | 5 votes |
@Bean @ConditionalOnMissingBean @ConditionalOnEnabledHealthIndicator("eureka") public EurekaHealthIndicator eurekaHealthIndicator(EurekaClient eurekaClient, EurekaInstanceConfig instanceConfig, EurekaClientConfig clientConfig) { return new EurekaHealthIndicator(eurekaClient, instanceConfig, clientConfig); }
Example #13
Source File: EurekaClientAutoConfiguration.java From spring-cloud-netflix with Apache License 2.0 | 5 votes |
@Bean @ConditionalOnMissingBean(value = ApplicationInfoManager.class, search = SearchStrategy.CURRENT) public ApplicationInfoManager eurekaApplicationInfoManager( EurekaInstanceConfig config) { InstanceInfo instanceInfo = new InstanceInfoFactory().create(config); return new ApplicationInfoManager(config, instanceInfo); }
Example #14
Source File: EurekaLoadBalancerClientConfiguration.java From spring-cloud-netflix with Apache License 2.0 | 5 votes |
public EurekaLoadBalancerClientConfiguration( @Autowired(required = false) EurekaClientConfig clientConfig, @Autowired(required = false) EurekaInstanceConfig eurekaInstanceConfig, LoadBalancerZoneConfig zoneConfig, EurekaLoadBalancerProperties eurekaLoadBalancerProperties) { this.clientConfig = clientConfig; this.eurekaConfig = eurekaInstanceConfig; this.zoneConfig = zoneConfig; this.eurekaLoadBalancerProperties = eurekaLoadBalancerProperties; }
Example #15
Source File: EurekaHealthIndicator.java From spring-cloud-netflix with Apache License 2.0 | 5 votes |
public EurekaHealthIndicator(EurekaClient eurekaClient, EurekaInstanceConfig instanceConfig, EurekaClientConfig clientConfig) { super(); this.eurekaClient = eurekaClient; this.instanceConfig = instanceConfig; this.clientConfig = clientConfig; }
Example #16
Source File: EurekaHandlerTest.java From riposte with Apache License 2.0 | 5 votes |
@Test public void register_does_nothing_if_already_registered() { // given handlerSpy.registered.set(true); // when handlerSpy.register(); // then verify(handlerSpy, never()).createEurekaInstanceConfig(); verify(handlerSpy, never()).initDiscoveryManager(any(EurekaInstanceConfig.class), any(EurekaClientConfig.class)); verify(handlerSpy, never()).setEurekaInstanceStatus(any(InstanceStatus.class)); }
Example #17
Source File: EurekaHandlerTest.java From riposte with Apache License 2.0 | 5 votes |
@Test public void register_does_nothing_if_eureka_is_disabled() { // given doReturn(true).when(eurekaIsDisabledPropertySupplierMock).get(); // when handlerSpy.register(); // then verify(handlerSpy, never()).createEurekaInstanceConfig(); verify(handlerSpy, never()).initDiscoveryManager(any(EurekaInstanceConfig.class), any(EurekaClientConfig.class)); verify(handlerSpy, never()).setEurekaInstanceStatus(any(InstanceStatus.class)); }
Example #18
Source File: EurekaInstanceConfigCreatorTest.java From api-layer with Eclipse Public License 2.0 | 5 votes |
@Test void givenYamlMetadata_whenParsedByJackson_shouldFlattenMetadataCorrectly() throws ServiceDefinitionException { ApiMediationServiceConfig testConfig = configReader.loadConfiguration("service-configuration.yml"); EurekaInstanceConfig translatedConfig = eurekaInstanceConfigCreator.createEurekaInstanceConfig(testConfig); assertThat(translatedConfig.getMetadataMap(), hasEntry("key", "value")); assertThat(translatedConfig.getMetadataMap(), hasEntry("customService.key1", "value1")); assertThat(translatedConfig.getMetadataMap(), hasEntry("customService.key2", "value2")); assertThat(translatedConfig.getMetadataMap(), hasEntry("customService.key3", "value3")); assertThat(translatedConfig.getMetadataMap(), hasEntry("customService.key4", "value4")); assertThat(translatedConfig.getMetadataMap(), hasEntry("customService.evenmorelevels.key5.key6.key7", "value7")); }
Example #19
Source File: ZuulBootstrap.java From Sentinel with Apache License 2.0 | 5 votes |
@Override protected void configure() { //DataCenterInfo bind(EurekaInstanceConfig.class) .toProvider(MyDataCenterInstanceConfigProvider.class) .in(Scopes.SINGLETON); super.configure(); }
Example #20
Source File: InitializeServletListener.java From s2g-zuul with MIT License | 5 votes |
private void registerEureka() { DynamicBooleanProperty eurekaEnabled = DynamicPropertyFactory.getInstance().getBooleanProperty("eureka.enabled", true); if (!eurekaEnabled.get()) return; EurekaInstanceConfig eurekaInstanceConfig = new PropertiesInstanceConfig() { }; ConfigurationManager.getConfigInstance().setProperty("eureka.statusPageUrl","http://"+ getTurbineInstance()); DiscoveryManager.getInstance().initComponent(eurekaInstanceConfig, new DefaultEurekaClientConfig()); final DynamicStringProperty serverStatus = DynamicPropertyFactory.getInstance() .getStringProperty("server." + IPUtil.getLocalIP() + ".status", "up"); DiscoveryManager.getInstance().getDiscoveryClient().registerHealthCheckCallback(new HealthCheckCallback() { @Override public boolean isHealthy() { return serverStatus.get().toLowerCase().equals("up"); } }); String version = String.valueOf(System.currentTimeMillis()); String group = ConfigurationManager.getConfigInstance().getString("server.group", "default"); String dataCenter = ConfigurationManager.getConfigInstance().getString("server.data-center", "default"); Map<String, String> metadata = new HashMap<String, String>(); metadata.put("version", version); metadata.put("group", group); metadata.put("dataCenter", dataCenter); String turbineInstance = getTurbineInstance(); if (turbineInstance != null) { metadata.put("turbine.instance", turbineInstance); } ApplicationInfoManager.getInstance().registerAppMetadata(metadata); }
Example #21
Source File: EurekaConfiguration.java From chassis with Apache License 2.0 | 4 votes |
/*** * Initializes Eureka Client Library (aka DiscoveryManager) * * @return discovery manager bean */ @Bean(destroyMethod = "shutdownComponent") public DiscoveryManager eurekaDiscoveryManager(MetadataCollector metadataCollector) { final DiscoveryManager bean = DiscoveryManager.getInstance(); if (!disableEureka) { // set eureka.port via http.port if not already set int httpPort = ConfigurationManager.getConfigInstance().getInt("http.port",-1); int httpsPort = ConfigurationManager.getConfigInstance().getInt("https.port",-1); int eurekaPort = ConfigurationManager.getConfigInstance().getInt("eureka.port",-1); int eurekaSecurePort = ConfigurationManager.getConfigInstance().getInt("eureka.securePort",-1); boolean httpPortEnabled = ConfigurationManager.getConfigInstance().getBoolean("http.enabled", false); boolean httpsPortEnabled = ConfigurationManager.getConfigInstance().getBoolean("https.enabled", false); if (httpPort != -1 && eurekaPort == -1) { ConfigurationManager.getConfigInstance().setProperty("eureka.port", httpPort); ConfigurationManager.getConfigInstance().setProperty("eureka.port.enabled", httpPortEnabled); } if(httpsPort != -1 && eurekaSecurePort == -1){ ConfigurationManager.getConfigInstance().setProperty("eureka.securePort", httpsPort); ConfigurationManager.getConfigInstance().setProperty("eureka.securePort.enabled", httpsPortEnabled); } // set eureka.name and eureka.vipAddress with @SpringApp name if not already set String appName = ConfigurationManager.getConfigInstance().getString("app.name",null); String eurekaName = ConfigurationManager.getConfigInstance().getString("eureka.name",null); String eurekaVip = ConfigurationManager.getConfigInstance().getString("eureka.vipAddress",null); String eurekaSecureVipAddress = ConfigurationManager.getConfigInstance().getString("eureka.secureVipAddress",null); if (appName != null && eurekaName == null) { ConfigurationManager.getConfigInstance().setProperty("eureka.name", appName); } if (appName != null && eurekaVip == null) { ConfigurationManager.getConfigInstance().setProperty("eureka.vipAddress", appName); } if (appName != null && eurekaSecureVipAddress == null) { ConfigurationManager.getConfigInstance().setProperty("eureka.secureVipAddress", appName); } // initialize DiscoveryManager if it hasn't already been done if (ApplicationInfoManager.getInstance().getInfo() == null) { EurekaInstanceConfig config; switch (datacenter.toLowerCase()) { case "amazon": case "cloud": config = new KixeyeCloudInstanceConfig(metadataCollector); break; default: config = new KixeyeMyDataCenterInstanceConfig(metadataCollector); break; } bean.initComponent(config, new DefaultEurekaClientConfig()); } } return bean; }
Example #22
Source File: EurekaHandler.java From riposte with Apache License 2.0 | 4 votes |
@SuppressWarnings("deprecation") protected void initDiscoveryManager(EurekaInstanceConfig eurekaInstanceConfig, EurekaClientConfig eurekaClientConfig) { DiscoveryManager.getInstance().initComponent(eurekaInstanceConfig, eurekaClientConfig); }
Example #23
Source File: EurekaDiscoveryClient.java From spring-cloud-netflix with Apache License 2.0 | 4 votes |
@Deprecated public EurekaDiscoveryClient(EurekaInstanceConfig config, EurekaClient eurekaClient) { this(eurekaClient, eurekaClient.getEurekaClientConfig()); }
Example #24
Source File: EurekaClientAutoConfiguration.java From spring-cloud-netflix with Apache License 2.0 | 4 votes |
@Bean @ConditionalOnMissingBean(value = EurekaInstanceConfig.class, search = SearchStrategy.CURRENT) public EurekaInstanceConfigBean eurekaInstanceConfigBean(InetUtils inetUtils, ManagementMetadataProvider managementMetadataProvider) { String hostname = getProperty("eureka.instance.hostname"); boolean preferIpAddress = Boolean .parseBoolean(getProperty("eureka.instance.prefer-ip-address")); String ipAddress = getProperty("eureka.instance.ip-address"); boolean isSecurePortEnabled = Boolean .parseBoolean(getProperty("eureka.instance.secure-port-enabled")); String serverContextPath = env.getProperty("server.servlet.context-path", "/"); int serverPort = Integer.parseInt( env.getProperty("server.port", env.getProperty("port", "8080"))); Integer managementPort = env.getProperty("management.server.port", Integer.class); String managementContextPath = env .getProperty("management.server.servlet.context-path"); Integer jmxPort = env.getProperty("com.sun.management.jmxremote.port", Integer.class); EurekaInstanceConfigBean instance = new EurekaInstanceConfigBean(inetUtils); instance.setNonSecurePort(serverPort); instance.setInstanceId(getDefaultInstanceId(env)); instance.setPreferIpAddress(preferIpAddress); instance.setSecurePortEnabled(isSecurePortEnabled); if (StringUtils.hasText(ipAddress)) { instance.setIpAddress(ipAddress); } if (isSecurePortEnabled) { instance.setSecurePort(serverPort); } if (StringUtils.hasText(hostname)) { instance.setHostname(hostname); } String statusPageUrlPath = getProperty("eureka.instance.status-page-url-path"); String healthCheckUrlPath = getProperty("eureka.instance.health-check-url-path"); if (StringUtils.hasText(statusPageUrlPath)) { instance.setStatusPageUrlPath(statusPageUrlPath); } if (StringUtils.hasText(healthCheckUrlPath)) { instance.setHealthCheckUrlPath(healthCheckUrlPath); } ManagementMetadata metadata = managementMetadataProvider.get(instance, serverPort, serverContextPath, managementContextPath, managementPort); if (metadata != null) { instance.setStatusPageUrl(metadata.getStatusPageUrl()); instance.setHealthCheckUrl(metadata.getHealthCheckUrl()); if (instance.isSecurePortEnabled()) { instance.setSecureHealthCheckUrl(metadata.getSecureHealthCheckUrl()); } Map<String, String> metadataMap = instance.getMetadataMap(); metadataMap.computeIfAbsent("management.port", k -> String.valueOf(metadata.getManagementPort())); } else { // without the metadata the status and health check URLs will not be set // and the status page and health check url paths will not include the // context path so set them here if (StringUtils.hasText(managementContextPath)) { instance.setHealthCheckUrlPath( managementContextPath + instance.getHealthCheckUrlPath()); instance.setStatusPageUrlPath( managementContextPath + instance.getStatusPageUrlPath()); } } setupJmxPort(instance, jmxPort); return instance; }
Example #25
Source File: ApiMediationClientImpl.java From api-layer with Eclipse Public License 2.0 | 4 votes |
private ApplicationInfoManager initializeApplicationInfoManager(ApiMediationServiceConfig config) throws ServiceDefinitionException { EurekaInstanceConfig eurekaInstanceConfig = eurekaInstanceConfigCreator.createEurekaInstanceConfig(config); InstanceInfo instanceInformation = new EurekaConfigBasedInstanceInfoProvider(eurekaInstanceConfig).get(); return new ApplicationInfoManager(eurekaInstanceConfig, instanceInformation); }
Example #26
Source File: InstanceInfoFactory.java From spring-cloud-netflix with Apache License 2.0 | 4 votes |
public InstanceInfo create(EurekaInstanceConfig config) { LeaseInfo.Builder leaseInfoBuilder = LeaseInfo.Builder.newBuilder() .setRenewalIntervalInSecs(config.getLeaseRenewalIntervalInSeconds()) .setDurationInSecs(config.getLeaseExpirationDurationInSeconds()); // Builder the instance information to be registered with eureka // server InstanceInfo.Builder builder = InstanceInfo.Builder.newBuilder(); String namespace = config.getNamespace(); if (!namespace.endsWith(".")) { namespace = namespace + "."; } builder.setNamespace(namespace).setAppName(config.getAppname()) .setInstanceId(config.getInstanceId()) .setAppGroupName(config.getAppGroupName()) .setDataCenterInfo(config.getDataCenterInfo()) .setIPAddr(config.getIpAddress()).setHostName(config.getHostName(false)) .setPort(config.getNonSecurePort()) .enablePort(InstanceInfo.PortType.UNSECURE, config.isNonSecurePortEnabled()) .setSecurePort(config.getSecurePort()) .enablePort(InstanceInfo.PortType.SECURE, config.getSecurePortEnabled()) .setVIPAddress(config.getVirtualHostName()) .setSecureVIPAddress(config.getSecureVirtualHostName()) .setHomePageUrl(config.getHomePageUrlPath(), config.getHomePageUrl()) .setStatusPageUrl(config.getStatusPageUrlPath(), config.getStatusPageUrl()) .setHealthCheckUrls(config.getHealthCheckUrlPath(), config.getHealthCheckUrl(), config.getSecureHealthCheckUrl()) .setASGName(config.getASGName()); // Start off with the STARTING state to avoid traffic if (!config.isInstanceEnabledOnit()) { InstanceInfo.InstanceStatus initialStatus = InstanceInfo.InstanceStatus.STARTING; if (log.isInfoEnabled()) { log.info("Setting initial instance status as: " + initialStatus); } builder.setStatus(initialStatus); } else { if (log.isInfoEnabled()) { log.info("Setting initial instance status as: " + InstanceInfo.InstanceStatus.UP + ". This may be too early for the instance to advertise itself as available. " + "You would instead want to control this via a healthcheck handler."); } } // Add any user-specific metadata information for (Map.Entry<String, String> mapEntry : config.getMetadataMap().entrySet()) { String key = mapEntry.getKey(); String value = mapEntry.getValue(); // only add the metadata if the value is present if (value != null && !value.isEmpty()) { builder.add(key, value); } } InstanceInfo instanceInfo = builder.build(); instanceInfo.setLeaseInfo(leaseInfoBuilder.build()); return instanceInfo; }
Example #27
Source File: MultRegisterCenterServerMgmtConfig.java From Moss with Apache License 2.0 | 4 votes |
public ApplicationInfoManager eurekaApplicationInfoManager( EurekaInstanceConfig config) { InstanceInfo instanceInfo = new InstanceInfoFactory().create(config); return new ApplicationInfoManager(config, instanceInfo); }
Example #28
Source File: KaryonEurekaModule.java From karyon with Apache License 2.0 | 4 votes |
protected LinkedBindingBuilder<EurekaInstanceConfig> bindEurekaInstanceConfig() { return bind(EurekaInstanceConfig.class); }