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


Java EurekaInstanceConfig类代码示例

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


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

示例1: testInstanceRegistrationUsingProvidedEurekaClient

import com.netflix.appinfo.EurekaInstanceConfig; //导入依赖的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: register

import com.netflix.appinfo.EurekaInstanceConfig; //导入依赖的package包/类
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);
}
 
开发者ID:Nike-Inc,项目名称:riposte,代码行数:17,代码来源:EurekaHandler.java

示例3: beforeMethod

import com.netflix.appinfo.EurekaInstanceConfig; //导入依赖的package包/类
@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());
}
 
开发者ID:Nike-Inc,项目名称:riposte,代码行数:18,代码来源:EurekaHandlerTest.java

示例4: mock

import com.netflix.appinfo.EurekaInstanceConfig; //导入依赖的package包/类
@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);
}
 
开发者ID:Nike-Inc,项目名称:riposte,代码行数:24,代码来源:EurekaHandlerTest.java

示例5: doReturn

import com.netflix.appinfo.EurekaInstanceConfig; //导入依赖的package包/类
@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);
}
 
开发者ID:Nike-Inc,项目名称:riposte,代码行数:20,代码来源:EurekaHandlerTest.java

示例6: createEurekaInstanceConfig_returns_CloudInstanceConfig_when_datacenterType_is_amazon_or_netflix

import com.netflix.appinfo.EurekaInstanceConfig; //导入依赖的package包/类
@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);
}
 
开发者ID:Nike-Inc,项目名称:riposte,代码行数:19,代码来源:EurekaHandlerTest.java

示例7: initializeApplicationInfoManager

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

示例8: buildInstanceConfig

import com.netflix.appinfo.EurekaInstanceConfig; //导入依赖的package包/类
private EurekaInstanceConfig buildInstanceConfig(DiscoveryNode localNode) {
    try {

        String configProperty = DynamicPropertyFactory
                .getInstance()
                .getStringProperty("eureka.client.props", "eureka-client")
                .get();

        String eurekaPropertyFile = String.format("%s.properties", configProperty);
        ClassLoader loader = Thread.currentThread().getContextClassLoader();
        URL url = loader.getResource(eurekaPropertyFile);
        if (url == null) {
            throw new IllegalStateException("Cannot locate " + eurekaPropertyFile + " as a classpath resource.");
        }
        Properties props = new Properties();
        props.load(url.openStream());

        String key = String.format("%s.datacenter", this.namespace);
        String value = props.getProperty(key, "");
        if ("cloud".equals(value.trim().toLowerCase())) {
            return new DelegatingInstanceConfig(new CloudInstanceConfig(this.namespace), localNode);
        }
        return new DelegatingInstanceConfig(new MyDataCenterInstanceConfig(this.namespace), localNode);
    } catch (IOException e) {
        throw new IllegalStateException("Cannot build EurekaInstanceInfo", e);
    }
}
 
开发者ID:hazelcast,项目名称:hazelcast-eureka,代码行数:28,代码来源:EurekaOneDiscoveryStrategy.java

示例9: register_does_nothing_if_eureka_is_disabled

import com.netflix.appinfo.EurekaInstanceConfig; //导入依赖的package包/类
@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));
}
 
开发者ID:Nike-Inc,项目名称:riposte,代码行数:15,代码来源:EurekaHandlerTest.java

示例10: register_does_nothing_if_already_registered

import com.netflix.appinfo.EurekaInstanceConfig; //导入依赖的package包/类
@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));
}
 
开发者ID:Nike-Inc,项目名称:riposte,代码行数:15,代码来源:EurekaHandlerTest.java

示例11: start

