use of com.recurly.v3.QueryParams in project dawdler-series by srchen1987.
the class ConsulConfigClient method start.
@Override
public void start() {
if (watchKeys != null) {
for (String watchKey : watchKeys) {
long updateIndex = flushCache(watchKey);
executor.execute(() -> {
try {
long index = updateIndex;
while (start) {
Response<List<String>> responseKeys = client.getKVKeysOnly(watchKey, separator, token, new QueryParams(waitTime, index));
if (responseKeys == null) {
Thread.sleep(10000);
logger.error("not found watchKey {} !", watchKey);
continue;
}
long currentIndex = responseKeys.getConsulIndex();
if (currentIndex != index) {
index = currentIndex;
flushCache(watchKey);
}
}
} catch (Throwable e) {
logger.error("", e);
try {
Thread.sleep(1000);
} catch (InterruptedException interruptedException) {
// ignore
}
}
});
}
}
}
use of com.recurly.v3.QueryParams in project sofa-rpc by sofastack.
the class HealthServiceInformer method watchHealthService.
private void watchHealthService() {
try {
HealthServicesRequest request = HealthServicesRequest.newBuilder().setTag(tag).setQueryParams(new QueryParams(properties.getWatchTimeout(), currentData.getConsulIndex())).setToken(properties.getToken()).setPassing(true).build();
Response<List<HealthService>> response = consulClient.getHealthServices(serviceName, request);
if (response.getConsulIndex().equals(currentData.getConsulIndex())) {
return;
}
this.currentData = response;
ProviderGroup providerGroup = new ProviderGroup(currentProviders());
listeners.stream().filter(Objects::nonNull).forEach(l -> l.updateProviders(providerGroup));
} catch (Exception e) {
LOGGER.error(LogCodes.getLog(LogCodes.ERROR_WATCH_HEALTH, "Consul"), e);
}
}
use of com.recurly.v3.QueryParams in project brpc-java by baidu.
the class ConsulNamingService method lookupHealthService.
public Response<List<HealthService>> lookupHealthService(String serviceName, long lastConsulIndex) {
QueryParams queryParams = new QueryParams(ConsulConstants.CONSUL_BLOCK_TIME_SECONDS, lastConsulIndex);
HealthServicesRequest request = HealthServicesRequest.newBuilder().setTag(ConsulConstants.CONSUL_SERVICE_TAG).setQueryParams(queryParams).setPassing(true).build();
return client.getHealthServices(serviceName, request);
}
use of com.recurly.v3.QueryParams in project motan by weibocom.
the class ConsulRegistryService method getNodes.
@Override
public List<JSONObject> getNodes(String dcGroup, String service, String nodeType) {
List<JSONObject> results = new ArrayList<JSONObject>();
List<Check> checks = consulClient.getHealthChecksForService(getGroupName(dcGroup), new QueryParams(getDcName(dcGroup))).getValue();
for (Check check : checks) {
String serviceId = check.getServiceId();
String[] strings = serviceId.split("-");
if (strings[1].equals(service)) {
Check.CheckStatus status = check.getStatus();
JSONObject node = new JSONObject();
if (nodeType.equals(status.toString())) {
node.put("host", strings[0]);
node.put("info", null);
results.add(node);
}
}
}
return results;
}
use of com.recurly.v3.QueryParams in project spring-cloud-consul by spring-cloud.
the class EventService method watch.
public List<Event> watch(Long lastIndex) {
// TODO: parameterized or configurable watch time
long index = -1;
if (lastIndex != null) {
index = lastIndex;
}
int eventTimeout = 5;
if (this.properties != null) {
eventTimeout = this.properties.getEventTimeout();
}
Response<List<Event>> watch = this.consul.eventList(EventListRequest.newBuilder().setQueryParams(new QueryParams(eventTimeout, index)).build());
return filterEvents(readEvents(watch), lastIndex);
}
Aggregations