• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java EurekaInstanceConfig类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: eurekaHealthIndicator

import com.netflix.appinfo.EurekaInstanceConfig; //导入依赖的package包/类
@Bean
@ConditionalOnMissingBean
@ConditionalOnEnabledHealthIndicator("eureka")
public EurekaHealthIndicator eurekaHealthIndicator(EurekaClient eurekaClient,
												   EurekaInstanceConfig instanceConfig, EurekaClientConfig clientConfig) {
	return new EurekaHealthIndicator(eurekaClient, instanceConfig, clientConfig);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:8,代码来源:EurekaClientAutoConfiguration.java


示例17: onWhenRequested

import com.netflix.appinfo.EurekaInstanceConfig; //导入依赖的package包/类
@Test
public void onWhenRequested() {
	new ApplicationContextRunner()
		.withConfiguration(AutoConfigurations.of(
			EurekaClientConfigServerAutoConfiguration.class,
			ConfigServerProperties.class, EurekaInstanceConfigBean.class))
		.withPropertyValues("spring.cloud.config.server.prefix=/config")
		.run(c -> {
			assertEquals(1,
				c.getBeanNamesForType(EurekaInstanceConfig.class).length);
			EurekaInstanceConfig instance = c.getBean(EurekaInstanceConfig.class);
			assertEquals("/config", instance.getMetadataMap().get("configPath"));
		});
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:15,代码来源:EurekaClientConfigServerAutoConfigurationTests.java


示例18: DelegatingInstanceConfig

import com.netflix.appinfo.EurekaInstanceConfig; //导入依赖的package包/类
private DelegatingInstanceConfig(EurekaInstanceConfig instanceConfig, DiscoveryNode localNode) {
    this.instanceConfig = instanceConfig;
    this.localNode = localNode;
    this.uuid = UuidUtil.newSecureUuidString();
}
 
开发者ID:hazelcast,项目名称:hazelcast-eureka,代码行数:6,代码来源:EurekaOneDiscoveryStrategy.java


示例19: initDiscoveryManager

import com.netflix.appinfo.EurekaInstanceConfig; //导入依赖的package包/类
@SuppressWarnings("deprecation")
protected void initDiscoveryManager(EurekaInstanceConfig eurekaInstanceConfig,
                                    EurekaClientConfig eurekaClientConfig) {
    DiscoveryManager.getInstance().initComponent(eurekaInstanceConfig, eurekaClientConfig);
}
 
开发者ID:Nike-Inc,项目名称:riposte,代码行数:6,代码来源:EurekaHandler.java


示例20: eurekaDiscoveryManager

import com.netflix.appinfo.EurekaInstanceConfig; //导入依赖的package包/类
/***
 * 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;
}
 
开发者ID:Kixeye,项目名称:chassis,代码行数:58,代码来源:EurekaConfiguration.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java FollowState类代码示例发布时间:2022-05-23
下一篇:
Java OpGroup类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap