Class PublishedEventModelMigration

java.lang.Object
io.fluxzero.sdk.configuration.PublishedEventModelMigration
All Implemented Interfaces:
AutoCloseable

public final class PublishedEventModelMigration extends Object implements AutoCloseable
Runs a published-event Aggregate-to-Model migration in an isolated Fluxzero application context.

The migration application registers only the selected Model definitions and one global EVENT consumer. It never registers ordinary application handlers, automatic Model command handling or materialized Graph projections while replaying. Every original global event is reduced through the normal Model replay pipeline without being published again. Direct documents remain invisible until adopt(long) verifies the durable consumer boundary and asks the ModelRepository to adopt them.

The consumer name must remain stable across restarts and application instances. Fluxzero fixes the consumer to one globally ordered tracker and one synchronous handler thread; extra application instances therefore act as failover candidates. Each event's Model commit completes before the next event is reduced and before the durable consumer position advances. The durable position and idempotent source-event identity make restart overlap safe and allow a reading application to coordinate legacy-event Graph injection through ModelRepository.followPublishedEventMigration(String).

A legacy Aggregate application and this migration may run concurrently as separate applications. If an old entity and its replacement Model use the same fully qualified class name, they cannot coexist in one classloader; the migration application must then be built from the new Model classes while the old application keeps running in its own process.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final class 
    Builder for one isolated published-event Model migration application.
  • Method Summary

    Modifier and Type
    Method
    Description
    adopt(long cutoverEventIndex)
    Adopts all staged Model documents after the replay consumer has durably reached cutoverEventIndex.
    Creates a migration builder.
    void
     
    Returns the complete, validated Model catalog used for replay and adoption.
    Returns the stable durable consumer name shared by all migration instances.
    io.fluxzero.common.Registration
    Starts replaying the global event log from its beginning.
    Returns the isolated repository used to validate migrated state before cutover.
    void
    run(String... args)
    Runs the standard migration command-line contract: no arguments starts replay; adopt <event-index> performs the checked cutover operation and then closes the isolated application.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • builder

      public static PublishedEventModelMigration.Builder builder()
      Creates a migration builder.
    • name

      public String name()
      Returns the stable durable consumer name shared by all migration instances.
    • modelTypes

      public List<Class<?>> modelTypes()
      Returns the complete, validated Model catalog used for replay and adoption.
    • repository

      public ModelRepository repository()
      Returns the isolated repository used to validate migrated state before cutover.
    • replay

      public io.fluxzero.common.Registration replay()
      Starts replaying the global event log from its beginning.

      Multiple processes may call this with the same migration name. Exactly one tracker receives the complete segment range; the others remain available for failover.

      Returns:
      a registration that stops this process' replay tracker
    • adopt

      public CompletableFuture<Integer> adopt(long cutoverEventIndex)
      Adopts all staged Model documents after the replay consumer has durably reached cutoverEventIndex.

      Run this as an explicit cutover operation. Per-Model Runtime adoption is atomic and resumable; invoking a single adoption job avoids redundant Graph rebuilds and ambiguous operator reporting.

      Parameters:
      cutoverEventIndex - inclusive global event index that must already have been processed
      Returns:
      the number of staged Model documents visited and adopted by this invocation
    • run

      public void run(String... args)
      Runs the standard migration command-line contract: no arguments starts replay; adopt <event-index> performs the checked cutover operation and then closes the isolated application.
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable