Search in sources :

Example 1 with UrlList

use of io.confluent.kafka.schemaregistry.client.rest.utils.UrlList in project schema-registry by confluentinc.

the class KafkaSchemaRegistry method forwardRegisterRequestToLeader.

private int forwardRegisterRequestToLeader(String subject, Schema schema, boolean normalize, Map<String, String> headerProperties) throws SchemaRegistryRequestForwardingException {
    final UrlList baseUrl = leaderRestService.getBaseUrls();
    RegisterSchemaRequest registerSchemaRequest = new RegisterSchemaRequest();
    registerSchemaRequest.setSchema(schema.getSchema());
    registerSchemaRequest.setSchemaType(schema.getSchemaType());
    registerSchemaRequest.setReferences(schema.getReferences());
    registerSchemaRequest.setVersion(schema.getVersion());
    registerSchemaRequest.setId(schema.getId());
    log.debug(String.format("Forwarding registering schema request %s to %s", registerSchemaRequest, baseUrl));
    try {
        int id = leaderRestService.registerSchema(headerProperties, registerSchemaRequest, subject, normalize);
        return id;
    } catch (IOException e) {
        throw new SchemaRegistryRequestForwardingException(String.format("Unexpected error while forwarding the registering schema request %s to %s", registerSchemaRequest, 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) RegisterSchemaRequest(io.confluent.kafka.schemaregistry.client.rest.entities.requests.RegisterSchemaRequest)

Example 2 with UrlList

use of io.confluent.kafka.schemaregistry.client.rest.utils.UrlList in project schema-registry by confluentinc.

the class KafkaSchemaRegistry method forwardDeleteSchemaVersionRequestToLeader.

private void forwardDeleteSchemaVersionRequestToLeader(Map<String, String> headerProperties, String subject, Integer version, boolean permanentDelete) throws SchemaRegistryRequestForwardingException {
    UrlList baseUrl = leaderRestService.getBaseUrls();
    log.debug(String.format("Forwarding deleteSchemaVersion schema version request %s-%s to %s", subject, version, baseUrl));
    try {
        leaderRestService.deleteSchemaVersion(headerProperties, subject, String.valueOf(version), permanentDelete);
    } catch (IOException e) {
        throw new SchemaRegistryRequestForwardingException(String.format("Unexpected error while forwarding deleteSchemaVersion schema version " + "request %s-%s to %s", subject, version, 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 3 with UrlList

use of io.confluent.kafka.schemaregistry.client.rest.utils.UrlList in project schema-registry by confluentinc.

the class KafkaSchemaRegistry method forwardDeleteSubjectRequestToLeader.

private List<Integer> forwardDeleteSubjectRequestToLeader(Map<String, String> requestProperties, String subject, boolean permanentDelete) throws SchemaRegistryRequestForwardingException {
    UrlList baseUrl = leaderRestService.getBaseUrls();
    log.debug(String.format("Forwarding delete subject request for  %s to %s", subject, baseUrl));
    try {
        return leaderRestService.deleteSubject(requestProperties, subject, permanentDelete);
    } catch (IOException e) {
        throw new SchemaRegistryRequestForwardingException(String.format("Unexpected error while forwarding delete subject " + "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 4 with UrlList

use of io.confluent.kafka.schemaregistry.client.rest.utils.UrlList 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 5 with UrlList

use of io.confluent.kafka.schemaregistry.client.rest.utils.UrlList 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)

Aggregations

RestClientException (io.confluent.kafka.schemaregistry.client.rest.exceptions.RestClientException)7 UrlList (io.confluent.kafka.schemaregistry.client.rest.utils.UrlList)7 SchemaRegistryRequestForwardingException (io.confluent.kafka.schemaregistry.exceptions.SchemaRegistryRequestForwardingException)7 RestException (io.confluent.rest.exceptions.RestException)7 IOException (java.io.IOException)7 ConfigUpdateRequest (io.confluent.kafka.schemaregistry.client.rest.entities.requests.ConfigUpdateRequest)1 ModeUpdateRequest (io.confluent.kafka.schemaregistry.client.rest.entities.requests.ModeUpdateRequest)1 RegisterSchemaRequest (io.confluent.kafka.schemaregistry.client.rest.entities.requests.RegisterSchemaRequest)1