Search in sources :

Example 1 with GetServiceResponse

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

the class ServiceRegistryClientImpl method getMicroservice.

@Override
public Microservice getMicroservice(String microserviceId) {
    Holder<GetServiceResponse> holder = new Holder<>();
    IpPort ipPort = ipPortManager.getAvailableAddress();
    CountDownLatch countDownLatch = new CountDownLatch(1);
    RestUtils.get(ipPort, String.format(Const.REGISTRY_API.MICROSERVICE_OPERATION_ONE, microserviceId), new RequestParam(), syncHandler(countDownLatch, GetServiceResponse.class, holder));
    try {
        countDownLatch.await();
        if (holder.value != null) {
            return holder.value.getService();
        }
    } catch (Exception e) {
        LOGGER.error("query microservice {} failed", microserviceId, e);
    }
    return null;
}
Also used : GetServiceResponse(org.apache.servicecomb.serviceregistry.api.response.GetServiceResponse) Holder(javax.xml.ws.Holder) IpPort(org.apache.servicecomb.foundation.common.net.IpPort) CountDownLatch(java.util.concurrent.CountDownLatch) 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 GetServiceResponse (org.apache.servicecomb.serviceregistry.api.response.GetServiceResponse)1 ClientException (org.apache.servicecomb.serviceregistry.client.ClientException)1