本文整理了Java中com.ecwid.consul.v1.Response.isConsulKnownLeader
方法的一些代码示例,展示了Response.isConsulKnownLeader
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Response.isConsulKnownLeader
方法的具体详情如下:
包路径:com.ecwid.consul.v1.Response
类名称:Response
方法名:isConsulKnownLeader
暂无
代码示例来源:origin: alipay/sofa-rpc
public ConsulRouterResp lookupRouterMessage(String serviceName, long lastConsulIndex) {
QueryParams queryParams = new QueryParams(ConsulConstants.CONSUL_BLOCK_TIME_SECONDS, lastConsulIndex);
Response<GetValue> orgResponse = client.getKVValue(serviceName, queryParams);
GetValue getValue = orgResponse.getValue();
if (getValue != null && StringUtils.isNotBlank(getValue.getValue())) {
String router = new String(Base64.decodeBase64(getValue.getValue()));
ConsulRouterResp response = ConsulRouterResp.newResponse()//
.withValue(router)//
.withConsulIndex(orgResponse.getConsulIndex())//
.withConsulLastContact(orgResponse.getConsulLastContact())//
.withConsulKnowLeader(orgResponse.isConsulKnownLeader())//
.build();
return response;
}
return null;
}
代码示例来源:origin: alipay/sofa-rpc
public ConsulRouterResp lookupRouterMessage(String serviceName, long lastConsulIndex) {
QueryParams queryParams = new QueryParams(ConsulConstants.CONSUL_BLOCK_TIME_SECONDS, lastConsulIndex);
Response<GetValue> orgResponse = client.getKVValue(serviceName, queryParams);
GetValue getValue = orgResponse.getValue();
if (getValue != null && StringUtils.isNotBlank(getValue.getValue())) {
String router = new String(Base64.decodeBase64(getValue.getValue()));
ConsulRouterResp response = ConsulRouterResp.newResponse()//
.withValue(router)//
.withConsulIndex(orgResponse.getConsulIndex())//
.withConsulLastContact(orgResponse.getConsulLastContact())//
.withConsulKnowLeader(orgResponse.isConsulKnownLeader())//
.build();
return response;
}
return null;
}
代码示例来源:origin: weibocom/motan
.getConsulLastContact());
newResponse.setConsulKnownLeader(orgResponse
.isConsulKnownLeader());
代码示例来源:origin: alipay/sofa-rpc
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> consulServices = Lists.newArrayList();
for (HealthService orgService : healthServices) {
Service org = orgService.getService();
ConsulService newService = ConsulService.newService()//
.withAddress(org.getAddress())//
.withName(org.getService())//
.withId(org.getId())//
.withPort(org.getPort().toString())//
.withTags(org.getTags())//
.build();
consulServices.add(newService);
}
if (!consulServices.isEmpty()) {
ConsulServiceResp response = ConsulServiceResp.newResponse()//
.withValue(consulServices)//
.withConsulIndex(orgResponse.getConsulIndex())//
.withConsulLastContact(orgResponse.getConsulLastContact())//
.withConsulKnowLeader(orgResponse.isConsulKnownLeader())//
.build();
return response;
}
}
return null;
}
代码示例来源:origin: alipay/sofa-rpc
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> consulServices = Lists.newArrayList();
for (HealthService orgService : healthServices) {
Service org = orgService.getService();
ConsulService newService = ConsulService.newService()//
.withAddress(org.getAddress())//
.withName(org.getService())//
.withId(org.getId())//
.withPort(org.getPort().toString())//
.withTags(org.getTags())//
.build();
consulServices.add(newService);
}
if (!consulServices.isEmpty()) {
ConsulServiceResp response = ConsulServiceResp.newResponse()//
.withValue(consulServices)//
.withConsulIndex(orgResponse.getConsulIndex())//
.withConsulLastContact(orgResponse.getConsulLastContact())//
.withConsulKnowLeader(orgResponse.isConsulKnownLeader())//
.build();
return response;
}
}
return null;
}
代码示例来源:origin: com.alipay.sofa/sofa-rpc-all
public ConsulRouterResp lookupRouterMessage(String serviceName, long lastConsulIndex) {
QueryParams queryParams = new QueryParams(ConsulConstants.CONSUL_BLOCK_TIME_SECONDS, lastConsulIndex);
Response<GetValue> orgResponse = client.getKVValue(serviceName, queryParams);
GetValue getValue = orgResponse.getValue();
if (getValue != null && StringUtils.isNotBlank(getValue.getValue())) {
String router = new String(Base64.decodeBase64(getValue.getValue()));
ConsulRouterResp response = ConsulRouterResp.newResponse()//
.withValue(router)//
.withConsulIndex(orgResponse.getConsulIndex())//
.withConsulLastContact(orgResponse.getConsulLastContact())//
.withConsulKnowLeader(orgResponse.isConsulKnownLeader())//
.build();
return response;
}
return null;
}
代码示例来源:origin: venus-boot/saluki
public ConsulRouterResp lookupRouterMessage(String serviceName, long lastConsulIndex) {
QueryParams queryParams = new QueryParams(ConsulConstants.CONSUL_BLOCK_TIME_SECONDS, lastConsulIndex);
Response<GetValue> orgResponse = client.getKVValue(serviceName, queryParams);
GetValue getValue = orgResponse.getValue();
if (getValue != null && StringUtils.isNoneBlank(getValue.getValue())) {
String router = new String(Base64.decodeBase64(getValue.getValue()));
ConsulRouterResp response = ConsulRouterResp.newResponse()//
.withValue(router)//
.withConsulIndex(orgResponse.getConsulIndex())//
.withConsulLastContact(orgResponse.getConsulLastContact())//
.withConsulKnowLeader(orgResponse.isConsulKnownLeader())//
.build();
return response;
}
return null;
}
代码示例来源:origin: com.weibo/motan-registry-consul
.getConsulLastContact());
newResponse.setConsulKnownLeader(orgResponse
.isConsulKnownLeader());
代码示例来源:origin: venus-boot/saluki
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;
}
代码示例来源:origin: com.alipay.sofa/sofa-rpc-all
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> consulServices = Lists.newArrayList();
for (HealthService orgService : healthServices) {
Service org = orgService.getService();
ConsulService newService = ConsulService.newService()//
.withAddress(org.getAddress())//
.withName(org.getService())//
.withId(org.getId())//
.withPort(org.getPort().toString())//
.withTags(org.getTags())//
.build();
consulServices.add(newService);
}
if (!consulServices.isEmpty()) {
ConsulServiceResp response = ConsulServiceResp.newResponse()//
.withValue(consulServices)//
.withConsulIndex(orgResponse.getConsulIndex())//
.withConsulLastContact(orgResponse.getConsulLastContact())//
.withConsulKnowLeader(orgResponse.isConsulKnownLeader())//
.build();
return response;
}
}
return null;
}
内容来源于网络,如有侵权,请联系作者删除!