Class SchemaSnapshot
Loading the full schema is expensive: it walks the type graph and reassembles every definition. It used to be performed solely to serialize the result into Redis, after which the loaded objects were discarded — so any other consumer needing the same information had to pay for it again. The same load now produces this value object, which feeds the Redis cache, the model knowledge, and the generated documentation alike.
The schemaVersion is the value of SchemaVersionCounter observed when the load
began. A consumer records the version its projection was built from and compares it against the
current one to decide whether it is stale — which is what makes the projections self-healing when
a change notification is lost. Taking the version before the load is deliberate: if a
change lands midway through, the snapshot is stamped with the older version and will simply be
rebuilt, whereas stamping it afterwards could mark a partially-stale snapshot as current.
- Author:
- Luca Frosini (ISTI - CNR)
-
Constructor Summary
ConstructorsConstructorDescriptionSchemaSnapshot(List<org.gcube.informationsystem.types.reference.Type> types, long schemaVersion) Creates a snapshot. -
Method Summary
Modifier and TypeMethodDescriptionlongReturns when this snapshot was loaded.longReturns the schema version this snapshot corresponds to.List<org.gcube.informationsystem.types.reference.Type>getTypes()Returns every Type known when this snapshot was taken.intsize()Returns how many types this snapshot holds.
-
Constructor Details
-
SchemaSnapshot
public SchemaSnapshot(List<org.gcube.informationsystem.types.reference.Type> types, long schemaVersion) Creates a snapshot.- Parameters:
types- every Type known at load timeschemaVersion- the schema version observed before loading began
-
-
Method Details
-
getTypes
Returns every Type known when this snapshot was taken.- Returns:
- an unmodifiable list of types
-
getSchemaVersion
public long getSchemaVersion()Returns the schema version this snapshot corresponds to.- Returns:
- the schema version
-
getLoadedAt
public long getLoadedAt()Returns when this snapshot was loaded.- Returns:
- the load time, in milliseconds since the epoch
-
size
public int size()Returns how many types this snapshot holds.- Returns:
- the type count
-