Record Class PartitionTablePayload
- Record Components:
numPartitions- number of partitions in the cluster (must be > 0)partitionToGroup- partition → group id, length == numPartitionsrevision- monotonic revision (used to detect staleness between refreshes)
PARTITION_TABLE_REQUEST /
PARTITION_TABLE_RESPONSE opcodes introduced in
BLK-2026-04-22-007 Day 2.
Carries the server's current partition ownership snapshot — the mapping from each partition id to the Raft group that owns it. Clients cache this snapshot and route keyed requests directly to the owning group instead of relying on server-side NOT_OWNER redirects.
Node-endpoint resolution (which TCP endpoint currently leads each group) is a follow-up: clients still consult their existing leader tracker for that. This payload is the minimum needed to replace the current "hash % active-node-count" routing with a partition-owner lookup.
Legacy wire format (fixed layout, big-endian):
int numPartitions ≥ 1 int × N partitionToGroup[0..N-1] groupId per partition (≥ 0) long revision monotonic snapshot revision
Peers that negotiate ProtocolFeatures.PARTITION_TABLE_ENDPOINTS
may append endpoint metadata after revision. The default serializer
intentionally emits the legacy layout so rolling upgrades do not break old
strict decoders.
-
Constructor Summary
ConstructorsConstructorDescriptionPartitionTablePayload(int numPartitions, int[] partitionToGroup, long revision) PartitionTablePayload(int numPartitions, int[] partitionToGroup, long revision, Map<Integer, String> groupLeaderEndpoints) Creates an instance of aPartitionTablePayloadrecord class. -
Method Summary
Modifier and TypeMethodDescriptionstatic PartitionTablePayloaddeserialize(byte[] bytes) Deserialize a payload from wire bytes.final booleanIndicates whether some other object is "equal to" this one.Returns the value of thegroupLeaderEndpointsrecord component.final inthashCode()Returns a hash code value for this object.intReturns the value of thenumPartitionsrecord component.ownerEndpointForHash(int hash) intownerGroupForHash(int hash) int[]Returns the value of thepartitionToGrouprecord component.longrevision()Returns the value of therevisionrecord component.static byte[]serialize(PartitionTablePayload payload) Serialize a payload to its wire bytes.static byte[]serialize(PartitionTablePayload payload, boolean includeEndpointMetadata) Serialize a payload to its wire bytes.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
PartitionTablePayload
public PartitionTablePayload(int numPartitions, int[] partitionToGroup, long revision) -
PartitionTablePayload
public PartitionTablePayload(int numPartitions, int[] partitionToGroup, long revision, Map<Integer, String> groupLeaderEndpoints) Creates an instance of aPartitionTablePayloadrecord class.- Parameters:
numPartitions- the value for thenumPartitionsrecord componentpartitionToGroup- the value for thepartitionToGrouprecord componentrevision- the value for therevisionrecord componentgroupLeaderEndpoints- the value for thegroupLeaderEndpointsrecord component
-
-
Method Details
-
partitionToGroup
public int[] partitionToGroup()Returns the value of thepartitionToGrouprecord component.- Returns:
- the value of the
partitionToGrouprecord component
-
ownerGroupForHash
public int ownerGroupForHash(int hash) - Returns:
- the group id owning the partition that
hashmaps to
-
ownerEndpointForHash
- Returns:
- the advertised leader/owner endpoint for the group owning
hash, ornullif this snapshot does not carry endpoint metadata for that group
-
serialize
Serialize a payload to its wire bytes.- Parameters:
payload- the payload (non-null)- Returns:
- big-endian wire bytes
-
serialize
Serialize a payload to its wire bytes.- Parameters:
payload- the payload (non-null)includeEndpointMetadata- whether to append negotiated endpoint metadata- Returns:
- big-endian wire bytes
-
deserialize
Deserialize a payload from wire bytes.- Parameters:
bytes- the wire bytes (non-null)- Returns:
- the parsed payload
- Throws:
IllegalArgumentException- if the bytes are truncated or carry invalid fields
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
numPartitions
public int numPartitions()Returns the value of thenumPartitionsrecord component.- Returns:
- the value of the
numPartitionsrecord component
-
revision
-
groupLeaderEndpoints
-