Search in sources :

Example 1 with GetExistenceResponse

use of io.servicecomb.serviceregistry.api.response.GetExistenceResponse in project java-chassis by ServiceComb.

the class ServiceRegistryClientImpl method isSchemaExist.

@Override
public boolean isSchemaExist(String microserviceId, String schemaId) {
    Holder<GetExistenceResponse> holder = new Holder<>();
    IpPort ipPort = IpPortManager.INSTANCE.get();
    CountDownLatch countDownLatch = new CountDownLatch(1);
    RestUtils.get(ipPort, Const.MS_API_PATH + Const.EXISTENCE_PATH, new RequestParam().addQueryParam("type", "schema").addQueryParam("serviceId", microserviceId).addQueryParam("schemaId", schemaId), syncHandler(countDownLatch, GetExistenceResponse.class, holder));
    try {
        countDownLatch.await();
    } catch (Exception e) {
        LOGGER.error("query schema exist {}/{} fail", microserviceId, schemaId, e);
    }
    return holder.value != null;
}
Also used : Holder(javax.xml.ws.Holder) IpPort(io.servicecomb.foundation.common.net.IpPort) CountDownLatch(java.util.concurrent.CountDownLatch) GetExistenceResponse(io.servicecomb.serviceregistry.api.response.GetExistenceResponse) ClientException(io.servicecomb.serviceregistry.client.ClientException)

Example 2 with GetExistenceResponse

use of io.servicecomb.serviceregistry.api.response.GetExistenceResponse in project java-chassis by ServiceComb.

the class ServiceRegistryClientImpl method getMicroserviceId.

@Override
public String getMicroserviceId(String appId, String microserviceName, String versionRule) {
    Holder<GetExistenceResponse> holder = new Holder<>();
    IpPort ipPort = IpPortManager.INSTANCE.get();
    CountDownLatch countDownLatch = new CountDownLatch(1);
    RestUtils.get(ipPort, Const.MS_API_PATH + Const.EXISTENCE_PATH, new RequestParam().addQueryParam("type", "microservice").addQueryParam("appId", appId).addQueryParam("serviceName", microserviceName).addQueryParam("version", versionRule), syncHandler(countDownLatch, GetExistenceResponse.class, holder));
    try {
        countDownLatch.await();
        if (holder.value != null) {
            return holder.value.getServiceId();
        }
    } catch (Exception e) {
        LOGGER.error("query microservice id {}/{}/{} fail", appId, microserviceName, versionRule, e);
    }
    return null;
}
Also used : Holder(javax.xml.ws.Holder) IpPort(io.servicecomb.foundation.common.net.IpPort) CountDownLatch(java.util.concurrent.CountDownLatch) GetExistenceResponse(io.servicecomb.serviceregistry.api.response.GetExistenceResponse) ClientException(io.servicecomb.serviceregistry.client.ClientException)

Aggregations

IpPort (io.servicecomb.foundation.common.net.IpPort)2 GetExistenceResponse (io.servicecomb.serviceregistry.api.response.GetExistenceResponse)2 ClientException (io.servicecomb.serviceregistry.client.ClientException)2 CountDownLatch (java.util.concurrent.CountDownLatch)2 Holder (javax.xml.ws.Holder)2