Search in sources :

Example 21 with SchemaVersionKey

use of com.hortonworks.registries.schemaregistry.SchemaVersionKey in project registry by hortonworks.

the class AvroCompositeSchemasTest method testComposites.

@Before
public void testComposites() throws Exception {
    versions = new HashMap<>();
    versions.put("utils", cretaeSchemaVersionInfo("/avro/composites/util.avsc"));
    versions.put("account", cretaeSchemaVersionInfo("/avro/composites/account.avsc"));
    versions.put("account-cyclic", cretaeSchemaVersionInfo("/avro/composites/account-cyclic.avsc"));
    versions.put("account-dep", cretaeSchemaVersionInfo("/avro/composites/account-dep.avsc"));
    avroSchemaProvider = new AvroSchemaProvider();
    SchemaVersionRetriever schemaVersionRetriever = new SchemaVersionRetriever() {

        @Override
        public SchemaVersionInfo retrieveSchemaVersion(SchemaVersionKey key) throws SchemaNotFoundException {
            return versions.get(key.getSchemaName());
        }

        @Override
        public SchemaVersionInfo retrieveSchemaVersion(SchemaIdVersion key) throws SchemaNotFoundException {
            return null;
        }
    };
    Map<String, Object> config = Collections.singletonMap(SchemaProvider.SCHEMA_VERSION_RETRIEVER_CONFIG, schemaVersionRetriever);
    avroSchemaProvider.init(config);
}
Also used : SchemaVersionRetriever(com.hortonworks.registries.schemaregistry.SchemaVersionRetriever) SchemaIdVersion(com.hortonworks.registries.schemaregistry.SchemaIdVersion) SchemaVersionKey(com.hortonworks.registries.schemaregistry.SchemaVersionKey) Before(org.junit.Before)

Example 22 with SchemaVersionKey

use of com.hortonworks.registries.schemaregistry.SchemaVersionKey in project registry by hortonworks.

the class SchemaVersionInfoCache method invalidateSchema.

public void invalidateSchema(SchemaVersionInfoCache.Key key) {
    LOG.debug("Invalidating cache entry for key [{}]", key);
    loadingCache.invalidate(key);
    SchemaVersionKey schemaVersionKey = key.schemaIdVersion != null ? idWithNameVersion.get(key.schemaIdVersion) : key.schemaVersionKey;
    // it can be null if it is not accessed earlier.
    if (schemaVersionKey != null) {
        loadingCache.invalidate(Key.of(schemaVersionKey));
        List<SchemaIdVersion> schemaIdVersions = nameVersionWithIds.get(schemaVersionKey);
        if (schemaIdVersions != null) {
            for (SchemaIdVersion schemaIdVersion : schemaIdVersions) {
                loadingCache.invalidate(Key.of(schemaIdVersion));
            }
        }
    }
}
Also used : SchemaIdVersion(com.hortonworks.registries.schemaregistry.SchemaIdVersion) SchemaVersionKey(com.hortonworks.registries.schemaregistry.SchemaVersionKey)

Aggregations

SchemaVersionKey (com.hortonworks.registries.schemaregistry.SchemaVersionKey)22 SchemaVersionInfo (com.hortonworks.registries.schemaregistry.SchemaVersionInfo)11 SchemaIdVersion (com.hortonworks.registries.schemaregistry.SchemaIdVersion)8 SchemaMetadata (com.hortonworks.registries.schemaregistry.SchemaMetadata)8 SchemaMetadataInfo (com.hortonworks.registries.schemaregistry.SchemaMetadataInfo)7 SchemaNotFoundException (com.hortonworks.registries.schemaregistry.errors.SchemaNotFoundException)7 IOException (java.io.IOException)7 InvalidSchemaException (com.hortonworks.registries.schemaregistry.errors.InvalidSchemaException)6 Schema (org.apache.avro.Schema)6 SchemaVersion (com.hortonworks.registries.schemaregistry.SchemaVersion)5 IncompatibleSchemaException (com.hortonworks.registries.schemaregistry.errors.IncompatibleSchemaException)5 Test (org.junit.Test)5 Path (javax.ws.rs.Path)4 Timed (com.codahale.metrics.annotation.Timed)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 CatalogResponse (com.hortonworks.registries.common.catalog.CatalogResponse)3 UnitOfWork (com.hortonworks.registries.common.transaction.UnitOfWork)3 SchemaRegistryClient (com.hortonworks.registries.schemaregistry.client.SchemaRegistryClient)3 UnsupportedSchemaTypeException (com.hortonworks.registries.schemaregistry.errors.UnsupportedSchemaTypeException)3 ApiOperation (io.swagger.annotations.ApiOperation)3