com.netflix.appinfo.ApplicationInfoManager Java Examples
The following examples show how to use
com.netflix.appinfo.ApplicationInfoManager.
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: BaseServerStartup.java From zuul with Apache License 2.0 | 6 votes |
@Inject public BaseServerStartup(ServerStatusManager serverStatusManager, FilterLoader filterLoader, SessionContextDecorator sessionCtxDecorator, FilterUsageNotifier usageNotifier, RequestCompleteHandler reqCompleteHandler, Registry registry, DirectMemoryMonitor directMemoryMonitor, EventLoopGroupMetrics eventLoopGroupMetrics, EurekaClient discoveryClient, ApplicationInfoManager applicationInfoManager, AccessLogPublisher accessLogPublisher) { this.serverStatusManager = serverStatusManager; this.registry = registry; this.directMemoryMonitor = directMemoryMonitor; this.eventLoopGroupMetrics = eventLoopGroupMetrics; this.discoveryClient = discoveryClient; this.applicationInfoManager = applicationInfoManager; this.accessLogPublisher = accessLogPublisher; this.sessionCtxDecorator = sessionCtxDecorator; this.reqCompleteHandler = reqCompleteHandler; this.filterLoader = filterLoader; this.usageNotifier = usageNotifier; }
Example #2
Source File: AbstractDocumentationTests.java From spring-cloud-netflix with Apache License 2.0 | 6 votes |
@Bean public EurekaServerContext testEurekaServerContext(ServerCodecs serverCodecs, PeerAwareInstanceRegistry registry, PeerEurekaNodes peerEurekaNodes, ApplicationInfoManager applicationInfoManager, EurekaServerConfig eurekaServerConfig) { return new DefaultEurekaServerContext(eurekaServerConfig, serverCodecs, registry, peerEurekaNodes, applicationInfoManager) { @Override public void shutdown() { logger.info( "Shutting down (except ServoControl and EurekaMonitors).."); registry.shutdown(); peerEurekaNodes.shutdown(); // ServoControl.shutdown(); // EurekaMonitors.shutdown(); logger.info("Shut down"); } }; }
Example #3
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 #4
Source File: EurekaServiceRegistryTests.java From spring-cloud-netflix with Apache License 2.0 | 6 votes |
@Test public void eurekaClientNotShutdownInDeregister() { EurekaServiceRegistry registry = new EurekaServiceRegistry(); CloudEurekaClient eurekaClient = mock(CloudEurekaClient.class); ApplicationInfoManager applicationInfoManager = mock( ApplicationInfoManager.class); when(applicationInfoManager.getInfo()).thenReturn(mock(InstanceInfo.class)); EurekaRegistration registration = EurekaRegistration .builder(new EurekaInstanceConfigBean( new InetUtils(new InetUtilsProperties()))) .with(eurekaClient).with(applicationInfoManager) .with(new EurekaClientConfigBean(), mock(ApplicationEventPublisher.class)) .build(); registry.deregister(registration); verifyNoInteractions(eurekaClient); }
Example #5
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 #6
Source File: ChassisConfiguration.java From chassis with Apache License 2.0 | 6 votes |
@Override public void onApplicationEvent(ApplicationEvent event) { //we only want to tell Eureka that the application is up //when the root application context (thisApplicationContext) has //been fully started. we want to ignore any ContextRefreshedEvent //from child application contexts. if (!event.getSource().equals(thisApplicationContext)) { return; } if (event instanceof ContextRefreshedEvent) { if (!disableEureka) { // tell Eureka the server UP which in turn starts the health checks and heartbeat ApplicationInfoManager.getInstance().setInstanceStatus(InstanceStatus.UP); } } else if (event instanceof ContextClosedEvent) { if (!disableEureka) { ApplicationInfoManager.getInstance().setInstanceStatus(InstanceStatus.DOWN); } } }
Example #7
Source File: EurekaRegistration.java From spring-cloud-netflix with Apache License 2.0 | 6 votes |
public EurekaRegistration build() { Assert.notNull(instanceConfig, "instanceConfig may not be null"); if (this.applicationInfoManager == null) { InstanceInfo instanceInfo = new InstanceInfoFactory() .create(this.instanceConfig); this.applicationInfoManager = new ApplicationInfoManager( this.instanceConfig, instanceInfo); } if (this.eurekaClient == null) { Assert.notNull(this.clientConfig, "if eurekaClient is null, EurekaClientConfig may not be null"); Assert.notNull(this.publisher, "if eurekaClient is null, ApplicationEventPublisher may not be null"); this.eurekaClient = new CloudEurekaClient(this.applicationInfoManager, this.clientConfig, this.publisher); } return new EurekaRegistration(instanceConfig, eurekaClient, applicationInfoManager, healthCheckHandler); }
Example #8
Source File: ChassisEurekaRegistrationTest.java From chassis with Apache License 2.0 | 6 votes |
@Test public void testServiceRegistration() throws InterruptedException { // Registers "chasis-default-name" with a Eurkea server running on local host. // http://localhost:8184/v2/apps/chassis-default-name // tell eureka the service is up which causes a registration ApplicationInfoManager.getInstance().setInstanceStatus(InstanceInfo.InstanceStatus.UP); // get application registration from Eureka DiscoveryClient client = DiscoveryManager.getInstance().getDiscoveryClient(); InstanceInfo instanceInfo = null; for (int i = 0; (instanceInfo == null) && (i < 50); i++) { Thread.sleep(5000); try { instanceInfo = client.getNextServerFromEureka("default-service", false); } catch (RuntimeException e) { // eat not found runtime exception } } Assert.assertNotNull(instanceInfo); Assert.assertEquals(InstanceStatus.UP, instanceInfo.getStatus()); System.out.println("done"); }
Example #9
Source File: EurekaClientAutoConfigurationTests.java From spring-cloud-netflix with Apache License 2.0 | 6 votes |
@Bean(destroyMethod = "shutdown") @ConditionalOnMissingBean(value = EurekaClient.class, search = SearchStrategy.CURRENT) public EurekaClient eurekaClient(ApplicationInfoManager manager, EurekaClientConfig config, ApplicationContext context) { return new CloudEurekaClient(manager, config, null, context) { @Override public synchronized void shutdown() { CountDownLatch latch = countDownLatch(); if (latch.getCount() == 1) { latch.countDown(); } super.shutdown(); } }; }
Example #10
Source File: EurekaCustomPeerNodesTest.java From didi-eureka-server with MIT License | 5 votes |
public CustomEurekaPeerNodes(PeerAwareInstanceRegistry registry, EurekaServerConfig serverConfig, EurekaClientConfig clientConfig, ServerCodecs serverCodecs, ApplicationInfoManager applicationInfoManager) { super(registry, serverConfig, clientConfig, serverCodecs, applicationInfoManager); }
Example #11
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 #12
Source File: EurekaHealthStatusBridgeModuleTest.java From runtime-health with Apache License 2.0 | 5 votes |
@Test public void testHealthCheckHandlerRegistered() { InjectorBuilder.fromModules(new EurekaHealthStatusBridgeModule(), new AbstractModule() { @Override protected void configure() { bind(ApplicationInfoManager.class).toInstance(infoManager); bind(EurekaClient.class).toInstance(eurekaClient); bind(HealthCheckAggregator.class).toInstance(healthCheckAggregator); } }).createInjector(); Mockito.verify(eurekaClient, Mockito.times(1)).registerHealthCheck(Mockito.any(HealthCheckHandler.class)); }
Example #13
Source File: EurekaClientAutoConfiguration.java From spring-cloud-netflix with Apache License 2.0 | 5 votes |
@Bean @ConditionalOnBean(AutoServiceRegistrationProperties.class) @ConditionalOnProperty( value = "spring.cloud.service-registry.auto-registration.enabled", matchIfMissing = true) public EurekaRegistration eurekaRegistration(EurekaClient eurekaClient, CloudEurekaInstanceConfig instanceConfig, ApplicationInfoManager applicationInfoManager, @Autowired( required = false) ObjectProvider<HealthCheckHandler> healthCheckHandler) { return EurekaRegistration.builder(instanceConfig).with(applicationInfoManager) .with(eurekaClient).with(healthCheckHandler).build(); }
Example #14
Source File: BootHealthCheckHandler.java From kork with Apache License 2.0 | 5 votes |
public BootHealthCheckHandler( ApplicationInfoManager applicationInfoManager, HealthAggregator aggregator, Map<String, HealthIndicator> healthIndicators) { this.applicationInfoManager = Objects.requireNonNull(applicationInfoManager, "applicationInfoManager"); this.aggregateHealth = new CompositeHealthIndicator(aggregator, healthIndicators); }
Example #15
Source File: EurekaCustomPeerNodesTest.java From didi-eureka-server with MIT License | 5 votes |
@Bean public PeerEurekaNodes myPeerEurekaNodes(PeerAwareInstanceRegistry registry, EurekaServerConfig eurekaServerConfig, EurekaClientConfig eurekaClientConfig, ServerCodecs serverCodecs, ApplicationInfoManager applicationInfoManager) { return new CustomEurekaPeerNodes(registry, eurekaServerConfig, eurekaClientConfig, serverCodecs, applicationInfoManager); }
Example #16
Source File: EurekaClientAutoConfiguration.java From spring-cloud-netflix with Apache License 2.0 | 5 votes |
@Bean @org.springframework.cloud.context.config.annotation.RefreshScope @ConditionalOnBean(AutoServiceRegistrationProperties.class) @ConditionalOnProperty( value = "spring.cloud.service-registry.auto-registration.enabled", matchIfMissing = true) public EurekaRegistration eurekaRegistration(EurekaClient eurekaClient, CloudEurekaInstanceConfig instanceConfig, ApplicationInfoManager applicationInfoManager, @Autowired( required = false) ObjectProvider<HealthCheckHandler> healthCheckHandler) { return EurekaRegistration.builder(instanceConfig).with(applicationInfoManager) .with(eurekaClient).with(healthCheckHandler).build(); }
Example #17
Source File: EurekaRegisterHandler.java From TarsJava with BSD 3-Clause "New" or "Revised" License | 5 votes |
public EurekaRegisterHandler(EurekaClient client, TarsEurekaInstance instanceConfig, HealthCheckHandler healthCheckHandler, ApplicationInfoManager applicationInfoManager) { this.client = client; this.instanceConfig = instanceConfig; this.healthCheckHandler = healthCheckHandler; this.applicationInfoManager = applicationInfoManager; }
Example #18
Source File: KaryonEurekaModule.java From karyon with Apache License 2.0 | 5 votes |
@Override protected void configure() { bind(com.netflix.appinfo.HealthCheckHandler.class).to(EurekaHealthCheckHandler.class); bind(ApplicationInfoManager.class).asEagerSingleton(); bind(DiscoveryClient.class).asEagerSingleton(); configureEureka(); }
Example #19
Source File: DIBase.java From EVCache with Apache License 2.0 | 5 votes |
@BeforeSuite public void setupEnv() { Properties props = getProps(); try { LifecycleInjectorBuilder builder = LifecycleInjector.builder(); builder.withModules( new EurekaClientModule(), new EVCacheModule(), new DIConnectionModule(), new SpectatorModule(), new ArchaiusModule() { protected void configureArchaius() { bindApplicationConfigurationOverride().toInstance(MapConfig.from(props)); }; } ); injector = builder.build().createInjector(); lifecycleManager = injector.getInstance(LifecycleManager.class); lifecycleManager.start(); injector.getInstance(ApplicationInfoManager.class); final EVCacheModule lib = injector.getInstance(EVCacheModule.class); manager = injector.getInstance(EVCacheClientPoolManager.class); } catch (Throwable e) { e.printStackTrace(); log.error(e.getMessage(), e); } }
Example #20
Source File: EurekaClientAutoConfiguration.java From spring-cloud-netflix with Apache License 2.0 | 5 votes |
@Bean(destroyMethod = "shutdown") @ConditionalOnMissingBean(value = EurekaClient.class, search = SearchStrategy.CURRENT) public EurekaClient eurekaClient(ApplicationInfoManager manager, EurekaClientConfig config) { return new CloudEurekaClient(manager, config, this.optionalArgs, this.context); }
Example #21
Source File: CloudEurekaClient.java From spring-cloud-netflix with Apache License 2.0 | 5 votes |
public CloudEurekaClient(ApplicationInfoManager applicationInfoManager, EurekaClientConfig config, AbstractDiscoveryClientOptionalArgs<?> args, ApplicationEventPublisher publisher) { super(applicationInfoManager, config, args); this.applicationInfoManager = applicationInfoManager; this.publisher = publisher; this.eurekaTransportField = ReflectionUtils.findField(DiscoveryClient.class, "eurekaTransport"); ReflectionUtils.makeAccessible(this.eurekaTransportField); }
Example #22
Source File: EurekaControllerTest.java From didi-eureka-server with MIT License | 5 votes |
@Before public void setup() throws Exception { PeerEurekaNodes peerEurekaNodes = mock(PeerEurekaNodes.class); when(peerEurekaNodes.getPeerNodesView()).thenReturn(Collections.<PeerEurekaNode>emptyList()); InstanceInfo instanceInfo = InstanceInfo.Builder.newBuilder() .setAppName("test") .setDataCenterInfo(new MyDataCenterInfo(DataCenterInfo.Name.MyOwn)) .build(); this.infoManager = mock(ApplicationInfoManager.class); this.original = ApplicationInfoManager.getInstance(); setInstance(this.infoManager); when(this.infoManager.getInfo()).thenReturn(instanceInfo); Application myapp = new Application("myapp"); myapp.addInstance(InstanceInfo.Builder.newBuilder() .setAppName("myapp") .setDataCenterInfo(new MyDataCenterInfo(DataCenterInfo.Name.MyOwn)) .setInstanceId("myapp:1") .build()); ArrayList<Application> applications = new ArrayList<>(); applications.add(myapp); PeerAwareInstanceRegistry registry = mock(PeerAwareInstanceRegistry.class); when(registry.getSortedApplications()).thenReturn(applications); EurekaServerContext serverContext = mock(EurekaServerContext.class); EurekaServerContextHolder.initialize(serverContext); when(serverContext.getRegistry()).thenReturn(registry); when(serverContext.getPeerEurekaNodes()).thenReturn(peerEurekaNodes); when(serverContext.getApplicationInfoManager()).thenReturn(this.infoManager); }
Example #23
Source File: MetadataCollector.java From chassis with Apache License 2.0 | 5 votes |
/** * Update Eurkea if the metadata has changed since the last poll. */ @Scheduled(fixedDelay = 30000) private void updateMetaData() { // Early out if Eureka has NOT been initialized. InstanceInfo instanceInfo = ApplicationInfoManager.getInstance().getInfo(); if (instanceInfo == null) { return; } // Early out if we only have static metadata since that has already // been reported to Eureka. Map<String, String> dynamic = getDynamicMetadataMap(); if (dynamic == null) { return; } // Early out if dynamic metadata has not changed since the last poll. if (oldMetaData != null && dynamic.size() == oldMetaData.size()) { boolean different = false; for (Map.Entry<String,String> kvp : dynamic.entrySet()) { if (!kvp.getValue().equals(oldMetaData.get(kvp.getKey()))) { different = true; break; } } if (!different) { return; } } // Update the instance info which will eventually get replicated to the eureka servers. // Note that registerAppMetadata is additive so we just need to include the dynamic values // since it already has the static ones. oldMetaData = dynamic; ApplicationInfoManager.getInstance().registerAppMetadata( dynamic ); }
Example #24
Source File: EurekaServerBootstrap.java From spring-cloud-netflix with Apache License 2.0 | 5 votes |
public EurekaServerBootstrap(ApplicationInfoManager applicationInfoManager, EurekaClientConfig eurekaClientConfig, EurekaServerConfig eurekaServerConfig, PeerAwareInstanceRegistry registry, EurekaServerContext serverContext) { this.applicationInfoManager = applicationInfoManager; this.eurekaClientConfig = eurekaClientConfig; this.eurekaServerConfig = eurekaServerConfig; this.registry = registry; this.serverContext = serverContext; }
Example #25
Source File: EurekaServerAutoConfiguration.java From spring-cloud-netflix with Apache License 2.0 | 5 votes |
RefreshablePeerEurekaNodes(final PeerAwareInstanceRegistry registry, final EurekaServerConfig serverConfig, final EurekaClientConfig clientConfig, final ServerCodecs serverCodecs, final ApplicationInfoManager applicationInfoManager, final ReplicationClientAdditionalFilters replicationClientAdditionalFilters) { super(registry, serverConfig, clientConfig, serverCodecs, applicationInfoManager); this.replicationClientAdditionalFilters = replicationClientAdditionalFilters; }
Example #26
Source File: EurekaCustomPeerNodesTests.java From spring-cloud-netflix with Apache License 2.0 | 5 votes |
@Bean public PeerEurekaNodes myPeerEurekaNodes(PeerAwareInstanceRegistry registry, EurekaServerConfig eurekaServerConfig, EurekaClientConfig eurekaClientConfig, ServerCodecs serverCodecs, ApplicationInfoManager applicationInfoManager) { return new CustomEurekaPeerNodes(registry, eurekaServerConfig, eurekaClientConfig, serverCodecs, applicationInfoManager); }
Example #27
Source File: EurekaCustomPeerNodesTests.java From spring-cloud-netflix with Apache License 2.0 | 5 votes |
CustomEurekaPeerNodes(PeerAwareInstanceRegistry registry, EurekaServerConfig serverConfig, EurekaClientConfig clientConfig, ServerCodecs serverCodecs, ApplicationInfoManager applicationInfoManager) { super(registry, serverConfig, clientConfig, serverCodecs, applicationInfoManager); }
Example #28
Source File: EurekaControllerTests.java From spring-cloud-netflix with Apache License 2.0 | 5 votes |
@Before public void setup() throws Exception { PeerEurekaNodes peerEurekaNodes = mock(PeerEurekaNodes.class); when(peerEurekaNodes.getPeerNodesView()) .thenReturn(Collections.<PeerEurekaNode>emptyList()); InstanceInfo instanceInfo = InstanceInfo.Builder.newBuilder().setAppName("test") .setDataCenterInfo(new MyDataCenterInfo(DataCenterInfo.Name.MyOwn)) .build(); this.infoManager = mock(ApplicationInfoManager.class); this.original = ApplicationInfoManager.getInstance(); setInstance(this.infoManager); when(this.infoManager.getInfo()).thenReturn(instanceInfo); Application myapp = new Application("myapp"); myapp.addInstance(InstanceInfo.Builder.newBuilder().setAppName("myapp") .setDataCenterInfo(new MyDataCenterInfo(DataCenterInfo.Name.MyOwn)) .setInstanceId("myapp:1").build()); ArrayList<Application> applications = new ArrayList<>(); applications.add(myapp); PeerAwareInstanceRegistry registry = mock(PeerAwareInstanceRegistry.class); when(registry.getSortedApplications()).thenReturn(applications); EurekaServerContext serverContext = mock(EurekaServerContext.class); EurekaServerContextHolder.initialize(serverContext); when(serverContext.getRegistry()).thenReturn(registry); when(serverContext.getPeerEurekaNodes()).thenReturn(peerEurekaNodes); when(serverContext.getApplicationInfoManager()).thenReturn(this.infoManager); }
Example #29
Source File: EurekaControllerTests.java From spring-cloud-netflix with Apache License 2.0 | 5 votes |
static void setInstance(ApplicationInfoManager infoManager) throws IllegalAccessException { Field instance = ReflectionUtils.findField(ApplicationInfoManager.class, "instance"); ReflectionUtils.makeAccessible(instance); instance.set(null, infoManager); }
Example #30
Source File: EurekaRegistration.java From spring-cloud-netflix with Apache License 2.0 | 5 votes |
private EurekaRegistration(CloudEurekaInstanceConfig instanceConfig, EurekaClient eurekaClient, ApplicationInfoManager applicationInfoManager, ObjectProvider<HealthCheckHandler> healthCheckHandler) { this.eurekaClient = eurekaClient; this.instanceConfig = instanceConfig; this.applicationInfoManager = applicationInfoManager; this.healthCheckHandler = healthCheckHandler; }