From 3a279ca67fa3f1cfcad960677781a0d4df6cad03 Mon Sep 17 00:00:00 2001 From: Artem Bilan Date: Mon, 2 Jul 2018 20:52:40 -0400 Subject: [PATCH] Rename DynamoDbMetadataStore class for consistency --- README.md | 10 +++---- ...aStore.java => DynamoDbMetadataStore.java} | 30 +++++++++---------- .../metadata/DynamoDbMetadataStoreTests.java | 4 +-- 3 files changed, 22 insertions(+), 22 deletions(-) rename src/main/java/org/springframework/integration/aws/metadata/{DynamoDbMetaDataStore.java => DynamoDbMetadataStore.java} (92%) diff --git a/README.md b/README.md index 7f8240d..f9c8961 100644 --- a/README.md +++ b/README.md @@ -474,12 +474,12 @@ See `SnsHeaderMapper` implementation for more information and also consult with ## Metadata Store for Amazon DynamoDB -The `DynamoDbMetaDataStore`, a `ConcurrentMetadataStore` implementation, is provided to keep the metadata for Spring Integration components in the distributed Amazon DynamoDB store. +The `DynamoDbMetadataStore`, a `ConcurrentMetadataStore` implementation, is provided to keep the metadata for Spring Integration components in the distributed Amazon DynamoDB store. The implementation is based on a simple table with `KEY` and `VALUE` attributes, both are string types and the `KEY` is primary key of the table. By default the `SpringIntegrationMetadataStore` table is used and it is created during `DynamoDbMetaDataStore` initialization if that doesn't exist yet. -The `DynamoDbMetaDataStore` can be used for the `KinesisMessageDrivenChannelAdapter` as a cloud-based `cehckpointStore`. +The `DynamoDbMetadataStore` can be used for the `KinesisMessageDrivenChannelAdapter` as a cloud-based `cehckpointStore`. -For testing application with the `DynamoDbMetaDataStore` you can use [Dynalite][] NPM module. +For testing application with the `DynamoDbMetadataStore` you can use [Dynalite][] NPM module. What you need in your application is to configure DynamoDB client properly: ````java @@ -500,7 +500,7 @@ Where you should specify the port on which you have ran the Dynalite service. Also you can use for your testing purpose a copy of `org.springframework.integration.aws.DynamoDbLocalRunning` in the `/test` directory of this project. The default port is expected as `4568`, because the `4567` is reserved for the `KinesisLocalRunning` against local Kinesalite npm service. -Starting with _version 2.0_, the `DynamoDbMetaDataStore` can be configured with the `timeToLive` option to enable the [DynamoDB TTL][] feature. +Starting with _version 2.0_, the `DynamoDbMetadataStore` can be configured with the `timeToLive` option to enable the [DynamoDB TTL][] feature. The `TTL` attribute is added to each item with the value based on the sum of current time and provided `timeToLive` in seconds. If the provided `timeToLive` value is non-positive, the TTL functionality is disable on the table. @@ -531,7 +531,7 @@ public static class MyConfiguration { } ```` -This channel adapter can be configured with the `DynamoDbMetaDataStore` mentioned above to track sequence checkpoints for shards in the cloud environment when we have several instances of our Kinesis application. +This channel adapter can be configured with the `DynamoDbMetadataStore` mentioned above to track sequence checkpoints for shards in the cloud environment when we have several instances of our Kinesis application. By default this adapter uses `DeserializingConverter` to convert `byte[]` from the `Record` data. Can be specified as `null` with meaning no conversion and the target `Message` is sent with the `byte[]` payload. diff --git a/src/main/java/org/springframework/integration/aws/metadata/DynamoDbMetaDataStore.java b/src/main/java/org/springframework/integration/aws/metadata/DynamoDbMetadataStore.java similarity index 92% rename from src/main/java/org/springframework/integration/aws/metadata/DynamoDbMetaDataStore.java rename to src/main/java/org/springframework/integration/aws/metadata/DynamoDbMetadataStore.java index c5a5797..7b87414 100644 --- a/src/main/java/org/springframework/integration/aws/metadata/DynamoDbMetaDataStore.java +++ b/src/main/java/org/springframework/integration/aws/metadata/DynamoDbMetadataStore.java @@ -64,14 +64,14 @@ import com.amazonaws.waiters.WaiterParameters; * * @since 1.1 */ -public class DynamoDbMetaDataStore implements ConcurrentMetadataStore, InitializingBean { +public class DynamoDbMetadataStore implements ConcurrentMetadataStore, InitializingBean { /** * The {@value DEFAULT_TABLE_NAME} default name for the metadata table in the DynamoDB. */ public static final String DEFAULT_TABLE_NAME = "SpringIntegrationMetadataStore"; - private static final Log logger = LogFactory.getLog(DynamoDbMetaDataStore.class); + private static final Log logger = LogFactory.getLog(DynamoDbMetadataStore.class); private static final String KEY = "KEY"; @@ -97,11 +97,11 @@ public class DynamoDbMetaDataStore implements ConcurrentMetadataStore, Initializ private volatile boolean initialized; - public DynamoDbMetaDataStore(AmazonDynamoDBAsync dynamoDB) { + public DynamoDbMetadataStore(AmazonDynamoDBAsync dynamoDB) { this(dynamoDB, DEFAULT_TABLE_NAME); } - public DynamoDbMetaDataStore(AmazonDynamoDBAsync dynamoDB, String tableName) { + public DynamoDbMetadataStore(AmazonDynamoDBAsync dynamoDB, String tableName) { Assert.notNull(dynamoDB, "'dynamoDB' must not be null."); Assert.hasText(tableName, "'tableName' must not be empty."); this.dynamoDB = dynamoDB; @@ -166,38 +166,38 @@ public class DynamoDbMetaDataStore implements ConcurrentMetadataStore, Initializ @Override public void onError(Exception e) { logger.error("Cannot create DynamoDb table: " + - DynamoDbMetaDataStore.this.table.getTableName(), e); - DynamoDbMetaDataStore.this.createTableLatch.countDown(); + DynamoDbMetadataStore.this.table.getTableName(), e); + DynamoDbMetadataStore.this.createTableLatch.countDown(); } @Override public void onSuccess(CreateTableRequest request, CreateTableResult createTableResult) { Waiter waiter = - DynamoDbMetaDataStore.this.dynamoDB.waiters() + DynamoDbMetadataStore.this.dynamoDB.waiters() .tableExists(); WaiterParameters waiterParameters = new WaiterParameters<>( - new DescribeTableRequest(DynamoDbMetaDataStore.this.table.getTableName())) + new DescribeTableRequest(DynamoDbMetadataStore.this.table.getTableName())) .withPollingStrategy( new PollingStrategy( - new MaxAttemptsRetryStrategy(DynamoDbMetaDataStore.this.createTableRetries), - new FixedDelayStrategy(DynamoDbMetaDataStore.this.createTableDelay))); + new MaxAttemptsRetryStrategy(DynamoDbMetadataStore.this.createTableRetries), + new FixedDelayStrategy(DynamoDbMetadataStore.this.createTableDelay))); waiter.runAsync(waiterParameters, new WaiterHandler() { @Override public void onWaitSuccess(DescribeTableRequest request) { updateTimeToLiveIfAny(); - DynamoDbMetaDataStore.this.createTableLatch.countDown(); - DynamoDbMetaDataStore.this.table.describe(); + DynamoDbMetadataStore.this.createTableLatch.countDown(); + DynamoDbMetadataStore.this.table.describe(); } @Override public void onWaitFailure(Exception e) { logger.error("Cannot describe DynamoDb table: " + - DynamoDbMetaDataStore.this.table.getTableName(), e); - DynamoDbMetaDataStore.this.createTableLatch.countDown(); + DynamoDbMetadataStore.this.table.getTableName(), e); + DynamoDbMetadataStore.this.createTableLatch.countDown(); } }); @@ -367,7 +367,7 @@ public class DynamoDbMetaDataStore implements ConcurrentMetadataStore, Initializ @Override public String toString() { - return "DynamoDbMetaDataStore{" + "table=" + this.table + + return "DynamoDbMetadataStore{" + "table=" + this.table + ", createTableRetries=" + this.createTableRetries + ", createTableDelay=" + this.createTableDelay + ", readCapacity=" + this.readCapacity + diff --git a/src/test/java/org/springframework/integration/aws/metadata/DynamoDbMetadataStoreTests.java b/src/test/java/org/springframework/integration/aws/metadata/DynamoDbMetadataStoreTests.java index 7dea69b..629d747 100644 --- a/src/test/java/org/springframework/integration/aws/metadata/DynamoDbMetadataStoreTests.java +++ b/src/test/java/org/springframework/integration/aws/metadata/DynamoDbMetadataStoreTests.java @@ -51,7 +51,7 @@ public class DynamoDbMetadataStoreTests { private static final String TEST_TABLE = "testMetadataStore"; - private static DynamoDbMetaDataStore store; + private static DynamoDbMetadataStore store; private final String file1 = "/remotepath/filesTodownload/file-1.txt"; @@ -76,7 +76,7 @@ public class DynamoDbMetadataStoreTests { } - store = new DynamoDbMetaDataStore(dynamoDB, TEST_TABLE); + store = new DynamoDbMetadataStore(dynamoDB, TEST_TABLE); store.setTimeToLive(10); // Dynalite doesn't support TTL store.afterPropertiesSet(); }