mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 15:11:59 +01:00
[dynamodb] AWS SDK updated to 2.17.102 (#11914)
* [dynamodb] Update guide for updating the SDK Some steps were obsolete and required corrections. Signed-off-by: Sami Salonen <ssalonen@gmail.com> * [dynamodb] Update AWS SDK to 2.17.102 - Added NOTICE with all compiled dependencies. Dependencies listed in feature.xml are omitted. - jackson dependency is now provided by AWS SDK as a 'shaded' copy - log4j version used in tests updated - Specifying DefaultsMode=STANDARD to make the SDK utilize latest recommended parameters. RetryMode is also controlled by DefaultsMode, so we avoid setting it explicitly unless overridden by the user. - Fixed test regressions due to SDK changes Signed-off-by: Sami Salonen <ssalonen@gmail.com>
This commit is contained in:
parent
dee9ab891f
commit
76855fd81a
@ -11,3 +11,34 @@ https://www.eclipse.org/legal/epl-2.0/.
|
|||||||
== Source Code
|
== Source Code
|
||||||
|
|
||||||
https://github.com/openhab/openhab-addons
|
https://github.com/openhab/openhab-addons
|
||||||
|
|
||||||
|
== Third-party Content
|
||||||
|
|
||||||
|
com.typesafe.netty: netty-reactive-streams-http
|
||||||
|
* License: Apache 2.0 License
|
||||||
|
* Project: https://github.com/playframework/netty-reactive-streams
|
||||||
|
* Source: https://github.com/playframework/netty-reactive-streams
|
||||||
|
|
||||||
|
com.typesafe.netty: netty-reactive-streams
|
||||||
|
* License: Apache 2.0 License
|
||||||
|
* Project: https://github.com/playframework/netty-reactive-streams
|
||||||
|
* Source: https://github.com/playframework/netty-reactive-streams
|
||||||
|
|
||||||
|
org.reactivestreams: reactive-streams
|
||||||
|
* License: Public Domain (CC0)
|
||||||
|
* Project: http://www.reactive-streams.org/
|
||||||
|
* Source: https://github.com/reactive-streams/reactive-streams-jvm/tree/v1.0.3
|
||||||
|
|
||||||
|
software.amazon.awssdk: annotations, auth, aws-core, aws-json-protocol,
|
||||||
|
dynamodb-enhanced, dynamodb, http-client-spi,
|
||||||
|
json-utils, metrics-spi, netty-nio-client, profiles,
|
||||||
|
protocol-core, regions, sdk-core,
|
||||||
|
third-party-jackson-core, utils
|
||||||
|
* License: Apache 2.0 License
|
||||||
|
* Project: https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/home.html
|
||||||
|
* Source: https://github.com/aws/aws-sdk-java-v2/
|
||||||
|
|
||||||
|
software.amazon.eventstream: eventstream
|
||||||
|
* License: Apache 2.0 License
|
||||||
|
* Project: https://github.com/awslabs/aws-eventstream-java/
|
||||||
|
* Source: https://github.com/awslabs/aws-eventstream-java/
|
||||||
|
@ -95,7 +95,7 @@ Modify the policy accordingly if needed.
|
|||||||
<!-- markdownlint-disable ol-prefix -->
|
<!-- markdownlint-disable ol-prefix -->
|
||||||
4. Click _Next: Tags_
|
4. Click _Next: Tags_
|
||||||
5. Click _Next: Review_
|
5. Click _Next: Review_
|
||||||
6. Enter `openhab-dynamodb-policy` as the _Name_ol-prefix -->
|
6. Enter `openhab-dynamodb-policy` as the _Name_
|
||||||
7. Click _Create policy_ to finish policy creation
|
7. Click _Create policy_ to finish policy creation
|
||||||
<!-- markdownlint-enable ol-prefix -->
|
<!-- markdownlint-enable ol-prefix -->
|
||||||
|
|
||||||
@ -224,10 +224,10 @@ Similar caveat applies for DynamoDB Time to Live (TTL) setting `expireDays`.
|
|||||||
|
|
||||||
### Updating Amazon SDK
|
### Updating Amazon SDK
|
||||||
|
|
||||||
1. Clean `lib/*`
|
1. Update SDK version and `netty-nio-client` version in `scripts/fetch_sdk_pom.xml`. You can use the [maven online repository browser](https://mvnrepository.com/artifact/software.amazon.awssdk/dynamodb-enhanced) to find the latest version available online.
|
||||||
2. Update SDK version in `scripts/fetch_sdk_pom.xml`. You can use the [maven online repository browser](https://mvnrepository.com/artifact/com.amazonaws/aws-java-sdk-dynamodb) to find the latest version available online.
|
2. `scripts/fetch_sdk.sh`
|
||||||
3. `scripts/fetch_sdk.sh`
|
3. Copy printed dependencies to `pom.xml`. If necessary, adjust feature.xml, bnd.importpackage and dep.noembedding as well (probably rarely needed but [it happens](https://aws.amazon.com/blogs/developer/the-aws-sdk-for-java-2-17-removes-its-external-dependency-on-jackson/)).
|
||||||
4. Copy printed dependencies to `pom.xml`
|
4. Check & update `NOTICE` file with all the updated, new and removed dependencies.
|
||||||
|
|
||||||
After these changes, it's good practice to run integration tests (against live AWS DynamoDB) in `org.openhab.persistence.dynamodb.test` bundle.
|
After these changes, it's good practice to run integration tests (against live AWS DynamoDB) in `org.openhab.persistence.dynamodb.test` bundle.
|
||||||
See README.md in the test bundle for more information how to execute the tests.
|
See README.md in the test bundle for more information how to execute the tests.
|
||||||
|
@ -19,10 +19,10 @@
|
|||||||
<dependencies> -->
|
<dependencies> -->
|
||||||
<bnd.importpackage>!com.amazonaws.*,!com.sun.org.apache.xpath.*,!kotlin,!org.apache.log.*,!org.bouncycastle.*,!org.joda.convert.*,!scala.util.*,!software.amazon.*,!org.reactivestreams,!com.typesafe.netty</bnd.importpackage>
|
<bnd.importpackage>!com.amazonaws.*,!com.sun.org.apache.xpath.*,!kotlin,!org.apache.log.*,!org.bouncycastle.*,!org.joda.convert.*,!scala.util.*,!software.amazon.*,!org.reactivestreams,!com.typesafe.netty</bnd.importpackage>
|
||||||
<!-- We do not want to embed/compile in dependencies that are declared as OSGi imports (feature.xml). This includes e.g.
|
<!-- We do not want to embed/compile in dependencies that are declared as OSGi imports (feature.xml). This includes e.g.
|
||||||
netty & jackson. Let's ensure by listing relevant packages with dep.noembedding -->
|
netty. Let's ensure by listing relevant packages with dep.noembedding -->
|
||||||
<dep.noembedding>netty-common,netty-transport,netty-transport-native-epoll,netty-transport-native-unix-common,netty-buffer,netty-resolver,netty-codec,netty-codec-http,netty-codec-http2,netty-handler,jackson-core,jackson-annotations,jackson-dataformat-cbor,jackson-databind</dep.noembedding>
|
<dep.noembedding>netty-common,netty-transport,netty-transport-native-epoll,netty-transport-native-unix-common,netty-buffer,netty-resolver,netty-codec,netty-codec-http,netty-codec-http2,netty-handler</dep.noembedding>
|
||||||
<!-- netty version matching the openhab.tp-netty feature version -->
|
<!-- slf4j version matching the version specified in openhab-core/pom.xml -->
|
||||||
<slf4j.version>1.7.21</slf4j.version>
|
<slf4j.version>1.7.32</slf4j.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<!--Custom repository for DynamoDBLocal -->
|
<!--Custom repository for DynamoDBLocal -->
|
||||||
@ -61,7 +61,7 @@
|
|||||||
|
|
||||||
<!-- Let's ensure the correct versions with dependencyManagement.
|
<!-- Let's ensure the correct versions with dependencyManagement.
|
||||||
|
|
||||||
We want to run our tests and compilations using netty and jackson version used in the runtime (provided as OSGi features).
|
We want to run our tests and compilations using netty version used in the runtime (provided as OSGi features).
|
||||||
slf4j-api version is locked to core-version. Also: slf4j comes via openHAB logging, so setting it here as provided to
|
slf4j-api version is locked to core-version. Also: slf4j comes via openHAB logging, so setting it here as provided to
|
||||||
have the right OSGi imports.
|
have the right OSGi imports.
|
||||||
-->
|
-->
|
||||||
@ -73,21 +73,6 @@
|
|||||||
<version>${slf4j.version}</version>
|
<version>${slf4j.version}</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
|
||||||
<artifactId>jackson-annotations</artifactId>
|
|
||||||
<version>${jackson.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
|
||||||
<artifactId>jackson-core</artifactId>
|
|
||||||
<version>${jackson.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
|
||||||
<artifactId>jackson-databind</artifactId>
|
|
||||||
<version>${jackson.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.netty</groupId>
|
<groupId>io.netty</groupId>
|
||||||
<artifactId>netty-buffer</artifactId>
|
<artifactId>netty-buffer</artifactId>
|
||||||
@ -213,87 +198,97 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.typesafe.netty</groupId>
|
<groupId>com.typesafe.netty</groupId>
|
||||||
<artifactId>netty-reactive-streams-http</artifactId>
|
<artifactId>netty-reactive-streams-http</artifactId>
|
||||||
<version>2.0.4</version>
|
<version>2.0.5</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.typesafe.netty</groupId>
|
<groupId>com.typesafe.netty</groupId>
|
||||||
<artifactId>netty-reactive-streams</artifactId>
|
<artifactId>netty-reactive-streams</artifactId>
|
||||||
<version>2.0.4</version>
|
<version>2.0.5</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.reactivestreams</groupId>
|
<groupId>org.reactivestreams</groupId>
|
||||||
<artifactId>reactive-streams</artifactId>
|
<artifactId>reactive-streams</artifactId>
|
||||||
<version>1.0.2</version>
|
<version>1.0.3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>software.amazon.awssdk</groupId>
|
<groupId>software.amazon.awssdk</groupId>
|
||||||
<artifactId>annotations</artifactId>
|
<artifactId>annotations</artifactId>
|
||||||
<version>2.15.56</version>
|
<version>2.17.102</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>software.amazon.awssdk</groupId>
|
<groupId>software.amazon.awssdk</groupId>
|
||||||
<artifactId>auth</artifactId>
|
<artifactId>auth</artifactId>
|
||||||
<version>2.15.56</version>
|
<version>2.17.102</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>software.amazon.awssdk</groupId>
|
<groupId>software.amazon.awssdk</groupId>
|
||||||
<artifactId>aws-core</artifactId>
|
<artifactId>aws-core</artifactId>
|
||||||
<version>2.15.56</version>
|
<version>2.17.102</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>software.amazon.awssdk</groupId>
|
<groupId>software.amazon.awssdk</groupId>
|
||||||
<artifactId>aws-json-protocol</artifactId>
|
<artifactId>aws-json-protocol</artifactId>
|
||||||
<version>2.15.56</version>
|
<version>2.17.102</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>software.amazon.awssdk</groupId>
|
<groupId>software.amazon.awssdk</groupId>
|
||||||
<artifactId>dynamodb-enhanced</artifactId>
|
<artifactId>dynamodb-enhanced</artifactId>
|
||||||
<version>2.15.56</version>
|
<version>2.17.102</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>software.amazon.awssdk</groupId>
|
<groupId>software.amazon.awssdk</groupId>
|
||||||
<artifactId>dynamodb</artifactId>
|
<artifactId>dynamodb</artifactId>
|
||||||
<version>2.15.56</version>
|
<version>2.17.102</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>software.amazon.awssdk</groupId>
|
<groupId>software.amazon.awssdk</groupId>
|
||||||
<artifactId>http-client-spi</artifactId>
|
<artifactId>http-client-spi</artifactId>
|
||||||
<version>2.15.56</version>
|
<version>2.17.102</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>software.amazon.awssdk</groupId>
|
||||||
|
<artifactId>json-utils</artifactId>
|
||||||
|
<version>2.17.102</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>software.amazon.awssdk</groupId>
|
<groupId>software.amazon.awssdk</groupId>
|
||||||
<artifactId>metrics-spi</artifactId>
|
<artifactId>metrics-spi</artifactId>
|
||||||
<version>2.15.77</version>
|
<version>2.17.102</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>software.amazon.awssdk</groupId>
|
<groupId>software.amazon.awssdk</groupId>
|
||||||
<artifactId>netty-nio-client</artifactId>
|
<artifactId>netty-nio-client</artifactId>
|
||||||
<version>2.15.77</version>
|
<version>2.17.102</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>software.amazon.awssdk</groupId>
|
<groupId>software.amazon.awssdk</groupId>
|
||||||
<artifactId>profiles</artifactId>
|
<artifactId>profiles</artifactId>
|
||||||
<version>2.15.56</version>
|
<version>2.17.102</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>software.amazon.awssdk</groupId>
|
<groupId>software.amazon.awssdk</groupId>
|
||||||
<artifactId>protocol-core</artifactId>
|
<artifactId>protocol-core</artifactId>
|
||||||
<version>2.15.56</version>
|
<version>2.17.102</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>software.amazon.awssdk</groupId>
|
<groupId>software.amazon.awssdk</groupId>
|
||||||
<artifactId>regions</artifactId>
|
<artifactId>regions</artifactId>
|
||||||
<version>2.15.56</version>
|
<version>2.17.102</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>software.amazon.awssdk</groupId>
|
<groupId>software.amazon.awssdk</groupId>
|
||||||
<artifactId>sdk-core</artifactId>
|
<artifactId>sdk-core</artifactId>
|
||||||
<version>2.15.56</version>
|
<version>2.17.102</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>software.amazon.awssdk</groupId>
|
||||||
|
<artifactId>third-party-jackson-core</artifactId>
|
||||||
|
<version>2.17.102</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>software.amazon.awssdk</groupId>
|
<groupId>software.amazon.awssdk</groupId>
|
||||||
<artifactId>utils</artifactId>
|
<artifactId>utils</artifactId>
|
||||||
<version>2.15.56</version>
|
<version>2.17.102</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>software.amazon.eventstream</groupId>
|
<groupId>software.amazon.eventstream</groupId>
|
||||||
|
@ -10,31 +10,19 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>software.amazon.awssdk</groupId>
|
<groupId>software.amazon.awssdk</groupId>
|
||||||
<artifactId>dynamodb-enhanced</artifactId>
|
<artifactId>dynamodb-enhanced</artifactId>
|
||||||
<version>2.15.56</version>
|
<version>2.17.102</version>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
<!-- exclude artifacts available via openhab jackson feature -->
|
<!-- exclude artifacts available via openhab jackson feature -->
|
||||||
<exclusion>
|
<exclusion>
|
||||||
<groupId>org.slf4j</groupId>
|
<groupId>org.slf4j</groupId>
|
||||||
<artifactId>slf4j-api</artifactId>
|
<artifactId>slf4j-api</artifactId>
|
||||||
</exclusion>
|
</exclusion>
|
||||||
<exclusion>
|
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
|
||||||
<artifactId>jackson-annotations</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
|
||||||
<artifactId>jackson-core</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
|
||||||
<artifactId>jackson-databind</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>software.amazon.awssdk</groupId>
|
<groupId>software.amazon.awssdk</groupId>
|
||||||
<artifactId>netty-nio-client</artifactId>
|
<artifactId>netty-nio-client</artifactId>
|
||||||
<version>2.15.77</version>
|
<version>2.17.102</version>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
<!-- exclude artifacts available via openhab netty feature, or otherwise added in feature.xml -->
|
<!-- exclude artifacts available via openhab netty feature, or otherwise added in feature.xml -->
|
||||||
<exclusion>
|
<exclusion>
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
<feature name="openhab-persistence-dynamodb" description="DynamoDB Persistence" version="${project.version}">
|
<feature name="openhab-persistence-dynamodb" description="DynamoDB Persistence" version="${project.version}">
|
||||||
<feature>openhab-runtime-base</feature>
|
<feature>openhab-runtime-base</feature>
|
||||||
<feature dependency="true">openhab.tp-jackson</feature>
|
|
||||||
<feature dependency="true">openhab.tp-netty</feature>
|
<feature dependency="true">openhab.tp-netty</feature>
|
||||||
<bundle start-level="80">mvn:org.openhab.addons.bundles/org.openhab.persistence.dynamodb/${project.version}</bundle>
|
<bundle start-level="80">mvn:org.openhab.addons.bundles/org.openhab.persistence.dynamodb/${project.version}</bundle>
|
||||||
<configfile finalname="${openhab.conf}/services/dynamodb.cfg" override="false">mvn:org.openhab.addons.features.karaf/org.openhab.addons.features.karaf.openhab-addons-external/${project.version}/cfg/dynamodb</configfile>
|
<configfile finalname="${openhab.conf}/services/dynamodb.cfg" override="false">mvn:org.openhab.addons.features.karaf/org.openhab.addons.features.karaf.openhab-addons-external/${project.version}/cfg/dynamodb</configfile>
|
||||||
|
@ -49,14 +49,13 @@ public class DynamoDBConfig {
|
|||||||
public static final String DEFAULT_TABLE_NAME = "openhab";
|
public static final String DEFAULT_TABLE_NAME = "openhab";
|
||||||
public static final long DEFAULT_READ_CAPACITY_UNITS = 1;
|
public static final long DEFAULT_READ_CAPACITY_UNITS = 1;
|
||||||
public static final long DEFAULT_WRITE_CAPACITY_UNITS = 1;
|
public static final long DEFAULT_WRITE_CAPACITY_UNITS = 1;
|
||||||
public static final RetryMode DEFAULT_RETRY_MODE = RetryMode.STANDARD;
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(DynamoDBConfig.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(DynamoDBConfig.class);
|
||||||
|
|
||||||
private long readCapacityUnits;
|
private long readCapacityUnits;
|
||||||
private long writeCapacityUnits;
|
private long writeCapacityUnits;
|
||||||
private Region region;
|
private Region region;
|
||||||
private AwsCredentials credentials;
|
private AwsCredentials credentials;
|
||||||
private RetryPolicy retryPolicy;
|
private Optional<RetryPolicy> retryPolicy;
|
||||||
private ExpectedTableSchema tableRevision;
|
private ExpectedTableSchema tableRevision;
|
||||||
private String table;
|
private String table;
|
||||||
private String tablePrefixLegacy;
|
private String tablePrefixLegacy;
|
||||||
@ -81,7 +80,7 @@ public class DynamoDBConfig {
|
|||||||
}
|
}
|
||||||
region = Region.of(regionName);
|
region = Region.of(regionName);
|
||||||
|
|
||||||
RetryMode retryMode = RetryMode.STANDARD;
|
Optional<RetryMode> retryMode = Optional.empty();
|
||||||
AwsCredentials credentials;
|
AwsCredentials credentials;
|
||||||
String accessKey = (String) config.get("accessKey");
|
String accessKey = (String) config.get("accessKey");
|
||||||
String secretKey = (String) config.get("secretKey");
|
String secretKey = (String) config.get("secretKey");
|
||||||
@ -110,11 +109,12 @@ public class DynamoDBConfig {
|
|||||||
return Optional.of(value);
|
return Optional.of(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LOGGER.warn("Unknown retry_mode '{}' in profile. Ignoring and using default {} retry mode.",
|
LOGGER.warn(
|
||||||
retry_mode, DEFAULT_RETRY_MODE);
|
"Unknown retry_mode '{}' in profile. Ignoring and using SDK default retry mode.",
|
||||||
|
retry_mode);
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
|
|
||||||
}).orElse(DEFAULT_RETRY_MODE);
|
});
|
||||||
LOGGER.debug("Retry mode {}", retryMode);
|
LOGGER.debug("Retry mode {}", retryMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -169,18 +169,19 @@ public class DynamoDBConfig {
|
|||||||
switch (tableRevision) {
|
switch (tableRevision) {
|
||||||
case NEW:
|
case NEW:
|
||||||
LOGGER.debug("Using new DynamoDB table schema");
|
LOGGER.debug("Using new DynamoDB table schema");
|
||||||
return DynamoDBConfig.newSchema(region, credentials, AwsRetryPolicy.forRetryMode(retryMode), table,
|
return DynamoDBConfig.newSchema(region, credentials, retryMode.map(AwsRetryPolicy::forRetryMode),
|
||||||
readCapacityUnits, writeCapacityUnits, expireDays);
|
table, readCapacityUnits, writeCapacityUnits, expireDays);
|
||||||
case LEGACY:
|
case LEGACY:
|
||||||
LOGGER.warn(
|
LOGGER.warn(
|
||||||
"Using legacy DynamoDB table schema. It is recommended to transition to new schema by defining 'table' parameter and not configuring 'tablePrefix'");
|
"Using legacy DynamoDB table schema. It is recommended to transition to new schema by defining 'table' parameter and not configuring 'tablePrefix'");
|
||||||
return DynamoDBConfig.legacySchema(region, credentials, AwsRetryPolicy.forRetryMode(retryMode),
|
return DynamoDBConfig.legacySchema(region, credentials, retryMode.map(AwsRetryPolicy::forRetryMode),
|
||||||
tablePrefixLegacy, readCapacityUnits, writeCapacityUnits);
|
tablePrefixLegacy, readCapacityUnits, writeCapacityUnits);
|
||||||
case MAYBE_LEGACY:
|
case MAYBE_LEGACY:
|
||||||
LOGGER.debug(
|
LOGGER.debug(
|
||||||
"Unclear whether we should use new legacy DynamoDB table schema. It is recommended to explicitly define new 'table' parameter. The correct table schema will be detected at runtime.");
|
"Unclear whether we should use new legacy DynamoDB table schema. It is recommended to explicitly define new 'table' parameter. The correct table schema will be detected at runtime.");
|
||||||
return DynamoDBConfig.maybeLegacySchema(region, credentials, AwsRetryPolicy.forRetryMode(retryMode),
|
return DynamoDBConfig.maybeLegacySchema(region, credentials,
|
||||||
table, tablePrefixLegacy, readCapacityUnits, writeCapacityUnits, expireDays);
|
retryMode.map(AwsRetryPolicy::forRetryMode), table, tablePrefixLegacy, readCapacityUnits,
|
||||||
|
writeCapacityUnits, expireDays);
|
||||||
default:
|
default:
|
||||||
throw new IllegalStateException("Unhandled enum. Bug");
|
throw new IllegalStateException("Unhandled enum. Bug");
|
||||||
}
|
}
|
||||||
@ -190,26 +191,28 @@ public class DynamoDBConfig {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static DynamoDBConfig newSchema(Region region, AwsCredentials credentials, RetryPolicy retryPolicy,
|
private static DynamoDBConfig newSchema(Region region, AwsCredentials credentials,
|
||||||
String table, long readCapacityUnits, long writeCapacityUnits, @Nullable Integer expireDays) {
|
Optional<RetryPolicy> retryPolicy, String table, long readCapacityUnits, long writeCapacityUnits,
|
||||||
|
@Nullable Integer expireDays) {
|
||||||
return new DynamoDBConfig(region, credentials, retryPolicy, table, "", ExpectedTableSchema.NEW,
|
return new DynamoDBConfig(region, credentials, retryPolicy, table, "", ExpectedTableSchema.NEW,
|
||||||
readCapacityUnits, writeCapacityUnits, expireDays);
|
readCapacityUnits, writeCapacityUnits, expireDays);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static DynamoDBConfig legacySchema(Region region, AwsCredentials credentials, RetryPolicy retryPolicy,
|
private static DynamoDBConfig legacySchema(Region region, AwsCredentials credentials,
|
||||||
String tablePrefixLegacy, long readCapacityUnits, long writeCapacityUnits) {
|
Optional<RetryPolicy> retryPolicy, String tablePrefixLegacy, long readCapacityUnits,
|
||||||
|
long writeCapacityUnits) {
|
||||||
return new DynamoDBConfig(region, credentials, retryPolicy, "", tablePrefixLegacy, ExpectedTableSchema.LEGACY,
|
return new DynamoDBConfig(region, credentials, retryPolicy, "", tablePrefixLegacy, ExpectedTableSchema.LEGACY,
|
||||||
readCapacityUnits, writeCapacityUnits, null);
|
readCapacityUnits, writeCapacityUnits, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static DynamoDBConfig maybeLegacySchema(Region region, AwsCredentials credentials, RetryPolicy retryPolicy,
|
private static DynamoDBConfig maybeLegacySchema(Region region, AwsCredentials credentials,
|
||||||
String table, String tablePrefixLegacy, long readCapacityUnits, long writeCapacityUnits,
|
Optional<RetryPolicy> retryPolicy, String table, String tablePrefixLegacy, long readCapacityUnits,
|
||||||
@Nullable Integer expireDays) {
|
long writeCapacityUnits, @Nullable Integer expireDays) {
|
||||||
return new DynamoDBConfig(region, credentials, retryPolicy, table, tablePrefixLegacy,
|
return new DynamoDBConfig(region, credentials, retryPolicy, table, tablePrefixLegacy,
|
||||||
ExpectedTableSchema.MAYBE_LEGACY, readCapacityUnits, writeCapacityUnits, expireDays);
|
ExpectedTableSchema.MAYBE_LEGACY, readCapacityUnits, writeCapacityUnits, expireDays);
|
||||||
}
|
}
|
||||||
|
|
||||||
private DynamoDBConfig(Region region, AwsCredentials credentials, RetryPolicy retryPolicy, String table,
|
private DynamoDBConfig(Region region, AwsCredentials credentials, Optional<RetryPolicy> retryPolicy, String table,
|
||||||
String tablePrefixLegacy, ExpectedTableSchema tableRevision, long readCapacityUnits,
|
String tablePrefixLegacy, ExpectedTableSchema tableRevision, long readCapacityUnits,
|
||||||
long writeCapacityUnits, @Nullable Integer expireDays) {
|
long writeCapacityUnits, @Nullable Integer expireDays) {
|
||||||
this.region = region;
|
this.region = region;
|
||||||
@ -251,7 +254,7 @@ public class DynamoDBConfig {
|
|||||||
return writeCapacityUnits;
|
return writeCapacityUnits;
|
||||||
}
|
}
|
||||||
|
|
||||||
public RetryPolicy getRetryPolicy() {
|
public Optional<RetryPolicy> getRetryPolicy() {
|
||||||
return retryPolicy;
|
return retryPolicy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,6 +63,7 @@ import org.slf4j.LoggerFactory;
|
|||||||
|
|
||||||
import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
|
import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
|
||||||
import software.amazon.awssdk.awscore.AwsRequestOverrideConfiguration;
|
import software.amazon.awssdk.awscore.AwsRequestOverrideConfiguration;
|
||||||
|
import software.amazon.awssdk.awscore.defaultsmode.DefaultsMode;
|
||||||
import software.amazon.awssdk.core.async.SdkPublisher;
|
import software.amazon.awssdk.core.async.SdkPublisher;
|
||||||
import software.amazon.awssdk.core.client.config.ClientAsyncConfiguration;
|
import software.amazon.awssdk.core.client.config.ClientAsyncConfiguration;
|
||||||
import software.amazon.awssdk.core.client.config.ClientOverrideConfiguration;
|
import software.amazon.awssdk.core.client.config.ClientOverrideConfiguration;
|
||||||
@ -125,7 +126,7 @@ public class DynamoDBPersistenceService implements QueryablePersistenceService {
|
|||||||
DynamoDBConfig localDbConfig = dbConfig;
|
DynamoDBConfig localDbConfig = dbConfig;
|
||||||
config.apiCallAttemptTimeout(TIMEOUT_API_CALL_ATTEMPT).apiCallTimeout(TIMEOUT_API_CALL);
|
config.apiCallAttemptTimeout(TIMEOUT_API_CALL_ATTEMPT).apiCallTimeout(TIMEOUT_API_CALL);
|
||||||
if (localDbConfig != null) {
|
if (localDbConfig != null) {
|
||||||
config.retryPolicy(localDbConfig.getRetryPolicy());
|
localDbConfig.getRetryPolicy().ifPresent(config::retryPolicy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -220,6 +221,7 @@ public class DynamoDBPersistenceService implements QueryablePersistenceService {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
DynamoDbAsyncClientBuilder lowlevelClientBuilder = DynamoDbAsyncClient.builder()
|
DynamoDbAsyncClientBuilder lowlevelClientBuilder = DynamoDbAsyncClient.builder()
|
||||||
|
.defaultsMode(DefaultsMode.STANDARD)
|
||||||
.credentialsProvider(StaticCredentialsProvider.create(localDbConfig.getCredentials()))
|
.credentialsProvider(StaticCredentialsProvider.create(localDbConfig.getCredentials()))
|
||||||
.httpClient(NettyNioAsyncHttpClient.builder().maxConcurrency(MAX_CONCURRENCY).build())
|
.httpClient(NettyNioAsyncHttpClient.builder().maxConcurrency(MAX_CONCURRENCY).build())
|
||||||
.asyncConfiguration(
|
.asyncConfiguration(
|
||||||
|
@ -22,6 +22,7 @@ import java.util.HashMap;
|
|||||||
import java.util.Hashtable;
|
import java.util.Hashtable;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
@ -428,25 +429,10 @@ public class BaseIntegrationTest extends JavaTest {
|
|||||||
|
|
||||||
lowLevelClient.deleteTable(req -> req.tableName(table)).get();
|
lowLevelClient.deleteTable(req -> req.tableName(table)).get();
|
||||||
final WaiterResponse<DescribeTableResponse> waiterResponse;
|
final WaiterResponse<DescribeTableResponse> waiterResponse;
|
||||||
try {
|
waiterResponse = lowLevelClient.waiter().waitUntilTableNotExists(req -> req.tableName(table)).get();
|
||||||
waiterResponse = lowLevelClient.waiter().waitUntilTableNotExists(req -> req.tableName(table)).get();
|
Optional<Throwable> waiterException = waiterResponse.matched().exception()
|
||||||
} catch (ExecutionException e) {
|
.filter(e -> !(e instanceof ResourceNotFoundException));
|
||||||
// the waiting might fail with SdkClientException: An exception was thrown and did not match any
|
assertTrue(waiterException.isEmpty(), waiterException::toString);
|
||||||
// waiter acceptors
|
|
||||||
// (the exception being CompletionException of ResourceNotFound)
|
|
||||||
|
|
||||||
// We check if table has been removed, and continue if it has
|
|
||||||
try {
|
|
||||||
lowLevelClient.describeTable(req -> req.tableName(table)).get();
|
|
||||||
} catch (ExecutionException e2) {
|
|
||||||
if (e2.getCause() instanceof ResourceNotFoundException) {
|
|
||||||
// Table does not exist, this table does not need cleaning, continue to next table
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
assertTrue(waiterResponse.matched().exception().isEmpty());
|
|
||||||
} catch (ExecutionException | InterruptedException e) {
|
} catch (ExecutionException | InterruptedException e) {
|
||||||
fail("Error cleaning up test (deleting table)", e);
|
fail("Error cleaning up test (deleting table)", e);
|
||||||
}
|
}
|
||||||
|
@ -22,12 +22,14 @@ import java.nio.file.StandardOpenOption;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.io.TempDir;
|
import org.junit.jupiter.api.io.TempDir;
|
||||||
|
|
||||||
import software.amazon.awssdk.core.retry.RetryMode;
|
import software.amazon.awssdk.core.retry.RetryMode;
|
||||||
|
import software.amazon.awssdk.core.retry.RetryPolicy;
|
||||||
import software.amazon.awssdk.regions.Region;
|
import software.amazon.awssdk.regions.Region;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -77,7 +79,7 @@ public class DynamoDBConfigTest {
|
|||||||
assertEquals("openhab-", fromConfig.getTablePrefixLegacy());
|
assertEquals("openhab-", fromConfig.getTablePrefixLegacy());
|
||||||
assertEquals(1, fromConfig.getReadCapacityUnits());
|
assertEquals(1, fromConfig.getReadCapacityUnits());
|
||||||
assertEquals(1, fromConfig.getWriteCapacityUnits());
|
assertEquals(1, fromConfig.getWriteCapacityUnits());
|
||||||
assertEquals(RetryMode.STANDARD, fromConfig.getRetryPolicy().retryMode());
|
assertEquals(Optional.empty(), fromConfig.getRetryPolicy().map(RetryPolicy::retryMode));
|
||||||
assertEquals(ExpectedTableSchema.MAYBE_LEGACY, fromConfig.getTableRevision());
|
assertEquals(ExpectedTableSchema.MAYBE_LEGACY, fromConfig.getTableRevision());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,7 +99,7 @@ public class DynamoDBConfigTest {
|
|||||||
assertEquals("openhab-", fromConfig.getTablePrefixLegacy());
|
assertEquals("openhab-", fromConfig.getTablePrefixLegacy());
|
||||||
assertEquals(1, fromConfig.getReadCapacityUnits());
|
assertEquals(1, fromConfig.getReadCapacityUnits());
|
||||||
assertEquals(1, fromConfig.getWriteCapacityUnits());
|
assertEquals(1, fromConfig.getWriteCapacityUnits());
|
||||||
assertEquals(RetryMode.STANDARD, fromConfig.getRetryPolicy().retryMode());
|
assertEquals(Optional.empty(), fromConfig.getRetryPolicy().map(RetryPolicy::retryMode));
|
||||||
assertEquals(ExpectedTableSchema.MAYBE_LEGACY, fromConfig.getTableRevision());
|
assertEquals(ExpectedTableSchema.MAYBE_LEGACY, fromConfig.getTableRevision());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,7 +119,7 @@ public class DynamoDBConfigTest {
|
|||||||
assertEquals("openhab-", fromConfig.getTablePrefixLegacy());
|
assertEquals("openhab-", fromConfig.getTablePrefixLegacy());
|
||||||
assertEquals(1, fromConfig.getReadCapacityUnits());
|
assertEquals(1, fromConfig.getReadCapacityUnits());
|
||||||
assertEquals(1, fromConfig.getWriteCapacityUnits());
|
assertEquals(1, fromConfig.getWriteCapacityUnits());
|
||||||
assertEquals(RetryMode.LEGACY, fromConfig.getRetryPolicy().retryMode());
|
assertEquals(Optional.of(RetryMode.LEGACY), fromConfig.getRetryPolicy().map(RetryPolicy::retryMode));
|
||||||
assertEquals(ExpectedTableSchema.MAYBE_LEGACY, fromConfig.getTableRevision());
|
assertEquals(ExpectedTableSchema.MAYBE_LEGACY, fromConfig.getTableRevision());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,7 +163,7 @@ public class DynamoDBConfigTest {
|
|||||||
assertEquals("foobie-", fromConfig.getTablePrefixLegacy());
|
assertEquals("foobie-", fromConfig.getTablePrefixLegacy());
|
||||||
assertEquals(1, fromConfig.getReadCapacityUnits());
|
assertEquals(1, fromConfig.getReadCapacityUnits());
|
||||||
assertEquals(1, fromConfig.getWriteCapacityUnits());
|
assertEquals(1, fromConfig.getWriteCapacityUnits());
|
||||||
assertEquals(RetryMode.STANDARD, fromConfig.getRetryPolicy().retryMode());
|
assertEquals(Optional.empty(), fromConfig.getRetryPolicy().map(RetryPolicy::retryMode));
|
||||||
assertEquals(ExpectedTableSchema.LEGACY, fromConfig.getTableRevision());
|
assertEquals(ExpectedTableSchema.LEGACY, fromConfig.getTableRevision());
|
||||||
assertNull(fromConfig.getExpireDays()); // not supported with legacy
|
assertNull(fromConfig.getExpireDays()); // not supported with legacy
|
||||||
}
|
}
|
||||||
@ -177,7 +179,7 @@ public class DynamoDBConfigTest {
|
|||||||
assertEquals("mytable", fromConfig.getTable());
|
assertEquals("mytable", fromConfig.getTable());
|
||||||
assertEquals(1, fromConfig.getReadCapacityUnits());
|
assertEquals(1, fromConfig.getReadCapacityUnits());
|
||||||
assertEquals(1, fromConfig.getWriteCapacityUnits());
|
assertEquals(1, fromConfig.getWriteCapacityUnits());
|
||||||
assertEquals(RetryMode.STANDARD, fromConfig.getRetryPolicy().retryMode());
|
assertEquals(Optional.empty(), fromConfig.getRetryPolicy().map(RetryPolicy::retryMode));
|
||||||
assertEquals(ExpectedTableSchema.NEW, fromConfig.getTableRevision());
|
assertEquals(ExpectedTableSchema.NEW, fromConfig.getTableRevision());
|
||||||
assertEquals(105, fromConfig.getExpireDays());
|
assertEquals(105, fromConfig.getExpireDays());
|
||||||
}
|
}
|
||||||
@ -193,7 +195,7 @@ public class DynamoDBConfigTest {
|
|||||||
assertEquals("openhab-", fromConfig.getTablePrefixLegacy());
|
assertEquals("openhab-", fromConfig.getTablePrefixLegacy());
|
||||||
assertEquals(5, fromConfig.getReadCapacityUnits());
|
assertEquals(5, fromConfig.getReadCapacityUnits());
|
||||||
assertEquals(1, fromConfig.getWriteCapacityUnits());
|
assertEquals(1, fromConfig.getWriteCapacityUnits());
|
||||||
assertEquals(RetryMode.STANDARD, fromConfig.getRetryPolicy().retryMode());
|
assertEquals(Optional.empty(), fromConfig.getRetryPolicy().map(RetryPolicy::retryMode));
|
||||||
assertEquals(ExpectedTableSchema.MAYBE_LEGACY, fromConfig.getTableRevision());
|
assertEquals(ExpectedTableSchema.MAYBE_LEGACY, fromConfig.getTableRevision());
|
||||||
assertEquals(105, fromConfig.getExpireDays());
|
assertEquals(105, fromConfig.getExpireDays());
|
||||||
}
|
}
|
||||||
@ -209,7 +211,7 @@ public class DynamoDBConfigTest {
|
|||||||
assertEquals("openhab-", fromConfig.getTablePrefixLegacy());
|
assertEquals("openhab-", fromConfig.getTablePrefixLegacy());
|
||||||
assertEquals(1, fromConfig.getReadCapacityUnits());
|
assertEquals(1, fromConfig.getReadCapacityUnits());
|
||||||
assertEquals(5, fromConfig.getWriteCapacityUnits());
|
assertEquals(5, fromConfig.getWriteCapacityUnits());
|
||||||
assertEquals(RetryMode.STANDARD, fromConfig.getRetryPolicy().retryMode());
|
assertEquals(Optional.empty(), fromConfig.getRetryPolicy().map(RetryPolicy::retryMode));
|
||||||
assertEquals(ExpectedTableSchema.MAYBE_LEGACY, fromConfig.getTableRevision());
|
assertEquals(ExpectedTableSchema.MAYBE_LEGACY, fromConfig.getTableRevision());
|
||||||
assertNull(fromConfig.getExpireDays()); // default is null
|
assertNull(fromConfig.getExpireDays()); // default is null
|
||||||
}
|
}
|
||||||
@ -225,7 +227,7 @@ public class DynamoDBConfigTest {
|
|||||||
assertEquals("openhab-", fromConfig.getTablePrefixLegacy());
|
assertEquals("openhab-", fromConfig.getTablePrefixLegacy());
|
||||||
assertEquals(3, fromConfig.getReadCapacityUnits());
|
assertEquals(3, fromConfig.getReadCapacityUnits());
|
||||||
assertEquals(5, fromConfig.getWriteCapacityUnits());
|
assertEquals(5, fromConfig.getWriteCapacityUnits());
|
||||||
assertEquals(RetryMode.STANDARD, fromConfig.getRetryPolicy().retryMode());
|
assertEquals(Optional.empty(), fromConfig.getRetryPolicy().map(RetryPolicy::retryMode));
|
||||||
assertEquals(ExpectedTableSchema.MAYBE_LEGACY, fromConfig.getTableRevision());
|
assertEquals(ExpectedTableSchema.MAYBE_LEGACY, fromConfig.getTableRevision());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -241,7 +243,7 @@ public class DynamoDBConfigTest {
|
|||||||
assertEquals("openhab-", fromConfig.getTablePrefixLegacy());
|
assertEquals("openhab-", fromConfig.getTablePrefixLegacy());
|
||||||
assertEquals(3, fromConfig.getReadCapacityUnits());
|
assertEquals(3, fromConfig.getReadCapacityUnits());
|
||||||
assertEquals(5, fromConfig.getWriteCapacityUnits());
|
assertEquals(5, fromConfig.getWriteCapacityUnits());
|
||||||
assertEquals(RetryMode.STANDARD, fromConfig.getRetryPolicy().retryMode());
|
assertEquals(Optional.empty(), fromConfig.getRetryPolicy().map(RetryPolicy::retryMode));
|
||||||
assertEquals(ExpectedTableSchema.MAYBE_LEGACY, fromConfig.getTableRevision());
|
assertEquals(ExpectedTableSchema.MAYBE_LEGACY, fromConfig.getTableRevision());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user