use of org.apache.servicecomb.serviceregistry.api.response.CreateServiceResponse in project incubator-servicecomb-java-chassis by apache.
the class ServiceRegistryClientImpl method registerMicroservice.
@Override
public String registerMicroservice(Microservice microservice) {
Holder<CreateServiceResponse> holder = new Holder<>();
IpPort ipPort = ipPortManager.getAvailableAddress();
try {
CreateServiceRequest request = new CreateServiceRequest();
request.setService(microservice);
byte[] body = JsonUtils.writeValueAsBytes(request);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("register microservice: {}", new String(body, Charset.defaultCharset()));
}
CountDownLatch countDownLatch = new CountDownLatch(1);
RestUtils.post(ipPort, Const.REGISTRY_API.MICROSERVICE_OPERATION_ALL, new RequestParam().setBody(body), syncHandler(countDownLatch, CreateServiceResponse.class, holder));
countDownLatch.await();
if (holder.value != null) {
return holder.value.getServiceId();
}
} catch (Exception e) {
LOGGER.error("register microservice {}/{}/{} failed", microservice.getAppId(), microservice.getServiceName(), microservice.getVersion(), e);
}
return null;
}
Aggregations