Search in sources :

Example 1 with MicroserviceInstanceResponse

use of org.apache.servicecomb.service.center.client.model.MicroserviceInstanceResponse in project java-chassis by ServiceComb.

the class ServiceCenterClient method getMicroserviceInstance.

@Override
public MicroserviceInstance getMicroserviceInstance(String serviceId, String instanceId) {
    try {
        HttpResponse response = httpClient.getHttpRequest("/registry/microservices/" + serviceId + "/instances/" + instanceId, null, null);
        if (response.getStatusCode() == HttpStatus.SC_OK) {
            MicroserviceInstanceResponse instanceResponse = HttpUtils.deserialize(response.getContent(), MicroserviceInstanceResponse.class);
            return instanceResponse.getInstance();
        }
        sendUnAuthorizedEvent(response);
        throw new OperationException("get service instance message fails, statusCode = " + response.getStatusCode() + "; message = " + response.getMessage() + "; content = " + response.getContent());
    } catch (IOException e) {
        throw new OperationException("get service instance message fails", e);
    }
}
Also used : HttpResponse(org.apache.servicecomb.http.client.common.HttpResponse) IOException(java.io.IOException) OperationException(org.apache.servicecomb.service.center.client.exception.OperationException) RegisteredMicroserviceInstanceResponse(org.apache.servicecomb.service.center.client.model.RegisteredMicroserviceInstanceResponse) MicroserviceInstanceResponse(org.apache.servicecomb.service.center.client.model.MicroserviceInstanceResponse)

Example 2 with MicroserviceInstanceResponse

use of org.apache.servicecomb.service.center.client.model.MicroserviceInstanceResponse in project incubator-servicecomb-java-chassis by apache.

the class ServiceCenterClient method getMicroserviceInstance.

@Override
public MicroserviceInstance getMicroserviceInstance(String serviceId, String instanceId) {
    try {
        HttpResponse response = httpClient.getHttpRequest("/registry/microservices/" + serviceId + "/instances/" + instanceId, null, null);
        if (response.getStatusCode() == HttpStatus.SC_OK) {
            MicroserviceInstanceResponse instanceResponse = HttpUtils.deserialize(response.getContent(), MicroserviceInstanceResponse.class);
            return instanceResponse.getInstance();
        }
        sendUnAuthorizedEvent(response);
        throw new OperationException("get service instance message fails, statusCode = " + response.getStatusCode() + "; message = " + response.getMessage() + "; content = " + response.getContent());
    } catch (IOException e) {
        throw new OperationException("get service instance message fails", e);
    }
}
Also used : HttpResponse(org.apache.servicecomb.http.client.common.HttpResponse) IOException(java.io.IOException) OperationException(org.apache.servicecomb.service.center.client.exception.OperationException) RegisteredMicroserviceInstanceResponse(org.apache.servicecomb.service.center.client.model.RegisteredMicroserviceInstanceResponse) MicroserviceInstanceResponse(org.apache.servicecomb.service.center.client.model.MicroserviceInstanceResponse)

Aggregations

IOException (java.io.IOException)2 HttpResponse (org.apache.servicecomb.http.client.common.HttpResponse)2 OperationException (org.apache.servicecomb.service.center.client.exception.OperationException)2 MicroserviceInstanceResponse (org.apache.servicecomb.service.center.client.model.MicroserviceInstanceResponse)2 RegisteredMicroserviceInstanceResponse (org.apache.servicecomb.service.center.client.model.RegisteredMicroserviceInstanceResponse)2