當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。