public class LeaseTableWorkerMetricStatsDAODelegate extends WorkerMetricStatsDAODelegate<WorkerMetricStats.LeaseTableWorkerMetricStats>
The lease table uses leaseKey as its partition key attribute name,
whereas the legacy dedicated table uses wid. This delegate uses the
WorkerMetricStats.LeaseTableWorkerMetricStats inner subclass which overrides the partition key
getter to map the workerId field to the leaseKey DDB attribute.
The lease table is always available (created by the lease management layer),
so initialize() is a no-op.
Note on scan efficiency: The scan in getAllWorkerMetricStats() uses a
filter expression on entityType = WORKER_METRIC_STATS. In the legacy dedicated
table this filter is effectively a no-op (all records match). In the lease table, this
is not efficient as DynamoDB still reads the entire table and applies the filter
server-side. A dedicated entityType GSI would have poor partition distribution for lease
entries since all leases share the same entityType value. A better future optimization is
to use the leaseOwner GSI (with entityType stored in the leaseOwner attribute position
(for non-lease entities) and once the GSI becomes available after the migration
state machine completes it can be used for efficient scans which is essentially a query.
log, table, tableName| Constructor and Description |
|---|
LeaseTableWorkerMetricStatsDAODelegate(software.amazon.awssdk.services.dynamodb.DynamoDbAsyncClient dynamoDbAsyncClient,
String leaseTableName,
Long workerMetricsReporterFrequencyMillis) |
| Modifier and Type | Method and Description |
|---|---|
List<WorkerMetricStats> |
getAllWorkerMetricStats()
Retrieve all worker metric stats entries from the backing table, filtered by
entityType = WORKER_METRIC_STATS. |
void |
initialize()
Initialize the delegate.
|
protected WorkerMetricStats.LeaseTableWorkerMetricStats |
toEntity(WorkerMetricStats workerMetrics)
Convert a base
WorkerMetricStats into a WorkerMetricStats.LeaseTableWorkerMetricStats
so the Enhanced Client maps workerId to the leaseKey attribute. |
void |
updateMetrics(WorkerMetricStats workerMetrics)
Update (or create) the worker metric stats for a given worker.
|
deleteMetrics, getDynamoDbAsyncClient, getTableNamepublic void initialize()
throws DependencyException
WorkerMetricStatsDAODelegateinitialize in class WorkerMetricStatsDAODelegate<WorkerMetricStats.LeaseTableWorkerMetricStats>DependencyException - if initialization fails due to external dependenciespublic List<WorkerMetricStats> getAllWorkerMetricStats() throws DependencyException, InvalidStateException, ProvisionedThroughputException
entityType = WORKER_METRIC_STATS. In the legacy dedicated table this
filter is a no-op since all entries should match. In the lease table, this
ensures only WorkerMetricStats records are returned (not leases, coordinator state, etc.).getAllWorkerMetricStats in class WorkerMetricStatsDAODelegate<WorkerMetricStats.LeaseTableWorkerMetricStats>WorkerMetricStats entriesDependencyException - if DynamoDB operation fails unexpectedlyInvalidStateException - if the backing table does not existProvisionedThroughputException - if DynamoDB lacks capacitypublic void updateMetrics(WorkerMetricStats workerMetrics) throws DependencyException, InvalidStateException, ProvisionedThroughputException
WorkerMetricStatsDAODelegateupdateMetrics in class WorkerMetricStatsDAODelegate<WorkerMetricStats.LeaseTableWorkerMetricStats>workerMetrics - the worker metrics to persistDependencyException - if DynamoDB operation fails unexpectedlyInvalidStateException - if the backing table does not existProvisionedThroughputException - if DynamoDB lacks capacityprotected WorkerMetricStats.LeaseTableWorkerMetricStats toEntity(WorkerMetricStats workerMetrics)
WorkerMetricStats into a WorkerMetricStats.LeaseTableWorkerMetricStats
so the Enhanced Client maps workerId to the leaseKey attribute.toEntity in class WorkerMetricStatsDAODelegate<WorkerMetricStats.LeaseTableWorkerMetricStats>Copyright © 2026. All rights reserved.