use of org.apache.servicecomb.service.center.client.model.CreateMicroserviceInstanceRequest in project java-chassis by ServiceComb.
the class ServiceCenterClient method registerMicroserviceInstance.
@Override
public RegisteredMicroserviceInstanceResponse registerMicroserviceInstance(MicroserviceInstance instance) {
try {
CreateMicroserviceInstanceRequest request = new CreateMicroserviceInstanceRequest();
request.setInstance(instance);
HttpResponse response = httpClient.postHttpRequest("/registry/microservices/" + instance.getServiceId() + "/instances", null, HttpUtils.serialize(request));
if (response.getStatusCode() == HttpStatus.SC_OK) {
return HttpUtils.deserialize(response.getContent(), RegisteredMicroserviceInstanceResponse.class);
}
sendUnAuthorizedEvent(response);
throw new OperationException("register service instance fails, statusCode = " + response.getStatusCode() + "; message = " + response.getMessage() + "; content = " + response.getContent());
} catch (IOException e) {
throw new OperationException("register service instance fails", e);
}
}
Aggregations