Search in sources :

Example 16 with SchemaRegistryStoreException

use of io.confluent.kafka.schemaregistry.exceptions.SchemaRegistryStoreException in project schema-registry by confluentinc.

the class ConfigResource method getSubjectLevelConfig.

@Path("/{subject}")
@GET
@Operation(summary = "Get compatibility level for a subject.", responses = { @ApiResponse(responseCode = "404", description = "Subject not found"), @ApiResponse(responseCode = "500", description = "Error code 50001 -- Error in the backend " + "data store") })
public Config getSubjectLevelConfig(@Parameter(description = "Name of the subject", required = true) @PathParam("subject") String subject, @Parameter(description = "Whether to return the global compatibility level " + " if subject compatibility level not found") @QueryParam("defaultToGlobal") boolean defaultToGlobal) {
    subject = QualifiedSubject.normalize(schemaRegistry.tenant(), subject);
    Config config;
    try {
        CompatibilityLevel compatibilityLevel = defaultToGlobal ? schemaRegistry.getCompatibilityLevelInScope(subject) : schemaRegistry.getCompatibilityLevel(subject);
        if (compatibilityLevel == null) {
            throw Errors.subjectLevelCompatibilityNotConfiguredException(subject);
        }
        config = new Config(compatibilityLevel.name);
    } catch (SchemaRegistryStoreException e) {
        throw Errors.storeException("Failed to get the configs for subject " + subject, e);
    }
    return config;
}
Also used : CompatibilityLevel(io.confluent.kafka.schemaregistry.CompatibilityLevel) Config(io.confluent.kafka.schemaregistry.client.rest.entities.Config) SchemaRegistryStoreException(io.confluent.kafka.schemaregistry.exceptions.SchemaRegistryStoreException) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET) Operation(io.swagger.v3.oas.annotations.Operation)

Example 17 with SchemaRegistryStoreException

use of io.confluent.kafka.schemaregistry.exceptions.SchemaRegistryStoreException in project schema-registry by confluentinc.

the class ConfigResource method getTopLevelConfig.

@GET
@Operation(summary = "Get global compatibility level.", responses = { @ApiResponse(responseCode = "500", description = "Error code 50001 -- Error in the backend " + "data store") })
public Config getTopLevelConfig() {
    Config config;
    try {
        CompatibilityLevel compatibilityLevel = schemaRegistry.getCompatibilityLevel(null);
        config = new Config(compatibilityLevel == null ? null : compatibilityLevel.name);
    } catch (SchemaRegistryStoreException e) {
        throw Errors.storeException("Failed to get compatibility level", e);
    }
    return config;
}
Also used : CompatibilityLevel(io.confluent.kafka.schemaregistry.CompatibilityLevel) Config(io.confluent.kafka.schemaregistry.client.rest.entities.Config) SchemaRegistryStoreException(io.confluent.kafka.schemaregistry.exceptions.SchemaRegistryStoreException) GET(javax.ws.rs.GET) Operation(io.swagger.v3.oas.annotations.Operation)

Example 18 with SchemaRegistryStoreException

use of io.confluent.kafka.schemaregistry.exceptions.SchemaRegistryStoreException in project schema-registry by confluentinc.

the class KafkaGroupLeaderElector method init.

@Override
public void init() throws SchemaRegistryTimeoutException, SchemaRegistryStoreException {
    log.debug("Initializing schema registry group member");
    executor = Executors.newSingleThreadExecutor();
    executor.submit(new Runnable() {

        @Override
        public void run() {
            try {
                while (!stopped.get()) {
                    coordinator.poll(Integer.MAX_VALUE);
                }
            } catch (Throwable t) {
                log.error("Unexpected exception in schema registry group processing thread", t);
            }
        }
    });
    try {
        if (!joinedLatch.await(initTimeout, TimeUnit.MILLISECONDS)) {
            throw new SchemaRegistryTimeoutException("Timed out waiting for join group to complete");
        }
    } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
        throw new SchemaRegistryStoreException("Interrupted while waiting for join group to " + "complete", e);
    }
    log.debug("Schema registry group member initialized and joined group");
}
Also used : SchemaRegistryStoreException(io.confluent.kafka.schemaregistry.exceptions.SchemaRegistryStoreException) SchemaRegistryTimeoutException(io.confluent.kafka.schemaregistry.exceptions.SchemaRegistryTimeoutException)

