java.lang.Object
org.gcube.informationsystem.resourceregistry.types.SchemaSnapshot

public class SchemaSnapshot extends Object
An immutable, version-stamped view of every Type registered in the system, loaded once and shared by everything derived from it.

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

    Constructors
    Constructor
    Description
    SchemaSnapshot(List<org.gcube.informationsystem.types.reference.Type> types, long schemaVersion)
    Creates a snapshot.
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    Returns when this snapshot was loaded.
    long
    Returns the schema version this snapshot corresponds to.
    List<org.gcube.informationsystem.types.reference.Type>
    Returns every Type known when this snapshot was taken.
    int
    Returns how many types this snapshot holds.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 time
      schemaVersion - the schema version observed before loading began
  • Method Details

    • getTypes

      public List<org.gcube.informationsystem.types.reference.Type> 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