Search in sources :

Example 1 with GetInstancesResponse

use of org.apache.servicecomb.serviceregistry.api.response.GetInstancesResponse in project incubator-servicecomb-java-chassis by apache.

the class ServiceRegistryClientImpl method getMicroserviceInstance.

@Override
public List<MicroserviceInstance> getMicroserviceInstance(String consumerId, String providerId) {
    Holder<GetInstancesResponse> holder = new Holder<>();
    IpPort ipPort = ipPortManager.getAvailableAddress();
    CountDownLatch countDownLatch = new CountDownLatch(1);
    RestUtils.get(ipPort, String.format(Const.REGISTRY_API.MICROSERVICE_INSTANCE_OPERATION_ALL, providerId), 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;
}
Also used : Holder(javax.xml.ws.Holder) IpPort(org.apache.servicecomb.foundation.common.net.IpPort) CountDownLatch(java.util.concurrent.CountDownLatch) GetInstancesResponse(org.apache.servicecomb.serviceregistry.api.response.GetInstancesResponse) ClientException(org.apache.servicecomb.serviceregistry.client.ClientException)

Aggregations

CountDownLatch (java.util.concurrent.CountDownLatch)1 Holder (javax.xml.ws.Holder)1 IpPort (org.apache.servicecomb.foundation.common.net.IpPort)1 GetInstancesResponse (org.apache.servicecomb.serviceregistry.api.response.GetInstancesResponse)1 ClientException (org.apache.servicecomb.serviceregistry.client.ClientException)1