primaryReplicasAsync
- Parameters:
tableId- Table ID.maxStartTime- Timestamp.- Returns:
- Primary replicas for the table, or null when not yet known.
ClientInboundMessageHandler.
Keeps up-to-date lists of primary replicas by partition for every zone, avoiding expensive placement driver calls in most cases.
Every "assignment" (set of primary replicas per partition) is identified by a maxStartTime - latest known lease start time.
Assumptions: - Primary replicas are not changed often. - We do "best effort" partition awareness - it is ok if we don't have the latest primary replicas at some point or don't have them at all. What matters is that we have the correct assignment eventually. - It is allowed to return incomplete assignment (null for some partitions) - better than nothing. - We don't know which tables the client is going to use, so we track a common maxStartTime for all tables.
Tracking logic: - Listen to election events from placement driver, update primary replicas. This is the main source of information. - When we have not yet received events for all partitions of a certain table, and the client requests the assignment, load it from the placement driver. Wait for a limited amount of time (in getPrimaryReplica) and return what we have. Don't block the client for too long, it is better to miss the primary than to delay the request.
static class ClientPrimaryReplicaTracker(org.apache.ignite.internal.placementdriver.PlacementDriver placementDriver,
org.apache.ignite.internal.catalog.CatalogService catalogService,
org.apache.ignite.internal.hlc.ClockService clockService,
org.apache.ignite.internal.schema.SchemaSyncService schemaSyncService,
org.apache.ignite.internal.lowwatermark.LowWatermark lowWatermark) primaryReplicasAsync(int tableId,
@Nullable Long maxStartTime) primaryReplicasAsync(int tableId,
@Nullable Long maxStartTime,
int @Nullable [] partitionIds) placementDriver - Placement driver.catalogService - Catalog.clockService - Clock service.schemaSyncService - Schema synchronization service.lowWatermark - Low watermark.tableId - Table ID.maxStartTime - Timestamp.Only the requested partitions are resolved and awaited, so a partition outside the requested set does not
delay or fail the call. The result list still has one entry per partition of the table; entries for partitions
that were not requested are null.
The result's timestamp comes from the tracker-wide counter, but only the requested partitions are checked against it. Never cache a scoped result as the table's full assignment at that timestamp: the tracker may have older data for the partitions that were not requested.
tableId - Table ID.maxStartTime - Timestamp.partitionIds - Partitions to resolve, null to resolve all partitions of the table.