Example 19 with SchemaRegistryStoreException

use of io.confluent.kafka.schemaregistry.exceptions.SchemaRegistryStoreException in project schema-registry by confluentinc.

the class KafkaSchemaRegistry method getModeInScope.

public Mode getModeInScope(String subject) throws SchemaRegistryStoreException {
    try {
        Mode globalMode = lookupCache.mode(null, true, defaultMode);
        Mode subjectMode = lookupCache.mode(subject, true, defaultMode);
        return globalMode == Mode.READONLY_OVERRIDE ? globalMode : subjectMode;
    } catch (StoreException e) {
        throw new SchemaRegistryStoreException("Failed to write new config value to the store", e);
    }
}
Also used : SchemaRegistryStoreException(io.confluent.kafka.schemaregistry.exceptions.SchemaRegistryStoreException) SchemaRegistryStoreException(io.confluent.kafka.schemaregistry.exceptions.SchemaRegistryStoreException) StoreException(io.confluent.kafka.schemaregistry.storage.exceptions.StoreException)

Example 20 with SchemaRegistryStoreException

use of io.confluent.kafka.schemaregistry.exceptions.SchemaRegistryStoreException in project schema-registry by confluentinc.

the class KafkaSchemaRegistry method getReferencedBy.

public List<Integer> getReferencedBy(String subject, VersionId versionId) throws SchemaRegistryException {
    try {
        int version = versionId.getVersionId();
        if (versionId.isLatest()) {
            version = getLatestVersion(subject).getVersion();
        }
        SchemaKey key = new SchemaKey(subject, version);
        List<Integer> ids = new ArrayList<>(lookupCache.referencesSchema(key));
        Collections.sort(ids);
        return ids;
    } catch (StoreException e) {
        throw new SchemaRegistryStoreException("Error from the backend Kafka store", e);
    }
}
Also used : ArrayList(java.util.ArrayList) SchemaRegistryStoreException(io.confluent.kafka.schemaregistry.exceptions.SchemaRegistryStoreException) SchemaRegistryStoreException(io.confluent.kafka.schemaregistry.exceptions.SchemaRegistryStoreException) StoreException(io.confluent.kafka.schemaregistry.storage.exceptions.StoreException)

Aggregations

SchemaRegistryStoreException (io.confluent.kafka.schemaregistry.exceptions.SchemaRegistryStoreException)37 Operation (io.swagger.v3.oas.annotations.Operation)19 StoreException (io.confluent.kafka.schemaregistry.storage.exceptions.StoreException)16 OperationNotPermittedException (io.confluent.kafka.schemaregistry.exceptions.OperationNotPermittedException)14 Path (javax.ws.rs.Path)13 SchemaRegistryException (io.confluent.kafka.schemaregistry.exceptions.SchemaRegistryException)12 Schema (io.confluent.kafka.schemaregistry.client.rest.entities.Schema)11 AvroSchema (io.confluent.kafka.schemaregistry.avro.AvroSchema)10 SchemaRegistryRequestForwardingException (io.confluent.kafka.schemaregistry.exceptions.SchemaRegistryRequestForwardingException)9 UnknownLeaderException (io.confluent.kafka.schemaregistry.exceptions.UnknownLeaderException)9 GET (javax.ws.rs.GET)9 SchemaString (io.confluent.kafka.schemaregistry.client.rest.entities.SchemaString)8 SchemaRegistryTimeoutException (io.confluent.kafka.schemaregistry.exceptions.SchemaRegistryTimeoutException)8 PerformanceMetric (io.confluent.rest.annotations.PerformanceMetric)8 ArrayList (java.util.ArrayList)8 CompatibilityLevel (io.confluent.kafka.schemaregistry.CompatibilityLevel)7 ParsedSchema (io.confluent.kafka.schemaregistry.ParsedSchema)5 VersionId (io.confluent.kafka.schemaregistry.rest.VersionId)5 Config (io.confluent.kafka.schemaregistry.client.rest.entities.Config)4 ReferenceExistsException (io.confluent.kafka.schemaregistry.exceptions.ReferenceExistsException)4