本文整理汇总了Java中com.netflix.appinfo.ApplicationInfoManager类的典型用法代码示例。如果您正苦于以下问题:Java ApplicationInfoManager类的具体用法?Java ApplicationInfoManager怎么用?Java ApplicationInfoManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ApplicationInfoManager类属于com.netflix.appinfo包,在下文中一共展示了ApplicationInfoManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testInstanceRegistrationUsingProvidedEurekaClient
import com.netflix.appinfo.ApplicationInfoManager; //导入依赖的package包/类
@Test
public void testInstanceRegistrationUsingProvidedEurekaClient() {
EurekaClient eurekaClient = mock(EurekaClient.class);
ApplicationInfoManager applicationInfoManager = mock(ApplicationInfoManager.class);
EurekaInstanceConfig eurekaInstanceConfig = mock(EurekaInstanceConfig.class);
when(eurekaClient.getApplicationInfoManager()).thenReturn(applicationInfoManager);
when(eurekaClient.getApplication(anyString())).thenReturn(new Application(APP_NAME));
when(applicationInfoManager.getEurekaInstanceConfig()).thenReturn(eurekaInstanceConfig);
when(eurekaInstanceConfig.getAppname()).thenReturn(APP_NAME);
// use provided EurekaClient
EurekaOneDiscoveryStrategyFactory.setEurekaClient(eurekaClient);
HazelcastInstance hz1 = factory.newHazelcastInstance();
HazelcastInstance hz2 = factory.newHazelcastInstance();
verify(eurekaClient, times(2)).getApplicationInfoManager();
verify(eurekaClient, times(2)).getApplication(APP_NAME);
verify(applicationInfoManager, never()).setInstanceStatus(InstanceStatus.UP);
verify(applicationInfoManager, never()).setInstanceStatus(any(InstanceStatus.class));
assertClusterSizeEventually(2, hz1);
assertClusterSizeEventually(2, hz2);
}
示例2: onApplicationEvent
import com.netflix.appinfo.ApplicationInfoManager; //导入依赖的package包/类
@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);
}
}
}
示例3: testServiceRegistration
import com.netflix.appinfo.ApplicationInfoManager; //导入依赖的package包/类
@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");
}
示例4: eurekaClientNotShutdownInDeregister
import com.netflix.appinfo.ApplicationInfoManager; //导入依赖的package包/类
@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);
verifyZeroInteractions(eurekaClient);
}
示例5: onWhenRequested
import com.netflix.appinfo.ApplicationInfoManager; //导入依赖的package包/类
@Test
public void onWhenRequested() throws Exception {
setup("spring.cloud.config.discovery.enabled=true",
"eureka.instance.metadataMap.foo:bar",
"eureka.instance.nonSecurePort:7001", "eureka.instance.hostname:foo");
assertEquals(1, this.context.getBeanNamesForType(
EurekaDiscoveryClientConfigServiceAutoConfiguration.class).length);
EurekaClient eurekaClient = this.context.getParent().getBean(EurekaClient.class);
Mockito.verify(eurekaClient, times(2)).getInstancesByVipAddress(DEFAULT_CONFIG_SERVER,
false);
Mockito.verify(eurekaClient, times(1)).shutdown();
ConfigClientProperties locator = this.context
.getBean(ConfigClientProperties.class);
assertEquals("http://foo:7001/", locator.getRawUri());
ApplicationInfoManager infoManager = this.context
.getBean(ApplicationInfoManager.class);
assertEquals("bar", infoManager.getInfo().getMetadata().get("foo"));
}
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:19,代码来源:DiscoveryClientConfigServiceAutoConfigurationTests.java
示例6: EurekaMetadataPopulator
import com.netflix.appinfo.ApplicationInfoManager; //导入依赖的package包/类
public EurekaMetadataPopulator(SnitchEndpoint snitch, ApplicationInfoManager manager,
EurekaInstanceSnitchProperties props, ObjectMapper mapper) {
this.snitch = Objects.requireNonNull(snitch, "Snitch required");
this.appInfoManager = Objects.requireNonNull(manager, "Eureka ApplicationInfoManager required");
this.objectMapper = Objects.requireNonNull(mapper, "ObjectMapper required");
this.properties = Objects.requireNonNull(props, "Configuration properties required");
}
示例7: eurekaMetadataPopulator
import com.netflix.appinfo.ApplicationInfoManager; //导入依赖的package包/类
@Bean
@ConditionalOnBean(SnitchEndpoint.class)
public EurekaMetadataPopulator eurekaMetadataPopulator(SnitchEndpoint snitch, ApplicationInfoManager manager,
ObjectMapper mapper) {
RelaxedPropertyResolver relaxedPropertyResolver = new RelaxedPropertyResolver(env, "cereebro.snitch.eureka.");
EurekaInstanceSnitchProperties props = new EurekaInstanceSnitchProperties();
props.setEndpointUrl(relaxedPropertyResolver.getProperty("endpointUrl"));
props.setEndpointUrlPath(relaxedPropertyResolver.getProperty("endpointUrlPath"));
EurekaMetadataPopulator metadataPopulator = new EurekaMetadataPopulator(snitch, manager, props, mapper);
metadataPopulator.populate();
return metadataPopulator;
}
示例8: setup
import com.netflix.appinfo.ApplicationInfoManager; //导入依赖的package包/类
@Before
public void setup() {
cloudEurekaInstanceConfig = Mockito.mock(CloudEurekaInstanceConfig.class);
appInfoManager = Mockito.mock(ApplicationInfoManager.class);
Mockito.when(appInfoManager.getEurekaInstanceConfig()).thenReturn(cloudEurekaInstanceConfig);
metadata = new HashMap<String, String>();
Mockito.when(cloudEurekaInstanceConfig.getMetadataMap()).thenReturn(metadata);
Mockito.when(cloudEurekaInstanceConfig.getHostName(true)).thenReturn("localhost");
Mockito.when(cloudEurekaInstanceConfig.getNonSecurePort()).thenReturn(8080);
snitch = Mockito.mock(SnitchEndpoint.class);
Mockito.when(snitch.getUri()).thenReturn(TEST_URI);
props = new EurekaInstanceSnitchProperties();
populator = new EurekaMetadataPopulator(snitch, appInfoManager, props, new ObjectMapper());
}
示例9: EurekaServerBootstrap
import com.netflix.appinfo.ApplicationInfoManager; //导入依赖的package包/类
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;
}
示例10: setup
import com.netflix.appinfo.ApplicationInfoManager; //导入依赖的package包/类
@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);
}
示例11: myPeerEurekaNodes
import com.netflix.appinfo.ApplicationInfoManager; //导入依赖的package包/类
@Bean
public PeerEurekaNodes myPeerEurekaNodes(PeerAwareInstanceRegistry registry,
EurekaServerConfig eurekaServerConfig,
EurekaClientConfig eurekaClientConfig, ServerCodecs serverCodecs,
ApplicationInfoManager applicationInfoManager) {
return new CustomEurekaPeerNodes(registry, eurekaServerConfig,
eurekaClientConfig, serverCodecs, applicationInfoManager);
}
示例12: CustomEurekaPeerNodes
import com.netflix.appinfo.ApplicationInfoManager; //导入依赖的package包/类
public CustomEurekaPeerNodes(PeerAwareInstanceRegistry registry,
EurekaServerConfig serverConfig, EurekaClientConfig clientConfig,
ServerCodecs serverCodecs,
ApplicationInfoManager applicationInfoManager) {
super(registry, serverConfig, clientConfig, serverCodecs,
applicationInfoManager);
}
示例13: testHealthCheckHandlerRegistered
import com.netflix.appinfo.ApplicationInfoManager; //导入依赖的package包/类
@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));
}
示例14: initializeApplicationInfoManager
import com.netflix.appinfo.ApplicationInfoManager; //导入依赖的package包/类
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;
}
示例15: update
import com.netflix.appinfo.ApplicationInfoManager; //导入依赖的package包/类
@Override
public void update(ApplicationInfoManager manager, InstanceInfo.InstanceStatus status) {
Preconditions.checkNotNull(manager);
Preconditions.checkNotNull(status);
manager.setInstanceStatus(status);
}