@Test public void indexRecordTypeAdded() { RecordMetaData metaData1 = RecordMetaData.build(TestRecords1Proto.getDescriptor()); validateIndexMutation("new index adds record type that is not newer than old meta-data", metaData1, "MySimpleRecord$num_value_3_indexed", indexProto -> indexProto.toBuilder().addRecordType("MyOtherRecord").build() ); RecordMetaData tempMetaData = addNewRecordType(metaData1); RecordMetaData metaData2 = replaceIndex(tempMetaData, "MySimpleRecord$num_value_3_indexed", indexProto -> indexProto.toBuilder().addRecordType("NewRecord").build()); validator.validate(metaData1, metaData2); assertInvalid("new index adds record type that is not newer than old meta-data", tempMetaData, metaData2); }
public void validate(@Nonnull RecordMetaData oldMetaData, @Nonnull RecordMetaData newMetaData) { if (oldMetaData.getVersion() > newMetaData.getVersion() || !allowNoVersionChange && oldMetaData.getVersion() == newMetaData.getVersion()) { throw new MetaDataException("new meta-data does not have newer version than old meta-data", LogMessageKeys.OLD_VERSION, oldMetaData.getVersion(), LogMessageKeys.NEW_VERSION, newMetaData.getVersion()); } validateSchemaOptions(oldMetaData, newMetaData); validateUnion(oldMetaData.getUnionDescriptor(), newMetaData.getUnionDescriptor()); Map<String, String> typeRenames = getTypeRenames(oldMetaData.getUnionDescriptor(), newMetaData.getUnionDescriptor()); validateRecordTypes(oldMetaData, newMetaData, typeRenames); validateCurrentAndFormerIndexes(oldMetaData, newMetaData, typeRenames); }
MetaDataEvolutionValidator { public void validate(@Nonnull RecordMetaData oldMetaData, @Nonnull RecordMetaData newMetaData) { if (oldMetaData.getVersion() > newMetaData.getVersion() || !allowNoVersionChange && oldMetaData.getVersion() == newMetaData.getVersion()) { throw new MetaDataException("new meta-data does not have newer version than old meta-data", LogMessageKeys.OLD_VERSION, oldMetaData.getVersion(), LogMessageKeys.NEW_VERSION, newMetaData.getVersion()); } validateSchemaOptions(oldMetaData, newMetaData); validateUnion(oldMetaData.getUnionDescriptor(), newMetaData.getUnionDescriptor()); Map<String, String> typeRenames = getTypeRenames(oldMetaData.getUnionDescriptor(), newMetaData.getUnionDescriptor()); validateRecordTypes(oldMetaData, newMetaData, typeRenames); validateCurrentAndFormerIndexes(oldMetaData, newMetaData, typeRenames); } }
MetaDataEvolutionValidator { public void validate(@Nonnull RecordMetaData oldMetaData, @Nonnull RecordMetaData newMetaData) { if (oldMetaData.getVersion() > newMetaData.getVersion() || !allowNoVersionChange && oldMetaData.getVersion() == newMetaData.getVersion()) { throw new MetaDataException("new meta-data does not have newer version than old meta-data", LogMessageKeys.OLD_VERSION, oldMetaData.getVersion(), LogMessageKeys.NEW_VERSION, newMetaData.getVersion()); } validateSchemaOptions(oldMetaData, newMetaData); validateUnion(oldMetaData.getUnionDescriptor(), newMetaData.getUnionDescriptor()); Map<String, String> typeRenames = getTypeRenames(oldMetaData.getUnionDescriptor(), newMetaData.getUnionDescriptor()); validateRecordTypes(oldMetaData, newMetaData, typeRenames); validateCurrentAndFormerIndexes(oldMetaData, newMetaData, typeRenames); } private  MetaDataEvolutionValidator(); private  MetaDataEvolutionValidator(@Nonnull Builder builder); }
MetaDataEvolutionValidator { public void validate(@Nonnull RecordMetaData oldMetaData, @Nonnull RecordMetaData newMetaData) { if (oldMetaData.getVersion() > newMetaData.getVersion() || !allowNoVersionChange && oldMetaData.getVersion() == newMetaData.getVersion()) { throw new MetaDataException("new meta-data does not have newer version than old meta-data", LogMessageKeys.OLD_VERSION, oldMetaData.getVersion(), LogMessageKeys.NEW_VERSION, newMetaData.getVersion()); } validateSchemaOptions(oldMetaData, newMetaData); validateUnion(oldMetaData.getUnionDescriptor(), newMetaData.getUnionDescriptor()); Map<String, String> typeRenames = getTypeRenames(oldMetaData.getUnionDescriptor(), newMetaData.getUnionDescriptor()); validateRecordTypes(oldMetaData, newMetaData, typeRenames); validateCurrentAndFormerIndexes(oldMetaData, newMetaData, typeRenames); } private  MetaDataEvolutionValidator(); private  MetaDataEvolutionValidator(@Nonnull Builder builder); void validate(@Nonnull RecordMetaData oldMetaData, @Nonnull RecordMetaData newMetaData); @SuppressWarnings("PMD.CompareObjectsWithEquals") void validateUnion(@Nonnull Descriptor oldUnionDescriptor, @Nonnull Descriptor newUnionDescriptor); @Nonnull IndexMaintainerRegistry getIndexMaintainerRegistry(); boolean allowsNoVersionChange(); boolean allowsNoSinceVersion(); boolean allowsIndexRebuilds(); boolean allowsMissingFormerIndexNames(); boolean allowsOlderFormerIndexAddedVersions(); boolean allowsUnsplitToSplit(); boolean disallowsTypeRenames(); @Nonnull Builder asBuilder(); @Nonnull static Builder newBuilder(); @Nonnull static MetaDataEvolutionValidator getDefaultInstance(); }
MetaDataEvolutionValidator { public void validate(@Nonnull RecordMetaData oldMetaData, @Nonnull RecordMetaData newMetaData) { if (oldMetaData.getVersion() > newMetaData.getVersion() || !allowNoVersionChange && oldMetaData.getVersion() == newMetaData.getVersion()) { throw new MetaDataException("new meta-data does not have newer version than old meta-data", LogMessageKeys.OLD_VERSION, oldMetaData.getVersion(), LogMessageKeys.NEW_VERSION, newMetaData.getVersion()); } validateSchemaOptions(oldMetaData, newMetaData); validateUnion(oldMetaData.getUnionDescriptor(), newMetaData.getUnionDescriptor()); Map<String, String> typeRenames = getTypeRenames(oldMetaData.getUnionDescriptor(), newMetaData.getUnionDescriptor()); validateRecordTypes(oldMetaData, newMetaData, typeRenames); validateCurrentAndFormerIndexes(oldMetaData, newMetaData, typeRenames); } private  MetaDataEvolutionValidator(); private  MetaDataEvolutionValidator(@Nonnull Builder builder); void validate(@Nonnull RecordMetaData oldMetaData, @Nonnull RecordMetaData newMetaData); @SuppressWarnings("PMD.CompareObjectsWithEquals") void validateUnion(@Nonnull Descriptor oldUnionDescriptor, @Nonnull Descriptor newUnionDescriptor); @Nonnull IndexMaintainerRegistry getIndexMaintainerRegistry(); boolean allowsNoVersionChange(); boolean allowsNoSinceVersion(); boolean allowsIndexRebuilds(); boolean allowsMissingFormerIndexNames(); boolean allowsOlderFormerIndexAddedVersions(); boolean allowsUnsplitToSplit(); boolean disallowsTypeRenames(); @Nonnull Builder asBuilder(); @Nonnull static Builder newBuilder(); @Nonnull static MetaDataEvolutionValidator getDefaultInstance();  }