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 table, 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,
org.apache.ignite.internal.components.NodeProperties nodeProperties) primaryReplicasAsync(int tableId,
@Nullable Long maxStartTime) placementDriver - Placement driver.catalogService - Catalog.clockService - Clock service.schemaSyncService - Schema synchronization service.lowWatermark - Low watermark.tableId - Table ID.maxStartTime - Timestamp.