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); } }
@Override public void archiveSchemaVersion(Long schemaVersionId) throws SchemaNotFoundException, SchemaLifecycleException { schemaVersionLifecycleManager.archiveSchemaVersion(schemaVersionId); }
public CompatibilityResult checkCompatibility(String schemaBranchName, String schemaName, String toSchema) throws SchemaNotFoundException, SchemaBranchNotFoundException { return schemaVersionLifecycleManager.checkCompatibility(schemaBranchName, schemaName, toSchema); }
SchemaVersionInfo schemaVersionInfo = getSchemaVersionInfo(new SchemaIdVersion(schemaVersionId)); SchemaMetadataInfo schemaMetadataInfo = getSchemaMetadataInfo(schemaVersionInfo.getName()); Set<SchemaBranch> schemaBranches = getSchemaBranches(schemaVersionId).stream().filter(schemaBranch -> { try { return !getRootVersion(schemaBranch).getId().equals(schemaVersionId); } catch (SchemaNotFoundException e) { throw new RuntimeException(e); 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'", SchemaVersionInfo existingSchemaVersionInfo = findSchemaVersion(SchemaBranch.MASTER_BRANCH, schemaMetadataInfo.getSchemaMetadata() .getType(), createdSchemaVersionInfo = createSchemaVersion(SchemaBranch.MASTER_BRANCH, schemaMetadataInfo.getSchemaMetadata(), schemaMetadataInfo.getId(), updateSchemaVersionState(createdSchemaVersionInfo.getId(), schemaVersionStates.iterator().next().getSequence(), SchemaVersionLifecycleStates.ENABLED.getId(),
if (getSchemaProvider(type) == null) { throw new UnsupportedSchemaTypeException("Given schema type " + type + " not supported"); 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 fingerprint = getFingerprint(type, schemaVersion.getSchemaText()); final String schemaName = schemaMetadata.getName(); CompatibilityResult compatibilityResult = checkCompatibility(schemaBranchName, schemaName, schemaVersion .getSchemaText()); if (!compatibilityResult.isCompatible()) { SchemaVersionInfo latestSchemaVersionInfo = getLatestSchemaVersionInfo(schemaName); if (latestSchemaVersionInfo != null) { version = latestSchemaVersionInfo.getVersion(); updateSchemaVersionState(schemaVersionStorable.getId(), 1, initialState, schemaVersion.getStateDetails()); List<SchemaFieldInfo> schemaFieldInfos = getSchemaProvider(type).generateFields(schemaVersionStorable.getSchemaText()); for (SchemaFieldInfo schemaFieldInfo : schemaFieldInfos) { final Long fieldInstanceId = storageManager.nextId(storableNamespace);
Preconditions.checkNotNull(schemaVersion, "schemaVersion can't be null"); checkSchemaText(schemaVersion.getSchemaText()); SchemaMetadataInfo retrievedschemaMetadataInfo = getSchemaMetadataInfo(schemaName); Long schemaMetadataId; if (retrievedschemaMetadataInfo != null) { schemaMetadataId = retrievedschemaMetadataInfo.getId(); schemaVersionInfo = getSchemaVersionInfo(schemaName, schemaVersion.getSchemaText()); if (schemaVersionInfo == null) { schemaVersionInfo = createSchemaVersion(schemaBranchName, schemaMetadata, retrievedschemaMetadataInfo.getId(), schemaVersionInfo = createSchemaVersion(schemaBranchName, schemaMetadata, schemaMetadataId,
SchemaMetadataInfo schemaMetadataInfo = getSchemaMetadataInfo(schemaName); SchemaMetadata schemaMetadata = schemaMetadataInfo.getSchemaMetadata(); SchemaValidationLevel validationLevel = schemaMetadata.getValidationLevel(); switch (validationLevel) { case LATEST: SchemaVersionInfo latestSchemaVersionInfo = getLatestEnabledSchemaVersionInfo(schemaBranchName, schemaName); if (latestSchemaVersionInfo != null) { compatibilityResult = checkCompatibility(schemaMetadata.getType(), toSchema, latestSchemaVersionInfo.getSchemaText(), Collection<SchemaVersionInfo> schemaVersionInfos = getAllVersions(schemaBranchName, schemaName); for (SchemaVersionInfo schemaVersionInfo : schemaVersionInfos) { if (SchemaVersionLifecycleStates.ENABLED.getId().equals(schemaVersionInfo.getStateId())) { compatibilityResult = checkCompatibility(schemaMetadata.getType(), toSchema, schemaVersionInfo.getSchemaText(),
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()); }
public void disableSchemaVersion(Long schemaVersionId) throws SchemaNotFoundException, SchemaLifecycleException { ImmutablePair<SchemaVersionLifecycleContext, SchemaVersionLifecycleState> pair = createSchemaVersionLifeCycleContextAndState(schemaVersionId); ((InbuiltSchemaVersionLifecycleState) pair.getRight()).disable(pair.getLeft()); }
public SchemaVersionLifecycleManager(StorageManager storageManager, Map<String, Object> props, DefaultSchemaRegistry.SchemaMetadataFetcher schemaMetadataFetcher, SchemaBranchCache schemaBranchCache, HAServerNotificationManager haServerNotificationManager) { this.storageManager = storageManager; this.schemaMetadataFetcher = schemaMetadataFetcher; this.schemaBranchCache = schemaBranchCache; this.haServerNotificationManager = haServerNotificationManager; SchemaVersionLifecycleStateMachine.Builder builder = SchemaVersionLifecycleStateMachine.newBuilder(); DefaultSchemaRegistry.Options options = new DefaultSchemaRegistry.Options(props); schemaVersionRetriever = createSchemaVersionRetriever(); schemaVersionInfoCache = new SchemaVersionInfoCache( schemaVersionRetriever, options.getMaxSchemaCacheSize(), options.getSchemaExpiryInSecs() * 1000L); customSchemaStateExecutor = createSchemaReviewExecutor(props, builder); schemaVersionLifecycleStateMachine = builder.build(); }
schemaVersionLifecycleManager = new SchemaVersionLifecycleManager(storageManager, props, schemaMetadataFetcher, schemaVersionLifecycleManager.getSchemaVersionRetriever());
Collection<AggregatedSchemaBranch> aggregatedSchemaBranches = new ArrayList<>(); for (SchemaBranch schemaBranch : getSchemaBranches(schemaName)) { Long rootVersion = schemaBranch.getName().equals(SchemaBranch.MASTER_BRANCH) ? null: schemaVersionLifecycleManager.getRootVersion(schemaBranch).getId(); Collection<SchemaVersionInfo> schemaVersionInfos = getAllVersions(schemaBranch.getName(), schemaName); schemaVersionInfos.stream().forEach(schemaVersionInfo -> { SchemaVersionLifecycleContext context = null; try { context = schemaVersionLifecycleManager.createSchemaVersionLifeCycleContext(schemaVersionInfo.getId(), SchemaVersionLifecycleStates.INITIATED); MergeInfo mergeInfo = null; if (context.getDetails() == null) {
public SchemaIdVersion addSchemaVersion(String schemaName, SchemaVersion schemaVersion) throws SchemaNotFoundException, IncompatibleSchemaException, InvalidSchemaException, SchemaBranchNotFoundException { lockSchemaMetadata(schemaName); return schemaVersionLifecycleManager.addSchemaVersion(SchemaBranch.MASTER_BRANCH, schemaName, schemaVersion); }
public void deleteSchemaVersion(Long schemaVersionId) throws SchemaNotFoundException, SchemaLifecycleException { ImmutablePair<SchemaVersionLifecycleContext, SchemaVersionLifecycleState> pair = createSchemaVersionLifeCycleContextAndState(schemaVersionId); ((InbuiltSchemaVersionLifecycleState) pair.getRight()).delete(pair.getLeft()); }
public SchemaIdVersion addSchemaVersion(String schemaBranchName, String schemaName, SchemaVersion schemaVersion) throws SchemaNotFoundException, IncompatibleSchemaException, InvalidSchemaException, SchemaBranchNotFoundException { lockSchemaMetadata(schemaName); return schemaVersionLifecycleManager.addSchemaVersion(schemaBranchName, schemaName, schemaVersion); }
public void archiveSchemaVersion(Long schemaVersionId) throws SchemaNotFoundException, SchemaLifecycleException { ImmutablePair<SchemaVersionLifecycleContext, SchemaVersionLifecycleState> pair = createSchemaVersionLifeCycleContextAndState(schemaVersionId); ((InbuiltSchemaVersionLifecycleState) pair.getRight()).archive(pair.getLeft()); }
public SchemaIdVersion addSchemaVersion(String schemaBranchName, SchemaMetadata schemaMetadata, SchemaVersion schemaVersion) throws IncompatibleSchemaException, InvalidSchemaException, SchemaNotFoundException, SchemaBranchNotFoundException { lockSchemaMetadata(schemaMetadata.getName()); return schemaVersionLifecycleManager.addSchemaVersion(schemaBranchName, schemaMetadata, schemaVersion, x -> registerSchemaMetadata(x)); }
public CompatibilityResult checkCompatibility(String schemaName, String toSchema) throws SchemaNotFoundException, SchemaBranchNotFoundException { return schemaVersionLifecycleManager.checkCompatibility(SchemaBranch.MASTER_BRANCH, schemaName, toSchema); }
public void startSchemaVersionReview(Long schemaVersionId) throws SchemaNotFoundException, SchemaLifecycleException { ImmutablePair<SchemaVersionLifecycleContext, SchemaVersionLifecycleState> pair = createSchemaVersionLifeCycleContextAndState(schemaVersionId); ((InbuiltSchemaVersionLifecycleState) pair.getRight()).startReview(pair.getLeft()); }
public SchemaIdVersion addSchemaVersion(SchemaMetadata schemaMetadata, SchemaVersion schemaVersion) throws IncompatibleSchemaException, InvalidSchemaException, SchemaNotFoundException, SchemaBranchNotFoundException { lockSchemaMetadata(schemaMetadata.getName()); return schemaVersionLifecycleManager.addSchemaVersion(SchemaBranch.MASTER_BRANCH, schemaMetadata, schemaVersion, x -> registerSchemaMetadata(x)); }