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


Java HealthService类代码示例

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


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

示例1: addInstancesToList

import com.ecwid.consul.v1.health.model.HealthService; //导入依赖的package包/类
private void addInstancesToList(List<ServiceInstance> instances, String serviceId,
		QueryParams queryParams) {

	String aclToken = properties.getAclToken();
	Response<List<HealthService>> services;
	if (StringUtils.hasText(aclToken)) {
		services = client.getHealthServices(serviceId,
				this.properties.getDefaultQueryTag(),
				this.properties.isQueryPassing(), queryParams, aclToken);
	}
	else {
		services = client.getHealthServices(serviceId,
				this.properties.getDefaultQueryTag(),
				this.properties.isQueryPassing(), queryParams);
	}
	for (HealthService service : services.getValue()) {
		String host = findHost(service);
		instances.add(new DefaultServiceInstance(serviceId, host, service
				.getService().getPort(), false, getMetadata(service)));
	}
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-consul,代码行数:22,代码来源:ConsulDiscoveryClient.java

示例2: newServer

import com.ecwid.consul.v1.health.model.HealthService; //导入依赖的package包/类
private ConsulServer newServer(Check.CheckStatus checkStatus) {
	HealthService healthService = new HealthService();
	HealthService.Node node = new HealthService.Node();
	node.setAddress("nodeaddr"+checkStatus.name());
	node.setNode("nodenode"+checkStatus.name());
	healthService.setNode(node);
	HealthService.Service service = new HealthService.Service();
	service.setAddress("serviceaddr"+checkStatus.name());
	service.setId("serviceid"+checkStatus.name());
	service.setPort(8080);
	service.setService("serviceservice"+checkStatus.name());
	healthService.setService(service);
	ArrayList<Check> checks = new ArrayList<>();
	Check check = new Check();
	check.setStatus(checkStatus);
	checks.add(check);
	healthService.setChecks(checks);
	return new ConsulServer(healthService);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-consul,代码行数:20,代码来源:HealthServiceServerListFilterTests.java

示例3: getServiceInstances

import com.ecwid.consul.v1.health.model.HealthService; //导入依赖的package包/类
@Override
protected List<ServerInstance> getServiceInstances(String serviceName) {
    List<ServiceInstance> instances = new ArrayList<>();

    Response<List<HealthService>> healthServices = consulClient.getHealthServices(serviceName, true, QueryParams.DEFAULT);
    for (HealthService healthService : healthServices.getValue()) {
        if (isPassingChecks(healthService)) {
            String host = findHost(healthService);
            instances.add(new DefaultServiceInstance(serviceName, host,
                    healthService.getService().getPort(), false, getMetadata(healthService)));
        }
    }
    return convertToServerInstanceList(instances);
}
 
开发者ID:darren-fu,项目名称:RestyPass,代码行数:15,代码来源:CloudConsulServerContext.java

示例4: isPassingChecks

import com.ecwid.consul.v1.health.model.HealthService; //导入依赖的package包/类
/**
 * Is passing checks boolean.
 *
 * @param service the service
 * @return the boolean
 */
public boolean isPassingChecks(HealthService service) {
    for (Check check : service.getChecks()) {
        if (check.getStatus() != Check.CheckStatus.PASSING) {
            return false;
        }
    }
    return true;
}
 
开发者ID:darren-fu,项目名称:RestyPass,代码行数:15,代码来源:CloudConsulServerContext.java

示例5: findHost

import com.ecwid.consul.v1.health.model.HealthService; //导入依赖的package包/类
private static String findHost(HealthService healthService) {
    HealthService.Service service = healthService.getService();
    HealthService.Node node = healthService.getNode();

    if (org.springframework.util.StringUtils.hasText(service.getAddress())) {
        return service.getAddress();
    } else if (org.springframework.util.StringUtils.hasText(node.getAddress())) {
        return node.getAddress();
    }
    return node.getNode();
}
 
开发者ID:darren-fu,项目名称:RestyPass,代码行数:12,代码来源:CloudConsulServerContext.java

示例6: lookupHealthService

import com.ecwid.consul.v1.health.model.HealthService; //导入依赖的package包/类
public ConsulServiceResp lookupHealthService(String serviceName, long lastConsulIndex) {
    QueryParams queryParams = new QueryParams(ConsulConstants.CONSUL_BLOCK_TIME_SECONDS, lastConsulIndex);
    Response<List<HealthService>> orgResponse = client.getHealthServices(serviceName, true, queryParams);
    if (orgResponse != null && orgResponse.getValue() != null && !orgResponse.getValue().isEmpty()) {
        List<HealthService> HealthServices = orgResponse.getValue();
        List<ConsulService> ConsulServcies = Lists.newArrayList();
        for (HealthService orgService : HealthServices) {
            Service org = orgService.getService();
            ConsulService newService = ConsulService.newSalukiService()//
                                                    .withAddress(org.getAddress())//
                                                    .withName(org.getService())//
                                                    .withId(org.getId())//
                                                    .withPort(org.getPort().toString())//
                                                    .withTags(org.getTags())//
                                                    .build();
            ConsulServcies.add(newService);
        }
        if (!ConsulServcies.isEmpty()) {
            ConsulServiceResp response = ConsulServiceResp.newResponse()//
                                                          .withValue(ConsulServcies)//
                                                          .withConsulIndex(orgResponse.getConsulIndex())//
                                                          .withConsulLastContact(orgResponse.getConsulLastContact())//
                                                          .withConsulKnowLeader(orgResponse.isConsulKnownLeader())//
                                                          .build();
            return response;
        }
    }
    return null;
}
 
开发者ID:venus-boot,项目名称:saluki,代码行数:30,代码来源:ConsulClient.java

示例7: getProviderUrls

import com.ecwid.consul.v1.health.model.HealthService; //导入依赖的package包/类
public List<URL> getProviderUrls(String serviceName) {
    List<URL> urls = new ArrayList<>();
    Response<List<HealthService>> healthServices = consulClient.getHealthServices(serviceName, true, null);
    for (HealthService healthService : healthServices.getValue()) {
        urls.add(URL.valueOf(healthService.getService().getAddress()));
    }
    return urls;
}
 
开发者ID:linux-china,项目名称:dubbo3,代码行数:9,代码来源:NotifyListenerConsulWrapper.java

示例8: findHost

import com.ecwid.consul.v1.health.model.HealthService; //导入依赖的package包/类
public static String findHost(HealthService healthService) {
    HealthService.Service service = healthService.getService();
    HealthService.Node node = healthService.getNode();

    if (StringUtils.isNotBlank(service.getAddress())) {
        return service.getAddress();
    } else if (StringUtils.isNotBlank(node.getAddress())) {
        return node.getAddress();
    }
    return node.getNode();
}
 
开发者ID:Netflix,项目名称:dyno,代码行数:12,代码来源:ConsulHelper.java

示例9: findHost

import com.ecwid.consul.v1.health.model.HealthService; //导入依赖的package包/类
public static String findHost(HealthService healthService) {
	HealthService.Service service = healthService.getService();
	HealthService.Node node = healthService.getNode();

	if (StringUtils.hasText(service.getAddress())) {
		return fixIPv6Address(service.getAddress());
	} else if (StringUtils.hasText(node.getAddress())) {
		return fixIPv6Address(node.getAddress());
	}
	return node.getNode();
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-consul,代码行数:12,代码来源:ConsulServerUtils.java

示例10: ConsulServer

import com.ecwid.consul.v1.health.model.HealthService; //导入依赖的package包/类
public ConsulServer(final HealthService healthService) {
	super(findHost(healthService), healthService.getService().getPort());
	this.service = healthService;
	this.metadata = ConsulServerUtils.getMetadata(this.service);
	metaInfo = new MetaInfo() {
		@Override
		public String getAppName() {
			return service.getService().getService();
		}

		@Override
		public String getServerGroup() {
			return getMetadata().get("group");
		}

		@Override
		public String getServiceIdForDiscovery() {
			return null;
		}

		@Override
		public String getInstanceId() {
			return service.getService().getId();
		}
	};

	setAlive(isPassingChecks());
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-consul,代码行数:29,代码来源:ConsulServer.java

示例11: getServers

import com.ecwid.consul.v1.health.model.HealthService; //导入依赖的package包/类
private List<ConsulServer> getServers() {
	if (this.client == null) {
		return Collections.emptyList();
	}
	String tag = getTag(); // null is ok
	Response<List<HealthService>> response = this.client.getHealthServices(
			this.serviceId, tag, this.properties.isQueryPassing(),
			createQueryParamsForClientRequest(), this.properties.getAclToken());
	if (response.getValue() == null || response.getValue().isEmpty()) {
		return Collections.emptyList();
	}
	return transformResponse(response.getValue());
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-consul,代码行数:14,代码来源:ConsulServerList.java

示例12: transformResponse

import com.ecwid.consul.v1.health.model.HealthService; //导入依赖的package包/类
/**
 * Transforms the response from Consul in to a list of usable {@link ConsulServer}s.
 *
 * @param healthServices the initial list of servers from Consul. Guaranteed to be non-empty list
 * @return ConsulServer instances
 * @see ConsulServer#ConsulServer(HealthService)
 */
protected List<ConsulServer> transformResponse(List<HealthService> healthServices) {
	List<ConsulServer> servers = new ArrayList<>();
	for (HealthService service : healthServices) {
		ConsulServer server = new ConsulServer(service);
		if (server.getMetadata().containsKey(this.properties.getDefaultZoneMetadataName())) {
			server.setZone(server.getMetadata().get(this.properties.getDefaultZoneMetadataName()));
		}
		servers.add(server);
	}
	return servers;
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-consul,代码行数:19,代码来源:ConsulServerList.java

示例13: getMetadata

import com.ecwid.consul.v1.health.model.HealthService; //导入依赖的package包/类
private static Map<String, String> getMetadata(HealthService healthService) {
    return getMetadata(healthService.getService().getTags());
}
 
开发者ID:darren-fu,项目名称:RestyPass,代码行数:4,代码来源:CloudConsulServerContext.java

示例14: getHealthServices

import com.ecwid.consul.v1.health.model.HealthService; //导入依赖的package包/类
@Override
public Response<List<HealthService>> getHealthServices(String serviceName,
		boolean onlyPassing, QueryParams queryParams) {
	return wrapped.getHealthServices(serviceName, onlyPassing, queryParams);
}
 
开发者ID:flyaruu,项目名称:tasman,代码行数:6,代码来源:ConsulOSGiClient.java

示例15: getHealthServices

import com.ecwid.consul.v1.health.model.HealthService; //导入依赖的package包/类
@Override
public Response<List<HealthService>> getHealthServices(String serviceName, boolean onlyPassing, QueryParams queryParams) {
	return healthClient.getHealthServices(serviceName, onlyPassing, queryParams);
}
 
开发者ID:flyaruu,项目名称:tasman,代码行数:5,代码来源:ConsulClient.java


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