Consolidate DynamoDB clients/configuration
This commit is contained in:
parent
eaa4c318e3
commit
2d1ca98605
|
@ -1 +1 @@
|
||||||
Subproject commit 82b7b374c57cf993f9a188d7a5ee7e7be83beb36
|
Subproject commit e24dabb53940738bdbf67b9b7ac74d39fe876a58
|
|
@ -13,19 +13,47 @@ dynamoDbClientConfiguration:
|
||||||
region: us-west-2 # AWS Region
|
region: us-west-2 # AWS Region
|
||||||
|
|
||||||
dynamoDbTables:
|
dynamoDbTables:
|
||||||
|
accounts:
|
||||||
|
tableName: Example_Accounts
|
||||||
|
phoneNumberTableName: Example_Accounts_PhoneNumbers
|
||||||
|
phoneNumberIdentifierTableName: Example_Accounts_PhoneNumberIdentifiers
|
||||||
|
usernamesTableName: Example_Accounts_Usernames
|
||||||
|
scanPageSize: 100
|
||||||
|
deletedAccounts:
|
||||||
|
tableName: Example_DeletedAccounts
|
||||||
|
needsReconciliationIndexName: NeedsReconciliation
|
||||||
|
deletedAccountsLock:
|
||||||
|
tableName: Example_DeletedAccountsLock
|
||||||
issuedReceipts:
|
issuedReceipts:
|
||||||
tableName: Example_IssuedReceipts
|
tableName: Example_IssuedReceipts
|
||||||
expiration: P30D # Duration of time until rows expire
|
expiration: P30D # Duration of time until rows expire
|
||||||
generator: abcdefg12345678= # random base64-encoded binary sequence
|
generator: abcdefg12345678= # random base64-encoded binary sequence
|
||||||
|
keys:
|
||||||
|
tableName: Example_Keys
|
||||||
|
messages:
|
||||||
|
tableName: Example_Messages
|
||||||
|
expiration: P30D # Duration of time until rows expire
|
||||||
|
pendingAccounts:
|
||||||
|
tableName: Example_PendingAccounts
|
||||||
|
pendingDevices:
|
||||||
|
tableName: Example_PendingDevices
|
||||||
|
phoneNumberIdentifiers:
|
||||||
|
tableName: Example_PhoneNumberIdentifiers
|
||||||
|
profiles:
|
||||||
|
tableName: Example_Profiles
|
||||||
|
pushChallenge:
|
||||||
|
tableName: Example_PushChallenge
|
||||||
redeemedReceipts:
|
redeemedReceipts:
|
||||||
tableName: Example_RedeemedReceipts
|
tableName: Example_RedeemedReceipts
|
||||||
expiration: P30D # Duration of time until rows expire
|
expiration: P30D # Duration of time until rows expire
|
||||||
subscriptions:
|
|
||||||
tableName: Example_Subscriptions
|
|
||||||
profiles:
|
|
||||||
tableName: Example_Profiles
|
|
||||||
remoteConfig:
|
remoteConfig:
|
||||||
tableName: Example_RemoteConfig
|
tableName: Example_RemoteConfig
|
||||||
|
reportMessage:
|
||||||
|
tableName: Example_ReportMessage
|
||||||
|
reservedUsernames:
|
||||||
|
tableName: Example_ReservedUsernames
|
||||||
|
subscriptions:
|
||||||
|
tableName: Example_Subscriptions
|
||||||
|
|
||||||
twilio: # Twilio gateway configuration
|
twilio: # Twilio gateway configuration
|
||||||
accountId: unset
|
accountId: unset
|
||||||
|
@ -126,54 +154,6 @@ messageCache: # Redis server configuration for message store cache
|
||||||
metricsCluster:
|
metricsCluster:
|
||||||
configurationUri: redis://redis.example.com:6379/
|
configurationUri: redis://redis.example.com:6379/
|
||||||
|
|
||||||
messageDynamoDb: # DynamoDB table configuration
|
|
||||||
region: us-west-2
|
|
||||||
tableName: Example_Messages
|
|
||||||
|
|
||||||
keysDynamoDb: # DynamoDB table configuration
|
|
||||||
region: us-west-2
|
|
||||||
tableName: Example_PreKeys
|
|
||||||
|
|
||||||
accountsDynamoDb: # DynamoDB table configuration
|
|
||||||
region: us-west-2
|
|
||||||
tableName: Example_Accounts
|
|
||||||
phoneNumberTableName: Example_Accounts_PhoneNumbers
|
|
||||||
phoneNumberIdentifierTableName: Example_Accounts_PhoneNumberIdentifiers
|
|
||||||
usernamesTableName: Example_Accounts_Usernames
|
|
||||||
|
|
||||||
deletedAccountsDynamoDb: # DynamoDb table configuration
|
|
||||||
region: us-west-2
|
|
||||||
tableName: Example_DeletedAccounts
|
|
||||||
needsReconciliationIndexName: NeedsReconciliation
|
|
||||||
|
|
||||||
deletedAccountsLockDynamoDb: # DynamoDb table configuration
|
|
||||||
region: us-west-2
|
|
||||||
tableName: Example_DeletedAccountsLock
|
|
||||||
|
|
||||||
pendingAccountsDynamoDb: # DynamoDB table configuration
|
|
||||||
region: us-west-2
|
|
||||||
tableName: Example_PendingAccounts
|
|
||||||
|
|
||||||
pendingDevicesDynamoDb: # DynamoDB table configuration
|
|
||||||
region: us-west-2
|
|
||||||
tableName: Example_PendingDevices
|
|
||||||
|
|
||||||
reservedUsernamesDynamoDb: # DynamoDB table configuration
|
|
||||||
region: us-west-2
|
|
||||||
tableName: Example_ReservedUsernames
|
|
||||||
|
|
||||||
phoneNumberIdentifiersDynamoDb: # DynamoDB table configuration
|
|
||||||
region: us-west-2
|
|
||||||
tableName: Example_PhoneNumberIdentifiers
|
|
||||||
|
|
||||||
pushChallengeDynamoDb: # DynamoDB table configuration
|
|
||||||
region: us-west-2
|
|
||||||
tableName: Example_PushChallenges
|
|
||||||
|
|
||||||
reportMessageDynamoDb: # DynamoDB table configuration
|
|
||||||
region: us-west-2
|
|
||||||
tableName: Example_ReportedMessages
|
|
||||||
|
|
||||||
awsAttachments: # AWS S3 configuration
|
awsAttachments: # AWS S3 configuration
|
||||||
accessKey: test
|
accessKey: test
|
||||||
accessSecret: test
|
accessSecret: test
|
||||||
|
|
|
@ -15,7 +15,6 @@ import javax.validation.Valid;
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
import org.whispersystems.textsecuregcm.configuration.AbusiveMessageFilterConfiguration;
|
import org.whispersystems.textsecuregcm.configuration.AbusiveMessageFilterConfiguration;
|
||||||
import org.whispersystems.textsecuregcm.configuration.AccountDatabaseCrawlerConfiguration;
|
import org.whispersystems.textsecuregcm.configuration.AccountDatabaseCrawlerConfiguration;
|
||||||
import org.whispersystems.textsecuregcm.configuration.AccountsDynamoDbConfiguration;
|
|
||||||
import org.whispersystems.textsecuregcm.configuration.ApnConfiguration;
|
import org.whispersystems.textsecuregcm.configuration.ApnConfiguration;
|
||||||
import org.whispersystems.textsecuregcm.configuration.AppConfigConfiguration;
|
import org.whispersystems.textsecuregcm.configuration.AppConfigConfiguration;
|
||||||
import org.whispersystems.textsecuregcm.configuration.AwsAttachmentsConfiguration;
|
import org.whispersystems.textsecuregcm.configuration.AwsAttachmentsConfiguration;
|
||||||
|
@ -24,18 +23,15 @@ import org.whispersystems.textsecuregcm.configuration.BoostConfiguration;
|
||||||
import org.whispersystems.textsecuregcm.configuration.CdnConfiguration;
|
import org.whispersystems.textsecuregcm.configuration.CdnConfiguration;
|
||||||
import org.whispersystems.textsecuregcm.configuration.DatabaseConfiguration;
|
import org.whispersystems.textsecuregcm.configuration.DatabaseConfiguration;
|
||||||
import org.whispersystems.textsecuregcm.configuration.DatadogConfiguration;
|
import org.whispersystems.textsecuregcm.configuration.DatadogConfiguration;
|
||||||
import org.whispersystems.textsecuregcm.configuration.DeletedAccountsDynamoDbConfiguration;
|
|
||||||
import org.whispersystems.textsecuregcm.configuration.DirectoryConfiguration;
|
import org.whispersystems.textsecuregcm.configuration.DirectoryConfiguration;
|
||||||
import org.whispersystems.textsecuregcm.configuration.DirectoryV2Configuration;
|
import org.whispersystems.textsecuregcm.configuration.DirectoryV2Configuration;
|
||||||
import org.whispersystems.textsecuregcm.configuration.DonationConfiguration;
|
import org.whispersystems.textsecuregcm.configuration.DonationConfiguration;
|
||||||
import org.whispersystems.textsecuregcm.configuration.DynamoDbClientConfiguration;
|
import org.whispersystems.textsecuregcm.configuration.DynamoDbClientConfiguration;
|
||||||
import org.whispersystems.textsecuregcm.configuration.DynamoDbConfiguration;
|
|
||||||
import org.whispersystems.textsecuregcm.configuration.DynamoDbTables;
|
import org.whispersystems.textsecuregcm.configuration.DynamoDbTables;
|
||||||
import org.whispersystems.textsecuregcm.configuration.GcmConfiguration;
|
import org.whispersystems.textsecuregcm.configuration.GcmConfiguration;
|
||||||
import org.whispersystems.textsecuregcm.configuration.GcpAttachmentsConfiguration;
|
import org.whispersystems.textsecuregcm.configuration.GcpAttachmentsConfiguration;
|
||||||
import org.whispersystems.textsecuregcm.configuration.MaxDeviceConfiguration;
|
import org.whispersystems.textsecuregcm.configuration.MaxDeviceConfiguration;
|
||||||
import org.whispersystems.textsecuregcm.configuration.MessageCacheConfiguration;
|
import org.whispersystems.textsecuregcm.configuration.MessageCacheConfiguration;
|
||||||
import org.whispersystems.textsecuregcm.configuration.MessageDynamoDbConfiguration;
|
|
||||||
import org.whispersystems.textsecuregcm.configuration.PaymentsServiceConfiguration;
|
import org.whispersystems.textsecuregcm.configuration.PaymentsServiceConfiguration;
|
||||||
import org.whispersystems.textsecuregcm.configuration.PushConfiguration;
|
import org.whispersystems.textsecuregcm.configuration.PushConfiguration;
|
||||||
import org.whispersystems.textsecuregcm.configuration.RateLimitsConfiguration;
|
import org.whispersystems.textsecuregcm.configuration.RateLimitsConfiguration;
|
||||||
|
@ -155,61 +151,6 @@ public class WhisperServerConfiguration extends Configuration {
|
||||||
@JsonProperty
|
@JsonProperty
|
||||||
private RedisClusterConfiguration clientPresenceCluster;
|
private RedisClusterConfiguration clientPresenceCluster;
|
||||||
|
|
||||||
@Valid
|
|
||||||
@NotNull
|
|
||||||
@JsonProperty
|
|
||||||
private MessageDynamoDbConfiguration messageDynamoDb;
|
|
||||||
|
|
||||||
@Valid
|
|
||||||
@NotNull
|
|
||||||
@JsonProperty
|
|
||||||
private DynamoDbConfiguration keysDynamoDb;
|
|
||||||
|
|
||||||
@Valid
|
|
||||||
@NotNull
|
|
||||||
@JsonProperty
|
|
||||||
private AccountsDynamoDbConfiguration accountsDynamoDb;
|
|
||||||
|
|
||||||
@Valid
|
|
||||||
@NotNull
|
|
||||||
@JsonProperty
|
|
||||||
private DynamoDbConfiguration phoneNumberIdentifiersDynamoDb;
|
|
||||||
|
|
||||||
@Valid
|
|
||||||
@NotNull
|
|
||||||
@JsonProperty
|
|
||||||
private DeletedAccountsDynamoDbConfiguration deletedAccountsDynamoDb;
|
|
||||||
|
|
||||||
@Valid
|
|
||||||
@NotNull
|
|
||||||
@JsonProperty
|
|
||||||
private DynamoDbConfiguration deletedAccountsLockDynamoDb;
|
|
||||||
|
|
||||||
@Valid
|
|
||||||
@NotNull
|
|
||||||
@JsonProperty
|
|
||||||
private DynamoDbConfiguration pushChallengeDynamoDb;
|
|
||||||
|
|
||||||
@Valid
|
|
||||||
@NotNull
|
|
||||||
@JsonProperty
|
|
||||||
private DynamoDbConfiguration reportMessageDynamoDb;
|
|
||||||
|
|
||||||
@Valid
|
|
||||||
@NotNull
|
|
||||||
@JsonProperty
|
|
||||||
private DynamoDbConfiguration pendingAccountsDynamoDb;
|
|
||||||
|
|
||||||
@Valid
|
|
||||||
@NotNull
|
|
||||||
@JsonProperty
|
|
||||||
private DynamoDbConfiguration pendingDevicesDynamoDb;
|
|
||||||
|
|
||||||
@Valid
|
|
||||||
@NotNull
|
|
||||||
@JsonProperty
|
|
||||||
private DynamoDbConfiguration reservedUsernamesDynamoDb;
|
|
||||||
|
|
||||||
@Valid
|
@Valid
|
||||||
@NotNull
|
@NotNull
|
||||||
@JsonProperty
|
@JsonProperty
|
||||||
|
@ -428,30 +369,6 @@ public class WhisperServerConfiguration extends Configuration {
|
||||||
return rateLimitersCluster;
|
return rateLimitersCluster;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MessageDynamoDbConfiguration getMessageDynamoDbConfiguration() {
|
|
||||||
return messageDynamoDb;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DynamoDbConfiguration getKeysDynamoDbConfiguration() {
|
|
||||||
return keysDynamoDb;
|
|
||||||
}
|
|
||||||
|
|
||||||
public AccountsDynamoDbConfiguration getAccountsDynamoDbConfiguration() {
|
|
||||||
return accountsDynamoDb;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DynamoDbConfiguration getPhoneNumberIdentifiersDynamoDbConfiguration() {
|
|
||||||
return phoneNumberIdentifiersDynamoDb;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DeletedAccountsDynamoDbConfiguration getDeletedAccountsDynamoDbConfiguration() {
|
|
||||||
return deletedAccountsDynamoDb;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DynamoDbConfiguration getDeletedAccountsLockDynamoDbConfiguration() {
|
|
||||||
return deletedAccountsLockDynamoDb;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DatabaseConfiguration getAbuseDatabaseConfiguration() {
|
public DatabaseConfiguration getAbuseDatabaseConfiguration() {
|
||||||
return abuseDatabase;
|
return abuseDatabase;
|
||||||
}
|
}
|
||||||
|
@ -530,26 +447,6 @@ public class WhisperServerConfiguration extends Configuration {
|
||||||
return appConfig;
|
return appConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DynamoDbConfiguration getPushChallengeDynamoDbConfiguration() {
|
|
||||||
return pushChallengeDynamoDb;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DynamoDbConfiguration getReportMessageDynamoDbConfiguration() {
|
|
||||||
return reportMessageDynamoDb;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DynamoDbConfiguration getPendingAccountsDynamoDbConfiguration() {
|
|
||||||
return pendingAccountsDynamoDb;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DynamoDbConfiguration getPendingDevicesDynamoDbConfiguration() {
|
|
||||||
return pendingDevicesDynamoDb;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DynamoDbConfiguration getReservedUsernamesDynamoDbConfiguration() {
|
|
||||||
return reservedUsernamesDynamoDb;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DonationConfiguration getDonationConfiguration() {
|
public DonationConfiguration getDonationConfiguration() {
|
||||||
return donation;
|
return donation;
|
||||||
}
|
}
|
||||||
|
|
|
@ -320,53 +320,18 @@ public class WhisperServerService extends Application<WhisperServerConfiguration
|
||||||
config.getDynamoDbClientConfiguration(),
|
config.getDynamoDbClientConfiguration(),
|
||||||
software.amazon.awssdk.auth.credentials.InstanceProfileCredentialsProvider.create());
|
software.amazon.awssdk.auth.credentials.InstanceProfileCredentialsProvider.create());
|
||||||
|
|
||||||
DynamoDbClient messageDynamoDb = DynamoDbFromConfig.client(config.getMessageDynamoDbConfiguration(),
|
|
||||||
software.amazon.awssdk.auth.credentials.InstanceProfileCredentialsProvider.create());
|
|
||||||
|
|
||||||
DynamoDbClient preKeyDynamoDb = DynamoDbFromConfig.client(config.getKeysDynamoDbConfiguration(),
|
|
||||||
software.amazon.awssdk.auth.credentials.InstanceProfileCredentialsProvider.create());
|
|
||||||
|
|
||||||
DynamoDbClient accountsDynamoDbClient = DynamoDbFromConfig.client(config.getAccountsDynamoDbConfiguration(),
|
|
||||||
software.amazon.awssdk.auth.credentials.InstanceProfileCredentialsProvider.create());
|
|
||||||
|
|
||||||
DynamoDbClient reservedUsernamesDynamoDbClient = DynamoDbFromConfig.client(config.getReservedUsernamesDynamoDbConfiguration(),
|
|
||||||
software.amazon.awssdk.auth.credentials.InstanceProfileCredentialsProvider.create());
|
|
||||||
|
|
||||||
DynamoDbClient phoneNumberIdentifiersDynamoDbClient =
|
|
||||||
DynamoDbFromConfig.client(config.getPhoneNumberIdentifiersDynamoDbConfiguration(),
|
|
||||||
software.amazon.awssdk.auth.credentials.InstanceProfileCredentialsProvider.create());
|
|
||||||
|
|
||||||
DynamoDbClient deletedAccountsDynamoDbClient = DynamoDbFromConfig.client(config.getDeletedAccountsDynamoDbConfiguration(),
|
|
||||||
software.amazon.awssdk.auth.credentials.InstanceProfileCredentialsProvider.create());
|
|
||||||
|
|
||||||
DynamoDbClient pushChallengeDynamoDbClient = DynamoDbFromConfig.client(
|
|
||||||
config.getPushChallengeDynamoDbConfiguration(),
|
|
||||||
software.amazon.awssdk.auth.credentials.InstanceProfileCredentialsProvider.create());
|
|
||||||
|
|
||||||
DynamoDbClient reportMessageDynamoDbClient = DynamoDbFromConfig.client(
|
|
||||||
config.getReportMessageDynamoDbConfiguration(),
|
|
||||||
software.amazon.awssdk.auth.credentials.InstanceProfileCredentialsProvider.create());
|
|
||||||
|
|
||||||
DynamoDbClient pendingAccountsDynamoDbClient = DynamoDbFromConfig.client(
|
|
||||||
config.getPendingAccountsDynamoDbConfiguration(),
|
|
||||||
software.amazon.awssdk.auth.credentials.InstanceProfileCredentialsProvider.create());
|
|
||||||
|
|
||||||
DynamoDbClient pendingDevicesDynamoDbClient = DynamoDbFromConfig.client(
|
|
||||||
config.getPendingDevicesDynamoDbConfiguration(),
|
|
||||||
software.amazon.awssdk.auth.credentials.InstanceProfileCredentialsProvider.create());
|
|
||||||
|
|
||||||
AmazonDynamoDB deletedAccountsLockDynamoDbClient = AmazonDynamoDBClientBuilder.standard()
|
AmazonDynamoDB deletedAccountsLockDynamoDbClient = AmazonDynamoDBClientBuilder.standard()
|
||||||
.withRegion(config.getDeletedAccountsLockDynamoDbConfiguration().getRegion())
|
.withRegion(config.getDynamoDbClientConfiguration().getRegion())
|
||||||
.withClientConfiguration(new ClientConfiguration().withClientExecutionTimeout(
|
.withClientConfiguration(new ClientConfiguration().withClientExecutionTimeout(
|
||||||
((int) config.getDeletedAccountsLockDynamoDbConfiguration().getClientExecutionTimeout().toMillis()))
|
((int) config.getDynamoDbClientConfiguration().getClientExecutionTimeout().toMillis()))
|
||||||
.withRequestTimeout(
|
.withRequestTimeout(
|
||||||
(int) config.getDeletedAccountsLockDynamoDbConfiguration().getClientRequestTimeout().toMillis()))
|
(int) config.getDynamoDbClientConfiguration().getClientRequestTimeout().toMillis()))
|
||||||
.withCredentials(InstanceProfileCredentialsProvider.getInstance())
|
.withCredentials(InstanceProfileCredentialsProvider.getInstance())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
DeletedAccounts deletedAccounts = new DeletedAccounts(deletedAccountsDynamoDbClient,
|
DeletedAccounts deletedAccounts = new DeletedAccounts(dynamoDbClient,
|
||||||
config.getDeletedAccountsDynamoDbConfiguration().getTableName(),
|
config.getDynamoDbTables().getDeletedAccounts().getTableName(),
|
||||||
config.getDeletedAccountsDynamoDbConfiguration().getNeedsReconciliationIndexName());
|
config.getDynamoDbTables().getDeletedAccounts().getNeedsReconciliationIndexName());
|
||||||
|
|
||||||
DynamicConfigurationManager<DynamicConfiguration> dynamicConfigurationManager =
|
DynamicConfigurationManager<DynamicConfiguration> dynamicConfigurationManager =
|
||||||
new DynamicConfigurationManager<>(config.getAppConfig().getApplication(),
|
new DynamicConfigurationManager<>(config.getAppConfig().getApplication(),
|
||||||
|
@ -374,34 +339,34 @@ public class WhisperServerService extends Application<WhisperServerConfiguration
|
||||||
config.getAppConfig().getConfigurationName(),
|
config.getAppConfig().getConfigurationName(),
|
||||||
DynamicConfiguration.class);
|
DynamicConfiguration.class);
|
||||||
|
|
||||||
Accounts accounts = new Accounts(accountsDynamoDbClient,
|
Accounts accounts = new Accounts(dynamoDbClient,
|
||||||
config.getAccountsDynamoDbConfiguration().getTableName(),
|
config.getDynamoDbTables().getAccounts().getTableName(),
|
||||||
config.getAccountsDynamoDbConfiguration().getPhoneNumberTableName(),
|
config.getDynamoDbTables().getAccounts().getPhoneNumberTableName(),
|
||||||
config.getAccountsDynamoDbConfiguration().getPhoneNumberIdentifierTableName(),
|
config.getDynamoDbTables().getAccounts().getPhoneNumberIdentifierTableName(),
|
||||||
config.getAccountsDynamoDbConfiguration().getUsernamesTableName(),
|
config.getDynamoDbTables().getAccounts().getUsernamesTableName(),
|
||||||
config.getAccountsDynamoDbConfiguration().getScanPageSize());
|
config.getDynamoDbTables().getAccounts().getScanPageSize());
|
||||||
PhoneNumberIdentifiers phoneNumberIdentifiers = new PhoneNumberIdentifiers(phoneNumberIdentifiersDynamoDbClient,
|
PhoneNumberIdentifiers phoneNumberIdentifiers = new PhoneNumberIdentifiers(dynamoDbClient,
|
||||||
config.getPhoneNumberIdentifiersDynamoDbConfiguration().getTableName());
|
config.getDynamoDbTables().getPhoneNumberIdentifiers().getTableName());
|
||||||
ReservedUsernames reservedUsernames = new ReservedUsernames(reservedUsernamesDynamoDbClient,
|
ReservedUsernames reservedUsernames = new ReservedUsernames(dynamoDbClient,
|
||||||
config.getReservedUsernamesDynamoDbConfiguration().getTableName());
|
config.getDynamoDbTables().getReservedUsernames().getTableName());
|
||||||
Profiles profiles = new Profiles(dynamoDbClient, dynamoDbAsyncClient,
|
Profiles profiles = new Profiles(dynamoDbClient, dynamoDbAsyncClient,
|
||||||
config.getDynamoDbTables().getProfiles().getTableName());
|
config.getDynamoDbTables().getProfiles().getTableName());
|
||||||
Keys keys = new Keys(preKeyDynamoDb, config.getKeysDynamoDbConfiguration().getTableName());
|
Keys keys = new Keys(dynamoDbClient, config.getDynamoDbTables().getKeys().getTableName());
|
||||||
MessagesDynamoDb messagesDynamoDb = new MessagesDynamoDb(messageDynamoDb,
|
MessagesDynamoDb messagesDynamoDb = new MessagesDynamoDb(dynamoDbClient,
|
||||||
config.getMessageDynamoDbConfiguration().getTableName(),
|
config.getDynamoDbTables().getMessages().getTableName(),
|
||||||
config.getMessageDynamoDbConfiguration().getTimeToLive());
|
config.getDynamoDbTables().getMessages().getExpiration());
|
||||||
AbusiveHostRules abusiveHostRules = new AbusiveHostRules(abuseDatabase);
|
AbusiveHostRules abusiveHostRules = new AbusiveHostRules(abuseDatabase);
|
||||||
RemoteConfigs remoteConfigs = new RemoteConfigs(dynamoDbClient,
|
RemoteConfigs remoteConfigs = new RemoteConfigs(dynamoDbClient,
|
||||||
config.getDynamoDbTables().getRemoteConfig().getTableName());
|
config.getDynamoDbTables().getRemoteConfig().getTableName());
|
||||||
PushChallengeDynamoDb pushChallengeDynamoDb = new PushChallengeDynamoDb(pushChallengeDynamoDbClient,
|
PushChallengeDynamoDb pushChallengeDynamoDb = new PushChallengeDynamoDb(dynamoDbClient,
|
||||||
config.getPushChallengeDynamoDbConfiguration().getTableName());
|
config.getDynamoDbTables().getPushChallenge().getTableName());
|
||||||
ReportMessageDynamoDb reportMessageDynamoDb = new ReportMessageDynamoDb(reportMessageDynamoDbClient,
|
ReportMessageDynamoDb reportMessageDynamoDb = new ReportMessageDynamoDb(dynamoDbClient,
|
||||||
config.getReportMessageDynamoDbConfiguration().getTableName(),
|
config.getDynamoDbTables().getReportMessage().getTableName(),
|
||||||
config.getReportMessageConfiguration().getReportTtl());
|
config.getReportMessageConfiguration().getReportTtl());
|
||||||
VerificationCodeStore pendingAccounts = new VerificationCodeStore(pendingAccountsDynamoDbClient,
|
VerificationCodeStore pendingAccounts = new VerificationCodeStore(dynamoDbClient,
|
||||||
config.getPendingAccountsDynamoDbConfiguration().getTableName());
|
config.getDynamoDbTables().getPendingAccounts().getTableName());
|
||||||
VerificationCodeStore pendingDevices = new VerificationCodeStore(pendingDevicesDynamoDbClient,
|
VerificationCodeStore pendingDevices = new VerificationCodeStore(dynamoDbClient,
|
||||||
config.getPendingDevicesDynamoDbConfiguration().getTableName());
|
config.getDynamoDbTables().getPendingDevices().getTableName());
|
||||||
|
|
||||||
RedisClientFactory pubSubClientFactory = new RedisClientFactory("pubsub_cache", config.getPubsubCacheConfiguration().getUrl(), config.getPubsubCacheConfiguration().getReplicaUrls(), config.getPubsubCacheConfiguration().getCircuitBreakerConfiguration());
|
RedisClientFactory pubSubClientFactory = new RedisClientFactory("pubsub_cache", config.getPubsubCacheConfiguration().getUrl(), config.getPubsubCacheConfiguration().getReplicaUrls(), config.getPubsubCacheConfiguration().getCircuitBreakerConfiguration());
|
||||||
ReplicatedJedisPool pubsubClient = pubSubClientFactory.getRedisClientPool();
|
ReplicatedJedisPool pubsubClient = pubSubClientFactory.getRedisClientPool();
|
||||||
|
@ -471,7 +436,7 @@ public class WhisperServerService extends Application<WhisperServerConfiguration
|
||||||
ReportMessageManager reportMessageManager = new ReportMessageManager(reportMessageDynamoDb, rateLimitersCluster, Metrics.globalRegistry, config.getReportMessageConfiguration().getCounterTtl());
|
ReportMessageManager reportMessageManager = new ReportMessageManager(reportMessageDynamoDb, rateLimitersCluster, Metrics.globalRegistry, config.getReportMessageConfiguration().getCounterTtl());
|
||||||
MessagesManager messagesManager = new MessagesManager(messagesDynamoDb, messagesCache, pushLatencyManager, reportMessageManager);
|
MessagesManager messagesManager = new MessagesManager(messagesDynamoDb, messagesCache, pushLatencyManager, reportMessageManager);
|
||||||
DeletedAccountsManager deletedAccountsManager = new DeletedAccountsManager(deletedAccounts,
|
DeletedAccountsManager deletedAccountsManager = new DeletedAccountsManager(deletedAccounts,
|
||||||
deletedAccountsLockDynamoDbClient, config.getDeletedAccountsLockDynamoDbConfiguration().getTableName());
|
deletedAccountsLockDynamoDbClient, config.getDynamoDbTables().getDeletedAccounts().getTableName());
|
||||||
AccountsManager accountsManager = new AccountsManager(accounts, phoneNumberIdentifiers, cacheCluster,
|
AccountsManager accountsManager = new AccountsManager(accounts, phoneNumberIdentifiers, cacheCluster,
|
||||||
deletedAccountsManager, directoryQueue, keys, messagesManager, reservedUsernames, profilesManager,
|
deletedAccountsManager, directoryQueue, keys, messagesManager, reservedUsernames, profilesManager,
|
||||||
pendingAccountsManager, secureStorageClient, secureBackupClient, clientPresenceManager, clock);
|
pendingAccountsManager, secureStorageClient, secureBackupClient, clientPresenceManager, clock);
|
||||||
|
|
|
@ -1,38 +0,0 @@
|
||||||
package org.whispersystems.textsecuregcm.configuration;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
||||||
import javax.validation.constraints.NotNull;
|
|
||||||
|
|
||||||
public class AccountsDynamoDbConfiguration extends DynamoDbConfiguration {
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
private String phoneNumberTableName;
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
private String phoneNumberIdentifierTableName;
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
private String usernamesTableName;
|
|
||||||
|
|
||||||
private int scanPageSize = 100;
|
|
||||||
|
|
||||||
@JsonProperty
|
|
||||||
public String getPhoneNumberTableName() {
|
|
||||||
return phoneNumberTableName;
|
|
||||||
}
|
|
||||||
|
|
||||||
@JsonProperty
|
|
||||||
public String getPhoneNumberIdentifierTableName() {
|
|
||||||
return phoneNumberIdentifierTableName;
|
|
||||||
}
|
|
||||||
|
|
||||||
@JsonProperty
|
|
||||||
public String getUsernamesTableName() {
|
|
||||||
return usernamesTableName;
|
|
||||||
}
|
|
||||||
|
|
||||||
@JsonProperty
|
|
||||||
public int getScanPageSize() {
|
|
||||||
return scanPageSize;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,49 @@
|
||||||
|
package org.whispersystems.textsecuregcm.configuration;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import org.whispersystems.textsecuregcm.configuration.DynamoDbTables.Table;
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
|
||||||
|
public class AccountsTableConfiguration extends Table {
|
||||||
|
|
||||||
|
private final String phoneNumberTableName;
|
||||||
|
private final String phoneNumberIdentifierTableName;
|
||||||
|
private final String usernamesTableName;
|
||||||
|
private final int scanPageSize;
|
||||||
|
|
||||||
|
@JsonCreator
|
||||||
|
public AccountsTableConfiguration(
|
||||||
|
@JsonProperty("tableName") final String tableName,
|
||||||
|
@JsonProperty("phoneNumberTableName") final String phoneNumberTableName,
|
||||||
|
@JsonProperty("phoneNumberIdentifierTableName") final String phoneNumberIdentifierTableName,
|
||||||
|
@JsonProperty("usernamesTableName") final String usernamesTableName,
|
||||||
|
@JsonProperty("scanPageSize") final int scanPageSize) {
|
||||||
|
|
||||||
|
super(tableName);
|
||||||
|
|
||||||
|
this.phoneNumberTableName = phoneNumberTableName;
|
||||||
|
this.phoneNumberIdentifierTableName = phoneNumberIdentifierTableName;
|
||||||
|
this.usernamesTableName = usernamesTableName;
|
||||||
|
this.scanPageSize = scanPageSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotBlank
|
||||||
|
public String getPhoneNumberTableName() {
|
||||||
|
return phoneNumberTableName;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotBlank
|
||||||
|
public String getPhoneNumberIdentifierTableName() {
|
||||||
|
return phoneNumberIdentifierTableName;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotBlank
|
||||||
|
public String getUsernamesTableName() {
|
||||||
|
return usernamesTableName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getScanPageSize() {
|
||||||
|
return scanPageSize;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,13 +0,0 @@
|
||||||
package org.whispersystems.textsecuregcm.configuration;
|
|
||||||
|
|
||||||
import javax.validation.constraints.NotNull;
|
|
||||||
|
|
||||||
public class DeletedAccountsDynamoDbConfiguration extends DynamoDbConfiguration {
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
private String needsReconciliationIndexName;
|
|
||||||
|
|
||||||
public String getNeedsReconciliationIndexName() {
|
|
||||||
return needsReconciliationIndexName;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
package org.whispersystems.textsecuregcm.configuration;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
import org.whispersystems.textsecuregcm.configuration.DynamoDbTables.Table;
|
||||||
|
|
||||||
|
public class DeletedAccountsTableConfiguration extends Table {
|
||||||
|
|
||||||
|
private final String needsReconciliationIndexName;
|
||||||
|
|
||||||
|
@JsonCreator
|
||||||
|
public DeletedAccountsTableConfiguration(
|
||||||
|
@JsonProperty("tableName") final String tableName,
|
||||||
|
@JsonProperty("needsReconciliationIndexName") final String needsReconciliationIndexName) {
|
||||||
|
|
||||||
|
super(tableName);
|
||||||
|
this.needsReconciliationIndexName = needsReconciliationIndexName;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotBlank
|
||||||
|
public String getNeedsReconciliationIndexName() {
|
||||||
|
return needsReconciliationIndexName;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,44 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2021 Signal Messenger, LLC
|
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.whispersystems.textsecuregcm.configuration;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
||||||
|
|
||||||
import javax.validation.Valid;
|
|
||||||
import javax.validation.constraints.NotEmpty;
|
|
||||||
import java.time.Duration;
|
|
||||||
|
|
||||||
public class DynamoDbConfiguration {
|
|
||||||
|
|
||||||
private String region;
|
|
||||||
private String tableName;
|
|
||||||
private Duration clientExecutionTimeout = Duration.ofSeconds(30);
|
|
||||||
private Duration clientRequestTimeout = Duration.ofSeconds(10);
|
|
||||||
|
|
||||||
@Valid
|
|
||||||
@NotEmpty
|
|
||||||
@JsonProperty
|
|
||||||
public String getRegion() {
|
|
||||||
return region;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Valid
|
|
||||||
@NotEmpty
|
|
||||||
@JsonProperty
|
|
||||||
public String getTableName() {
|
|
||||||
return tableName;
|
|
||||||
}
|
|
||||||
|
|
||||||
@JsonProperty
|
|
||||||
public Duration getClientExecutionTimeout() {
|
|
||||||
return clientExecutionTimeout;
|
|
||||||
}
|
|
||||||
|
|
||||||
@JsonProperty
|
|
||||||
public Duration getClientRequestTimeout() {
|
|
||||||
return clientRequestTimeout;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -46,53 +46,152 @@ public class DynamoDbTables {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private final AccountsTableConfiguration accounts;
|
||||||
|
private final DeletedAccountsTableConfiguration deletedAccounts;
|
||||||
|
private final Table deletedAccountsLock;
|
||||||
private final IssuedReceiptsTableConfiguration issuedReceipts;
|
private final IssuedReceiptsTableConfiguration issuedReceipts;
|
||||||
private final TableWithExpiration redeemedReceipts;
|
private final Table keys;
|
||||||
private final Table subscriptions;
|
private final TableWithExpiration messages;
|
||||||
|
private final Table pendingAccounts;
|
||||||
|
private final Table pendingDevices;
|
||||||
|
private final Table phoneNumberIdentifiers;
|
||||||
private final Table profiles;
|
private final Table profiles;
|
||||||
|
private final Table pushChallenge;
|
||||||
|
private final TableWithExpiration redeemedReceipts;
|
||||||
private final Table remoteConfig;
|
private final Table remoteConfig;
|
||||||
|
private final Table reportMessage;
|
||||||
|
private final Table reservedUsernames;
|
||||||
|
private final Table subscriptions;
|
||||||
|
|
||||||
@JsonCreator
|
|
||||||
public DynamoDbTables(
|
public DynamoDbTables(
|
||||||
|
@JsonProperty("accounts") final AccountsTableConfiguration accounts,
|
||||||
|
@JsonProperty("deletedAccounts") final DeletedAccountsTableConfiguration deletedAccounts,
|
||||||
|
@JsonProperty("deletedAccountsLock") final Table deletedAccountsLock,
|
||||||
@JsonProperty("issuedReceipts") final IssuedReceiptsTableConfiguration issuedReceipts,
|
@JsonProperty("issuedReceipts") final IssuedReceiptsTableConfiguration issuedReceipts,
|
||||||
@JsonProperty("redeemedReceipts") final TableWithExpiration redeemedReceipts,
|
@JsonProperty("keys") final Table keys,
|
||||||
@JsonProperty("subscriptions") final Table subscriptions,
|
@JsonProperty("messages") final TableWithExpiration messages,
|
||||||
|
@JsonProperty("pendingAccounts") final Table pendingAccounts,
|
||||||
|
@JsonProperty("pendingDevices") final Table pendingDevices,
|
||||||
|
@JsonProperty("phoneNumberIdentifiers") final Table phoneNumberIdentifiers,
|
||||||
@JsonProperty("profiles") final Table profiles,
|
@JsonProperty("profiles") final Table profiles,
|
||||||
@JsonProperty("remoteConfig") final Table remoteConfig) {
|
@JsonProperty("pushChallenge") final Table pushChallenge,
|
||||||
|
@JsonProperty("redeemedReceipts") final TableWithExpiration redeemedReceipts,
|
||||||
|
@JsonProperty("remoteConfig") final Table remoteConfig,
|
||||||
|
@JsonProperty("reportMessage") final Table reportMessage,
|
||||||
|
@JsonProperty("reservedUsernames") final Table reservedUsernames,
|
||||||
|
@JsonProperty("subscriptions") final Table subscriptions) {
|
||||||
|
|
||||||
|
this.accounts = accounts;
|
||||||
|
this.deletedAccounts = deletedAccounts;
|
||||||
|
this.deletedAccountsLock = deletedAccountsLock;
|
||||||
this.issuedReceipts = issuedReceipts;
|
this.issuedReceipts = issuedReceipts;
|
||||||
this.redeemedReceipts = redeemedReceipts;
|
this.keys = keys;
|
||||||
this.subscriptions = subscriptions;
|
this.messages = messages;
|
||||||
|
this.pendingAccounts = pendingAccounts;
|
||||||
|
this.pendingDevices = pendingDevices;
|
||||||
|
this.phoneNumberIdentifiers = phoneNumberIdentifiers;
|
||||||
this.profiles = profiles;
|
this.profiles = profiles;
|
||||||
|
this.pushChallenge = pushChallenge;
|
||||||
|
this.redeemedReceipts = redeemedReceipts;
|
||||||
this.remoteConfig = remoteConfig;
|
this.remoteConfig = remoteConfig;
|
||||||
|
this.reportMessage = reportMessage;
|
||||||
|
this.reservedUsernames = reservedUsernames;
|
||||||
|
this.subscriptions = subscriptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Valid
|
|
||||||
@NotNull
|
@NotNull
|
||||||
|
@Valid
|
||||||
|
public AccountsTableConfiguration getAccounts() {
|
||||||
|
return accounts;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Valid
|
||||||
|
public DeletedAccountsTableConfiguration getDeletedAccounts() {
|
||||||
|
return deletedAccounts;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Valid
|
||||||
|
public Table getDeletedAccountsLock() {
|
||||||
|
return deletedAccountsLock;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Valid
|
||||||
public IssuedReceiptsTableConfiguration getIssuedReceipts() {
|
public IssuedReceiptsTableConfiguration getIssuedReceipts() {
|
||||||
return issuedReceipts;
|
return issuedReceipts;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Valid
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public TableWithExpiration getRedeemedReceipts() {
|
@Valid
|
||||||
return redeemedReceipts;
|
public Table getKeys() {
|
||||||
|
return keys;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Valid
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public Table getSubscriptions() {
|
@Valid
|
||||||
return subscriptions;
|
public TableWithExpiration getMessages() {
|
||||||
|
return messages;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Valid
|
|
||||||
@NotNull
|
@NotNull
|
||||||
|
@Valid
|
||||||
|
public Table getPendingAccounts() {
|
||||||
|
return pendingAccounts;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Valid
|
||||||
|
public Table getPendingDevices() {
|
||||||
|
return pendingDevices;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Valid
|
||||||
|
public Table getPhoneNumberIdentifiers() {
|
||||||
|
return phoneNumberIdentifiers;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Valid
|
||||||
public Table getProfiles() {
|
public Table getProfiles() {
|
||||||
return profiles;
|
return profiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Valid
|
|
||||||
@NotNull
|
@NotNull
|
||||||
|
@Valid
|
||||||
|
public Table getPushChallenge() {
|
||||||
|
return pushChallenge;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Valid
|
||||||
|
public TableWithExpiration getRedeemedReceipts() {
|
||||||
|
return redeemedReceipts;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Valid
|
||||||
public Table getRemoteConfig() {
|
public Table getRemoteConfig() {
|
||||||
return remoteConfig;
|
return remoteConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Valid
|
||||||
|
public Table getReportMessage() {
|
||||||
|
return reportMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Valid
|
||||||
|
public Table getReservedUsernames() {
|
||||||
|
return reservedUsernames;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Valid
|
||||||
|
public Table getSubscriptions() {
|
||||||
|
return subscriptions;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,19 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2021 Signal Messenger, LLC
|
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.whispersystems.textsecuregcm.configuration;
|
|
||||||
|
|
||||||
import java.time.Duration;
|
|
||||||
import javax.validation.Valid;
|
|
||||||
|
|
||||||
public class MessageDynamoDbConfiguration extends DynamoDbConfiguration {
|
|
||||||
|
|
||||||
private Duration timeToLive = Duration.ofDays(14);
|
|
||||||
|
|
||||||
@Valid
|
|
||||||
public Duration getTimeToLive() {
|
|
||||||
return timeToLive;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,7 +1,6 @@
|
||||||
package org.whispersystems.textsecuregcm.util;
|
package org.whispersystems.textsecuregcm.util;
|
||||||
|
|
||||||
import org.whispersystems.textsecuregcm.configuration.DynamoDbClientConfiguration;
|
import org.whispersystems.textsecuregcm.configuration.DynamoDbClientConfiguration;
|
||||||
import org.whispersystems.textsecuregcm.configuration.DynamoDbConfiguration;
|
|
||||||
import software.amazon.awssdk.auth.credentials.AwsCredentialsProvider;
|
import software.amazon.awssdk.auth.credentials.AwsCredentialsProvider;
|
||||||
import software.amazon.awssdk.core.client.config.ClientOverrideConfiguration;
|
import software.amazon.awssdk.core.client.config.ClientOverrideConfiguration;
|
||||||
import software.amazon.awssdk.regions.Region;
|
import software.amazon.awssdk.regions.Region;
|
||||||
|
@ -10,17 +9,6 @@ import software.amazon.awssdk.services.dynamodb.DynamoDbClient;
|
||||||
|
|
||||||
public class DynamoDbFromConfig {
|
public class DynamoDbFromConfig {
|
||||||
|
|
||||||
public static DynamoDbClient client(DynamoDbConfiguration config, AwsCredentialsProvider credentialsProvider) {
|
|
||||||
return DynamoDbClient.builder()
|
|
||||||
.region(Region.of(config.getRegion()))
|
|
||||||
.credentialsProvider(credentialsProvider)
|
|
||||||
.overrideConfiguration(ClientOverrideConfiguration.builder()
|
|
||||||
.apiCallTimeout(config.getClientExecutionTimeout())
|
|
||||||
.apiCallAttemptTimeout(config.getClientRequestTimeout())
|
|
||||||
.build())
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static DynamoDbClient client(DynamoDbClientConfiguration config, AwsCredentialsProvider credentialsProvider) {
|
public static DynamoDbClient client(DynamoDbClientConfiguration config, AwsCredentialsProvider credentialsProvider) {
|
||||||
return DynamoDbClient.builder()
|
return DynamoDbClient.builder()
|
||||||
.region(Region.of(config.getRegion()))
|
.region(Region.of(config.getRegion()))
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
|
|
||||||
package org.whispersystems.textsecuregcm.workers;
|
package org.whispersystems.textsecuregcm.workers;
|
||||||
|
|
||||||
|
import static com.codahale.metrics.MetricRegistry.name;
|
||||||
|
|
||||||
import com.amazonaws.ClientConfiguration;
|
import com.amazonaws.ClientConfiguration;
|
||||||
import com.amazonaws.auth.InstanceProfileCredentialsProvider;
|
import com.amazonaws.auth.InstanceProfileCredentialsProvider;
|
||||||
import com.amazonaws.services.dynamodbv2.AmazonDynamoDB;
|
import com.amazonaws.services.dynamodbv2.AmazonDynamoDB;
|
||||||
|
@ -15,10 +17,12 @@ import io.dropwizard.cli.EnvironmentCommand;
|
||||||
import io.dropwizard.setup.Environment;
|
import io.dropwizard.setup.Environment;
|
||||||
import io.lettuce.core.resource.ClientResources;
|
import io.lettuce.core.resource.ClientResources;
|
||||||
import io.micrometer.core.instrument.Metrics;
|
import io.micrometer.core.instrument.Metrics;
|
||||||
|
import java.time.Clock;
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
import net.sourceforge.argparse4j.inf.Namespace;
|
import net.sourceforge.argparse4j.inf.Namespace;
|
||||||
import net.sourceforge.argparse4j.inf.Subparser;
|
import net.sourceforge.argparse4j.inf.Subparser;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.whispersystems.textsecuregcm.WhisperServerConfiguration;
|
import org.whispersystems.textsecuregcm.WhisperServerConfiguration;
|
||||||
import org.whispersystems.textsecuregcm.auth.ExternalServiceCredentialGenerator;
|
import org.whispersystems.textsecuregcm.auth.ExternalServiceCredentialGenerator;
|
||||||
import org.whispersystems.textsecuregcm.configuration.dynamic.DynamicConfiguration;
|
import org.whispersystems.textsecuregcm.configuration.dynamic.DynamicConfiguration;
|
||||||
|
@ -28,10 +32,8 @@ import org.whispersystems.textsecuregcm.redis.FaultTolerantRedisCluster;
|
||||||
import org.whispersystems.textsecuregcm.securebackup.SecureBackupClient;
|
import org.whispersystems.textsecuregcm.securebackup.SecureBackupClient;
|
||||||
import org.whispersystems.textsecuregcm.securestorage.SecureStorageClient;
|
import org.whispersystems.textsecuregcm.securestorage.SecureStorageClient;
|
||||||
import org.whispersystems.textsecuregcm.sqs.DirectoryQueue;
|
import org.whispersystems.textsecuregcm.sqs.DirectoryQueue;
|
||||||
import org.whispersystems.textsecuregcm.storage.Account;
|
|
||||||
import org.whispersystems.textsecuregcm.storage.Accounts;
|
import org.whispersystems.textsecuregcm.storage.Accounts;
|
||||||
import org.whispersystems.textsecuregcm.storage.AccountsManager;
|
import org.whispersystems.textsecuregcm.storage.AccountsManager;
|
||||||
import org.whispersystems.textsecuregcm.storage.AccountsManager.DeletionReason;
|
|
||||||
import org.whispersystems.textsecuregcm.storage.DeletedAccounts;
|
import org.whispersystems.textsecuregcm.storage.DeletedAccounts;
|
||||||
import org.whispersystems.textsecuregcm.storage.DeletedAccountsManager;
|
import org.whispersystems.textsecuregcm.storage.DeletedAccountsManager;
|
||||||
import org.whispersystems.textsecuregcm.storage.DynamicConfigurationManager;
|
import org.whispersystems.textsecuregcm.storage.DynamicConfigurationManager;
|
||||||
|
@ -51,13 +53,6 @@ import org.whispersystems.textsecuregcm.storage.VerificationCodeStore;
|
||||||
import org.whispersystems.textsecuregcm.util.DynamoDbFromConfig;
|
import org.whispersystems.textsecuregcm.util.DynamoDbFromConfig;
|
||||||
import software.amazon.awssdk.services.dynamodb.DynamoDbAsyncClient;
|
import software.amazon.awssdk.services.dynamodb.DynamoDbAsyncClient;
|
||||||
import software.amazon.awssdk.services.dynamodb.DynamoDbClient;
|
import software.amazon.awssdk.services.dynamodb.DynamoDbClient;
|
||||||
import java.time.Clock;
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.concurrent.ExecutorService;
|
|
||||||
import java.util.concurrent.Executors;
|
|
||||||
|
|
||||||
import static com.codahale.metrics.MetricRegistry.name;
|
|
||||||
|
|
||||||
public class AssignUsernameCommand extends EnvironmentCommand<WhisperServerConfiguration> {
|
public class AssignUsernameCommand extends EnvironmentCommand<WhisperServerConfiguration> {
|
||||||
|
|
||||||
|
@ -95,23 +90,6 @@ public class AssignUsernameCommand extends EnvironmentCommand<WhisperServerConfi
|
||||||
|
|
||||||
ClientResources redisClusterClientResources = ClientResources.builder().build();
|
ClientResources redisClusterClientResources = ClientResources.builder().build();
|
||||||
|
|
||||||
DynamoDbClient reportMessagesDynamoDb = DynamoDbFromConfig.client(
|
|
||||||
configuration.getReportMessageDynamoDbConfiguration(),
|
|
||||||
software.amazon.awssdk.auth.credentials.InstanceProfileCredentialsProvider.create());
|
|
||||||
DynamoDbClient messageDynamoDb = DynamoDbFromConfig.client(configuration.getMessageDynamoDbConfiguration(),
|
|
||||||
software.amazon.awssdk.auth.credentials.InstanceProfileCredentialsProvider.create());
|
|
||||||
DynamoDbClient preKeysDynamoDb = DynamoDbFromConfig.client(configuration.getKeysDynamoDbConfiguration(),
|
|
||||||
software.amazon.awssdk.auth.credentials.InstanceProfileCredentialsProvider.create());
|
|
||||||
DynamoDbClient accountsDynamoDbClient = DynamoDbFromConfig.client(
|
|
||||||
configuration.getAccountsDynamoDbConfiguration(),
|
|
||||||
software.amazon.awssdk.auth.credentials.InstanceProfileCredentialsProvider.create());
|
|
||||||
DynamoDbClient deletedAccountsDynamoDbClient = DynamoDbFromConfig.client(
|
|
||||||
configuration.getDeletedAccountsDynamoDbConfiguration(),
|
|
||||||
software.amazon.awssdk.auth.credentials.InstanceProfileCredentialsProvider.create());
|
|
||||||
DynamoDbClient phoneNumberIdentifiersDynamoDbClient =
|
|
||||||
DynamoDbFromConfig.client(configuration.getPhoneNumberIdentifiersDynamoDbConfiguration(),
|
|
||||||
software.amazon.awssdk.auth.credentials.InstanceProfileCredentialsProvider.create());
|
|
||||||
|
|
||||||
FaultTolerantRedisCluster cacheCluster = new FaultTolerantRedisCluster("main_cache_cluster",
|
FaultTolerantRedisCluster cacheCluster = new FaultTolerantRedisCluster("main_cache_cluster",
|
||||||
configuration.getCacheClusterConfiguration(), redisClusterClientResources);
|
configuration.getCacheClusterConfiguration(), redisClusterClientResources);
|
||||||
|
|
||||||
|
@ -132,14 +110,6 @@ public class AssignUsernameCommand extends EnvironmentCommand<WhisperServerConfi
|
||||||
configuration.getAppConfig().getConfigurationName(), DynamicConfiguration.class);
|
configuration.getAppConfig().getConfigurationName(), DynamicConfiguration.class);
|
||||||
dynamicConfigurationManager.start();
|
dynamicConfigurationManager.start();
|
||||||
|
|
||||||
DynamoDbClient pendingAccountsDynamoDbClient = DynamoDbFromConfig.client(
|
|
||||||
configuration.getPendingAccountsDynamoDbConfiguration(),
|
|
||||||
software.amazon.awssdk.auth.credentials.InstanceProfileCredentialsProvider.create());
|
|
||||||
|
|
||||||
DynamoDbClient reservedUsernamesDynamoDbClient =
|
|
||||||
DynamoDbFromConfig.client(configuration.getReservedUsernamesDynamoDbConfiguration(),
|
|
||||||
software.amazon.awssdk.auth.credentials.InstanceProfileCredentialsProvider.create());
|
|
||||||
|
|
||||||
DynamoDbAsyncClient dynamoDbAsyncClient = DynamoDbFromConfig.asyncClient(
|
DynamoDbAsyncClient dynamoDbAsyncClient = DynamoDbFromConfig.asyncClient(
|
||||||
configuration.getDynamoDbClientConfiguration(),
|
configuration.getDynamoDbClientConfiguration(),
|
||||||
software.amazon.awssdk.auth.credentials.InstanceProfileCredentialsProvider.create());
|
software.amazon.awssdk.auth.credentials.InstanceProfileCredentialsProvider.create());
|
||||||
|
@ -149,39 +119,39 @@ public class AssignUsernameCommand extends EnvironmentCommand<WhisperServerConfi
|
||||||
software.amazon.awssdk.auth.credentials.InstanceProfileCredentialsProvider.create());
|
software.amazon.awssdk.auth.credentials.InstanceProfileCredentialsProvider.create());
|
||||||
|
|
||||||
AmazonDynamoDB deletedAccountsLockDynamoDbClient = AmazonDynamoDBClientBuilder.standard()
|
AmazonDynamoDB deletedAccountsLockDynamoDbClient = AmazonDynamoDBClientBuilder.standard()
|
||||||
.withRegion(configuration.getDeletedAccountsLockDynamoDbConfiguration().getRegion())
|
.withRegion(configuration.getDynamoDbClientConfiguration().getRegion())
|
||||||
.withClientConfiguration(new ClientConfiguration().withClientExecutionTimeout(
|
.withClientConfiguration(new ClientConfiguration().withClientExecutionTimeout(
|
||||||
((int) configuration.getDeletedAccountsLockDynamoDbConfiguration().getClientExecutionTimeout()
|
((int) configuration.getDynamoDbClientConfiguration().getClientExecutionTimeout()
|
||||||
.toMillis()))
|
.toMillis()))
|
||||||
.withRequestTimeout(
|
.withRequestTimeout(
|
||||||
(int) configuration.getDeletedAccountsLockDynamoDbConfiguration().getClientRequestTimeout()
|
(int) configuration.getDynamoDbClientConfiguration().getClientRequestTimeout()
|
||||||
.toMillis()))
|
.toMillis()))
|
||||||
.withCredentials(InstanceProfileCredentialsProvider.getInstance())
|
.withCredentials(InstanceProfileCredentialsProvider.getInstance())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
DeletedAccounts deletedAccounts = new DeletedAccounts(deletedAccountsDynamoDbClient,
|
DeletedAccounts deletedAccounts = new DeletedAccounts(dynamoDbClient,
|
||||||
configuration.getDeletedAccountsDynamoDbConfiguration().getTableName(),
|
configuration.getDynamoDbTables().getDeletedAccounts().getTableName(),
|
||||||
configuration.getDeletedAccountsDynamoDbConfiguration().getNeedsReconciliationIndexName());
|
configuration.getDynamoDbTables().getDeletedAccounts().getNeedsReconciliationIndexName());
|
||||||
VerificationCodeStore pendingAccounts = new VerificationCodeStore(pendingAccountsDynamoDbClient,
|
VerificationCodeStore pendingAccounts = new VerificationCodeStore(dynamoDbClient,
|
||||||
configuration.getPendingAccountsDynamoDbConfiguration().getTableName());
|
configuration.getDynamoDbTables().getPendingAccounts().getTableName());
|
||||||
|
|
||||||
Accounts accounts = new Accounts(accountsDynamoDbClient,
|
Accounts accounts = new Accounts(dynamoDbClient,
|
||||||
configuration.getAccountsDynamoDbConfiguration().getTableName(),
|
configuration.getDynamoDbTables().getAccounts().getTableName(),
|
||||||
configuration.getAccountsDynamoDbConfiguration().getPhoneNumberTableName(),
|
configuration.getDynamoDbTables().getAccounts().getPhoneNumberTableName(),
|
||||||
configuration.getAccountsDynamoDbConfiguration().getPhoneNumberIdentifierTableName(),
|
configuration.getDynamoDbTables().getAccounts().getPhoneNumberIdentifierTableName(),
|
||||||
configuration.getAccountsDynamoDbConfiguration().getUsernamesTableName(),
|
configuration.getDynamoDbTables().getAccounts().getUsernamesTableName(),
|
||||||
configuration.getAccountsDynamoDbConfiguration().getScanPageSize());
|
configuration.getDynamoDbTables().getAccounts().getScanPageSize());
|
||||||
PhoneNumberIdentifiers phoneNumberIdentifiers = new PhoneNumberIdentifiers(phoneNumberIdentifiersDynamoDbClient,
|
PhoneNumberIdentifiers phoneNumberIdentifiers = new PhoneNumberIdentifiers(dynamoDbClient,
|
||||||
configuration.getPhoneNumberIdentifiersDynamoDbConfiguration().getTableName());
|
configuration.getDynamoDbTables().getPhoneNumberIdentifiers().getTableName());
|
||||||
Profiles profiles = new Profiles(dynamoDbClient, dynamoDbAsyncClient,
|
Profiles profiles = new Profiles(dynamoDbClient, dynamoDbAsyncClient,
|
||||||
configuration.getDynamoDbTables().getProfiles().getTableName());
|
configuration.getDynamoDbTables().getProfiles().getTableName());
|
||||||
ReservedUsernames reservedUsernames = new ReservedUsernames(reservedUsernamesDynamoDbClient,
|
ReservedUsernames reservedUsernames = new ReservedUsernames(dynamoDbClient,
|
||||||
configuration.getReservedUsernamesDynamoDbConfiguration().getTableName());
|
configuration.getDynamoDbTables().getReservedUsernames().getTableName());
|
||||||
Keys keys = new Keys(preKeysDynamoDb,
|
Keys keys = new Keys(dynamoDbClient,
|
||||||
configuration.getKeysDynamoDbConfiguration().getTableName());
|
configuration.getDynamoDbTables().getKeys().getTableName());
|
||||||
MessagesDynamoDb messagesDynamoDb = new MessagesDynamoDb(messageDynamoDb,
|
MessagesDynamoDb messagesDynamoDb = new MessagesDynamoDb(dynamoDbClient,
|
||||||
configuration.getMessageDynamoDbConfiguration().getTableName(),
|
configuration.getDynamoDbTables().getMessages().getTableName(),
|
||||||
configuration.getMessageDynamoDbConfiguration().getTimeToLive());
|
configuration.getDynamoDbTables().getMessages().getExpiration());
|
||||||
FaultTolerantRedisCluster messageInsertCacheCluster = new FaultTolerantRedisCluster("message_insert_cluster",
|
FaultTolerantRedisCluster messageInsertCacheCluster = new FaultTolerantRedisCluster("message_insert_cluster",
|
||||||
configuration.getMessageCacheConfiguration().getRedisClusterConfiguration(), redisClusterClientResources);
|
configuration.getMessageCacheConfiguration().getRedisClusterConfiguration(), redisClusterClientResources);
|
||||||
FaultTolerantRedisCluster messageReadDeleteCluster = new FaultTolerantRedisCluster("message_read_delete_cluster",
|
FaultTolerantRedisCluster messageReadDeleteCluster = new FaultTolerantRedisCluster("message_read_delete_cluster",
|
||||||
|
@ -204,8 +174,8 @@ public class AssignUsernameCommand extends EnvironmentCommand<WhisperServerConfi
|
||||||
DirectoryQueue directoryQueue = new DirectoryQueue(
|
DirectoryQueue directoryQueue = new DirectoryQueue(
|
||||||
configuration.getDirectoryConfiguration().getSqsConfiguration());
|
configuration.getDirectoryConfiguration().getSqsConfiguration());
|
||||||
ProfilesManager profilesManager = new ProfilesManager(profiles, cacheCluster);
|
ProfilesManager profilesManager = new ProfilesManager(profiles, cacheCluster);
|
||||||
ReportMessageDynamoDb reportMessageDynamoDb = new ReportMessageDynamoDb(reportMessagesDynamoDb,
|
ReportMessageDynamoDb reportMessageDynamoDb = new ReportMessageDynamoDb(dynamoDbClient,
|
||||||
configuration.getReportMessageDynamoDbConfiguration().getTableName(),
|
configuration.getDynamoDbTables().getReportMessage().getTableName(),
|
||||||
configuration.getReportMessageConfiguration().getReportTtl());
|
configuration.getReportMessageConfiguration().getReportTtl());
|
||||||
ReportMessageManager reportMessageManager = new ReportMessageManager(reportMessageDynamoDb, rateLimitersCluster,
|
ReportMessageManager reportMessageManager = new ReportMessageManager(reportMessageDynamoDb, rateLimitersCluster,
|
||||||
Metrics.globalRegistry, configuration.getReportMessageConfiguration().getCounterTtl());
|
Metrics.globalRegistry, configuration.getReportMessageConfiguration().getCounterTtl());
|
||||||
|
@ -213,7 +183,7 @@ public class AssignUsernameCommand extends EnvironmentCommand<WhisperServerConfi
|
||||||
reportMessageManager);
|
reportMessageManager);
|
||||||
DeletedAccountsManager deletedAccountsManager = new DeletedAccountsManager(deletedAccounts,
|
DeletedAccountsManager deletedAccountsManager = new DeletedAccountsManager(deletedAccounts,
|
||||||
deletedAccountsLockDynamoDbClient,
|
deletedAccountsLockDynamoDbClient,
|
||||||
configuration.getDeletedAccountsLockDynamoDbConfiguration().getTableName());
|
configuration.getDynamoDbTables().getDeletedAccountsLock().getTableName());
|
||||||
StoredVerificationCodeManager pendingAccountsManager = new StoredVerificationCodeManager(pendingAccounts);
|
StoredVerificationCodeManager pendingAccountsManager = new StoredVerificationCodeManager(pendingAccounts);
|
||||||
AccountsManager accountsManager = new AccountsManager(accounts, phoneNumberIdentifiers, cacheCluster,
|
AccountsManager accountsManager = new AccountsManager(accounts, phoneNumberIdentifiers, cacheCluster,
|
||||||
deletedAccountsManager, directoryQueue, keys, messagesManager, reservedUsernames, profilesManager,
|
deletedAccountsManager, directoryQueue, keys, messagesManager, reservedUsernames, profilesManager,
|
||||||
|
|
|
@ -93,23 +93,6 @@ public class DeleteUserCommand extends EnvironmentCommand<WhisperServerConfigura
|
||||||
|
|
||||||
ClientResources redisClusterClientResources = ClientResources.builder().build();
|
ClientResources redisClusterClientResources = ClientResources.builder().build();
|
||||||
|
|
||||||
DynamoDbClient reportMessagesDynamoDb = DynamoDbFromConfig.client(
|
|
||||||
configuration.getReportMessageDynamoDbConfiguration(),
|
|
||||||
software.amazon.awssdk.auth.credentials.InstanceProfileCredentialsProvider.create());
|
|
||||||
DynamoDbClient messageDynamoDb = DynamoDbFromConfig.client(configuration.getMessageDynamoDbConfiguration(),
|
|
||||||
software.amazon.awssdk.auth.credentials.InstanceProfileCredentialsProvider.create());
|
|
||||||
DynamoDbClient preKeysDynamoDb = DynamoDbFromConfig.client(configuration.getKeysDynamoDbConfiguration(),
|
|
||||||
software.amazon.awssdk.auth.credentials.InstanceProfileCredentialsProvider.create());
|
|
||||||
DynamoDbClient accountsDynamoDbClient = DynamoDbFromConfig.client(
|
|
||||||
configuration.getAccountsDynamoDbConfiguration(),
|
|
||||||
software.amazon.awssdk.auth.credentials.InstanceProfileCredentialsProvider.create());
|
|
||||||
DynamoDbClient deletedAccountsDynamoDbClient = DynamoDbFromConfig.client(
|
|
||||||
configuration.getDeletedAccountsDynamoDbConfiguration(),
|
|
||||||
software.amazon.awssdk.auth.credentials.InstanceProfileCredentialsProvider.create());
|
|
||||||
DynamoDbClient phoneNumberIdentifiersDynamoDbClient =
|
|
||||||
DynamoDbFromConfig.client(configuration.getPhoneNumberIdentifiersDynamoDbConfiguration(),
|
|
||||||
software.amazon.awssdk.auth.credentials.InstanceProfileCredentialsProvider.create());
|
|
||||||
|
|
||||||
FaultTolerantRedisCluster cacheCluster = new FaultTolerantRedisCluster("main_cache_cluster",
|
FaultTolerantRedisCluster cacheCluster = new FaultTolerantRedisCluster("main_cache_cluster",
|
||||||
configuration.getCacheClusterConfiguration(), redisClusterClientResources);
|
configuration.getCacheClusterConfiguration(), redisClusterClientResources);
|
||||||
|
|
||||||
|
@ -130,13 +113,6 @@ public class DeleteUserCommand extends EnvironmentCommand<WhisperServerConfigura
|
||||||
configuration.getAppConfig().getConfigurationName(), DynamicConfiguration.class);
|
configuration.getAppConfig().getConfigurationName(), DynamicConfiguration.class);
|
||||||
dynamicConfigurationManager.start();
|
dynamicConfigurationManager.start();
|
||||||
|
|
||||||
DynamoDbClient pendingAccountsDynamoDbClient = DynamoDbFromConfig.client(configuration.getPendingAccountsDynamoDbConfiguration(),
|
|
||||||
software.amazon.awssdk.auth.credentials.InstanceProfileCredentialsProvider.create());
|
|
||||||
|
|
||||||
DynamoDbClient reservedUsernamesDynamoDbClient =
|
|
||||||
DynamoDbFromConfig.client(configuration.getReservedUsernamesDynamoDbConfiguration(),
|
|
||||||
software.amazon.awssdk.auth.credentials.InstanceProfileCredentialsProvider.create());
|
|
||||||
|
|
||||||
DynamoDbAsyncClient dynamoDbAsyncClient = DynamoDbFromConfig.asyncClient(
|
DynamoDbAsyncClient dynamoDbAsyncClient = DynamoDbFromConfig.asyncClient(
|
||||||
configuration.getDynamoDbClientConfiguration(),
|
configuration.getDynamoDbClientConfiguration(),
|
||||||
software.amazon.awssdk.auth.credentials.InstanceProfileCredentialsProvider.create());
|
software.amazon.awssdk.auth.credentials.InstanceProfileCredentialsProvider.create());
|
||||||
|
@ -146,39 +122,39 @@ public class DeleteUserCommand extends EnvironmentCommand<WhisperServerConfigura
|
||||||
software.amazon.awssdk.auth.credentials.InstanceProfileCredentialsProvider.create());
|
software.amazon.awssdk.auth.credentials.InstanceProfileCredentialsProvider.create());
|
||||||
|
|
||||||
AmazonDynamoDB deletedAccountsLockDynamoDbClient = AmazonDynamoDBClientBuilder.standard()
|
AmazonDynamoDB deletedAccountsLockDynamoDbClient = AmazonDynamoDBClientBuilder.standard()
|
||||||
.withRegion(configuration.getDeletedAccountsLockDynamoDbConfiguration().getRegion())
|
.withRegion(configuration.getDynamoDbClientConfiguration().getRegion())
|
||||||
.withClientConfiguration(new ClientConfiguration().withClientExecutionTimeout(
|
.withClientConfiguration(new ClientConfiguration().withClientExecutionTimeout(
|
||||||
((int) configuration.getDeletedAccountsLockDynamoDbConfiguration().getClientExecutionTimeout()
|
((int) configuration.getDynamoDbClientConfiguration().getClientExecutionTimeout()
|
||||||
.toMillis()))
|
.toMillis()))
|
||||||
.withRequestTimeout(
|
.withRequestTimeout(
|
||||||
(int) configuration.getDeletedAccountsLockDynamoDbConfiguration().getClientRequestTimeout()
|
(int) configuration.getDynamoDbClientConfiguration().getClientRequestTimeout()
|
||||||
.toMillis()))
|
.toMillis()))
|
||||||
.withCredentials(InstanceProfileCredentialsProvider.getInstance())
|
.withCredentials(InstanceProfileCredentialsProvider.getInstance())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
DeletedAccounts deletedAccounts = new DeletedAccounts(deletedAccountsDynamoDbClient,
|
DeletedAccounts deletedAccounts = new DeletedAccounts(dynamoDbClient,
|
||||||
configuration.getDeletedAccountsDynamoDbConfiguration().getTableName(),
|
configuration.getDynamoDbTables().getDeletedAccounts().getTableName(),
|
||||||
configuration.getDeletedAccountsDynamoDbConfiguration().getNeedsReconciliationIndexName());
|
configuration.getDynamoDbTables().getDeletedAccounts().getNeedsReconciliationIndexName());
|
||||||
VerificationCodeStore pendingAccounts = new VerificationCodeStore(pendingAccountsDynamoDbClient,
|
VerificationCodeStore pendingAccounts = new VerificationCodeStore(dynamoDbClient,
|
||||||
configuration.getPendingAccountsDynamoDbConfiguration().getTableName());
|
configuration.getDynamoDbTables().getPendingAccounts().getTableName());
|
||||||
|
|
||||||
Accounts accounts = new Accounts(accountsDynamoDbClient,
|
Accounts accounts = new Accounts(dynamoDbClient,
|
||||||
configuration.getAccountsDynamoDbConfiguration().getTableName(),
|
configuration.getDynamoDbTables().getAccounts().getTableName(),
|
||||||
configuration.getAccountsDynamoDbConfiguration().getPhoneNumberTableName(),
|
configuration.getDynamoDbTables().getAccounts().getPhoneNumberTableName(),
|
||||||
configuration.getAccountsDynamoDbConfiguration().getPhoneNumberIdentifierTableName(),
|
configuration.getDynamoDbTables().getAccounts().getPhoneNumberIdentifierTableName(),
|
||||||
configuration.getAccountsDynamoDbConfiguration().getUsernamesTableName(),
|
configuration.getDynamoDbTables().getAccounts().getUsernamesTableName(),
|
||||||
configuration.getAccountsDynamoDbConfiguration().getScanPageSize());
|
configuration.getDynamoDbTables().getAccounts().getScanPageSize());
|
||||||
PhoneNumberIdentifiers phoneNumberIdentifiers = new PhoneNumberIdentifiers(phoneNumberIdentifiersDynamoDbClient,
|
PhoneNumberIdentifiers phoneNumberIdentifiers = new PhoneNumberIdentifiers(dynamoDbClient,
|
||||||
configuration.getPhoneNumberIdentifiersDynamoDbConfiguration().getTableName());
|
configuration.getDynamoDbTables().getPhoneNumberIdentifiers().getTableName());
|
||||||
Profiles profiles = new Profiles(dynamoDbClient, dynamoDbAsyncClient,
|
Profiles profiles = new Profiles(dynamoDbClient, dynamoDbAsyncClient,
|
||||||
configuration.getDynamoDbTables().getProfiles().getTableName());
|
configuration.getDynamoDbTables().getProfiles().getTableName());
|
||||||
ReservedUsernames reservedUsernames = new ReservedUsernames(reservedUsernamesDynamoDbClient,
|
ReservedUsernames reservedUsernames = new ReservedUsernames(dynamoDbClient,
|
||||||
configuration.getReservedUsernamesDynamoDbConfiguration().getTableName());
|
configuration.getDynamoDbTables().getReservedUsernames().getTableName());
|
||||||
Keys keys = new Keys(preKeysDynamoDb,
|
Keys keys = new Keys(dynamoDbClient,
|
||||||
configuration.getKeysDynamoDbConfiguration().getTableName());
|
configuration.getDynamoDbTables().getKeys().getTableName());
|
||||||
MessagesDynamoDb messagesDynamoDb = new MessagesDynamoDb(messageDynamoDb,
|
MessagesDynamoDb messagesDynamoDb = new MessagesDynamoDb(dynamoDbClient,
|
||||||
configuration.getMessageDynamoDbConfiguration().getTableName(),
|
configuration.getDynamoDbTables().getMessages().getTableName(),
|
||||||
configuration.getMessageDynamoDbConfiguration().getTimeToLive());
|
configuration.getDynamoDbTables().getMessages().getExpiration());
|
||||||
FaultTolerantRedisCluster messageInsertCacheCluster = new FaultTolerantRedisCluster("message_insert_cluster",
|
FaultTolerantRedisCluster messageInsertCacheCluster = new FaultTolerantRedisCluster("message_insert_cluster",
|
||||||
configuration.getMessageCacheConfiguration().getRedisClusterConfiguration(), redisClusterClientResources);
|
configuration.getMessageCacheConfiguration().getRedisClusterConfiguration(), redisClusterClientResources);
|
||||||
FaultTolerantRedisCluster messageReadDeleteCluster = new FaultTolerantRedisCluster("message_read_delete_cluster",
|
FaultTolerantRedisCluster messageReadDeleteCluster = new FaultTolerantRedisCluster("message_read_delete_cluster",
|
||||||
|
@ -201,8 +177,8 @@ public class DeleteUserCommand extends EnvironmentCommand<WhisperServerConfigura
|
||||||
DirectoryQueue directoryQueue = new DirectoryQueue(
|
DirectoryQueue directoryQueue = new DirectoryQueue(
|
||||||
configuration.getDirectoryConfiguration().getSqsConfiguration());
|
configuration.getDirectoryConfiguration().getSqsConfiguration());
|
||||||
ProfilesManager profilesManager = new ProfilesManager(profiles, cacheCluster);
|
ProfilesManager profilesManager = new ProfilesManager(profiles, cacheCluster);
|
||||||
ReportMessageDynamoDb reportMessageDynamoDb = new ReportMessageDynamoDb(reportMessagesDynamoDb,
|
ReportMessageDynamoDb reportMessageDynamoDb = new ReportMessageDynamoDb(dynamoDbClient,
|
||||||
configuration.getReportMessageDynamoDbConfiguration().getTableName(),
|
configuration.getDynamoDbTables().getReportMessage().getTableName(),
|
||||||
configuration.getReportMessageConfiguration().getReportTtl());
|
configuration.getReportMessageConfiguration().getReportTtl());
|
||||||
ReportMessageManager reportMessageManager = new ReportMessageManager(reportMessageDynamoDb, rateLimitersCluster,
|
ReportMessageManager reportMessageManager = new ReportMessageManager(reportMessageDynamoDb, rateLimitersCluster,
|
||||||
Metrics.globalRegistry, configuration.getReportMessageConfiguration().getCounterTtl());
|
Metrics.globalRegistry, configuration.getReportMessageConfiguration().getCounterTtl());
|
||||||
|
@ -210,7 +186,7 @@ public class DeleteUserCommand extends EnvironmentCommand<WhisperServerConfigura
|
||||||
reportMessageManager);
|
reportMessageManager);
|
||||||
DeletedAccountsManager deletedAccountsManager = new DeletedAccountsManager(deletedAccounts,
|
DeletedAccountsManager deletedAccountsManager = new DeletedAccountsManager(deletedAccounts,
|
||||||
deletedAccountsLockDynamoDbClient,
|
deletedAccountsLockDynamoDbClient,
|
||||||
configuration.getDeletedAccountsLockDynamoDbConfiguration().getTableName());
|
configuration.getDynamoDbTables().getDeletedAccountsLock().getTableName());
|
||||||
StoredVerificationCodeManager pendingAccountsManager = new StoredVerificationCodeManager(pendingAccounts);
|
StoredVerificationCodeManager pendingAccountsManager = new StoredVerificationCodeManager(pendingAccounts);
|
||||||
AccountsManager accountsManager = new AccountsManager(accounts, phoneNumberIdentifiers, cacheCluster,
|
AccountsManager accountsManager = new AccountsManager(accounts, phoneNumberIdentifiers, cacheCluster,
|
||||||
deletedAccountsManager, directoryQueue, keys, messagesManager, reservedUsernames, profilesManager,
|
deletedAccountsManager, directoryQueue, keys, messagesManager, reservedUsernames, profilesManager,
|
||||||
|
|
|
@ -41,11 +41,11 @@ public class ReserveUsernameCommand extends ConfiguredCommand<WhisperServerConfi
|
||||||
protected void run(final Bootstrap<WhisperServerConfiguration> bootstrap, final Namespace namespace,
|
protected void run(final Bootstrap<WhisperServerConfiguration> bootstrap, final Namespace namespace,
|
||||||
final WhisperServerConfiguration config) throws Exception {
|
final WhisperServerConfiguration config) throws Exception {
|
||||||
|
|
||||||
final DynamoDbClient reservedUsernamesDynamoDbClient = DynamoDbFromConfig.client(config.getReservedUsernamesDynamoDbConfiguration(),
|
final DynamoDbClient dynamoDbClient = DynamoDbFromConfig.client(config.getDynamoDbClientConfiguration(),
|
||||||
software.amazon.awssdk.auth.credentials.InstanceProfileCredentialsProvider.create());
|
software.amazon.awssdk.auth.credentials.InstanceProfileCredentialsProvider.create());
|
||||||
|
|
||||||
final ReservedUsernames reservedUsernames = new ReservedUsernames(reservedUsernamesDynamoDbClient,
|
final ReservedUsernames reservedUsernames = new ReservedUsernames(dynamoDbClient,
|
||||||
config.getReservedUsernamesDynamoDbConfiguration().getTableName());
|
config.getDynamoDbTables().getReservedUsernames().getTableName());
|
||||||
|
|
||||||
final String pattern = namespace.getString("pattern").trim();
|
final String pattern = namespace.getString("pattern").trim();
|
||||||
|
|
||||||
|
|
|
@ -94,26 +94,6 @@ public class SetUserDiscoverabilityCommand extends EnvironmentCommand<WhisperSer
|
||||||
|
|
||||||
ClientResources redisClusterClientResources = ClientResources.builder().build();
|
ClientResources redisClusterClientResources = ClientResources.builder().build();
|
||||||
|
|
||||||
DynamoDbClient reportMessagesDynamoDb = DynamoDbFromConfig
|
|
||||||
.client(configuration.getReportMessageDynamoDbConfiguration(),
|
|
||||||
software.amazon.awssdk.auth.credentials.InstanceProfileCredentialsProvider.create());
|
|
||||||
DynamoDbClient messageDynamoDb = DynamoDbFromConfig.client(configuration.getMessageDynamoDbConfiguration(),
|
|
||||||
software.amazon.awssdk.auth.credentials.InstanceProfileCredentialsProvider.create());
|
|
||||||
DynamoDbClient preKeysDynamoDb = DynamoDbFromConfig.client(configuration.getKeysDynamoDbConfiguration(),
|
|
||||||
software.amazon.awssdk.auth.credentials.InstanceProfileCredentialsProvider.create());
|
|
||||||
DynamoDbClient accountsDynamoDbClient = DynamoDbFromConfig
|
|
||||||
.client(configuration.getAccountsDynamoDbConfiguration(),
|
|
||||||
software.amazon.awssdk.auth.credentials.InstanceProfileCredentialsProvider.create());
|
|
||||||
DynamoDbClient deletedAccountsDynamoDbClient = DynamoDbFromConfig
|
|
||||||
.client(configuration.getDeletedAccountsDynamoDbConfiguration(),
|
|
||||||
software.amazon.awssdk.auth.credentials.InstanceProfileCredentialsProvider.create());
|
|
||||||
DynamoDbClient phoneNumberIdentifiersDynamoDbClient =
|
|
||||||
DynamoDbFromConfig.client(configuration.getPhoneNumberIdentifiersDynamoDbConfiguration(),
|
|
||||||
software.amazon.awssdk.auth.credentials.InstanceProfileCredentialsProvider.create());
|
|
||||||
DynamoDbClient reservedUsernamesDynamoDbClient =
|
|
||||||
DynamoDbFromConfig.client(configuration.getReservedUsernamesDynamoDbConfiguration(),
|
|
||||||
software.amazon.awssdk.auth.credentials.InstanceProfileCredentialsProvider.create());
|
|
||||||
|
|
||||||
FaultTolerantRedisCluster cacheCluster = new FaultTolerantRedisCluster("main_cache_cluster",
|
FaultTolerantRedisCluster cacheCluster = new FaultTolerantRedisCluster("main_cache_cluster",
|
||||||
configuration.getCacheClusterConfiguration(), redisClusterClientResources);
|
configuration.getCacheClusterConfiguration(), redisClusterClientResources);
|
||||||
FaultTolerantRedisCluster rateLimitersCluster = new FaultTolerantRedisCluster("rate_limiters",
|
FaultTolerantRedisCluster rateLimitersCluster = new FaultTolerantRedisCluster("rate_limiters",
|
||||||
|
@ -136,10 +116,6 @@ public class SetUserDiscoverabilityCommand extends EnvironmentCommand<WhisperSer
|
||||||
configuration.getAppConfig().getConfigurationName(), DynamicConfiguration.class);
|
configuration.getAppConfig().getConfigurationName(), DynamicConfiguration.class);
|
||||||
dynamicConfigurationManager.start();
|
dynamicConfigurationManager.start();
|
||||||
|
|
||||||
DynamoDbClient pendingAccountsDynamoDbClient = DynamoDbFromConfig
|
|
||||||
.client(configuration.getPendingAccountsDynamoDbConfiguration(),
|
|
||||||
software.amazon.awssdk.auth.credentials.InstanceProfileCredentialsProvider.create());
|
|
||||||
|
|
||||||
DynamoDbAsyncClient dynamoDbAsyncClient = DynamoDbFromConfig.asyncClient(
|
DynamoDbAsyncClient dynamoDbAsyncClient = DynamoDbFromConfig.asyncClient(
|
||||||
configuration.getDynamoDbClientConfiguration(),
|
configuration.getDynamoDbClientConfiguration(),
|
||||||
software.amazon.awssdk.auth.credentials.InstanceProfileCredentialsProvider.create());
|
software.amazon.awssdk.auth.credentials.InstanceProfileCredentialsProvider.create());
|
||||||
|
@ -149,39 +125,39 @@ public class SetUserDiscoverabilityCommand extends EnvironmentCommand<WhisperSer
|
||||||
software.amazon.awssdk.auth.credentials.InstanceProfileCredentialsProvider.create());
|
software.amazon.awssdk.auth.credentials.InstanceProfileCredentialsProvider.create());
|
||||||
|
|
||||||
AmazonDynamoDB deletedAccountsLockDynamoDbClient = AmazonDynamoDBClientBuilder.standard()
|
AmazonDynamoDB deletedAccountsLockDynamoDbClient = AmazonDynamoDBClientBuilder.standard()
|
||||||
.withRegion(configuration.getDeletedAccountsLockDynamoDbConfiguration().getRegion())
|
.withRegion(configuration.getDynamoDbClientConfiguration().getRegion())
|
||||||
.withClientConfiguration(new ClientConfiguration().withClientExecutionTimeout(
|
.withClientConfiguration(new ClientConfiguration().withClientExecutionTimeout(
|
||||||
((int) configuration.getDeletedAccountsLockDynamoDbConfiguration().getClientExecutionTimeout()
|
((int) configuration.getDynamoDbClientConfiguration().getClientExecutionTimeout()
|
||||||
.toMillis()))
|
.toMillis()))
|
||||||
.withRequestTimeout(
|
.withRequestTimeout(
|
||||||
(int) configuration.getDeletedAccountsLockDynamoDbConfiguration().getClientRequestTimeout()
|
(int) configuration.getDynamoDbClientConfiguration().getClientRequestTimeout()
|
||||||
.toMillis()))
|
.toMillis()))
|
||||||
.withCredentials(InstanceProfileCredentialsProvider.getInstance())
|
.withCredentials(InstanceProfileCredentialsProvider.getInstance())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
DeletedAccounts deletedAccounts = new DeletedAccounts(deletedAccountsDynamoDbClient,
|
DeletedAccounts deletedAccounts = new DeletedAccounts(dynamoDbClient,
|
||||||
configuration.getDeletedAccountsDynamoDbConfiguration().getTableName(),
|
configuration.getDynamoDbTables().getDeletedAccounts().getTableName(),
|
||||||
configuration.getDeletedAccountsDynamoDbConfiguration().getNeedsReconciliationIndexName());
|
configuration.getDynamoDbTables().getDeletedAccounts().getNeedsReconciliationIndexName());
|
||||||
VerificationCodeStore pendingAccounts = new VerificationCodeStore(pendingAccountsDynamoDbClient,
|
VerificationCodeStore pendingAccounts = new VerificationCodeStore(dynamoDbClient,
|
||||||
configuration.getPendingAccountsDynamoDbConfiguration().getTableName());
|
configuration.getDynamoDbTables().getPendingAccounts().getTableName());
|
||||||
|
|
||||||
Accounts accounts = new Accounts(accountsDynamoDbClient,
|
Accounts accounts = new Accounts(dynamoDbClient,
|
||||||
configuration.getAccountsDynamoDbConfiguration().getTableName(),
|
configuration.getDynamoDbTables().getAccounts().getTableName(),
|
||||||
configuration.getAccountsDynamoDbConfiguration().getPhoneNumberTableName(),
|
configuration.getDynamoDbTables().getAccounts().getPhoneNumberTableName(),
|
||||||
configuration.getAccountsDynamoDbConfiguration().getPhoneNumberIdentifierTableName(),
|
configuration.getDynamoDbTables().getAccounts().getPhoneNumberIdentifierTableName(),
|
||||||
configuration.getAccountsDynamoDbConfiguration().getUsernamesTableName(),
|
configuration.getDynamoDbTables().getAccounts().getUsernamesTableName(),
|
||||||
configuration.getAccountsDynamoDbConfiguration().getScanPageSize());
|
configuration.getDynamoDbTables().getAccounts().getScanPageSize());
|
||||||
PhoneNumberIdentifiers phoneNumberIdentifiers = new PhoneNumberIdentifiers(phoneNumberIdentifiersDynamoDbClient,
|
PhoneNumberIdentifiers phoneNumberIdentifiers = new PhoneNumberIdentifiers(dynamoDbClient,
|
||||||
configuration.getPhoneNumberIdentifiersDynamoDbConfiguration().getTableName());
|
configuration.getDynamoDbTables().getPhoneNumberIdentifiers().getTableName());
|
||||||
Profiles profiles = new Profiles(dynamoDbClient, dynamoDbAsyncClient,
|
Profiles profiles = new Profiles(dynamoDbClient, dynamoDbAsyncClient,
|
||||||
configuration.getDynamoDbTables().getProfiles().getTableName());
|
configuration.getDynamoDbTables().getProfiles().getTableName());
|
||||||
ReservedUsernames reservedUsernames = new ReservedUsernames(reservedUsernamesDynamoDbClient,
|
ReservedUsernames reservedUsernames = new ReservedUsernames(dynamoDbClient,
|
||||||
configuration.getReservedUsernamesDynamoDbConfiguration().getTableName());
|
configuration.getDynamoDbTables().getReservedUsernames().getTableName());
|
||||||
Keys keys = new Keys(preKeysDynamoDb,
|
Keys keys = new Keys(dynamoDbClient,
|
||||||
configuration.getKeysDynamoDbConfiguration().getTableName());
|
configuration.getDynamoDbTables().getKeys().getTableName());
|
||||||
MessagesDynamoDb messagesDynamoDb = new MessagesDynamoDb(messageDynamoDb,
|
MessagesDynamoDb messagesDynamoDb = new MessagesDynamoDb(dynamoDbClient,
|
||||||
configuration.getMessageDynamoDbConfiguration().getTableName(),
|
configuration.getDynamoDbTables().getMessages().getTableName(),
|
||||||
configuration.getMessageDynamoDbConfiguration().getTimeToLive());
|
configuration.getDynamoDbTables().getMessages().getExpiration());
|
||||||
FaultTolerantRedisCluster messageInsertCacheCluster = new FaultTolerantRedisCluster("message_insert_cluster",
|
FaultTolerantRedisCluster messageInsertCacheCluster = new FaultTolerantRedisCluster("message_insert_cluster",
|
||||||
configuration.getMessageCacheConfiguration().getRedisClusterConfiguration(), redisClusterClientResources);
|
configuration.getMessageCacheConfiguration().getRedisClusterConfiguration(), redisClusterClientResources);
|
||||||
FaultTolerantRedisCluster messageReadDeleteCluster = new FaultTolerantRedisCluster("message_read_delete_cluster",
|
FaultTolerantRedisCluster messageReadDeleteCluster = new FaultTolerantRedisCluster("message_read_delete_cluster",
|
||||||
|
@ -202,8 +178,8 @@ public class SetUserDiscoverabilityCommand extends EnvironmentCommand<WhisperSer
|
||||||
DirectoryQueue directoryQueue = new DirectoryQueue(
|
DirectoryQueue directoryQueue = new DirectoryQueue(
|
||||||
configuration.getDirectoryConfiguration().getSqsConfiguration());
|
configuration.getDirectoryConfiguration().getSqsConfiguration());
|
||||||
ProfilesManager profilesManager = new ProfilesManager(profiles, cacheCluster);
|
ProfilesManager profilesManager = new ProfilesManager(profiles, cacheCluster);
|
||||||
ReportMessageDynamoDb reportMessageDynamoDb = new ReportMessageDynamoDb(reportMessagesDynamoDb,
|
ReportMessageDynamoDb reportMessageDynamoDb = new ReportMessageDynamoDb(dynamoDbClient,
|
||||||
configuration.getReportMessageDynamoDbConfiguration().getTableName(),
|
configuration.getDynamoDbTables().getReportMessage().getTableName(),
|
||||||
configuration.getReportMessageConfiguration().getReportTtl());
|
configuration.getReportMessageConfiguration().getReportTtl());
|
||||||
ReportMessageManager reportMessageManager = new ReportMessageManager(reportMessageDynamoDb, rateLimitersCluster,
|
ReportMessageManager reportMessageManager = new ReportMessageManager(reportMessageDynamoDb, rateLimitersCluster,
|
||||||
Metrics.globalRegistry, configuration.getReportMessageConfiguration().getCounterTtl());
|
Metrics.globalRegistry, configuration.getReportMessageConfiguration().getCounterTtl());
|
||||||
|
@ -211,7 +187,7 @@ public class SetUserDiscoverabilityCommand extends EnvironmentCommand<WhisperSer
|
||||||
reportMessageManager);
|
reportMessageManager);
|
||||||
DeletedAccountsManager deletedAccountsManager = new DeletedAccountsManager(deletedAccounts,
|
DeletedAccountsManager deletedAccountsManager = new DeletedAccountsManager(deletedAccounts,
|
||||||
deletedAccountsLockDynamoDbClient,
|
deletedAccountsLockDynamoDbClient,
|
||||||
configuration.getDeletedAccountsLockDynamoDbConfiguration().getTableName());
|
configuration.getDynamoDbTables().getDeletedAccountsLock().getTableName());
|
||||||
StoredVerificationCodeManager pendingAccountsManager = new StoredVerificationCodeManager(pendingAccounts);
|
StoredVerificationCodeManager pendingAccountsManager = new StoredVerificationCodeManager(pendingAccounts);
|
||||||
AccountsManager accountsManager = new AccountsManager(accounts, phoneNumberIdentifiers, cacheCluster,
|
AccountsManager accountsManager = new AccountsManager(accounts, phoneNumberIdentifiers, cacheCluster,
|
||||||
deletedAccountsManager, directoryQueue, keys, messagesManager, reservedUsernames, profilesManager,
|
deletedAccountsManager, directoryQueue, keys, messagesManager, reservedUsernames, profilesManager,
|
||||||
|
|
Loading…
Reference in New Issue