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


Java MyDataCenterInstanceConfig类代码示例

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


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

示例1: doReturn

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

示例2: buildInstanceConfig

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


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