Search in sources :

Example 21 with Holder

use of javax.xml.ws.Holder 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;
}
Also used : Holder(javax.xml.ws.Holder) IpPort(io.servicecomb.foundation.common.net.IpPort) CountDownLatch(java.util.concurrent.CountDownLatch) GetInstancesResponse(io.servicecomb.serviceregistry.api.response.GetInstancesResponse) ClientException(io.servicecomb.serviceregistry.client.ClientException)

Example 22 with Holder

use of javax.xml.ws.Holder in project java-chassis by ServiceComb.

the class ServiceRegistryClientImpl method updateMicroserviceProperties.

@Override
public boolean updateMicroserviceProperties(String microserviceId, Map<String, String> serviceProperties) {
    Holder<HttpClientResponse> holder = new Holder<>();
    IpPort ipPort = IpPortManager.INSTANCE.get();
    StringBuilder url = new StringBuilder(Const.MS_API_PATH);
    url.append(Const.MICROSERVICE_PATH).append("/").append(microserviceId).append(Const.PROPERTIES_PATH);
    try {
        UpdatePropertiesRequest request = new UpdatePropertiesRequest();
        request.setProperties(serviceProperties);
        byte[] body = JsonUtils.writeValueAsBytes(request);
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("update properties of microservice: {}", new String(body, Charset.defaultCharset()));
        }
        CountDownLatch countDownLatch = new CountDownLatch(1);
        RestUtils.put(ipPort, url.toString(), new RequestParam().setBody(body), syncHandler(countDownLatch, HttpClientResponse.class, holder));
        countDownLatch.await();
        if (holder.value != null) {
            if (holder.value.statusCode() == Status.OK.getStatusCode()) {
                return true;
            }
            LOGGER.warn(holder.value.statusMessage());
        }
    } catch (Exception e) {
        LOGGER.error("update properties of microservice {} failed", microserviceId, e);
    }
    return false;
}
Also used : Holder(javax.xml.ws.Holder) HttpClientResponse(io.vertx.core.http.HttpClientResponse) IpPort(io.servicecomb.foundation.common.net.IpPort) UpdatePropertiesRequest(io.servicecomb.serviceregistry.api.request.UpdatePropertiesRequest) CountDownLatch(java.util.concurrent.CountDownLatch) ClientException(io.servicecomb.serviceregistry.client.ClientException)

Example 23 with Holder

use of javax.xml.ws.Holder 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 24 with Holder

use of javax.xml.ws.Holder in project java-chassis by ServiceComb.

the class ServiceRegistryClientImpl method registerSchema.

@Override
public boolean registerSchema(String microserviceId, String schemaId, String schemaContent) {
    Holder<HttpClientResponse> holder = new Holder<>();
    IpPort ipPort = IpPortManager.INSTANCE.get();
    try {
        CreateSchemaRequest request = new CreateSchemaRequest();
        request.setSchema(schemaContent);
        byte[] body = JsonUtils.writeValueAsBytes(request);
        CountDownLatch countDownLatch = new CountDownLatch(1);
        RestUtils.put(ipPort, Const.MS_API_PATH + Const.MICROSERVICE_PATH + "/" + microserviceId + Const.SCHEMA_PATH + "/" + schemaId, new RequestParam().setBody(body), syncHandler(countDownLatch, HttpClientResponse.class, holder));
        countDownLatch.await();
        boolean result = false;
        if (holder.value != null) {
            result = holder.value.statusCode() == Status.OK.getStatusCode();
        }
        LOGGER.info("register schema {}/{}, result {}", microserviceId, schemaId, result);
        return result;
    } catch (Exception e) {
        LOGGER.error("query schema exist {}/{} fail", microserviceId, schemaId, e);
    }
    return false;
}
Also used : CreateSchemaRequest(io.servicecomb.serviceregistry.api.request.CreateSchemaRequest) Holder(javax.xml.ws.Holder) HttpClientResponse(io.vertx.core.http.HttpClientResponse) IpPort(io.servicecomb.foundation.common.net.IpPort) CountDownLatch(java.util.concurrent.CountDownLatch) ClientException(io.servicecomb.serviceregistry.client.ClientException)

Example 25 with Holder

use of javax.xml.ws.Holder in project java-chassis by ServiceComb.

the class ServiceRegistryClientImpl method getSchema.

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

Aggregations

Holder (javax.xml.ws.Holder)129 OperationResultType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType)77 Test (org.testng.annotations.Test)53 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)48 SelectorQualifiedGetOptionsType (com.evolveum.midpoint.xml.ns._public.common.common_3.SelectorQualifiedGetOptionsType)33 AbstractModelIntegrationTest (com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)29 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)29 PrismAsserts.assertEqualsPolyString (com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString)24 ObjectListType (com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectListType)23 SystemConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType)23 Test (org.junit.Test)23 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)21 LogfileTestTailer (com.evolveum.midpoint.test.util.LogfileTestTailer)21 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)19 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)18 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)16 GenericObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.GenericObjectType)15 CountDownLatch (java.util.concurrent.CountDownLatch)15 IpPort (io.servicecomb.foundation.common.net.IpPort)14 ClientException (io.servicecomb.serviceregistry.client.ClientException)14