本文整理汇总了Java中org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean类的典型用法代码示例。如果您正苦于以下问题:Java EurekaInstanceConfigBean类的具体用法?Java EurekaInstanceConfigBean怎么用?Java EurekaInstanceConfigBean使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EurekaInstanceConfigBean类属于org.springframework.cloud.netflix.eureka包,在下文中一共展示了EurekaInstanceConfigBean类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setup
import org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean; //导入依赖的package包/类
@Before
public void setup() {
eurekaHttpClient = new RestTemplateTransportClientFactory()
.newClient(new DefaultEndpoint(serviceUrl));
EurekaInstanceConfigBean config = new EurekaInstanceConfigBean(inetUtils);
String appname = "customapp";
config.setIpAddress("127.0.0.1");
config.setHostname("localhost");
config.setAppname(appname);
config.setVirtualHostName(appname);
config.setSecureVirtualHostName(appname);
config.setNonSecurePort(4444);
config.setSecurePort(8443);
config.setInstanceId("127.0.0.1:customapp:4444");
info = new EurekaConfigBasedInstanceInfoProvider(config).get();
}
示例2: get
import org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean; //导入依赖的package包/类
@Override
public ManagementMetadata get(EurekaInstanceConfigBean instance, int serverPort,
String serverContextPath, String managementContextPath,
Integer managementPort) {
if (isRandom(managementPort)) {
return null;
}
if (managementPort == null && isRandom(serverPort)) {
return null;
}
String healthCheckUrl = getHealthCheckUrl(instance, serverPort, serverContextPath,
managementContextPath, managementPort);
String statusPageUrl = getStatusPageUrl(instance, serverPort, serverContextPath,
managementContextPath, managementPort);
return new ManagementMetadata(healthCheckUrl, statusPageUrl, managementPort == null ? serverPort : managementPort);
}
示例3: basicConfigurationCreatedForLoadBalancer
import org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean; //导入依赖的package包/类
@Test
@Ignore
public void basicConfigurationCreatedForLoadBalancer() {
EurekaClientConfigBean client = new EurekaClientConfigBean();
EurekaInstanceConfigBean configBean = getEurekaInstanceConfigBean();
client.getAvailabilityZones().put(client.getRegion(), "foo");
SpringClientFactory clientFactory = new SpringClientFactory();
EurekaRibbonClientConfiguration clientPreprocessor = new EurekaRibbonClientConfiguration(
client, "service", configBean, false);
clientPreprocessor.preprocess();
ILoadBalancer balancer = clientFactory.getLoadBalancer("service");
assertNotNull(balancer);
@SuppressWarnings("unchecked")
ZoneAwareLoadBalancer<DiscoveryEnabledServer> aware = (ZoneAwareLoadBalancer<DiscoveryEnabledServer>) balancer;
assertTrue(aware.getServerListImpl() instanceof DomainExtractingServerList);
assertEquals("foo",
ConfigurationManager.getDeploymentContext().getValue(ContextKey.zone));
}
示例4: testSetProp
import org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean; //导入依赖的package包/类
@Test
public void testSetProp() {
EurekaClientConfigBean client = new EurekaClientConfigBean();
EurekaInstanceConfigBean configBean = getEurekaInstanceConfigBean();
EurekaRibbonClientConfiguration preprocessor = new EurekaRibbonClientConfiguration(
client, "myService", configBean, false);
String serviceId = "myService";
String suffix = "mySuffix";
String value = "myValue";
DynamicStringProperty property = getProperty(getRibbonKey(serviceId, suffix));
assertEquals("property doesn't have default value", VALUE_NOT_SET,
property.get());
setRibbonProperty(serviceId, suffix, value);
assertEquals("property has wrong value", value, property.get());
setRibbonProperty(serviceId, suffix, value);
assertEquals("property has wrong value", value, property.get());
}
示例5: eurekaClientNotShutdownInDeregister
import org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean; //导入依赖的package包/类
@Test
public void eurekaClientNotShutdownInDeregister() {
EurekaServiceRegistry registry = new EurekaServiceRegistry();
CloudEurekaClient eurekaClient = mock(CloudEurekaClient.class);
ApplicationInfoManager applicationInfoManager = mock(ApplicationInfoManager.class);
when(applicationInfoManager.getInfo()).thenReturn(mock(InstanceInfo.class));
EurekaRegistration registration = EurekaRegistration.builder(new EurekaInstanceConfigBean(new InetUtils(new InetUtilsProperties())))
.with(eurekaClient)
.with(applicationInfoManager)
.with(new EurekaClientConfigBean(), mock(ApplicationEventPublisher.class))
.build();
registry.deregister(registration);
verifyZeroInteractions(eurekaClient);
}
示例6: register
import org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean; //导入依赖的package包/类
@RequestMapping(path = "/register", method = POST)
public String register() {
EurekaInstanceConfigBean config = new EurekaInstanceConfigBean(inetUtils);
String appname = "customapp";
config.setIpAddress("127.0.0.1");
config.setHostname("localhost");
config.setAppname(appname);
config.setVirtualHostName(appname);
config.setSecureVirtualHostName(appname);
config.setNonSecurePort(4444);
config.setInstanceId("127.0.0.1:customapp:4444");
this.registration = EurekaRegistration.builder(config)
.with(this.clientConfig, this.context)
.build();
this.serviceRegistry.register(this.registration);
return config.getInstanceId();
}
示例7: eurekaInstanceConfig
import org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean; //导入依赖的package包/类
@Bean
/**
* Dynamically assign the hosts IP address to this instances of the Eureka Client
*
* @param inetUtils Java Networks Utilities
* @return An instance of a EurekaInstanceConfigBean with dynamically configured IP address
*/
public EurekaInstanceConfigBean eurekaInstanceConfig(InetUtils inetUtils){
EurekaInstanceConfigBean config = new EurekaInstanceConfigBean(inetUtils);
String ip = null;
String urlPattern = "http://{0}:{1}{2}";
try {
// Get the IP address of the current host using Java Network Utils
ip = InetAddress.getLocalHost().getHostAddress();
} catch (UnknownHostException e) {
e.printStackTrace();
}
config.setIpAddress(ip);
config.setPreferIpAddress(true);
// Build the Status Page URL specific to this instances IP Address
String statusPageUrl = MessageFormat.format(urlPattern,
config.getIpAddress(),
port,
config.getStatusPageUrlPath());
config.setStatusPageUrl(statusPageUrl);
// Build the Health Page URL specific to this instances IP Address
String healthPageUrl = MessageFormat.format(urlPattern,
config.getIpAddress(),
port,
config.getHealthCheckUrlPath());
config.setHealthCheckUrl(healthPageUrl);
return config;
}
示例8: LoggingConfiguration
import org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean; //导入依赖的package包/类
public LoggingConfiguration(@Value("${spring.application.name}") String appName, @Value("${server.port}") String serverPort,
EurekaInstanceConfigBean eurekaInstanceConfigBean, JHipsterProperties jHipsterProperties, @Value("${info.project.version}") String version) {
this.appName = appName;
this.serverPort = serverPort;
this.eurekaInstanceConfigBean = eurekaInstanceConfigBean;
this.jHipsterProperties = jHipsterProperties;
this.version = version;
if (jHipsterProperties.getLogging().getLogstash().isEnabled()) {
addLogstashAppender(context);
addContextListener(context);
}
if (jHipsterProperties.getMetrics().getLogs().isEnabled()) {
setMetricsMarkerLogbackFilter(context);
}
}
示例9: getInstanceInfo
import org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean; //导入依赖的package包/类
public InstanceInfo getInstanceInfo(Application application) {
EurekaInstanceConfigBean instanceConfig = new EurekaInstanceConfigBean(inetUtils);
instanceConfig.setInstanceEnabledOnit(true);
instanceConfig.setAppname(application.getName());
instanceConfig.setVirtualHostName(application.getName());
instanceConfig.setInstanceId(application.getInstance_id());
instanceConfig.setHostname(application.getHostname());
instanceConfig.setNonSecurePort(application.getPort());
return new InstanceInfoFactory().create(instanceConfig);
}
示例10: getHealthCheckUrl
import org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean; //导入依赖的package包/类
private String getHealthCheckUrl(EurekaInstanceConfigBean instance, int serverPort, String serverContextPath,
String managementContextPath, Integer managementPort) {
String healthCheckUrlPath = instance.getHealthCheckUrlPath();
String healthCheckUrl = getUrl(instance, serverPort, serverContextPath, managementContextPath,
managementPort, healthCheckUrlPath);
log.debug("Constructed eureka meta-data healthcheckUrl: " + healthCheckUrl);
return healthCheckUrl;
}
示例11: getStatusPageUrl
import org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean; //导入依赖的package包/类
public String getStatusPageUrl(EurekaInstanceConfigBean instance, int serverPort, String serverContextPath,
String managementContextPath, Integer managementPort) {
String statusPageUrlPath = instance.getStatusPageUrlPath();
String statusPageUrl = getUrl(instance, serverPort, serverContextPath, managementContextPath,
managementPort, statusPageUrlPath);
log.debug("Constructed eureka meta-data statusPageUrl: " + statusPageUrl);
return statusPageUrl;
}
示例12: getUrl
import org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean; //导入依赖的package包/类
private String getUrl(EurekaInstanceConfigBean instance, int serverPort,
String serverContextPath, String managementContextPath,
Integer managementPort, String urlPath) {
managementContextPath = refineManagementContextPath(serverContextPath, managementContextPath, managementPort);
if (managementPort == null) {
managementPort = serverPort;
}
String scheme = instance.getSecurePortEnabled() ? "https" : "http";
return constructValidUrl(scheme, instance.getHostname(), managementPort, managementContextPath, urlPath);
}
示例13: testExplicitZone
import org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean; //导入依赖的package包/类
@Test
public void testExplicitZone() {
EurekaClientConfigBean client = new EurekaClientConfigBean();
EurekaInstanceConfigBean configBean = getEurekaInstanceConfigBean();
configBean.getMetadataMap().put("zone", "myZone");
EurekaRibbonClientConfiguration preprocessor = new EurekaRibbonClientConfiguration(
client, "myService", configBean, false);
preprocessor.preprocess();
assertEquals("myZone",
ConfigurationManager.getDeploymentContext().getValue(ContextKey.zone));
}
示例14: testDefaultZone
import org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean; //导入依赖的package包/类
@Test
public void testDefaultZone() {
EurekaClientConfigBean client = new EurekaClientConfigBean();
EurekaInstanceConfigBean configBean = getEurekaInstanceConfigBean();
EurekaRibbonClientConfiguration preprocessor = new EurekaRibbonClientConfiguration(
client, "myService", configBean, false);
preprocessor.preprocess();
assertEquals("defaultZone",
ConfigurationManager.getDeploymentContext().getValue(ContextKey.zone));
}
示例15: testApproximateZone
import org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean; //导入依赖的package包/类
@Test
public void testApproximateZone() {
EurekaClientConfigBean client = new EurekaClientConfigBean();
EurekaInstanceConfigBean configBean = getEurekaInstanceConfigBean();
configBean.setHostname("this.is.a.test.com");
EurekaRibbonClientConfiguration preprocessor = new EurekaRibbonClientConfiguration(
client, "myService", configBean, true);
preprocessor.preprocess();
assertEquals("is.a.test.com",
ConfigurationManager.getDeploymentContext().getValue(ContextKey.zone));
}