use of io.confluent.kafka.schemaregistry.exceptions.SchemaRegistryRequestForwardingException in project schema-registry by confluentinc.
the class KafkaSchemaRegistry method forwardSetModeRequestToLeader.
private void forwardSetModeRequestToLeader(String subject, Mode mode, boolean force, Map<String, String> headerProperties) throws SchemaRegistryRequestForwardingException {
UrlList baseUrl = leaderRestService.getBaseUrls();
ModeUpdateRequest modeUpdateRequest = new ModeUpdateRequest();
modeUpdateRequest.setMode(mode.name());
log.debug(String.format("Forwarding update mode request %s to %s", modeUpdateRequest, baseUrl));
try {
leaderRestService.setMode(headerProperties, modeUpdateRequest, subject, force);
} catch (IOException e) {
throw new SchemaRegistryRequestForwardingException(String.format("Unexpected error while forwarding the update mode request %s to %s", modeUpdateRequest, baseUrl), e);
} catch (RestClientException e) {
throw new RestException(e.getMessage(), e.getStatus(), e.getErrorCode(), e);
}
}
use of io.confluent.kafka.schemaregistry.exceptions.SchemaRegistryRequestForwardingException in project schema-registry by confluentinc.
the class KafkaSchemaRegistry method forwardDeleteSubjectModeRequestToLeader.
private void forwardDeleteSubjectModeRequestToLeader(String subject, Map<String, String> headerProperties) throws SchemaRegistryRequestForwardingException {
UrlList baseUrl = leaderRestService.getBaseUrls();
log.debug(String.format("Forwarding delete subject mode request %s to %s", subject, baseUrl));
try {
leaderRestService.deleteSubjectMode(headerProperties, subject);
} catch (IOException e) {
throw new SchemaRegistryRequestForwardingException(String.format("Unexpected error while forwarding delete subject mode" + "request %s to %s", subject, baseUrl), e);
} catch (RestClientException e) {
throw new RestException(e.getMessage(), e.getStatus(), e.getErrorCode(), e);
}
}
use of io.confluent.kafka.schemaregistry.exceptions.SchemaRegistryRequestForwardingException in project schema-registry by confluentinc.
the class ConfigResource method deleteTopLevelConfig.
@DELETE
@Operation(summary = "Deletes the Global-level compatibility level config and " + "revert to the global default.", responses = { @ApiResponse(content = @Content(schema = @Schema(implementation = CompatibilityLevel.class))), @ApiResponse(responseCode = "500", description = "Error code 50001 -- Error in the backend " + "datastore") })
public void deleteTopLevelConfig(@Suspended final AsyncResponse asyncResponse, @Context HttpHeaders headers) {
log.info("Deleting Global compatibility setting and reverting back to default");
Config deletedConfig;
try {
CompatibilityLevel currentCompatibility = schemaRegistry.getCompatibilityLevel(null);
Map<String, String> headerProperties = requestHeaderBuilder.buildRequestHeaders(headers, schemaRegistry.config().whitelistHeaders());
schemaRegistry.deleteCompatibilityConfigOrForward(null, headerProperties);
deletedConfig = new Config(currentCompatibility.name);
} catch (OperationNotPermittedException e) {
throw Errors.operationNotPermittedException(e.getMessage());
} catch (SchemaRegistryStoreException e) {
throw Errors.storeException("Failed to delete compatibility level", e);
} catch (UnknownLeaderException e) {
throw Errors.unknownLeaderException("Failed to delete compatibility level", e);
} catch (SchemaRegistryRequestForwardingException e) {
throw Errors.requestForwardingFailedException("Error while forwarding delete config request" + " to the leader", e);
}
asyncResponse.resume(deletedConfig);
}
use of io.confluent.kafka.schemaregistry.exceptions.SchemaRegistryRequestForwardingException in project schema-registry by confluentinc.
the class KafkaSchemaRegistry method forwardDeleteCompatibilityConfigToLeader.
private void forwardDeleteCompatibilityConfigToLeader(Map<String, String> requestProperties, String subject) throws SchemaRegistryRequestForwardingException {
UrlList baseUrl = leaderRestService.getBaseUrls();
log.debug(String.format("Forwarding delete subject compatibility config request %s to %s", subject, baseUrl));
try {
leaderRestService.deleteConfig(requestProperties, subject);
} catch (IOException e) {
throw new SchemaRegistryRequestForwardingException(String.format("Unexpected error while forwarding delete subject compatibility config" + "request %s to %s", subject, baseUrl), e);
} catch (RestClientException e) {
throw new RestException(e.getMessage(), e.getStatus(), e.getErrorCode(), e);
}
}
use of io.confluent.kafka.schemaregistry.exceptions.SchemaRegistryRequestForwardingException in project schema-registry by confluentinc.
the class KafkaSchemaRegistry method forwardUpdateCompatibilityLevelRequestToLeader.
private void forwardUpdateCompatibilityLevelRequestToLeader(String subject, CompatibilityLevel compatibilityLevel, Map<String, String> headerProperties) throws SchemaRegistryRequestForwardingException {
UrlList baseUrl = leaderRestService.getBaseUrls();
ConfigUpdateRequest configUpdateRequest = new ConfigUpdateRequest();
configUpdateRequest.setCompatibilityLevel(compatibilityLevel.name);
log.debug(String.format("Forwarding update config request %s to %s", configUpdateRequest, baseUrl));
try {
leaderRestService.updateConfig(headerProperties, configUpdateRequest, subject);
} catch (IOException e) {
throw new SchemaRegistryRequestForwardingException(String.format("Unexpected error while forwarding the update config request %s to %s", configUpdateRequest, baseUrl), e);
} catch (RestClientException e) {
throw new RestException(e.getMessage(), e.getStatus(), e.getErrorCode(), e);
}
}
Aggregations