use of org.apache.servicecomb.serviceregistry.api.response.MicroserviceInstanceResponse in project incubator-servicecomb-java-chassis by apache.
the class ServiceRegistryClientImpl method findServiceInstance.
@Override
public MicroserviceInstance findServiceInstance(String serviceId, String instanceId) {
try {
Holder<MicroserviceInstanceResponse> holder = new Holder<>();
IpPort ipPort = ipPortManager.getAvailableAddress();
CountDownLatch countDownLatch = new CountDownLatch(1);
RestUtils.get(ipPort, String.format(Const.REGISTRY_API.MICROSERVICE_INSTANCE_OPERATION_ONE, serviceId, instanceId), new RequestParam().addHeader("X-ConsumerId", serviceId), syncHandler(countDownLatch, MicroserviceInstanceResponse.class, holder));
countDownLatch.await();
if (null != holder.value) {
return holder.value.getInstance();
}
return null;
} catch (Exception e) {
LOGGER.error("get instance from sc failed");
return null;
}
}
use of org.apache.servicecomb.serviceregistry.api.response.MicroserviceInstanceResponse in project java-chassis by ServiceComb.
the class ServiceRegistryClientImpl method findServiceInstance.
@Override
public MicroserviceInstance findServiceInstance(String serviceId, String instanceId) {
try {
Holder<MicroserviceInstanceResponse> holder = new Holder<>();
IpPort ipPort = ipPortManager.getAvailableAddress();
CountDownLatch countDownLatch = new CountDownLatch(1);
restClientUtil.get(ipPort, String.format(Const.REGISTRY_API.MICROSERVICE_INSTANCE_OPERATION_ONE, serviceId, instanceId), new RequestParam().addHeader("X-ConsumerId", serviceId).addQueryParam("global", "true"), syncHandler(countDownLatch, MicroserviceInstanceResponse.class, holder));
countDownLatch.await();
if (null != holder.value) {
return holder.value.getInstance();
}
return null;
} catch (Exception e) {
LOGGER.error("get instance from sc failed");
return null;
}
}
Aggregations