T - the concrete bean type that maps to the DDB table schemapublic abstract class WorkerMetricStatsDAODelegate<T extends WorkerMetricStats> extends Object
WorkerMetricStats from
the DDB table it is stored in.
This follows the same delegate pattern as
CoordinatorStateDAODelegate.
The base class contains all DDB operation implementations. Subclasses provide
their specific table name/configuration, bean type T, and override
initialize() behavior.
The type parameter T allows subclasses to use the correct bean type
for their DDB table schema. The legacy table uses WorkerMetricStats directly
(PK attribute: wid), while the lease table uses
software.amazon.kinesis.worker.metricstats.LeaseTableWorkerMetricStats
(PK attribute: leaseKey).
| Modifier and Type | Field and Description |
|---|---|
protected org.slf4j.Logger |
log |
protected software.amazon.awssdk.enhanced.dynamodb.DynamoDbAsyncTable<T> |
table |
protected String |
tableName |
| Constructor and Description |
|---|
WorkerMetricStatsDAODelegate(software.amazon.awssdk.services.dynamodb.DynamoDbAsyncClient dynamoDbAsyncClient,
String tableName,
Class<T> beanClass,
software.amazon.awssdk.enhanced.dynamodb.TableSchema<T> tableSchema,
String paritionKeyAttributeName,
Long workerMetricsReporterFrequencyMillis,
org.slf4j.Logger logger) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
deleteMetrics(WorkerMetricStats workerMetrics)
Delete the worker metric stats entry with a conditional check on lastUpdateTime.
|
abstract List<WorkerMetricStats> |
getAllWorkerMetricStats()
Retrieve all worker metric stats entries from the backing table
|
protected software.amazon.awssdk.services.dynamodb.DynamoDbAsyncClient |
getDynamoDbAsyncClient() |
protected String |
getTableName() |
abstract void |
initialize()
Initialize the delegate.
|
protected abstract T |
toEntity(WorkerMetricStats workerMetrics)
Convert a base
WorkerMetricStats into the concrete bean type T. |
void |
updateMetrics(WorkerMetricStats workerMetrics)
Update (or create) the worker metric stats for a given worker.
|
protected final org.slf4j.Logger log
protected final String tableName
protected final software.amazon.awssdk.enhanced.dynamodb.DynamoDbAsyncTable<T extends WorkerMetricStats> table
public WorkerMetricStatsDAODelegate(software.amazon.awssdk.services.dynamodb.DynamoDbAsyncClient dynamoDbAsyncClient,
String tableName,
Class<T> beanClass,
software.amazon.awssdk.enhanced.dynamodb.TableSchema<T> tableSchema,
String paritionKeyAttributeName,
Long workerMetricsReporterFrequencyMillis,
org.slf4j.Logger logger)
dynamoDbAsyncClient - the DynamoDB async clienttableName - the name of the DDB tablebeanClass - the class of the bean type (needed for UpdateItemEnhancedRequest)tableSchema - the schema to use for mapping the bean type to/from DDB recordspublic abstract void initialize()
throws DependencyException
DependencyException - if initialization fails due to external dependenciesprotected abstract T toEntity(WorkerMetricStats workerMetrics)
WorkerMetricStats into the concrete bean type T.
The legacy delegate can simply return the input (since T = WorkerMetricStats),
while the lease table delegate converts to LeaseTableWorkerMetricStats.protected software.amazon.awssdk.services.dynamodb.DynamoDbAsyncClient getDynamoDbAsyncClient()
protected String getTableName()
public abstract List<WorkerMetricStats> getAllWorkerMetricStats() throws DependencyException, InvalidStateException, ProvisionedThroughputException
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
workerMetrics - the worker metrics to persistDependencyException - if DynamoDB operation fails unexpectedlyInvalidStateException - if the backing table does not existProvisionedThroughputException - if DynamoDB lacks capacitypublic boolean deleteMetrics(WorkerMetricStats workerMetrics) throws DependencyException, InvalidStateException, ProvisionedThroughputException
workerMetrics - the entry to delete (workerId and lastUpdateTime required)DependencyException - if DynamoDB operation fails unexpectedlyInvalidStateException - if the backing table does not existProvisionedThroughputException - if DynamoDB lacks capacityCopyright © 2026. All rights reserved.