|
17 | 17 | import com.fasterxml.jackson.databind.ObjectMapper;
|
18 | 18 | import com.phocassoftware.graphql.database.manager.Database;
|
19 | 19 | import com.phocassoftware.graphql.database.manager.dynamo.DynamoDbManager;
|
| 20 | + |
20 | 21 | import java.io.IOException;
|
21 | 22 | import java.net.ServerSocket;
|
22 | 23 | import java.net.URI;
|
23 | 24 | import java.net.URISyntaxException;
|
24 | 25 | import java.util.concurrent.ExecutionException;
|
| 26 | + |
25 | 27 | import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
|
26 | 28 | import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
|
27 | 29 | import software.amazon.awssdk.regions.Region;
|
@@ -100,38 +102,41 @@ static void createHistoryTable(final DynamoDbClient client, final String name) t
|
100 | 102 | return;
|
101 | 103 | }
|
102 | 104 |
|
103 |
| - client |
104 |
| - .createTable( |
105 |
| - t -> t |
106 |
| - .tableName(name) |
107 |
| - .keySchema( |
108 |
| - KeySchemaElement.builder().attributeName("organisationIdType").keyType(KeyType.HASH).build(), |
109 |
| - KeySchemaElement.builder().attributeName("idRevision").keyType(KeyType.RANGE).build() |
110 |
| - ) |
111 |
| - .localSecondaryIndexes( |
112 |
| - builder -> builder |
113 |
| - .indexName("startsWithUpdatedAt") |
114 |
| - .projection(b -> b.projectionType(ProjectionType.ALL)) |
115 |
| - .keySchema( |
116 |
| - KeySchemaElement.builder().attributeName("organisationIdType").keyType(KeyType.HASH).build(), |
117 |
| - KeySchemaElement.builder().attributeName("startsWithUpdatedAt").keyType(KeyType.RANGE).build() |
118 |
| - ), |
119 |
| - builder -> builder |
120 |
| - .indexName("idDate") |
121 |
| - .projection(b -> b.projectionType(ProjectionType.ALL)) |
122 |
| - .keySchema( |
123 |
| - KeySchemaElement.builder().attributeName("organisationIdType").keyType(KeyType.HASH).build(), |
124 |
| - KeySchemaElement.builder().attributeName("idDate").keyType(KeyType.RANGE).build() |
125 |
| - ) |
126 |
| - ) |
127 |
| - .attributeDefinitions( |
128 |
| - AttributeDefinition.builder().attributeName("organisationIdType").attributeType(ScalarAttributeType.S).build(), |
129 |
| - AttributeDefinition.builder().attributeName("idRevision").attributeType(ScalarAttributeType.B).build(), |
130 |
| - AttributeDefinition.builder().attributeName("idDate").attributeType(ScalarAttributeType.B).build(), |
131 |
| - AttributeDefinition.builder().attributeName("startsWithUpdatedAt").attributeType(ScalarAttributeType.B).build() |
132 |
| - ) |
133 |
| - .provisionedThroughput(p -> p.readCapacityUnits(10L).writeCapacityUnits(10L).build()) |
134 |
| - ); |
| 105 | + // looks like bug within local dynamodb client around creating multiple tables at the same time |
| 106 | + synchronized (DynamoDbInitializer.class) { |
| 107 | + client |
| 108 | + .createTable( |
| 109 | + t -> t |
| 110 | + .tableName(name) |
| 111 | + .keySchema( |
| 112 | + KeySchemaElement.builder().attributeName("organisationIdType").keyType(KeyType.HASH).build(), |
| 113 | + KeySchemaElement.builder().attributeName("idRevision").keyType(KeyType.RANGE).build() |
| 114 | + ) |
| 115 | + .localSecondaryIndexes( |
| 116 | + builder -> builder |
| 117 | + .indexName("startsWithUpdatedAt") |
| 118 | + .projection(b -> b.projectionType(ProjectionType.ALL)) |
| 119 | + .keySchema( |
| 120 | + KeySchemaElement.builder().attributeName("organisationIdType").keyType(KeyType.HASH).build(), |
| 121 | + KeySchemaElement.builder().attributeName("startsWithUpdatedAt").keyType(KeyType.RANGE).build() |
| 122 | + ), |
| 123 | + builder -> builder |
| 124 | + .indexName("idDate") |
| 125 | + .projection(b -> b.projectionType(ProjectionType.ALL)) |
| 126 | + .keySchema( |
| 127 | + KeySchemaElement.builder().attributeName("organisationIdType").keyType(KeyType.HASH).build(), |
| 128 | + KeySchemaElement.builder().attributeName("idDate").keyType(KeyType.RANGE).build() |
| 129 | + ) |
| 130 | + ) |
| 131 | + .attributeDefinitions( |
| 132 | + AttributeDefinition.builder().attributeName("organisationIdType").attributeType(ScalarAttributeType.S).build(), |
| 133 | + AttributeDefinition.builder().attributeName("idRevision").attributeType(ScalarAttributeType.B).build(), |
| 134 | + AttributeDefinition.builder().attributeName("idDate").attributeType(ScalarAttributeType.B).build(), |
| 135 | + AttributeDefinition.builder().attributeName("startsWithUpdatedAt").attributeType(ScalarAttributeType.B).build() |
| 136 | + ) |
| 137 | + .provisionedThroughput(p -> p.readCapacityUnits(10L).writeCapacityUnits(10L).build()) |
| 138 | + ); |
| 139 | + } |
135 | 140 | }
|
136 | 141 |
|
137 | 142 | static synchronized DynamoDBProxyServer startDynamoServer(final String port) throws Exception {
|
|
0 commit comments