use of org.apache.servicecomb.service.center.client.exception.OperationException in project java-chassis by ServiceComb.
the class ServiceCenterClient method sendHeartBeat.
@Override
public boolean sendHeartBeat(String serviceId, String instanceId) {
try {
HttpResponse response = httpClient.putHttpRequest("/registry/microservices/" + serviceId + "/instances/" + instanceId + "/heartbeat", null, null);
if (response.getStatusCode() == HttpStatus.SC_OK) {
return true;
}
sendUnAuthorizedEvent(response);
throw new OperationException("heartbeats fails, statusCode = " + response.getStatusCode() + "; message = " + response.getMessage() + "; content = " + response.getContent());
} catch (IOException e) {
throw new OperationException("heartbeats fails ", e);
}
}
use of org.apache.servicecomb.service.center.client.exception.OperationException in project java-chassis by ServiceComb.
the class ServiceCenterClient method getMicroserviceByServiceId.
@Override
public Microservice getMicroserviceByServiceId(String serviceId) {
try {
HttpResponse response = httpClient.getHttpRequest("/registry/microservices/" + serviceId, null, null);
if (response.getStatusCode() == HttpStatus.SC_OK) {
MicroserviceResponse microserviceResponse = HttpUtils.deserialize(response.getContent(), MicroserviceResponse.class);
return microserviceResponse.getService();
}
sendUnAuthorizedEvent(response);
throw new OperationException("get service message fails, statusCode = " + response.getStatusCode() + "; message = " + response.getMessage() + "; content = " + response.getContent());
} catch (IOException e) {
throw new OperationException("get service message fails", e);
}
}
use of org.apache.servicecomb.service.center.client.exception.OperationException in project java-chassis by ServiceComb.
the class ServiceCenterClient method getMicroserviceInstanceList.
@Override
public MicroserviceInstancesResponse getMicroserviceInstanceList(String serviceId) {
try {
HttpResponse response = httpClient.getHttpRequest("/registry/microservices/" + serviceId + "/instances", null, null);
if (response.getStatusCode() == HttpStatus.SC_OK) {
return HttpUtils.deserialize(response.getContent(), MicroserviceInstancesResponse.class);
}
sendUnAuthorizedEvent(response);
throw new OperationException("get service instances list fails, statusCode = " + response.getStatusCode() + "; message = " + response.getMessage() + "; content = " + response.getContent());
} catch (IOException e) {
throw new OperationException("get service instances list fails", e);
}
}
use of org.apache.servicecomb.service.center.client.exception.OperationException in project java-chassis by ServiceComb.
the class ServiceCenterClient method getServiceSchemaContext.
/**
* Get one schema context of service
*
* @param serviceId
* @param schemaId
* @return
* @throws OperationException
*/
public String getServiceSchemaContext(String serviceId, String schemaId) {
try {
HttpResponse response = httpClient.getHttpRequest("/registry/microservices/" + serviceId + "/schemas/" + schemaId, null, null);
if (response.getStatusCode() == HttpStatus.SC_OK) {
GetSchemaResponse getSchemaResponse = HttpUtils.deserialize(response.getContent(), GetSchemaResponse.class);
return getSchemaResponse.getSchema();
}
sendUnAuthorizedEvent(response);
throw new OperationException("get service schema context fails, statusCode = " + response.getStatusCode() + "; message = " + response.getMessage() + "; content = " + response.getContent());
} catch (IOException e) {
throw new OperationException("get service schemas context fails", e);
}
}
use of org.apache.servicecomb.service.center.client.exception.OperationException in project java-chassis by ServiceComb.
the class ServiceCenterClient method registerSchema.
@Override
public boolean registerSchema(String serviceId, String schemaId, CreateSchemaRequest schema) {
try {
HttpResponse response = httpClient.putHttpRequest("/registry/microservices/" + serviceId + "/schemas/" + schemaId, null, HttpUtils.serialize(schema));
if (response.getStatusCode() == HttpStatus.SC_OK) {
return true;
}
sendUnAuthorizedEvent(response);
throw new OperationException("update service schema fails, statusCode = " + response.getStatusCode() + "; message = " + response.getMessage() + "; content = " + response.getContent());
} catch (IOException e) {
throw new OperationException("update service schema fails", e);
}
}
Aggregations