Class ManagedPartitionResource

java.lang.Object
org.j7m.middleware.application.distributed.ManagedPartitionResource
All Implemented Interfaces:
org.j7m.middleware.consensus.ReplicatedStateMachine, org.j7m.middleware.distributed.TransferableResource

public final class ManagedPartitionResource extends Object implements org.j7m.middleware.distributed.TransferableResource
Encoded, transferable state and bounded durable receipts for one pure generated POJO reducer. The trusted host must wrap this resource in PartitionStateMachine; exposing raw mutation methods bypasses ownership fencing. Reducer and schema callbacks must be deterministic and effect-free. A snapshot contains state, complete deduplication receipts and logical cursor; no Java heap is serialized. Program identity is exact, not a promise of mixed-code or automatic schema upgrade. Methods are serialized and thread-safe. The borrowed stateless reducer is not closed here.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final record 
    Durable first-commit result; its epoch is historical evidence, never current write authority.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Largest complete nested partition command, including its identity and program envelope.
    static final int
    Largest complete transferable image, including its checksum.
    static final int
    Largest encoded state, reserving space for the complete receipt journal in a16MiB snapshot.
  • Constructor Summary

    Constructors
    Constructor
    Description
    ManagedPartitionResource(org.j7m.middleware.application.api.ManagedPartitionDefinition<?> definition, Object reducer, org.j7m.middleware.codec.api.ValueCodec codec, org.j7m.middleware.codec.api.SchemaRegistry schemas, String fingerprint, String nativeGroup, String resourceScope, int maximumRequests)
    Creates initial encoded state from a validated trusted generated program.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    apply(long index, byte[] command)
    org.j7m.middleware.distributed.TransferableResource
    boolean
    identityConflict(byte[] command)
    void
    ownershipEpoch(long epoch)
    byte[]
    query(byte[] query)
    requestIdentity(byte[] command)
    void
    restore(byte[] snapshot)
    byte[]
    boolean
    void
    validate(byte[] command, String scope, boolean administrative)
    void
    validateQuery(byte[] query, String scope)
    void
    validateReplayCommand(byte[] command)
    void
    validateSnapshot(byte[] snapshot)

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.j7m.middleware.consensus.ReplicatedStateMachine

    appliedThrough, apply

    Methods inherited from interface org.j7m.middleware.distributed.TransferableResource

    ownershipChanged, timeCommand, timeControl, timeSensitive
  • Field Details

    • MAX_COMMAND_BYTES

      public static final int MAX_COMMAND_BYTES
      Largest complete nested partition command, including its identity and program envelope.
      See Also:
    • MAX_STATE_BYTES

      public static final int MAX_STATE_BYTES
      Largest encoded state, reserving space for the complete receipt journal in a16MiB snapshot.
      See Also:
    • MAX_SNAPSHOT_BYTES

      public static final int MAX_SNAPSHOT_BYTES
      Largest complete transferable image, including its checksum.
      See Also:
  • Constructor Details

    • ManagedPartitionResource

      public ManagedPartitionResource(org.j7m.middleware.application.api.ManagedPartitionDefinition<?> definition, Object reducer, org.j7m.middleware.codec.api.ValueCodec codec, org.j7m.middleware.codec.api.SchemaRegistry schemas, String fingerprint, String nativeGroup, String resourceScope, int maximumRequests)
      Creates initial encoded state from a validated trusted generated program.
      Parameters:
      definition - direct generated definition, already validated by the trusted host factory
      reducer - exact stateless component, borrowed until all resource work actually drains
      codec - borrowed effect-free thread-safe value codec
      schemas - explicit validated A01 data allowlist
      fingerprint - host-computed lowercase64-character program/schema/config digest
      nativeGroup - exact trusted local native replication group identity
      resourceScope - fixed authenticated tenant/resource scope; state is never shared across scopes
      maximumRequests - retained durable identities,1..10000; no automatic eviction
      Throws:
      IllegalArgumentException - for invalid program, capacity or initial state
  • Method Details

    • ownershipEpoch

      public void ownershipEpoch(long epoch)
      Specified by:
      ownershipEpoch in interface org.j7m.middleware.distributed.TransferableResource
    • transferReady

      public boolean transferReady()
      Specified by:
      transferReady in interface org.j7m.middleware.distributed.TransferableResource
    • requestIdentity

      public String requestIdentity(byte[] command)
      Specified by:
      requestIdentity in interface org.j7m.middleware.distributed.TransferableResource
    • validate

      public void validate(byte[] command, String scope, boolean administrative)
      Specified by:
      validate in interface org.j7m.middleware.distributed.TransferableResource
    • identityConflict

      public boolean identityConflict(byte[] command)
      Specified by:
      identityConflict in interface org.j7m.middleware.distributed.TransferableResource
    • validateReplayCommand

      public void validateReplayCommand(byte[] command)
      Specified by:
      validateReplayCommand in interface org.j7m.middleware.distributed.TransferableResource
    • apply

      public void apply(long index, byte[] command)
      Specified by:
      apply in interface org.j7m.middleware.consensus.ReplicatedStateMachine
    • validateQuery

      public void validateQuery(byte[] query, String scope)
      Specified by:
      validateQuery in interface org.j7m.middleware.distributed.TransferableResource
    • query

      public byte[] query(byte[] query)
      Specified by:
      query in interface org.j7m.middleware.distributed.TransferableResource
    • copyForTransfer

      public org.j7m.middleware.distributed.TransferableResource copyForTransfer()
      Specified by:
      copyForTransfer in interface org.j7m.middleware.distributed.TransferableResource
    • snapshot

      public byte[] snapshot()
      Specified by:
      snapshot in interface org.j7m.middleware.consensus.ReplicatedStateMachine
    • validateSnapshot

      public void validateSnapshot(byte[] snapshot)
      Specified by:
      validateSnapshot in interface org.j7m.middleware.distributed.TransferableResource
    • restore

      public void restore(byte[] snapshot)
      Specified by:
      restore in interface org.j7m.middleware.consensus.ReplicatedStateMachine