use of io.confluent.kafka.schemaregistry.exceptions.SchemaRegistryTimeoutException in project schema-registry by confluentinc.
the class KafkaSchemaRegistry method deleteSchemaVersion.
@Override
public void deleteSchemaVersion(String subject, Schema schema, boolean permanentDelete) throws SchemaRegistryException {
try {
if (isReadOnlyMode(subject)) {
throw new OperationNotPermittedException("Subject " + subject + " is in read-only mode");
}
SchemaKey key = new SchemaKey(subject, schema.getVersion());
if (!lookupCache.referencesSchema(key).isEmpty()) {
throw new ReferenceExistsException(key.toString());
}
SchemaValue schemaValue = (SchemaValue) lookupCache.get(key);
if (permanentDelete && schemaValue != null && !schemaValue.isDeleted()) {
throw new SchemaVersionNotSoftDeletedException(subject, schema.getVersion().toString());
}
// Ensure cache is up-to-date before any potential writes
kafkaStore.waitUntilKafkaReaderReachesLastOffset(subject, kafkaStoreTimeoutMs);
if (!permanentDelete) {
schemaValue = new SchemaValue(schema);
schemaValue.setDeleted(true);
kafkaStore.put(key, schemaValue);
if (!getAllVersions(subject, false).hasNext()) {
if (getMode(subject) != null) {
deleteMode(subject);
}
if (getCompatibilityLevel(subject) != null) {
deleteCompatibility(subject);
}
}
} else {
kafkaStore.put(key, null);
}
} catch (StoreTimeoutException te) {
throw new SchemaRegistryTimeoutException("Write to the Kafka store timed out while", te);
} catch (StoreException e) {
throw new SchemaRegistryStoreException("Error while deleting the schema for subject '" + subject + "' in the backend Kafka store", e);
}
}
use of io.confluent.kafka.schemaregistry.exceptions.SchemaRegistryTimeoutException in project schema-registry by confluentinc.
the class KafkaSchemaRegistry method init.
@Override
public void init() throws SchemaRegistryException {
try {
kafkaStore.init();
} catch (StoreInitializationException e) {
throw new SchemaRegistryInitializationException("Error initializing kafka store while initializing schema registry", e);
}
try {
config.checkBootstrapServers();
log.info("Joining schema registry with Kafka-based coordination");
leaderElector = new KafkaGroupLeaderElector(config, myIdentity, this);
leaderElector.init();
} catch (SchemaRegistryStoreException e) {
throw new SchemaRegistryInitializationException("Error electing leader while initializing schema registry", e);
} catch (SchemaRegistryTimeoutException e) {
throw new SchemaRegistryInitializationException(e);
}
}
Aggregations