Search in sources :

Example 6 with SchemaRegistryRequestForwardingException

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);
    }
}
Also used : SchemaRegistryRequestForwardingException(io.confluent.kafka.schemaregistry.exceptions.SchemaRegistryRequestForwardingException) ModeUpdateRequest(io.confluent.kafka.schemaregistry.client.rest.entities.requests.ModeUpdateRequest) RestClientException(io.confluent.kafka.schemaregistry.client.rest.exceptions.RestClientException) RestException(io.confluent.rest.exceptions.RestException) IOException(java.io.IOException) UrlList(io.confluent.kafka.schemaregistry.client.rest.utils.UrlList)

Example 7 with SchemaRegistryRequestForwardingException

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);
    }
}
Also used : SchemaRegistryRequestForwardingException(io.confluent.kafka.schemaregistry.exceptions.SchemaRegistryRequestForwardingException) RestClientException(io.confluent.kafka.schemaregistry.client.rest.exceptions.RestClientException) RestException(io.confluent.rest.exceptions.RestException) IOException(java.io.IOException) UrlList(io.confluent.kafka.schemaregistry.client.rest.utils.UrlList)

Example 8 with SchemaRegistryRequestForwardingException

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);
}
Also used : CompatibilityLevel(io.confluent.kafka.schemaregistry.CompatibilityLevel) UnknownLeaderException(io.confluent.kafka.schemaregistry.exceptions.UnknownLeaderException) SchemaRegistryRequestForwardingException(io.confluent.kafka.schemaregistry.exceptions.SchemaRegistryRequestForwardingException) Config(io.confluent.kafka.schemaregistry.client.rest.entities.Config) SchemaRegistryStoreException(io.confluent.kafka.schemaregistry.exceptions.SchemaRegistryStoreException) OperationNotPermittedException(io.confluent.kafka.schemaregistry.exceptions.OperationNotPermittedException) DELETE(javax.ws.rs.DELETE) Operation(io.swagger.v3.oas.annotations.Operation)

Example 9 with SchemaRegistryRequestForwardingException

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);
    }
}
Also used : SchemaRegistryRequestForwardingException(io.confluent.kafka.schemaregistry.exceptions.SchemaRegistryRequestForwardingException) RestClientException(io.confluent.kafka.schemaregistry.client.rest.exceptions.RestClientException) RestException(io.confluent.rest.exceptions.RestException) IOException(java.io.IOException) UrlList(io.confluent.kafka.schemaregistry.client.rest.utils.UrlList)

Example 10 with SchemaRegistryRequestForwardingException

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);
    }
}
Also used : SchemaRegistryRequestForwardingException(io.confluent.kafka.schemaregistry.exceptions.SchemaRegistryRequestForwardingException) ConfigUpdateRequest(io.confluent.kafka.schemaregistry.client.rest.entities.requests.ConfigUpdateRequest) RestClientException(io.confluent.kafka.schemaregistry.client.rest.exceptions.RestClientException) RestException(io.confluent.rest.exceptions.RestException) IOException(java.io.IOException) UrlList(io.confluent.kafka.schemaregistry.client.rest.utils.UrlList)

Aggregations

SchemaRegistryRequestForwardingException (io.confluent.kafka.schemaregistry.exceptions.SchemaRegistryRequestForwardingException)15 SchemaRegistryStoreException (io.confluent.kafka.schemaregistry.exceptions.SchemaRegistryStoreException)8 UnknownLeaderException (io.confluent.kafka.schemaregistry.exceptions.UnknownLeaderException)8 Operation (io.swagger.v3.oas.annotations.Operation)8 RestClientException (io.confluent.kafka.schemaregistry.client.rest.exceptions.RestClientException)7 UrlList (io.confluent.kafka.schemaregistry.client.rest.utils.UrlList)7 OperationNotPermittedException (io.confluent.kafka.schemaregistry.exceptions.OperationNotPermittedException)7 RestException (io.confluent.rest.exceptions.RestException)7 IOException (java.io.IOException)7 Path (javax.ws.rs.Path)5 CompatibilityLevel (io.confluent.kafka.schemaregistry.CompatibilityLevel)4 DELETE (javax.ws.rs.DELETE)4 PUT (javax.ws.rs.PUT)3 AvroSchema (io.confluent.kafka.schemaregistry.avro.AvroSchema)2 Config (io.confluent.kafka.schemaregistry.client.rest.entities.Config)2 Mode (io.confluent.kafka.schemaregistry.client.rest.entities.Mode)2 Schema (io.confluent.kafka.schemaregistry.client.rest.entities.Schema)2 SchemaRegistryException (io.confluent.kafka.schemaregistry.exceptions.SchemaRegistryException)2 SchemaRegistryTimeoutException (io.confluent.kafka.schemaregistry.exceptions.SchemaRegistryTimeoutException)2 RestInvalidCompatibilityException (io.confluent.kafka.schemaregistry.rest.exceptions.RestInvalidCompatibilityException)2