AWS DAX Java 身份验证问题



我正在尝试在使用 DAX 和 DynamoDB 进行性能测试之间编写灵活的身份验证机制。 我已经能够让它在所有区域中与 DynamoDB 正常工作,但它只能在 DAX 的 us-west-1 中正常工作。

if (this.useDax) {
try {
AWSCredentials credentials = new PropertiesCredentials(new File(credentialsFile));
ClientConfig daxConfig = new ClientConfig().withEndpoints(endpoint).withRegion(daxRegion)
.withCredentialsProvider(new AWSStaticCredentialsProvider(credentials));
daxDB = new ClusterDaxClient(daxConfig);
primaryKeyName = primaryKey;
LOGGER.info("dynamodb DAX connection created with " + this.endpoint);
} catch (Exception e1) {
LOGGER.error("DaxDBClient.init(): Could not initialize DaxDB client.", e1);
}
} else {
try {
AWSCredentials credentials = new PropertiesCredentials(new File(credentialsFile));
ClientConfiguration cconfig = new ClientConfiguration();
cconfig.setMaxConnections(maxConnects);
dynamoDB = new AmazonDynamoDBClient(credentials, cconfig);
dynamoDB.setEndpoint(this.endpoint);
primaryKeyName = primaryKey;
LOGGER.info("dynamodb connection created with " + this.endpoint);
} catch (Exception e1) {
LOGGER.error("DynamoDBClient.init(): Could not initialize DynamoDB client.", e1);
}
}

我得到的错误是:

com.amazon.dax.client.exceptions.DaxServiceException: [1.23.31.33] 连接需要身份验证(服务:空;状态代码: -1;错误代码:空;请求 ID:空(

我最终使用了不同的凭据提供程序(PropertiesFileCredentialsProvider(,它起作用了:

if (this.useDax) {
try {
ClientConfig daxConfig = new ClientConfig().withEndpoints(this.endpoint).withRegion(daxRegion)
.withCredentialsProvider(new PropertiesFileCredentialsProvider(credentialsFile));
daxDB = new ClusterDaxClient(daxConfig);
primaryKeyName = primaryKey;
LOGGER.info("dynamodb DAX connection created with " + this.endpoint);
} catch (Exception e1) {
LOGGER.error("DaxDBClient.init(): Could not initialize DaxDB client.", e1);
}
} else {
try {
AWSCredentials credentials = new PropertiesCredentials(new File(credentialsFile));
ClientConfiguration cconfig = new ClientConfiguration();
cconfig.setMaxConnections(maxConnects);
dynamoDB = new AmazonDynamoDBClient(credentials, cconfig);
dynamoDB.setEndpoint(this.endpoint);
primaryKeyName = primaryKey;
LOGGER.info("dynamodb connection created with " + this.endpoint);
} catch (Exception e1) {
LOGGER.error("DynamoDBClient.init(): Could not initialize DynamoDB client.", e1);
}
}

最新更新