import com.netflix.appinfo.EurekaInstanceConfig; //导入依赖的package包/类
@Override
public void start() throws Exception {
   EurekaClientConfiguration eurekaClientConfiguration = configuration.getEureka();
   ServerFactory serverFactory = configuration.getServerFactory();

   BaseConfiguration baseConfiguration = new BaseConfiguration();
   baseConfiguration.setProperty(eurekaNamespace + "name", eurekaClientConfiguration.getName());
   baseConfiguration.setProperty(eurekaNamespace + "vipAddress", eurekaClientConfiguration.getVipAddress());
   baseConfiguration.setProperty(eurekaNamespace + "serviceUrl.default", eurekaClientConfiguration.getDefaultServiceUrl());
   baseConfiguration.setProperty(eurekaNamespace + "port", eurekaClientConfiguration.getPort());

   Integer port = DropwizardServerHelpers.getPort(serverFactory);
   Integer adminPort = DropwizardServerHelpers.getAdminPort(serverFactory);

   baseConfiguration.setProperty(eurekaNamespace + "healthCheckUrl", String.format("http://${eureka.hostname}:%d/healthcheck", adminPort));
   baseConfiguration.setProperty(eurekaNamespace + "secureHealthCheckUrl", String.format("http://${eureka.hostname}:%d/healthcheck", adminPort));
   baseConfiguration.setProperty(eurekaNamespace + "statusPageUrl", String.format("http://${eureka.hostname}:%d/healthcheck", adminPort));
   ConfigurationManager.loadPropertiesFromConfiguration(baseConfiguration);

   EurekaInstanceConfig eurekaInstanceConfig = createEurekaInstanceConfig(discoveryMetadataProviders);

   DiscoveryManager.getInstance().initComponent(eurekaInstanceConfig, new DefaultEurekaClientConfig(eurekaNamespace));

   DiscoveryManager.getInstance().getDiscoveryClient().registerHealthCheckCallback(healthCheck);

   markAsUp();
}
 
开发者ID:guggens,项目名称:log-dropwizard-eureka-mongo-sample,代码行数:28,代码来源:EurekaInstance.java

示例12: createEurekaInstanceConfig

import com.netflix.appinfo.EurekaInstanceConfig; //导入依赖的package包/类
protected EurekaInstanceConfig createEurekaInstanceConfig(Collection<DiscoveryMetadataProvider> discoveryMetadataProviders) {
   if(datacenterType.toLowerCase().equals("developer")) {
      return new DeveloperMachineDataCenterInstanceConfig(eurekaNamespace, discoveryMetadataProviders);
   }
   if(datacenterType.toLowerCase().equals("amazon")) {
      // return new CloudInstanceConfig(eurekaNamespace);
   }
   // return new MyDataCenterInstanceConfig(eurekaNamespace);
   throw new RuntimeException("TODO: Make other InstanceConfig's work with metadata providers.");
}
 
开发者ID:guggens,项目名称:log-dropwizard-eureka-mongo-sample,代码行数:11,代码来源:EurekaInstance.java

示例13: EurekaRibbonClientConfiguration

import com.netflix.appinfo.EurekaInstanceConfig; //导入依赖的package包/类
public EurekaRibbonClientConfiguration(EurekaClientConfig clientConfig,
		String serviceId, EurekaInstanceConfig eurekaConfig,
		boolean approximateZoneFromHostname) {
	this.clientConfig = clientConfig;
	this.serviceId = serviceId;
	this.eurekaConfig = eurekaConfig;
	this.approximateZoneFromHostname = approximateZoneFromHostname;
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:9,代码来源:EurekaRibbonClientConfiguration.java

示例14: EurekaHealthIndicator

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

示例15: eurekaApplicationInfoManager

import com.netflix.appinfo.EurekaInstanceConfig; //导入依赖的package包/类
@Bean
@ConditionalOnMissingBean(value = ApplicationInfoManager.class, search = SearchStrategy.CURRENT)
public ApplicationInfoManager eurekaApplicationInfoManager(
		EurekaInstanceConfig config) {
	InstanceInfo instanceInfo = new InstanceInfoFactory().create(config);
	return new ApplicationInfoManager(config, instanceInfo);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:8,代码来源:EurekaClientAutoConfiguration.java


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