public class WorkerMetricStatsDAO extends Object
WorkerMetricStats operations to the appropriate
DDB table based on the TableMigrationStatus.
TableMigrationStatusProvider.
If status == COMPLETE, reads only from lease table.
Otherwise combines results from both legacy and lease table delegates.
Caller is responsible for determining which entries are current/latest/not expired.
| Constructor and Description |
|---|
WorkerMetricStatsDAO(software.amazon.awssdk.services.dynamodb.DynamoDbAsyncClient dynamoDbAsyncClient,
LeaseManagementConfig.WorkerMetricsTableConfig workerMetricsTableConfig,
String leaseTableName,
Long workerMetricsReporterFrequencyMillis,
TableMigrationStatusProvider tableMigrationStatusProvider) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
deleteMetrics(WorkerMetricStats workerMetrics)
Delete the worker metric stats entry with a conditional check on lastUpdateTime.
|
List<WorkerMetricStats> |
getAllWorkerMetricStats()
Get all worker metric stats by combining results from both delegates.
|
LeaseTableWorkerMetricStatsDAODelegate |
getLeaseTableDaoDelegate() |
LegacyTableWorkerMetricStatsDAODelegate |
getLegacyTableDaoDelegate() |
void |
initialize()
Initialize the DAO: initializes both delegates and caches the current migration status
to determine the write target for the lifetime of this DAO instance.
|
void |
updateMetrics(WorkerMetricStats workerMetrics)
Update (or create) the worker metric stats for a given worker.
|
public WorkerMetricStatsDAO(software.amazon.awssdk.services.dynamodb.DynamoDbAsyncClient dynamoDbAsyncClient,
LeaseManagementConfig.WorkerMetricsTableConfig workerMetricsTableConfig,
String leaseTableName,
Long workerMetricsReporterFrequencyMillis,
TableMigrationStatusProvider tableMigrationStatusProvider)
public LegacyTableWorkerMetricStatsDAODelegate getLegacyTableDaoDelegate()
public LeaseTableWorkerMetricStatsDAODelegate getLeaseTableDaoDelegate()
public void initialize()
throws DependencyException
DependencyException - if unable to determine legacy table existenceInvalidStateException - if the TableMigrationStatusProvider is still UNKNOWNpublic List<WorkerMetricStats> getAllWorkerMetricStats() throws DependencyException, InvalidStateException, ProvisionedThroughputException
DependencyException - if DDB fails unexpectedlyInvalidStateException - if a required table does not existProvisionedThroughputException - if DDB lacks capacitypublic void updateMetrics(WorkerMetricStats workerMetrics) throws DependencyException, InvalidStateException, ProvisionedThroughputException
workerMetrics - the worker metrics to persistDependencyException - if DDB fails unexpectedlyInvalidStateException - if not initialized or table does not existProvisionedThroughputException - if DDB lacks capacitypublic boolean deleteMetrics(WorkerMetricStats workerMetrics) throws DependencyException, InvalidStateException, ProvisionedThroughputException
workerMetrics - the entry to delete (workerId and lastUpdateTime required)DependencyException - if DDB fails unexpectedlyInvalidStateException - if not initialized or table does not existProvisionedThroughputException - if DDB lacks capacityCopyright © 2026. All rights reserved.