From 8c8e9330711268a195e32975426826882aa18cf9 Mon Sep 17 00:00:00 2001 From: Lucien Luc Date: Tue, 20 Feb 2024 13:53:39 -0800 Subject: [PATCH 1/3] Add deletionProtectionEnabled config --- .../kinesis/leases/LeaseManagementConfig.java | 8 ++++++++ .../DynamoDBLeaseManagementFactory.java | 19 +++++++++++++------ .../dynamodb/DynamoDBLeaseRefresher.java | 14 ++++++++++---- ...tegrationBillingModePayPerRequestTest.java | 2 +- .../kinesis/leases/LeaseIntegrationTest.java | 2 +- .../dynamodb/DynamoDBLeaseRefresherTest.java | 10 +++++++--- 6 files changed, 40 insertions(+), 15 deletions(-) diff --git a/amazon-kinesis-client/src/main/java/software/amazon/kinesis/leases/LeaseManagementConfig.java b/amazon-kinesis-client/src/main/java/software/amazon/kinesis/leases/LeaseManagementConfig.java index 9b95f562b..769dd0c1b 100644 --- a/amazon-kinesis-client/src/main/java/software/amazon/kinesis/leases/LeaseManagementConfig.java +++ b/amazon-kinesis-client/src/main/java/software/amazon/kinesis/leases/LeaseManagementConfig.java @@ -194,6 +194,13 @@ public class LeaseManagementConfig { private BillingMode billingMode = BillingMode.PAY_PER_REQUEST; + /** + * Whether to enabled deletion protection on the DyanmoDB lease table created by KCL. + * + *

Default value: false + */ + private boolean deletionProtectionEnabled = false; + /** * The list of tags to be applied to the DynamoDB table created for lease management. * @@ -382,6 +389,7 @@ public LeaseManagementFactory leaseManagementFactory(final LeaseSerializer lease tableCreatorCallback(), dynamoDbRequestTimeout(), billingMode(), + deletionProtectionEnabled(), tags(), leaseSerializer, customShardDetectorProvider(), diff --git a/amazon-kinesis-client/src/main/java/software/amazon/kinesis/leases/dynamodb/DynamoDBLeaseManagementFactory.java b/amazon-kinesis-client/src/main/java/software/amazon/kinesis/leases/dynamodb/DynamoDBLeaseManagementFactory.java index 8b60f6dd2..92844462b 100644 --- a/amazon-kinesis-client/src/main/java/software/amazon/kinesis/leases/dynamodb/DynamoDBLeaseManagementFactory.java +++ b/amazon-kinesis-client/src/main/java/software/amazon/kinesis/leases/dynamodb/DynamoDBLeaseManagementFactory.java @@ -89,6 +89,7 @@ public class DynamoDBLeaseManagementFactory implements LeaseManagementFactory { private final TableCreatorCallback tableCreatorCallback; private final Duration dynamoDbRequestTimeout; private final BillingMode billingMode; + private final boolean deletionProtectionEnabled; private final Collection tags; private final boolean isMultiStreamMode; private final LeaseCleanupConfig leaseCleanupConfig; @@ -450,7 +451,7 @@ private DynamoDBLeaseManagementFactory(final KinesisAsyncClient kinesisClient, f ignoreUnexpectedChildShards, shardSyncIntervalMillis, consistentReads, listShardsBackoffTimeMillis, maxListShardsRetryAttempts, maxCacheMissesBeforeReload, listShardsCacheAllowedAgeInSeconds, cacheMissWarningModulus, initialLeaseTableReadCapacity, initialLeaseTableWriteCapacity, - deprecatedHierarchicalShardSyncer, tableCreatorCallback, dynamoDbRequestTimeout, billingMode, + deprecatedHierarchicalShardSyncer, tableCreatorCallback, dynamoDbRequestTimeout, billingMode, false, DefaultSdkAutoConstructList.getInstance(), leaseSerializer); } @@ -483,6 +484,7 @@ private DynamoDBLeaseManagementFactory(final KinesisAsyncClient kinesisClient, f * @param tableCreatorCallback * @param dynamoDbRequestTimeout * @param billingMode + * @param deletionProtectionEnabled * @param tags */ private DynamoDBLeaseManagementFactory(final KinesisAsyncClient kinesisClient, final StreamConfig streamConfig, @@ -495,15 +497,17 @@ private DynamoDBLeaseManagementFactory(final KinesisAsyncClient kinesisClient, f final long listShardsCacheAllowedAgeInSeconds, final int cacheMissWarningModulus, final long initialLeaseTableReadCapacity, final long initialLeaseTableWriteCapacity, final HierarchicalShardSyncer deprecatedHierarchicalShardSyncer, final TableCreatorCallback tableCreatorCallback, - Duration dynamoDbRequestTimeout, BillingMode billingMode, Collection tags, LeaseSerializer leaseSerializer) { + Duration dynamoDbRequestTimeout, BillingMode billingMode, final boolean deletionProtectionEnabled, + Collection tags, LeaseSerializer leaseSerializer) { this(kinesisClient, dynamoDBClient, tableName, workerIdentifier, executorService, failoverTimeMillis, epsilonMillis, maxLeasesForWorker, maxLeasesToStealAtOneTime, maxLeaseRenewalThreads, cleanupLeasesUponShardCompletion, ignoreUnexpectedChildShards, shardSyncIntervalMillis, consistentReads, listShardsBackoffTimeMillis, maxListShardsRetryAttempts, maxCacheMissesBeforeReload, listShardsCacheAllowedAgeInSeconds, cacheMissWarningModulus, initialLeaseTableReadCapacity, initialLeaseTableWriteCapacity, - deprecatedHierarchicalShardSyncer, tableCreatorCallback, dynamoDbRequestTimeout, billingMode, tags, leaseSerializer, - null, false, LeaseManagementConfig.DEFAULT_LEASE_CLEANUP_CONFIG); + deprecatedHierarchicalShardSyncer, tableCreatorCallback, dynamoDbRequestTimeout, billingMode, + deletionProtectionEnabled, tags, leaseSerializer, null, false, + LeaseManagementConfig.DEFAULT_LEASE_CLEANUP_CONFIG); this.streamConfig = streamConfig; } @@ -534,6 +538,7 @@ private DynamoDBLeaseManagementFactory(final KinesisAsyncClient kinesisClient, f * @param tableCreatorCallback * @param dynamoDbRequestTimeout * @param billingMode + * @param deletionProtectionEnabled * @param leaseSerializer * @param customShardDetectorProvider * @param isMultiStreamMode @@ -549,7 +554,8 @@ public DynamoDBLeaseManagementFactory(final KinesisAsyncClient kinesisClient, final long listShardsCacheAllowedAgeInSeconds, final int cacheMissWarningModulus, final long initialLeaseTableReadCapacity, final long initialLeaseTableWriteCapacity, final HierarchicalShardSyncer deprecatedHierarchicalShardSyncer, final TableCreatorCallback tableCreatorCallback, - Duration dynamoDbRequestTimeout, BillingMode billingMode, Collection tags, LeaseSerializer leaseSerializer, + Duration dynamoDbRequestTimeout, BillingMode billingMode, final boolean deletionProtectionEnabled, + Collection tags, LeaseSerializer leaseSerializer, Function customShardDetectorProvider, boolean isMultiStreamMode, LeaseCleanupConfig leaseCleanupConfig) { this.kinesisClient = kinesisClient; @@ -577,6 +583,7 @@ public DynamoDBLeaseManagementFactory(final KinesisAsyncClient kinesisClient, this.tableCreatorCallback = tableCreatorCallback; this.dynamoDbRequestTimeout = dynamoDbRequestTimeout; this.billingMode = billingMode; + this.deletionProtectionEnabled = deletionProtectionEnabled; this.leaseSerializer = leaseSerializer; this.customShardDetectorProvider = customShardDetectorProvider; this.isMultiStreamMode = isMultiStreamMode; @@ -648,7 +655,7 @@ public ShardSyncTaskManager createShardSyncTaskManager(MetricsFactory metricsFac @Override public DynamoDBLeaseRefresher createLeaseRefresher() { return new DynamoDBLeaseRefresher(tableName, dynamoDBClient, leaseSerializer, consistentReads, - tableCreatorCallback, dynamoDbRequestTimeout, billingMode, tags); + tableCreatorCallback, dynamoDbRequestTimeout, billingMode, deletionProtectionEnabled, tags); } @Override diff --git a/amazon-kinesis-client/src/main/java/software/amazon/kinesis/leases/dynamodb/DynamoDBLeaseRefresher.java b/amazon-kinesis-client/src/main/java/software/amazon/kinesis/leases/dynamodb/DynamoDBLeaseRefresher.java index c87f3eb85..756711812 100644 --- a/amazon-kinesis-client/src/main/java/software/amazon/kinesis/leases/dynamodb/DynamoDBLeaseRefresher.java +++ b/amazon-kinesis-client/src/main/java/software/amazon/kinesis/leases/dynamodb/DynamoDBLeaseRefresher.java @@ -80,6 +80,7 @@ public class DynamoDBLeaseRefresher implements LeaseRefresher { private final Duration dynamoDbRequestTimeout; private final BillingMode billingMode; + private final boolean deletionProtectionEnabled; private final Collection tags; private boolean newTableCreated = false; @@ -134,7 +135,7 @@ public DynamoDBLeaseRefresher(final String table, final DynamoDbAsyncClient dyna public DynamoDBLeaseRefresher(final String table, final DynamoDbAsyncClient dynamoDBClient, final LeaseSerializer serializer, final boolean consistentReads, @NonNull final TableCreatorCallback tableCreatorCallback, Duration dynamoDbRequestTimeout) { - this(table, dynamoDBClient, serializer, consistentReads, tableCreatorCallback, dynamoDbRequestTimeout, BillingMode.PAY_PER_REQUEST); + this(table, dynamoDBClient, serializer, consistentReads, tableCreatorCallback, dynamoDbRequestTimeout, BillingMode.PAY_PER_REQUEST, false); } /** @@ -146,14 +147,15 @@ public DynamoDBLeaseRefresher(final String table, final DynamoDbAsyncClient dyna * @param tableCreatorCallback * @param dynamoDbRequestTimeout * @param billingMode + * @param deletionProtectionEnabled */ @Deprecated public DynamoDBLeaseRefresher(final String table, final DynamoDbAsyncClient dynamoDBClient, final LeaseSerializer serializer, final boolean consistentReads, @NonNull final TableCreatorCallback tableCreatorCallback, Duration dynamoDbRequestTimeout, - final BillingMode billingMode) { + final BillingMode billingMode, final boolean deletionProtectionEnabled) { this(table, dynamoDBClient, serializer, consistentReads, tableCreatorCallback, dynamoDbRequestTimeout, - billingMode, DefaultSdkAutoConstructList.getInstance()); + billingMode, deletionProtectionEnabled, DefaultSdkAutoConstructList.getInstance()); } /** @@ -165,12 +167,14 @@ public DynamoDBLeaseRefresher(final String table, final DynamoDbAsyncClient dyna * @param tableCreatorCallback * @param dynamoDbRequestTimeout * @param billingMode + * @param deletionProtectionEnabled * @param tags */ public DynamoDBLeaseRefresher(final String table, final DynamoDbAsyncClient dynamoDBClient, final LeaseSerializer serializer, final boolean consistentReads, @NonNull final TableCreatorCallback tableCreatorCallback, Duration dynamoDbRequestTimeout, - final BillingMode billingMode, final Collection tags) { + final BillingMode billingMode, final boolean deletionProtectionEnabled, + final Collection tags) { this.table = table; this.dynamoDBClient = dynamoDBClient; this.serializer = serializer; @@ -178,6 +182,7 @@ public DynamoDBLeaseRefresher(final String table, final DynamoDbAsyncClient dyna this.tableCreatorCallback = tableCreatorCallback; this.dynamoDbRequestTimeout = dynamoDbRequestTimeout; this.billingMode = billingMode; + this.deletionProtectionEnabled = deletionProtectionEnabled; this.tags = tags; } @@ -806,6 +811,7 @@ protected DependencyException convertAndRethrowExceptions(String operation, Stri private CreateTableRequest.Builder createTableRequestBuilder() { final CreateTableRequest.Builder builder = CreateTableRequest.builder().tableName(table).keySchema(serializer.getKeySchema()) .attributeDefinitions(serializer.getAttributeDefinitions()) + .deletionProtectionEnabled(deletionProtectionEnabled) .tags(tags); if (BillingMode.PAY_PER_REQUEST.equals(billingMode)) { builder.billingMode(billingMode); diff --git a/amazon-kinesis-client/src/test/java/software/amazon/kinesis/leases/LeaseIntegrationBillingModePayPerRequestTest.java b/amazon-kinesis-client/src/test/java/software/amazon/kinesis/leases/LeaseIntegrationBillingModePayPerRequestTest.java index 128d347a7..c9b791898 100644 --- a/amazon-kinesis-client/src/test/java/software/amazon/kinesis/leases/LeaseIntegrationBillingModePayPerRequestTest.java +++ b/amazon-kinesis-client/src/test/java/software/amazon/kinesis/leases/LeaseIntegrationBillingModePayPerRequestTest.java @@ -23,6 +23,6 @@ public class LeaseIntegrationBillingModePayPerRequestTest extends LeaseIntegrati @Override protected DynamoDBLeaseRefresher getLeaseRefresher() { return new DynamoDBLeaseRefresher(tableName+"Per-Request", ddbClient, leaseSerializer, true, - tableCreatorCallback, LeaseManagementConfig.DEFAULT_REQUEST_TIMEOUT, BillingMode.PAY_PER_REQUEST); + tableCreatorCallback, LeaseManagementConfig.DEFAULT_REQUEST_TIMEOUT, BillingMode.PAY_PER_REQUEST, false); } } diff --git a/amazon-kinesis-client/src/test/java/software/amazon/kinesis/leases/LeaseIntegrationTest.java b/amazon-kinesis-client/src/test/java/software/amazon/kinesis/leases/LeaseIntegrationTest.java index fd5106e40..66b221c8d 100644 --- a/amazon-kinesis-client/src/test/java/software/amazon/kinesis/leases/LeaseIntegrationTest.java +++ b/amazon-kinesis-client/src/test/java/software/amazon/kinesis/leases/LeaseIntegrationTest.java @@ -74,7 +74,7 @@ protected void starting(Description description) { protected DynamoDBLeaseRefresher getLeaseRefresher() { return new DynamoDBLeaseRefresher(tableName, ddbClient, leaseSerializer, true, - tableCreatorCallback, LeaseManagementConfig.DEFAULT_REQUEST_TIMEOUT, BillingMode.PAY_PER_REQUEST); + tableCreatorCallback, LeaseManagementConfig.DEFAULT_REQUEST_TIMEOUT, BillingMode.PAY_PER_REQUEST, false); } } diff --git a/amazon-kinesis-client/src/test/java/software/amazon/kinesis/leases/dynamodb/DynamoDBLeaseRefresherTest.java b/amazon-kinesis-client/src/test/java/software/amazon/kinesis/leases/dynamodb/DynamoDBLeaseRefresherTest.java index 102a9f17d..ac4d1cc20 100644 --- a/amazon-kinesis-client/src/test/java/software/amazon/kinesis/leases/dynamodb/DynamoDBLeaseRefresherTest.java +++ b/amazon-kinesis-client/src/test/java/software/amazon/kinesis/leases/dynamodb/DynamoDBLeaseRefresherTest.java @@ -81,6 +81,7 @@ public class DynamoDBLeaseRefresherTest { private static final String TABLE_NAME = "test"; private static final boolean CONSISTENT_READS = true; + private static final boolean DELETION_PROTECTION_ENABLED = false; @Mock private DynamoDbAsyncClient dynamoDbClient; @@ -127,6 +128,7 @@ public void setup() throws Exception { .keySchema(leaseSerializer.getKeySchema()) .attributeDefinitions(leaseSerializer.getAttributeDefinitions()) .billingMode(BillingMode.PAY_PER_REQUEST) + .deletionProtectionEnabled(DELETION_PROTECTION_ENABLED) .build(); } @@ -286,7 +288,7 @@ public void testLeaseTableExistsTimesOut() throws Exception { @Test public void testCreateLeaseTableProvisionedBillingModeIfNotExists() throws Exception { leaseRefresher = new DynamoDBLeaseRefresher(TABLE_NAME, dynamoDbClient, leaseSerializer, CONSISTENT_READS, - tableCreatorCallback, LeaseManagementConfig.DEFAULT_REQUEST_TIMEOUT, BillingMode.PROVISIONED); + tableCreatorCallback, LeaseManagementConfig.DEFAULT_REQUEST_TIMEOUT, BillingMode.PROVISIONED, DELETION_PROTECTION_ENABLED); when(dynamoDbClient.describeTable(describeTableRequest)).thenReturn(mockDescribeTableFuture); when(mockDescribeTableFuture.get(eq(LeaseManagementConfig.DEFAULT_REQUEST_TIMEOUT.toMillis()), eq(TimeUnit.MILLISECONDS))) @@ -299,6 +301,7 @@ public void testCreateLeaseTableProvisionedBillingModeIfNotExists() throws Excep .keySchema(leaseSerializer.getKeySchema()) .attributeDefinitions(leaseSerializer.getAttributeDefinitions()) .provisionedThroughput(throughput) + .deletionProtectionEnabled(DELETION_PROTECTION_ENABLED) .build(); when(dynamoDbClient.createTable(createTableRequest)).thenReturn(mockCreateTableFuture); when(mockCreateTableFuture.get(eq(LeaseManagementConfig.DEFAULT_REQUEST_TIMEOUT.toMillis()), eq(TimeUnit.MILLISECONDS))) @@ -319,7 +322,7 @@ public void testCreateLeaseTableProvisionedBillingModeIfNotExists() throws Excep public void testCreateLeaseTableWithTagsIfNotExists() throws Exception { tags = Collections.singletonList(Tag.builder().key("foo").value("bar").build()); leaseRefresher = new DynamoDBLeaseRefresher(TABLE_NAME, dynamoDbClient, leaseSerializer, CONSISTENT_READS, - tableCreatorCallback, LeaseManagementConfig.DEFAULT_REQUEST_TIMEOUT, BillingMode.PROVISIONED, tags); + tableCreatorCallback, LeaseManagementConfig.DEFAULT_REQUEST_TIMEOUT, BillingMode.PROVISIONED, DELETION_PROTECTION_ENABLED, tags); when(dynamoDbClient.describeTable(describeTableRequest)).thenReturn(mockDescribeTableFuture); when(mockDescribeTableFuture.get(LeaseManagementConfig.DEFAULT_REQUEST_TIMEOUT.toMillis(), TimeUnit.MILLISECONDS)) @@ -332,6 +335,7 @@ public void testCreateLeaseTableWithTagsIfNotExists() throws Exception { .keySchema(leaseSerializer.getKeySchema()) .attributeDefinitions(leaseSerializer.getAttributeDefinitions()) .provisionedThroughput(throughput) + .deletionProtectionEnabled(DELETION_PROTECTION_ENABLED) .tags(tags) .build(); when(dynamoDbClient.createTable(createTableRequest)).thenReturn(mockCreateTableFuture); @@ -462,7 +466,7 @@ public void testCreateLeaseTableIfNotExists_throwsTimeoutException_expectDepende @Test public void testCreateLeaseTableProvisionedBillingModeTimesOut() throws Exception { leaseRefresher = new DynamoDBLeaseRefresher(TABLE_NAME, dynamoDbClient, leaseSerializer, CONSISTENT_READS, - tableCreatorCallback, LeaseManagementConfig.DEFAULT_REQUEST_TIMEOUT, BillingMode.PROVISIONED); + tableCreatorCallback, LeaseManagementConfig.DEFAULT_REQUEST_TIMEOUT, BillingMode.PROVISIONED, false); TimeoutException te = setRuleForDependencyTimeout(); when(dynamoDbClient.describeTable(any(DescribeTableRequest.class))).thenReturn(mockDescribeTableFuture); From 49499f6697287c684bc76093df450eb35fe228bd Mon Sep 17 00:00:00 2001 From: Lucien Luc Date: Tue, 20 Feb 2024 14:15:57 -0800 Subject: [PATCH 2/3] Add unit test --- .../dynamodb/DynamoDBLeaseRefresherTest.java | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/amazon-kinesis-client/src/test/java/software/amazon/kinesis/leases/dynamodb/DynamoDBLeaseRefresherTest.java b/amazon-kinesis-client/src/test/java/software/amazon/kinesis/leases/dynamodb/DynamoDBLeaseRefresherTest.java index ac4d1cc20..6daa14a3e 100644 --- a/amazon-kinesis-client/src/test/java/software/amazon/kinesis/leases/dynamodb/DynamoDBLeaseRefresherTest.java +++ b/amazon-kinesis-client/src/test/java/software/amazon/kinesis/leases/dynamodb/DynamoDBLeaseRefresherTest.java @@ -373,6 +373,39 @@ public void testCreateLeaseTableIfNotExists() throws Exception { Assert.assertTrue(result); } + @Test + public void testCreateLeaseTableProvisionedWithDeletionProtectionIfNotExists() throws Exception { + leaseRefresher = new DynamoDBLeaseRefresher(TABLE_NAME, dynamoDbClient, leaseSerializer, CONSISTENT_READS, + tableCreatorCallback, LeaseManagementConfig.DEFAULT_REQUEST_TIMEOUT, BillingMode.PROVISIONED, true); + + when(dynamoDbClient.describeTable(describeTableRequest)).thenReturn(mockDescribeTableFuture); + when(mockDescribeTableFuture.get(eq(LeaseManagementConfig.DEFAULT_REQUEST_TIMEOUT.toMillis()), eq(TimeUnit.MILLISECONDS))) + .thenThrow(ResourceNotFoundException.builder().message("Table doesn't exist").build()); + + final ProvisionedThroughput throughput = ProvisionedThroughput.builder().readCapacityUnits(10L) + .writeCapacityUnits(10L).build(); + final CreateTableRequest createTableRequest = CreateTableRequest.builder() + .tableName(TABLE_NAME) + .keySchema(leaseSerializer.getKeySchema()) + .attributeDefinitions(leaseSerializer.getAttributeDefinitions()) + .provisionedThroughput(throughput) + .deletionProtectionEnabled(true) + .build(); + when(dynamoDbClient.createTable(createTableRequest)).thenReturn(mockCreateTableFuture); + when(mockCreateTableFuture.get(eq(LeaseManagementConfig.DEFAULT_REQUEST_TIMEOUT.toMillis()), eq(TimeUnit.MILLISECONDS))) + .thenReturn(null); + + final boolean result = leaseRefresher.createLeaseTableIfNotExists(10L, 10L); + + verify(dynamoDbClient, times(1)).describeTable(describeTableRequest); + verify(dynamoDbClient, times(1)).createTable(createTableRequest); + verify(mockDescribeTableFuture, times(1)) + .get(eq(LeaseManagementConfig.DEFAULT_REQUEST_TIMEOUT.toMillis()), eq(TimeUnit.MILLISECONDS)); + verify(mockCreateTableFuture, times(1)) + .get(eq(LeaseManagementConfig.DEFAULT_REQUEST_TIMEOUT.toMillis()), eq(TimeUnit.MILLISECONDS)); + Assert.assertTrue(result); + } + @Test public void testCreateLeaseTableIfNotExists_throwsDependencyException() throws Exception { when(dynamoDbClient.describeTable(describeTableRequest)).thenReturn(mockDescribeTableFuture); From f28d94ea6cd635f1fddb5c3266b46b16b35c95cc Mon Sep 17 00:00:00 2001 From: Lucien Luc Date: Tue, 20 Feb 2024 14:42:08 -0800 Subject: [PATCH 3/3] Rename variable --- .../kinesis/leases/LeaseManagementConfig.java | 6 +++--- .../dynamodb/DynamoDBLeaseManagementFactory.java | 16 ++++++++-------- .../leases/dynamodb/DynamoDBLeaseRefresher.java | 16 ++++++++-------- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/amazon-kinesis-client/src/main/java/software/amazon/kinesis/leases/LeaseManagementConfig.java b/amazon-kinesis-client/src/main/java/software/amazon/kinesis/leases/LeaseManagementConfig.java index 769dd0c1b..1fecbe7c0 100644 --- a/amazon-kinesis-client/src/main/java/software/amazon/kinesis/leases/LeaseManagementConfig.java +++ b/amazon-kinesis-client/src/main/java/software/amazon/kinesis/leases/LeaseManagementConfig.java @@ -195,11 +195,11 @@ public class LeaseManagementConfig { private BillingMode billingMode = BillingMode.PAY_PER_REQUEST; /** - * Whether to enabled deletion protection on the DyanmoDB lease table created by KCL. + * Whether to enabled deletion protection on the DynamoDB lease table created by KCL. * *

Default value: false */ - private boolean deletionProtectionEnabled = false; + private boolean leaseTableDeletionProtectionEnabled = false; /** * The list of tags to be applied to the DynamoDB table created for lease management. @@ -389,7 +389,7 @@ public LeaseManagementFactory leaseManagementFactory(final LeaseSerializer lease tableCreatorCallback(), dynamoDbRequestTimeout(), billingMode(), - deletionProtectionEnabled(), + leaseTableDeletionProtectionEnabled(), tags(), leaseSerializer, customShardDetectorProvider(), diff --git a/amazon-kinesis-client/src/main/java/software/amazon/kinesis/leases/dynamodb/DynamoDBLeaseManagementFactory.java b/amazon-kinesis-client/src/main/java/software/amazon/kinesis/leases/dynamodb/DynamoDBLeaseManagementFactory.java index 92844462b..f11e2f0a3 100644 --- a/amazon-kinesis-client/src/main/java/software/amazon/kinesis/leases/dynamodb/DynamoDBLeaseManagementFactory.java +++ b/amazon-kinesis-client/src/main/java/software/amazon/kinesis/leases/dynamodb/DynamoDBLeaseManagementFactory.java @@ -89,7 +89,7 @@ public class DynamoDBLeaseManagementFactory implements LeaseManagementFactory { private final TableCreatorCallback tableCreatorCallback; private final Duration dynamoDbRequestTimeout; private final BillingMode billingMode; - private final boolean deletionProtectionEnabled; + private final boolean leaseTableDeletionProtectionEnabled; private final Collection tags; private final boolean isMultiStreamMode; private final LeaseCleanupConfig leaseCleanupConfig; @@ -484,7 +484,7 @@ private DynamoDBLeaseManagementFactory(final KinesisAsyncClient kinesisClient, f * @param tableCreatorCallback * @param dynamoDbRequestTimeout * @param billingMode - * @param deletionProtectionEnabled + * @param leaseTableDeletionProtectionEnabled * @param tags */ private DynamoDBLeaseManagementFactory(final KinesisAsyncClient kinesisClient, final StreamConfig streamConfig, @@ -497,7 +497,7 @@ private DynamoDBLeaseManagementFactory(final KinesisAsyncClient kinesisClient, f final long listShardsCacheAllowedAgeInSeconds, final int cacheMissWarningModulus, final long initialLeaseTableReadCapacity, final long initialLeaseTableWriteCapacity, final HierarchicalShardSyncer deprecatedHierarchicalShardSyncer, final TableCreatorCallback tableCreatorCallback, - Duration dynamoDbRequestTimeout, BillingMode billingMode, final boolean deletionProtectionEnabled, + Duration dynamoDbRequestTimeout, BillingMode billingMode, final boolean leaseTableDeletionProtectionEnabled, Collection tags, LeaseSerializer leaseSerializer) { this(kinesisClient, dynamoDBClient, tableName, workerIdentifier, executorService, failoverTimeMillis, epsilonMillis, maxLeasesForWorker, @@ -506,7 +506,7 @@ private DynamoDBLeaseManagementFactory(final KinesisAsyncClient kinesisClient, f maxListShardsRetryAttempts, maxCacheMissesBeforeReload, listShardsCacheAllowedAgeInSeconds, cacheMissWarningModulus, initialLeaseTableReadCapacity, initialLeaseTableWriteCapacity, deprecatedHierarchicalShardSyncer, tableCreatorCallback, dynamoDbRequestTimeout, billingMode, - deletionProtectionEnabled, tags, leaseSerializer, null, false, + leaseTableDeletionProtectionEnabled, tags, leaseSerializer, null, false, LeaseManagementConfig.DEFAULT_LEASE_CLEANUP_CONFIG); this.streamConfig = streamConfig; } @@ -538,7 +538,7 @@ private DynamoDBLeaseManagementFactory(final KinesisAsyncClient kinesisClient, f * @param tableCreatorCallback * @param dynamoDbRequestTimeout * @param billingMode - * @param deletionProtectionEnabled + * @param leaseTableDeletionProtectionEnabled * @param leaseSerializer * @param customShardDetectorProvider * @param isMultiStreamMode @@ -554,7 +554,7 @@ public DynamoDBLeaseManagementFactory(final KinesisAsyncClient kinesisClient, final long listShardsCacheAllowedAgeInSeconds, final int cacheMissWarningModulus, final long initialLeaseTableReadCapacity, final long initialLeaseTableWriteCapacity, final HierarchicalShardSyncer deprecatedHierarchicalShardSyncer, final TableCreatorCallback tableCreatorCallback, - Duration dynamoDbRequestTimeout, BillingMode billingMode, final boolean deletionProtectionEnabled, + Duration dynamoDbRequestTimeout, BillingMode billingMode, final boolean leaseTableDeletionProtectionEnabled, Collection tags, LeaseSerializer leaseSerializer, Function customShardDetectorProvider, boolean isMultiStreamMode, LeaseCleanupConfig leaseCleanupConfig) { @@ -583,7 +583,7 @@ public DynamoDBLeaseManagementFactory(final KinesisAsyncClient kinesisClient, this.tableCreatorCallback = tableCreatorCallback; this.dynamoDbRequestTimeout = dynamoDbRequestTimeout; this.billingMode = billingMode; - this.deletionProtectionEnabled = deletionProtectionEnabled; + this.leaseTableDeletionProtectionEnabled = leaseTableDeletionProtectionEnabled; this.leaseSerializer = leaseSerializer; this.customShardDetectorProvider = customShardDetectorProvider; this.isMultiStreamMode = isMultiStreamMode; @@ -655,7 +655,7 @@ public ShardSyncTaskManager createShardSyncTaskManager(MetricsFactory metricsFac @Override public DynamoDBLeaseRefresher createLeaseRefresher() { return new DynamoDBLeaseRefresher(tableName, dynamoDBClient, leaseSerializer, consistentReads, - tableCreatorCallback, dynamoDbRequestTimeout, billingMode, deletionProtectionEnabled, tags); + tableCreatorCallback, dynamoDbRequestTimeout, billingMode, leaseTableDeletionProtectionEnabled, tags); } @Override diff --git a/amazon-kinesis-client/src/main/java/software/amazon/kinesis/leases/dynamodb/DynamoDBLeaseRefresher.java b/amazon-kinesis-client/src/main/java/software/amazon/kinesis/leases/dynamodb/DynamoDBLeaseRefresher.java index 756711812..11807b9c7 100644 --- a/amazon-kinesis-client/src/main/java/software/amazon/kinesis/leases/dynamodb/DynamoDBLeaseRefresher.java +++ b/amazon-kinesis-client/src/main/java/software/amazon/kinesis/leases/dynamodb/DynamoDBLeaseRefresher.java @@ -80,7 +80,7 @@ public class DynamoDBLeaseRefresher implements LeaseRefresher { private final Duration dynamoDbRequestTimeout; private final BillingMode billingMode; - private final boolean deletionProtectionEnabled; + private final boolean leaseTableDeletionProtectionEnabled; private final Collection tags; private boolean newTableCreated = false; @@ -147,15 +147,15 @@ public DynamoDBLeaseRefresher(final String table, final DynamoDbAsyncClient dyna * @param tableCreatorCallback * @param dynamoDbRequestTimeout * @param billingMode - * @param deletionProtectionEnabled + * @param leaseTableDeletionProtectionEnabled */ @Deprecated public DynamoDBLeaseRefresher(final String table, final DynamoDbAsyncClient dynamoDBClient, final LeaseSerializer serializer, final boolean consistentReads, @NonNull final TableCreatorCallback tableCreatorCallback, Duration dynamoDbRequestTimeout, - final BillingMode billingMode, final boolean deletionProtectionEnabled) { + final BillingMode billingMode, final boolean leaseTableDeletionProtectionEnabled) { this(table, dynamoDBClient, serializer, consistentReads, tableCreatorCallback, dynamoDbRequestTimeout, - billingMode, deletionProtectionEnabled, DefaultSdkAutoConstructList.getInstance()); + billingMode, leaseTableDeletionProtectionEnabled, DefaultSdkAutoConstructList.getInstance()); } /** @@ -167,13 +167,13 @@ public DynamoDBLeaseRefresher(final String table, final DynamoDbAsyncClient dyna * @param tableCreatorCallback * @param dynamoDbRequestTimeout * @param billingMode - * @param deletionProtectionEnabled + * @param leaseTableDeletionProtectionEnabled * @param tags */ public DynamoDBLeaseRefresher(final String table, final DynamoDbAsyncClient dynamoDBClient, final LeaseSerializer serializer, final boolean consistentReads, @NonNull final TableCreatorCallback tableCreatorCallback, Duration dynamoDbRequestTimeout, - final BillingMode billingMode, final boolean deletionProtectionEnabled, + final BillingMode billingMode, final boolean leaseTableDeletionProtectionEnabled, final Collection tags) { this.table = table; this.dynamoDBClient = dynamoDBClient; @@ -182,7 +182,7 @@ public DynamoDBLeaseRefresher(final String table, final DynamoDbAsyncClient dyna this.tableCreatorCallback = tableCreatorCallback; this.dynamoDbRequestTimeout = dynamoDbRequestTimeout; this.billingMode = billingMode; - this.deletionProtectionEnabled = deletionProtectionEnabled; + this.leaseTableDeletionProtectionEnabled = leaseTableDeletionProtectionEnabled; this.tags = tags; } @@ -811,7 +811,7 @@ protected DependencyException convertAndRethrowExceptions(String operation, Stri private CreateTableRequest.Builder createTableRequestBuilder() { final CreateTableRequest.Builder builder = CreateTableRequest.builder().tableName(table).keySchema(serializer.getKeySchema()) .attributeDefinitions(serializer.getAttributeDefinitions()) - .deletionProtectionEnabled(deletionProtectionEnabled) + .deletionProtectionEnabled(leaseTableDeletionProtectionEnabled) .tags(tags); if (BillingMode.PAY_PER_REQUEST.equals(billingMode)) { builder.billingMode(billingMode);