当前位置: 首页>>代码示例>>Java>>正文


Java EurekaClient类代码示例

本文整理汇总了Java中com.netflix.discovery.EurekaClient的典型用法代码示例。如果您正苦于以下问题:Java EurekaClient类的具体用法?Java EurekaClient怎么用?Java EurekaClient使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


EurekaClient类属于com.netflix.discovery包,在下文中一共展示了EurekaClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testInstanceRegistrationUsingProvidedEurekaClient

import com.netflix.discovery.EurekaClient; //导入依赖的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);
}
 
开发者ID:hazelcast,项目名称:hazelcast-eureka,代码行数:27,代码来源:HazelcastClientTestCase.java

示例2: onWhenRequested

import com.netflix.discovery.EurekaClient; //导入依赖的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

示例3: testFailIfDiscoveryIsNotAvailable

import com.netflix.discovery.EurekaClient; //导入依赖的package包/类
@Test(expected = IllegalStateException.class)
public void testFailIfDiscoveryIsNotAvailable() {
    EurekaNotificationServerListUpdater serverListUpdater = new EurekaNotificationServerListUpdater(
            new Provider<EurekaClient>() {
                @Override
                public EurekaClient get() {
                    return null;
                }
            },
            testExecutor
    );

    serverListUpdater.start(new ServerListUpdater.UpdateAction() {
        @Override
        public void doUpdate() {
            Assert.fail("Should not reach here");
        }
    });
}
 
开发者ID:Netflix,项目名称:ribbon,代码行数:20,代码来源:EurekaNotificationServerListUpdaterTest.java

示例4: setUp

import com.netflix.discovery.EurekaClient; //导入依赖的package包/类
@Before
public void setUp() {
    PowerMock.mockStatic(DiscoveryClient.class);

    EasyMock
            .expect(DiscoveryClient.getZone(EasyMock.isA(InstanceInfo.class)))
            .andReturn("zone")
            .anyTimes();

    eurekaClientMock = setUpEurekaClientMock(servers);
    eurekaClientProvider = new Provider<EurekaClient>() {
        @Override
        public EurekaClient get() {
            return eurekaClientMock;
        }
    };

    config = DefaultClientConfigImpl.getClientConfigWithDefaultValues();
    config.setProperty(CommonClientConfigKey.DeploymentContextBasedVipAddresses, vipAddress);
    config.setProperty(CommonClientConfigKey.ServerListUpdaterClassName, EurekaNotificationServerListUpdater.class.getName());
}
 
开发者ID:Netflix,项目名称:ribbon,代码行数:22,代码来源:EurekaDynamicServerListLoadBalancerTest.java

示例5: setUpEurekaClientMock

import com.netflix.discovery.EurekaClient; //导入依赖的package包/类
private EurekaClient setUpEurekaClientMock(List<InstanceInfo> servers) {
    final EurekaClient eurekaClientMock = PowerMock.createMock(EurekaClient.class);

    EasyMock
            .expect(eurekaClientMock.getInstancesByVipAddress(EasyMock.anyString(), EasyMock.anyBoolean(), EasyMock.anyString()))
            .andReturn(servers.subList(0, initialServerListSize)).times(1)
            .andReturn(servers.subList(initialServerListSize, servers.size())).anyTimes();

    EasyMock
            .expectLastCall();

    EasyMock
            .expect(eurekaClientMock.unregisterEventListener(EasyMock.isA(EurekaEventListener.class)))
            .andReturn(true).anyTimes();

    return eurekaClientMock;
}
 
开发者ID:Netflix,项目名称:ribbon,代码行数:18,代码来源:EurekaDynamicServerListLoadBalancerTest.java

示例6: EurekaServerRelationshipDetector

import com.netflix.discovery.EurekaClient; //导入依赖的package包/类
/**
 * Eureka Server relationship detector.
 * 
 * @param eurekaClients
 *            Eureka Client instances available (nullable).
 */
public EurekaServerRelationshipDetector(List<EurekaClient> eurekaClients) {
    this.eurekaClients = new ArrayList<>();
    if (eurekaClients != null) {
        this.eurekaClients.addAll(eurekaClients);
    }
}
 
开发者ID:cereebro,项目名称:cereebro,代码行数:13,代码来源:EurekaServerRelationshipDetector.java

示例7: multipleEurekaClientsShouldReturnSingleDependencyOnEurekaServer

import com.netflix.discovery.EurekaClient; //导入依赖的package包/类
@Test
public void multipleEurekaClientsShouldReturnSingleDependencyOnEurekaServer() {
    EurekaClient eurekaClientMock = Mockito.mock(EurekaClient.class);
    EurekaServerRelationshipDetector detector = new EurekaServerRelationshipDetector(
            Arrays.asList(eurekaClientMock));
    Dependency dependency = Dependency.on(Component.of("eureka-server", ComponentType.HTTP_APPLICATION_REGISTRY));
    Set<Relationship> expected = new HashSet<>(Arrays.asList(dependency));
    Assertions.assertThat(detector.detect()).isEqualTo(expected);
}
 
