Class ContextVersionCounter
java.lang.Object
org.gcube.informationsystem.resourceregistry.contexts.ContextVersionCounter
Stores the authoritative version of the persisted Context topology.
- Author:
- Luca Frosini (ISTI - CNR)
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longValue returned when the authoritative version cannot be read. -
Method Summary
Modifier and TypeMethodDescriptionstatic longReads the authoritative Context version from OrientDB.static longincrement(com.orientechnologies.orient.core.db.document.ODatabaseDocument session) Advances the Context version inside the caller's active transaction.static voidCreates the durable counter outside application mutation transactions when necessary.
-
Field Details
-
UNKNOWN_VERSION
public static final long UNKNOWN_VERSIONValue returned when the authoritative version cannot be read.- See Also:
-
-
Method Details
-
initialize
public static void initialize() throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryExceptionCreates the durable counter outside application mutation transactions when necessary.- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if the counter cannot be initialized
-
increment
public static long increment(com.orientechnologies.orient.core.db.document.ODatabaseDocument session) throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Advances the Context version inside the caller's active transaction.- Parameters:
session- the active writer session- Returns:
- the new version
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if the version cannot be advanced
-
getCurrentVersion
public static long getCurrentVersion()Reads the authoritative Context version from OrientDB.- Returns:
- the current version, zero before the first mutation, or
UNKNOWN_VERSION
-