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 ClassesModifier and TypeClassDescriptionstatic final recordDurable first-commit result; its epoch is historical evidence, never current write authority. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intLargest complete nested partition command, including its identity and program envelope.static final intLargest complete transferable image, including its checksum.static final intLargest encoded state, reserving space for the complete receipt journal in a16MiB snapshot. -
Constructor Summary
ConstructorsConstructorDescriptionManagedPartitionResource(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 TypeMethodDescriptionvoidapply(long index, byte[] command) org.j7m.middleware.distributed.TransferableResourcebooleanidentityConflict(byte[] command) voidownershipEpoch(long epoch) byte[]query(byte[] query) requestIdentity(byte[] command) voidrestore(byte[] snapshot) byte[]snapshot()booleanvoidvoidvalidateQuery(byte[] query, String scope) voidvalidateReplayCommand(byte[] command) voidvalidateSnapshot(byte[] snapshot) Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.j7m.middleware.consensus.ReplicatedStateMachine
appliedThrough, applyMethods inherited from interface org.j7m.middleware.distributed.TransferableResource
ownershipChanged, timeCommand, timeControl, timeSensitive
-
Field Details
-
MAX_COMMAND_BYTES
public static final int MAX_COMMAND_BYTESLargest complete nested partition command, including its identity and program envelope.- See Also:
-
MAX_STATE_BYTES
public static final int MAX_STATE_BYTESLargest encoded state, reserving space for the complete receipt journal in a16MiB snapshot.- See Also:
-
MAX_SNAPSHOT_BYTES
public static final int MAX_SNAPSHOT_BYTESLargest 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 factoryreducer- exact stateless component, borrowed until all resource work actually drainscodec- borrowed effect-free thread-safe value codecschemas- explicit validated A01 data allowlistfingerprint- host-computed lowercase64-character program/schema/config digestnativeGroup- exact trusted local native replication group identityresourceScope- fixed authenticated tenant/resource scope; state is never shared across scopesmaximumRequests- 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:
ownershipEpochin interfaceorg.j7m.middleware.distributed.TransferableResource
-
transferReady
public boolean transferReady()- Specified by:
transferReadyin interfaceorg.j7m.middleware.distributed.TransferableResource
-
requestIdentity
- Specified by:
requestIdentityin interfaceorg.j7m.middleware.distributed.TransferableResource
-
validate
- Specified by:
validatein interfaceorg.j7m.middleware.distributed.TransferableResource
-
identityConflict
public boolean identityConflict(byte[] command) - Specified by:
identityConflictin interfaceorg.j7m.middleware.distributed.TransferableResource
-
validateReplayCommand
public void validateReplayCommand(byte[] command) - Specified by:
validateReplayCommandin interfaceorg.j7m.middleware.distributed.TransferableResource
-
apply
public void apply(long index, byte[] command) - Specified by:
applyin interfaceorg.j7m.middleware.consensus.ReplicatedStateMachine
-
validateQuery
- Specified by:
validateQueryin interfaceorg.j7m.middleware.distributed.TransferableResource
-
query
public byte[] query(byte[] query) - Specified by:
queryin interfaceorg.j7m.middleware.distributed.TransferableResource
-
copyForTransfer
public org.j7m.middleware.distributed.TransferableResource copyForTransfer()- Specified by:
copyForTransferin interfaceorg.j7m.middleware.distributed.TransferableResource
-
snapshot
public byte[] snapshot()- Specified by:
snapshotin interfaceorg.j7m.middleware.consensus.ReplicatedStateMachine
-
validateSnapshot
public void validateSnapshot(byte[] snapshot) - Specified by:
validateSnapshotin interfaceorg.j7m.middleware.distributed.TransferableResource
-
restore
public void restore(byte[] snapshot) - Specified by:
restorein interfaceorg.j7m.middleware.consensus.ReplicatedStateMachine
-