private SchemaDigestEntry buildSchemaTextEntry(SchemaVersion schemaVersion, String name) { byte[] digest; try { digest = MessageDigest.getInstance("MD5").digest(schemaVersion.getSchemaText().getBytes("UTF-8")); } catch (NoSuchAlgorithmException | UnsupportedEncodingException e) { throw new RuntimeException(e.getMessage(), e); } // storing schema text string is expensive, so storing digest in cache's key. return new SchemaDigestEntry(name, digest); }
public SchemaIdVersion addSchemaVersion(String schemaBranchName, String schemaName, SchemaVersion schemaVersion) throws SchemaNotFoundException, IncompatibleSchemaException, InvalidSchemaException, SchemaBranchNotFoundException { Preconditions.checkNotNull(schemaBranchName, "Schema branch name can't be null"); Preconditions.checkNotNull(schemaName, "schemaName can't be null"); Preconditions.checkNotNull(schemaVersion, "schemaVersion can't be null"); checkSchemaText(schemaVersion.getSchemaText()); // check whether there exists schema-metadata for schema-metadata-key SchemaMetadataInfo schemaMetadataInfo = getSchemaMetadataInfo(schemaName); if (schemaMetadataInfo != null) { return addSchemaVersion(schemaBranchName, schemaMetadataInfo, schemaVersion); } else { throw new SchemaNotFoundException("SchemaMetadata not found with the schemaName: " + schemaName); } }
LOG.info("Registered schemaMetadataId [{}] for schema with name:[{}]", schemaMetadataId, schemaName); String streamsSchemaText = streamsSchemaInfo.getSchemaVersion().getSchemaText(); try {
Preconditions.checkNotNull(schemaVersion, "schemaVersion can't be null"); checkSchemaText(schemaVersion.getSchemaText()); schemaMetadataId = retrievedschemaMetadataInfo.getId(); schemaVersionInfo = getSchemaVersionInfo(schemaName, schemaVersion.getSchemaText()); if (schemaVersionInfo == null) { schemaVersionInfo = createSchemaVersion(schemaBranchName,
@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); } }
@Override public SchemaIdVersion addSchemaVersion(String schemaName, SchemaVersion schemaVersion) throws InvalidSchemaException, IncompatibleSchemaException, SchemaNotFoundException, SchemaBranchNotFoundException { try { return schemaRegistry.addSchemaVersion(schemaName, new SchemaVersion(schemaVersion.getSchemaText(), schemaVersion.getDescription())); } catch (UnsupportedSchemaTypeException e) { throw new RuntimeException(e); } }
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()); }
final String fingerprint = getFingerprint(type, schemaVersion.getSchemaText()); final String schemaName = schemaMetadata.getName(); schemaVersionStorable.setSchemaText(schemaVersion.getSchemaText()); schemaVersionStorable.setDescription(schemaVersion.getDescription()); schemaVersionStorable.setTimestamp(System.currentTimeMillis()); SchemaVersionLifecycleStates.INITIATED.getId().equals(initialState)) { CompatibilityResult compatibilityResult = checkCompatibility(schemaBranchName, schemaName, schemaVersion .getSchemaText()); if (!compatibilityResult.isCompatible()) { String errMsg = String.format("Given schema is not compatible with latest schema versions. \n" +