开发者ID:cereebro,项目名称:cereebro,代码行数:10,代码来源:EurekaServerRelationshipDetectorTest.java

示例8: InstanceRegistry

import com.netflix.discovery.EurekaClient; //导入依赖的package包/类
public InstanceRegistry(EurekaServerConfig serverConfig,
		EurekaClientConfig clientConfig, ServerCodecs serverCodecs,
		EurekaClient eurekaClient, int expectedNumberOfRenewsPerMin,
		int defaultOpenForTrafficCount) {
	super(serverConfig, clientConfig, serverCodecs, eurekaClient);

	this.expectedNumberOfRenewsPerMin = expectedNumberOfRenewsPerMin;
	this.defaultOpenForTrafficCount = defaultOpenForTrafficCount;
}
 
开发者ID:dyc87112,项目名称:didi-eureka-server,代码行数:10,代码来源:InstanceRegistry.java

示例9: getEurekaClient

import com.netflix.discovery.EurekaClient; //导入依赖的package包/类
private EurekaClient getEurekaClient(){
	if (eurekaClient==null){
		LifecycleInjectorBuilder builder = LifecycleInjector.builder();
		Injector injector = builder.build().createInjector();
		eurekaClient = injector.getInstance(EurekaClient.class);
	}
	return eurekaClient;
}
 
开发者ID:diegopacheco,项目名称:Building_Effective_Microservices,代码行数:9,代码来源:BaseRibbonTemplate.java

示例10: testHealthCheckHandlerRegistered

import com.netflix.discovery.EurekaClient; //导入依赖的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));
}
 
开发者ID:Netflix,项目名称:runtime-health,代码行数:13,代码来源:EurekaHealthStatusBridgeModuleTest.java

示例11: setEurekaClient

import com.netflix.discovery.EurekaClient; //导入依赖的package包/类
EurekaOneDiscoveryStrategyBuilder setEurekaClient(final EurekaClient eurekaClient) {
    this.eurekaClient = eurekaClient;
    if (eurekaClient != null) {
        this.applicationInfoManager = eurekaClient.getApplicationInfoManager();
        this.changeStrategy = new NoopUpdater();
    }
    return this;
}
 
开发者ID:hazelcast,项目名称:hazelcast-eureka,代码行数:9,代码来源:EurekaOneDiscoveryStrategy.java

示例12: CompositeInfoEndpoint

import com.netflix.discovery.EurekaClient; //导入依赖的package包/类
@SuppressWarnings("SpringJavaAutowiringInspection")
@Autowired
public CompositeInfoEndpoint(RestTemplate loadBalancedRestTemplate, DiscoveryClient discoveryClient, EurekaClient eurekaClient) {
	this.restTemplate = new RestTemplate(new HttpComponentsClientHttpRequestFactory(
			HttpClientBuilder.create().setSSLHostnameVerifier((s, sslSession) -> true).build()));

	this.loadBalancedRestTemplate = loadBalancedRestTemplate;
	this.discoveryClient = discoveryClient;
	this.eurekaClient = eurekaClient;
}
 
开发者ID:reportportal,项目名称:service-gateway,代码行数:11,代码来源:CompositeInfoEndpoint.java

示例13: configure

import com.netflix.discovery.EurekaClient; //导入依赖的package包/类
@Override
protected void configure() {
    bind(ApplicationInfoManager.class).in(Scopes.SINGLETON);
    bind(EurekaClientConfig.class).in(Scopes.SINGLETON);
    bind(InstanceInfo.class).in(Scopes.SINGLETON);
    bind(EurekaClient.class).in(Scopes.SINGLETON);

    bind(EurekaHealthCheck.class).asEagerSingleton();
    bind(EurekaService.class).asEagerSingleton();
}
 
开发者ID:schibsted,项目名称:ratpack-eureka,代码行数:11,代码来源:EurekaModule.java

示例14: ribbonServerList

import com.netflix.discovery.EurekaClient; //导入依赖的package包/类
@Bean
@ConditionalOnMissingBean
public ServerList<?> ribbonServerList(IClientConfig config, Provider<EurekaClient> eurekaClientProvider) {
	if (this.propertiesFactory.isSet(ServerList.class, serviceId)) {
		return this.propertiesFactory.get(ServerList.class, config, serviceId);
	}
	DiscoveryEnabledNIWSServerList discoveryServerList = new DiscoveryEnabledNIWSServerList(
			config, eurekaClientProvider);
	DomainExtractingServerList serverList = new DomainExtractingServerList(
			discoveryServerList, config, this.approximateZoneFromHostname);
	return serverList;
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:13,代码来源:EurekaRibbonClientConfiguration.java

示例15: EurekaHealthIndicator

import com.netflix.discovery.EurekaClient; //导入依赖的package包/类
public EurekaHealthIndicator(EurekaClient eurekaClient,
		EurekaInstanceConfig instanceConfig, EurekaClientConfig clientConfig) {
	super();
	this.eurekaClient = eurekaClient;
	this.instanceConfig = instanceConfig;
	this.clientConfig = clientConfig;
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:8,代码来源:EurekaHealthIndicator.java


注:本文中的com.netflix.discovery.EurekaClient类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。