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


Java DefaultEurekaClientConfig类代码示例

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


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

示例1: register

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

示例2: mock

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

示例3: configure

import com.netflix.discovery.DefaultEurekaClientConfig; //导入依赖的package包/类
@Override
protected void configure() {
    LOG.info("Configuring EurekaModule");
    
    // Initialize eureka
    // TODO: Move this to a bootstrap thingy
    DiscoveryManager.getInstance().initComponent(
            new CloudInstanceConfig(),
            new DefaultEurekaClientConfig());

    // Eureka - Astyanax integration
    MapBinder<String, HostSupplierProvider> hostSuppliers = MapBinder.newMapBinder(binder(), String.class, HostSupplierProvider.class);
    hostSuppliers.addBinding("eureka").to(EurekaAstyanaxHostSupplier.class);
    
    //bind(ClusterDiscoveryService.class).to(EurekaClusterDiscoveryService.class).asEagerSingleton();

}
 
开发者ID:Netflix,项目名称:staash,代码行数:18,代码来源:EurekaModule.java

示例4: start

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

示例5: configure

import com.netflix.discovery.DefaultEurekaClientConfig; //导入依赖的package包/类
@Override
protected void configure() {
    LOG.info("Configuring EurekaModule");
    
            DiscoveryManager.getInstance().initComponent(
            new CloudInstanceConfig(),
            new DefaultEurekaClientConfig());

    // Eureka - Astyanax integration
    MapBinder<String, HostSupplierProvider> hostSuppliers = MapBinder.newMapBinder(binder(), String.class, HostSupplierProvider.class);
    hostSuppliers.addBinding("eureka").to(EurekaAstyanaxHostSupplier.class).asEagerSingleton();
    
    //bind(ClusterDiscoveryService.class).to(EurekaClusterDiscoveryService.class).asEagerSingleton();

}
 
开发者ID:Netflix,项目名称:staash,代码行数:16,代码来源:EurekaModule.java

示例6: eurekaClientConfig

import com.netflix.discovery.DefaultEurekaClientConfig; //导入依赖的package包/类
@Bean
@DependsOn("environmentBackedConfig")
EurekaClientConfig eurekaClientConfig(EurekaConfigurationProperties eurekaConfigurationProperties) {
  return new DefaultEurekaClientConfig(eurekaConfigurationProperties.getClient().getNamespace());
}
 
开发者ID:spinnaker,项目名称:kork,代码行数:6,代码来源:EurekaComponents.java

示例7: eurekaDiscoveryManager

import com.netflix.discovery.DefaultEurekaClientConfig; //导入依赖的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.discovery.DefaultEurekaClientConfig类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。