use of io.servicecomb.serviceregistry.api.request.CreateSchemaRequest 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;
}
Aggregations