use of com.hortonworks.registries.schemaregistry.SchemaIdVersion in project registry by hortonworks.
the class SchemaBranchLifeCycleTest method deleteBranchWithRootVersionOfAnotherBranch.
@Test(expected = InvalidSchemaBranchDeletionException.class)
public void deleteBranchWithRootVersionOfAnotherBranch() throws InvalidSchemaException, SchemaNotFoundException, IncompatibleSchemaException, IOException, SchemaBranchAlreadyExistsException, SchemaLifecycleException, InvalidSchemaBranchDeletionException {
SchemaMetadata schemaMetadata = addSchemaMetadata(testNameRule.getMethodName(), SchemaCompatibility.NONE);
SchemaIdVersion masterSchemaIdVersion1 = addSchemaVersion(SchemaBranch.MASTER_BRANCH, schemaMetadata, "/device.avsc");
SchemaBranch schemaBranch1 = addSchemaBranch("BRANCH1", schemaMetadata, masterSchemaIdVersion1.getSchemaVersionId());
SchemaIdVersion schemaBranch1Version1 = addSchemaVersion(schemaBranch1.getName(), schemaMetadata, "/device-incompat.avsc");
addSchemaBranch("CHILD-BRANCH", schemaMetadata, schemaBranch1Version1.getSchemaVersionId());
schemaRegistryClient.enableSchemaVersion(schemaBranch1Version1.getSchemaVersionId());
schemaRegistryClient.archiveSchemaVersion(schemaBranch1Version1.getSchemaVersionId());
schemaRegistryClient.deleteSchemaBranch(schemaBranch1.getId());
}
use of com.hortonworks.registries.schemaregistry.SchemaIdVersion in project registry by hortonworks.
the class SchemaBranchLifeCycleTest method mergeSchemaWithInvalidSchemaVersion.
@Test(expected = SchemaNotFoundException.class)
public void mergeSchemaWithInvalidSchemaVersion() throws IOException, SchemaBranchNotFoundException, InvalidSchemaException, SchemaNotFoundException, IncompatibleSchemaException, SchemaBranchAlreadyExistsException {
SchemaMetadata schemaMetadata = addSchemaMetadata(testNameRule.getMethodName(), SchemaCompatibility.NONE);
SchemaIdVersion masterSchemaIdVersion1 = addSchemaVersion(SchemaBranch.MASTER_BRANCH, schemaMetadata, "/device.avsc");
SchemaBranch schemaBranch1 = addSchemaBranch("BRANCH1", schemaMetadata, masterSchemaIdVersion1.getSchemaVersionId());
SchemaIdVersion schemaBranch1Version1 = addSchemaVersion(schemaBranch1.getName(), schemaMetadata, "/device-incompat.avsc");
schemaRegistryClient.mergeSchemaVersion(schemaBranch1Version1.getSchemaVersionId() + 1);
}
use of com.hortonworks.registries.schemaregistry.SchemaIdVersion in project registry by hortonworks.
the class SchemaBranchLifeCycleTest method deleteSchemaBranch.
@Test
public void deleteSchemaBranch() throws SchemaNotFoundException, SchemaBranchAlreadyExistsException, IOException, InvalidSchemaException, IncompatibleSchemaException, SchemaBranchNotFoundException, InvalidSchemaBranchDeletionException {
SchemaMetadata schemaMetadata = addSchemaMetadata(testNameRule.getMethodName(), SchemaCompatibility.NONE);
SchemaIdVersion masterSchemaIdVersion1 = addSchemaVersion(SchemaBranch.MASTER_BRANCH, schemaMetadata, "/device.avsc");
SchemaBranch schemaBranch1 = addSchemaBranch("BRANCH1", schemaMetadata, masterSchemaIdVersion1.getSchemaVersionId());
addSchemaVersion(schemaBranch1.getName(), schemaMetadata, "/device-incompat.avsc");
addSchemaVersion(schemaBranch1.getName(), schemaMetadata, "/device-compat.avsc");
Assert.assertTrue(schemaRegistryClient.getSchemaBranches(schemaMetadata.getName()).size() == 2);
schemaRegistryClient.deleteSchemaBranch(schemaBranch1.getId());
Collection<SchemaVersionInfo> masterSchemaVersionInfos = schemaRegistryClient.getAllVersions(schemaMetadata.getName());
Assert.assertTrue(masterSchemaVersionInfos.size() == 1);
Assert.assertTrue(schemaRegistryClient.getSchemaBranches(schemaMetadata.getName()).size() == 1);
}
use of com.hortonworks.registries.schemaregistry.SchemaIdVersion in project registry by hortonworks.
the class SchemaBranchLifeCycleTest method createAlreadyExistingBranch.
@Test(expected = SchemaBranchAlreadyExistsException.class)
public void createAlreadyExistingBranch() throws IOException, SchemaBranchNotFoundException, InvalidSchemaException, SchemaNotFoundException, IncompatibleSchemaException, SchemaBranchAlreadyExistsException {
SchemaMetadata schemaMetadata = addSchemaMetadata(testNameRule.getMethodName(), SchemaCompatibility.NONE);
SchemaIdVersion masterSchemaIdVersion1 = addSchemaVersion(SchemaBranch.MASTER_BRANCH, schemaMetadata, "/device.avsc");
SchemaBranch schemaBranch1 = addSchemaBranch("BRANCH1", schemaMetadata, masterSchemaIdVersion1.getSchemaVersionId());
SchemaIdVersion masterSchemaIdVersion2 = addSchemaVersion(SchemaBranch.MASTER_BRANCH, schemaMetadata, "/device-incompat.avsc");
addSchemaBranch(schemaBranch1.getName(), schemaMetadata, masterSchemaIdVersion2.getSchemaVersionId());
}
use of com.hortonworks.registries.schemaregistry.SchemaIdVersion in project registry by hortonworks.
the class SchemaVersionInfoCache method updateCacheInvalidationEntries.
private void updateCacheInvalidationEntries(SchemaVersionInfo schemaVersionInfo) {
// need to support this as SchemaIdVersion supports multiple ways to construct for backward compatible APIs
// this would have been simple without that.
SchemaVersionKey schemaVersionKey = new SchemaVersionKey(schemaVersionInfo.getName(), schemaVersionInfo.getVersion());
SchemaIdVersion key1 = new SchemaIdVersion(schemaVersionInfo.getId());
idWithNameVersion.putIfAbsent(key1, schemaVersionKey);
Long schemaMetadataId = schemaVersionInfo.getSchemaMetadataId();
// schemaMetadataId can be null from earlier registry instances.
if (schemaMetadataId != null) {
SchemaIdVersion key2 = new SchemaIdVersion(schemaMetadataId, schemaVersionInfo.getVersion());
nameVersionWithIds.putIfAbsent(schemaVersionKey, Lists.newArrayList(key1, key2));
idWithNameVersion.putIfAbsent(key2, schemaVersionKey);
} else {
nameVersionWithIds.putIfAbsent(schemaVersionKey, Collections.singletonList(key1));
}
}
Aggregations