use of io.servicecomb.serviceregistry.api.response.GetInstancesResponse in project java-chassis by ServiceComb.
the class ServiceRegistryClientImpl method getMicroserviceInstance.
@Override
public List<MicroserviceInstance> getMicroserviceInstance(String consumerId, String providerId) {
Holder<GetInstancesResponse> holder = new Holder<>();
IpPort ipPort = IpPortManager.INSTANCE.get();
StringBuilder url = new StringBuilder(Const.MS_API_PATH);
url.append(Const.MICROSERVICE_PATH).append("/").append(providerId).append(Const.INSTANCES_PATH);
CountDownLatch countDownLatch = new CountDownLatch(1);
RestUtils.get(ipPort, url.toString(), new RequestParam().addHeader("X-ConsumerId", consumerId), syncHandler(countDownLatch, GetInstancesResponse.class, holder));
try {
countDownLatch.await();
if (holder.value != null) {
return holder.value.getInstances();
}
} catch (Exception e) {
LOGGER.error("query microservice instances {} failed", providerId, e);
}
return null;
}
Aggregations