|
1 | 1 | package bbs.priorityqueue.sdk |
2 | 2 |
|
3 | | -//import com.amazonaws.retry.PredefinedRetryPolicies |
4 | | -//import com.amazonaws.retry.RetryPolicy |
5 | | - |
6 | | - |
7 | | -//import com.amazonaws.services.dynamodbv2.AmazonDynamoDB |
8 | | -//import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClientBuilder |
9 | | -//import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper |
10 | | -//import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapperConfig |
11 | | -//import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapperConfig.TableNameOverride |
12 | | -//import com.amazonaws.services.dynamodbv2.document.DynamoDB |
13 | | -//import com.amazonaws.services.dynamodbv2.document.UpdateItemOutcome |
14 | | -//import com.amazonaws.services.dynamodbv2.document.spec.UpdateItemSpec |
15 | | -//import com.amazonaws.services.dynamodbv2.document.utils.NameMap |
16 | | -//import com.amazonaws.services.dynamodbv2.document.utils.ValueMap |
17 | | -//import com.amazonaws.services.dynamodbv2.model.AttributeValue |
18 | | -//import com.amazonaws.services.dynamodbv2.model.QueryRequest |
19 | | -//import com.amazonaws.services.dynamodbv2.model.ReturnValue |
20 | | - |
21 | | - |
22 | 3 | import bbs.priorityqueue.Constants |
23 | 4 | import bbs.priorityqueue.appdata.PriorityQueueElement |
24 | 5 | import bbs.priorityqueue.model.QueueStats |
25 | 6 | import bbs.priorityqueue.model.ReturnResult |
26 | 7 | import bbs.priorityqueue.model.ReturnStatusEnum |
27 | 8 | import bbs.priorityqueue.model.SystemInfo |
28 | 9 | import bbs.priorityqueue.utils.Utils |
29 | | -import com.amazonaws.auth.* |
| 10 | + |
30 | 11 | import software.amazon.awssdk.auth.credentials.ProfileCredentialsProvider |
31 | 12 | import software.amazon.awssdk.enhanced.dynamodb.DynamoDbEnhancedClient |
32 | 13 | import software.amazon.awssdk.enhanced.dynamodb.DynamoDbTable |
33 | 14 | import software.amazon.awssdk.enhanced.dynamodb.Key |
34 | 15 | import software.amazon.awssdk.enhanced.dynamodb.TableSchema |
35 | 16 | import software.amazon.awssdk.enhanced.dynamodb.model.GetItemEnhancedRequest |
36 | | -import software.amazon.awssdk.enhanced.dynamodb.model.UpdateItemEnhancedRequest |
| 17 | + |
37 | 18 | import software.amazon.awssdk.regions.Region |
38 | 19 | import software.amazon.awssdk.services.dynamodb.DynamoDbClient |
39 | 20 | import software.amazon.awssdk.services.dynamodb.model.AttributeValue |
@@ -66,49 +47,16 @@ class Dynamodb(builder: Builder) : Database { |
66 | 47 |
|
67 | 48 | override fun initialize() : Database { |
68 | 49 | Locale.setDefault(Locale.ENGLISH) |
69 | | -// var accessKey = System.getenv("AWS_ACCESS_KEY_ID") |
70 | | -// var secretKey = System.getenv("AWS_SECRET_ACCESS_KEY") |
71 | | -// |
72 | | -// // If the aws credentials aren't given via cli then checks Environment variables |
73 | | -// if (Utils.checkIfNotNullAndNotEmptyString(accessKey) && Utils.checkIfNotNullAndNotEmptyString(secretKey)) { |
74 | | -// if (Utils.checkIfNullOrEmptyString(accessKey)) accessKey = System.getenv("AWS_ACCESS_KEY_ID") |
75 | | -// if (Utils.checkIfNullOrEmptyString(secretKey)) secretKey = System.getenv("AWS_SECRET_ACCESS_KEY") |
76 | | -// credentials = BasicAWSCredentials(accessKey, secretKey) |
77 | | -// } else if (Utils.checkIfNotNullAndNotEmptyString(awsCredentialsProfileName)) { |
78 | | -// !!//(awsCredentialsProfileName).credentials |
79 | | -// } |
80 | | - |
81 | | - // val credentialProvider: ProfileCredentialsProvider= ProfileCredentialsProvider.create(awsCredentialsProfileName |
82 | | - // Creates a new instance of secure random everytime Dynamodb is instantiated |
83 | | - // Fix? to Random/SplittableRandom being stored in heap when library is being compiled for a native-image |
84 | 50 |
|
85 | 51 | dynamoDB =DynamoDbClient.builder() |
86 | 52 | .credentialsProvider(credentialProvider) |
87 | 53 | .region(awsRegion) |
88 | 54 | .build() |
89 | 55 |
|
90 | | - |
91 | | - |
92 | 56 | dynamoDBEnhanced = DynamoDbEnhancedClient.builder() |
93 | 57 | .dynamoDbClient(dynamoDB) |
94 | 58 | .build() |
95 | 59 |
|
96 | | - |
97 | | - |
98 | | -// .clientconfiguration( |
99 | | -// ClientConfiguration() |
100 | | -// .withMaxConnections(100) |
101 | | -// .withConnectionTimeout(30000) |
102 | | -// .withSecureRandom(secureRandom)) |
103 | | - |
104 | | - |
105 | | -// val mapperConfig = DynamoDBMapperConfig.builder() |
106 | | -// .withSaveBehavior(DynamoDBMapperConfig.SaveBehavior.CLOBBER) |
107 | | -// .withConsistentReads(DynamoDBMapperConfig.ConsistentReads.CONSISTENT) //.withConsistentReads(DynamoDBMapperConfig.ConsistentReads.EVENTUAL) |
108 | | -// .withTableNameOverride(TableNameOverride(tableName)) |
109 | | -// .withPaginationLoadingStrategy(DynamoDBMapperConfig.PaginationLoadingStrategy.EAGER_LOADING) |
110 | | -// .build() |
111 | | - |
112 | 60 | dbMapper = dynamoDBEnhanced?.table(tableName, TableSchema.fromBean(PriorityQueueElement::class.java)) |
113 | 61 | return this |
114 | 62 | } |
|
0 commit comments