schemaName = metadata.getName();
public Builder(SchemaMetadata schemaMetadata) { name = schemaMetadata.getName(); type = schemaMetadata.getType(); schemaGroup = schemaMetadata.getSchemaGroup(); description = schemaMetadata.getDescription(); compatibility = schemaMetadata.getCompatibility(); validationLevel = schemaMetadata.getValidationLevel(); evolve = schemaMetadata.isEvolve(); }
@Override public CompatibilityResult checkForCompatibility(SchemaMetadata schemaMetadata, String toSchemaText, String existingSchemaText) { return checkCompatibility(schemaMetadata.getType(), toSchemaText, existingSchemaText, schemaMetadata.getCompatibility()); }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; SchemaMetadata that = (SchemaMetadata) o; if (evolve != that.evolve) return false; if (type != null ? !type.equals(that.type) : that.type != null) return false; if (schemaGroup != null ? !schemaGroup.equals(that.schemaGroup) : that.schemaGroup != null) return false; if (name != null ? !name.equals(that.name) : that.name != null) return false; if (description != null ? !description.equals(that.description) : that.description != null) return false; if (getValidationLevel() != null ? !getValidationLevel().equals(that.getValidationLevel()) : that.getValidationLevel() != null) return false; return getCompatibility() == that.getCompatibility(); }
String schemaName = schemaMetadata.getName(); SchemaValidationLevel validationLevel = schemaMetadata.getValidationLevel();
public Long addSchemaMetadata(SchemaMetadata schemaMetadata, boolean throwErrorIfExists) throws UnsupportedSchemaTypeException { SchemaMetadataStorable givenSchemaMetadataStorable = SchemaMetadataStorable.fromSchemaMetadataInfo(new SchemaMetadataInfo(schemaMetadata)); String type = schemaMetadata.getType(); if (schemaTypeWithProviders.get(type) == null) { throw new UnsupportedSchemaTypeException("Given schema type " + type + " not supported"); } if (!throwErrorIfExists) { Storable schemaMetadataStorable = storageManager.get(givenSchemaMetadataStorable.getStorableKey()); if (schemaMetadataStorable != null) { return schemaMetadataStorable.getId(); } } final Long nextId = storageManager.nextId(givenSchemaMetadataStorable.getNameSpace()); givenSchemaMetadataStorable.setId(nextId); givenSchemaMetadataStorable.setTimestamp(System.currentTimeMillis()); storageManager.add(givenSchemaMetadataStorable); // Add a schema branch for this metadata SchemaBranchStorable schemaBranchStorable = new SchemaBranchStorable(SchemaBranch.MASTER_BRANCH, schemaMetadata.getName(), String.format(SchemaBranch.MASTER_BRANCH_DESC, schemaMetadata.getName()), System.currentTimeMillis()); schemaBranchStorable.setId(storageManager.nextId(SchemaBranchStorable.NAME_SPACE)); storageManager.add(schemaBranchStorable); storageManager.add(new SchemaLockStorable(givenSchemaMetadataStorable.getNameSpace(), givenSchemaMetadataStorable.getName(), System.currentTimeMillis())); return givenSchemaMetadataStorable.getId(); }
Response response; try { schemaMetadata.trim(); checkValueAsNullOrEmpty("Schema name", schemaMetadata.getName()); checkValueAsNullOrEmpty("Schema type", schemaMetadata.getType()); checkValidNames(schemaMetadata.getName()); response = WSUtils.respond(Response.Status.INTERNAL_SERVER_ERROR, CatalogResponse.ResponseMessage.EXCEPTION, String.format("Storing the given SchemaMetadata [%s] is failed", schemaMetadata.toString()));
Preconditions.checkNotNull(schemaMetadataId, "schemaMetadataId must not be null"); String type = schemaMetadata.getType(); if (getSchemaProvider(type) == null) { throw new UnsupportedSchemaTypeException("Given schema type " + type + " not supported"); try { schemaBranch = schemaBranchCache.get(SchemaBranchCache.Key.of(new SchemaBranchKey(schemaBranchName, schemaMetadata .getName()))); } catch (SchemaBranchNotFoundException e) { if (getAllVersions(schemaBranchName, schemaMetadata.getName()).size() != 0) throw new RuntimeException(String.format("Schema name : '%s' and branch name : '%s' has schema version, yet failed to obtain schema branch instance", schemaMetadata .getName(), schemaBranchName)); final String schemaName = schemaMetadata.getName(); if (schemaMetadata.isEvolve()) {
SchemaValidationLevel validationLevel = schemaMetadata.getValidationLevel(); CompatibilityResult compatibilityResult = null; switch (validationLevel) { SchemaVersionInfo latestSchemaVersionInfo = getLatestEnabledSchemaVersionInfo(schemaBranchName, schemaName); if (latestSchemaVersionInfo != null) { compatibilityResult = checkCompatibility(schemaMetadata.getType(), toSchema, latestSchemaVersionInfo.getSchemaText(), schemaMetadata.getCompatibility()); if (!compatibilityResult.isCompatible()) { LOG.info("Received schema is not compatible with the latest schema versions [{}] with schema name [{}]", for (SchemaVersionInfo schemaVersionInfo : schemaVersionInfos) { if (SchemaVersionLifecycleStates.ENABLED.getId().equals(schemaVersionInfo.getStateId())) { compatibilityResult = checkCompatibility(schemaMetadata.getType(), toSchema, schemaVersionInfo.getSchemaText(), schemaMetadata.getCompatibility()); if (!compatibilityResult.isCompatible()) { LOG.info("Received schema is not compatible with one of the schema versions [{}] with schema name [{}]",
public SchemaVersionInfo getSchemaVersionInfo(String schemaName, String schemaText) throws SchemaNotFoundException, InvalidSchemaException, SchemaBranchNotFoundException { SchemaMetadataInfo schemaMetadataInfo = getSchemaMetadataInfo(schemaName); if (schemaMetadataInfo == null) { throw new SchemaNotFoundException("No schema found for schema metadata key: " + schemaName); } return findSchemaVersion(SchemaBranch.MASTER_BRANCH, schemaMetadataInfo.getSchemaMetadata() .getType(), schemaText, schemaName); }
@Override public SchemaIdVersion addSchemaVersion(SchemaMetadata schemaMetadata, SchemaVersion schemaVersion) throws InvalidSchemaException, IncompatibleSchemaException, SchemaNotFoundException, SchemaBranchNotFoundException { try { return schemaRegistry.addSchemaVersion(schemaMetadata, new SchemaVersion(schemaVersion.getSchemaText(), schemaMetadata.getDescription())); } catch (UnsupportedSchemaTypeException e) { throw new RuntimeException(e); } }
String schemaName = schemaMetadata.getName(); SchemaValidationLevel validationLevel = schemaMetadata.getValidationLevel();
public SchemaIdVersion addSchemaVersion(String schemaBranchName, SchemaMetadataInfo schemaMetadataInfo, SchemaVersion schemaVersion) throws SchemaNotFoundException, IncompatibleSchemaException, InvalidSchemaException, SchemaBranchNotFoundException { Preconditions.checkNotNull(schemaBranchName, "Schema branch name can't be null"); checkSchemaText(schemaVersion.getSchemaText()); SchemaVersionInfo schemaVersionInfo; // check whether there exists schema-metadata for schema-metadata-key SchemaMetadata schemaMetadata = schemaMetadataInfo.getSchemaMetadata(); // check whether the same schema text exists schemaVersionInfo = findSchemaVersion(schemaBranchName, schemaMetadata.getType(), schemaVersion.getSchemaText(), schemaMetadataInfo .getSchemaMetadata().getName()); if (schemaVersionInfo == null) { schemaVersionInfo = createSchemaVersion(schemaBranchName, schemaMetadata, schemaMetadataInfo.getId(), schemaVersion); } return new SchemaIdVersion(schemaMetadataInfo.getId(), schemaVersionInfo.getVersion(), schemaVersionInfo.getId()); }
Response response; try { schemaMetadata.trim(); checkValueAsNullOrEmpty("Schema name", schemaMetadata.getName()); checkValueAsNullOrEmpty("Schema type", schemaMetadata.getType()); checkValidNames(schemaMetadata.getName()); response = WSUtils.respond(Response.Status.INTERNAL_SERVER_ERROR, CatalogResponse.ResponseMessage.EXCEPTION, String.format("Storing the given SchemaMetadata [%s] is failed", schemaMetadata.toString()));
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; SchemaMetadata that = (SchemaMetadata) o; if (evolve != that.evolve) return false; if (type != null ? !type.equals(that.type) : that.type != null) return false; if (schemaGroup != null ? !schemaGroup.equals(that.schemaGroup) : that.schemaGroup != null) return false; if (name != null ? !name.equals(that.name) : that.name != null) return false; if (description != null ? !description.equals(that.description) : that.description != null) return false; if (getValidationLevel() != null ? !getValidationLevel().equals(that.getValidationLevel()) : that.getValidationLevel() != null) return false; return getCompatibility() == that.getCompatibility(); }
private SnapshotSerializer<Object, byte[], SchemaMetadata> getSnapshotSerializer(SchemaMetadata schemaMetadata) { Collection<SerDesInfo> serializers = schemaRegistryClient.getSerDes(schemaMetadata.getName()); if (serializers.isEmpty()) { throw new RuntimeException("Serializer for schemaKey:" + schemaMetadata + " must exist"); } SerDesInfo serdesInfo = serializers.iterator().next(); return schemaRegistryClient.createSerializerInstance(serdesInfo); }
public Builder(SchemaMetadata schemaMetadata) { name = schemaMetadata.getName(); type = schemaMetadata.getType(); schemaGroup = schemaMetadata.getSchemaGroup(); description = schemaMetadata.getDescription(); compatibility = schemaMetadata.getCompatibility(); validationLevel = schemaMetadata.getValidationLevel(); evolve = schemaMetadata.isEvolve(); }
String schemaName = schemaMetadata.getName(); String schema1 = AvroSchemaRegistryClientUtil.getSchema("/schema-1.avsc"); SchemaIdVersion v1 = schemaRegistryClient.addSchemaVersion(schemaName, new SchemaVersion(schema1, "Initial version of the schema")); SchemaIdVersion v2 = schemaRegistryClient.uploadSchemaVersion(schemaMetadata.getName(), "second version", AvroSchemaRegistryClientTest.class.getResourceAsStream("/schema-2.avsc")); .getValidationLevel());
SchemaVersionInfo latestSchemaVersion = getLatestEnabledSchemaVersionInfo(SchemaBranch.MASTER_BRANCH, schemaMetadataInfo.getSchemaMetadata() .getName()); SchemaVersionInfo rootSchemaVersion = getRootVersion(schemaBranch); if (!latestSchemaVersion.getId().equals(rootSchemaVersion.getId())) { throw new SchemaVersionMergeException(String.format("The latest version of '%s' is different from the root version of the branch : '%s'", SchemaBranch.MASTER_BRANCH, schemaMetadataInfo.getSchemaMetadata() .getName())); SchemaVersionInfo existingSchemaVersionInfo = findSchemaVersion(SchemaBranch.MASTER_BRANCH, schemaMetadataInfo.getSchemaMetadata() .getType(), schemaVersionInfo.getSchemaText(), schemaMetadataInfo.getSchemaMetadata() .getName()); if (existingSchemaVersionInfo != null) { String mergeMessage = String.format("Given version %d is already merged to master with version %d",
@Override public int hashCode() { int result = type != null ? type.hashCode() : 0; result = 31 * result + (schemaGroup != null ? schemaGroup.hashCode() : 0); result = 31 * result + (name != null ? name.hashCode() : 0); result = 31 * result + (description != null ? description.hashCode() : 0); result = 31 * result + (getCompatibility() != null ? getCompatibility().hashCode() : 0); result = 31 * result + (getValidationLevel() != null ? getValidationLevel().hashCode() : 0); result = 31 * result + (evolve ? 1 : 0); return result; }