Class ArchiveVersionStabilizer
java.lang.Object
org.odpi.openmetadata.samples.archiveutilities.ArchiveVersionStabilizer
Carries the version numbers of unchanged elements over from the previous edition of an archive.
An archive writer stamps every element with the same new version number (see EgeriaBaseArchiveWriter.getVersionNumber()), which tells a repository that the element is newer than the copy it already holds. That is right for an element whose content has changed, but stamping the unchanged ones as well meant that every rebuild changed every element: the archive could not be reproduced, a review of a content change was buried in thousands of version changes, and a repository reloading the archive rewrote every element in it.
This class compares each element and type in the new archive with the one of the same unique identifier in the previous edition. If they are identical apart from version numbers - their own and those of the classifications, entity proxies and attribute types they carry - the previous edition's copy is used, so it keeps its previous versions. New and changed elements keep the new version. An entity is compared together with its classifications, so it keeps its previous version only if none of them has changed.
It also adds a deleted version of each entity and relationship that has been removed since the previous edition (see addDeletedVersions()), so that loading the new edition soft-deletes them from a repository that loaded an earlier one.
An archive writer stamps every element with the same new version number (see EgeriaBaseArchiveWriter.getVersionNumber()), which tells a repository that the element is newer than the copy it already holds. That is right for an element whose content has changed, but stamping the unchanged ones as well meant that every rebuild changed every element: the archive could not be reproduced, a review of a content change was buried in thousands of version changes, and a repository reloading the archive rewrote every element in it.
This class compares each element and type in the new archive with the one of the same unique identifier in the previous edition. If they are identical apart from version numbers - their own and those of the classifications, entity proxies and attribute types they carry - the previous edition's copy is used, so it keeps its previous versions. New and changed elements keep the new version. An entity is compared together with its classifications, so it keeps its previous version only if none of them has changed.
It also adds a deleted version of each entity and relationship that has been removed since the previous edition (see addDeletedVersions()), so that loading the new edition soft-deletes them from a repository that loaded an earlier one.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintaddDeletedVersions(OpenMetadataArchive newArchive, OpenMetadataArchive previousArchive) Add a deleted version of each entity and relationship of the previous edition that is not in the new archive.longgetHighestVersion(OpenMetadataArchive archive) Return the highest version number of any element in an archive, or zero if it has none.intstabilizeVersions(OpenMetadataArchive newArchive, OpenMetadataArchive previousArchive) Give each element and type of the new archive that is unchanged from the previous edition its previous version numbers.
-
Constructor Details
-
ArchiveVersionStabilizer
public ArchiveVersionStabilizer()
-
-
Method Details
-
stabilizeVersions
Give each element and type of the new archive that is unchanged from the previous edition its previous version numbers. An unchanged element is replaced by its copy from the previous edition, so its version - and the versions of the classifications and entity proxies it carries - are exactly as they were.- Parameters:
newArchive- archive about to be written - updated in placepreviousArchive- previous edition of the archive, or null if there is none- Returns:
- number of elements and types whose previous version was kept
-
addDeletedVersions
Add a deleted version of each entity and relationship of the previous edition that is not in the new archive. Without it, an element removed from an archive stays in every repository that loaded an earlier edition, since loading an archive only ever adds or updates elements. The deleted version is the previous edition's copy with its status set to DELETED (keeping the status it had as its statusOnDelete) and its version moved on by one, so a repository holding that copy soft-deletes it, just as it would on receiving the deletion from another member of its cohort. A repository that holds a later version of the element - from a later release - ignores it.
The deleted versions are carried forward unchanged into each later edition (they are in the previous edition but not in the new archive), so a repository that skips an edition still learns of the deletion. An element that is added back is simply in the new archive again, with the new archive's version, which restores it.
Nothing is added if the new archive shares no element with the previous edition. That is not the deliberate removal of the whole content of the archive: the writer has allocated new unique identifiers for everything, typically because it was run from a directory where it could not find its GUID map, and deleting the previous content would wipe it out. Classification extensions are not covered - a deleted entity takes its classifications with it.- Parameters:
newArchive- archive about to be written - updated in placepreviousArchive- previous edition of the archive, or null if there is none- Returns:
- number of deleted versions added, including those carried forward
-
getHighestVersion
Return the highest version number of any element in an archive, or zero if it has none. Once versions are carried over from one edition to the next, the elements of an archive no longer all share one version.- Parameters:
archive- archive to examine- Returns:
- highest version number, or zero
-