mirror of
https://github.com/floci-io/floci.git
synced 2026-11-23 22:11:36 -05:00
fix: include ProvisionedThroughput in DynamoDB GSI responses (#273)
DescribeTable responses were missing ProvisionedThroughput attributes on Global Secondary Indexes. Updated the JSON handler to extract and set ReadCapacityUnits and WriteCapacityUnits from the response payload for both DescribeTable and Create operations.
This commit is contained in:
1 parent
caabf46b1c
commit
399a96d70c
3 files changed
+44
-3
No files matched your search
+22
-2
@@ -95,7 +95,13 @@ public class DynamoDbJsonHandler {
|
||||
ks.path("AttributeName").asText(),
|
||||
ks.path("KeyType").asText())));
|
||||
String projectionType = gsiNode.path("Projection").path("ProjectionType").asText("ALL");
|
||||
gsis.add(new GlobalSecondaryIndex(indexName, gsiKeySchema, null, projectionType));
|
||||
GlobalSecondaryIndex gsi = new GlobalSecondaryIndex(indexName, gsiKeySchema, null, projectionType);
|
||||
JsonNode gsiPt = gsiNode.path("ProvisionedThroughput");
|
||||
if (!gsiPt.isMissingNode()) {
|
||||
gsi.getProvisionedThroughput().setReadCapacityUnits(gsiPt.path("ReadCapacityUnits").asLong(0));
|
||||
gsi.getProvisionedThroughput().setWriteCapacityUnits(gsiPt.path("WriteCapacityUnits").asLong(0));
|
||||
}
|
||||
gsis.add(gsi);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -410,7 +416,13 @@ public class DynamoDbJsonHandler {
|
||||
ks.path("AttributeName").asText(),
|
||||
ks.path("KeyType").asText())));
|
||||
String projectionType = createNode.path("Projection").path("ProjectionType").asText("ALL");
|
||||
gsiCreates.add(new GlobalSecondaryIndex(indexName, gsiKeySchema, null, projectionType));
|
||||
GlobalSecondaryIndex newGsi = new GlobalSecondaryIndex(indexName, gsiKeySchema, null, projectionType);
|
||||
JsonNode newGsiPt = createNode.path("ProvisionedThroughput");
|
||||
if (!newGsiPt.isMissingNode()) {
|
||||
newGsi.getProvisionedThroughput().setReadCapacityUnits(newGsiPt.path("ReadCapacityUnits").asLong(0));
|
||||
newGsi.getProvisionedThroughput().setWriteCapacityUnits(newGsiPt.path("WriteCapacityUnits").asLong(0));
|
||||
}
|
||||
gsiCreates.add(newGsi);
|
||||
}
|
||||
JsonNode deleteNode = update.path("Delete");
|
||||
if (!deleteNode.isMissingNode()) {
|
||||
@@ -655,6 +667,14 @@ public class DynamoDbJsonHandler {
|
||||
gsi.getProjectionType() != null ? gsi.getProjectionType() : "ALL");
|
||||
gsiNode.set("Projection", projection);
|
||||
|
||||
ObjectNode gsiPt = objectMapper.createObjectNode();
|
||||
gsiPt.put("ReadCapacityUnits", gsi.getProvisionedThroughput().getReadCapacityUnits());
|
||||
gsiPt.put("WriteCapacityUnits", gsi.getProvisionedThroughput().getWriteCapacityUnits());
|
||||
gsiPt.put("NumberOfDecreasesToday", gsi.getProvisionedThroughput().getNumberOfDecreasesToday());
|
||||
gsiNode.set("ProvisionedThroughput", gsiPt);
|
||||
gsiNode.put("IndexSizeBytes", gsi.getIndexSizeBytes());
|
||||
gsiNode.put("ItemCount", gsi.getItemCount());
|
||||
|
||||
gsiArray.add(gsiNode);
|
||||
}
|
||||
node.set("GlobalSecondaryIndexes", gsiArray);
|
||||
|
||||
+16
-1
@@ -13,8 +13,13 @@ public class GlobalSecondaryIndex {
|
||||
private List<KeySchemaElement> keySchema;
|
||||
private String indexArn;
|
||||
private String projectionType;
|
||||
private ProvisionedThroughput provisionedThroughput;
|
||||
private long itemCount;
|
||||
private long indexSizeBytes;
|
||||
|
||||
public GlobalSecondaryIndex() {}
|
||||
public GlobalSecondaryIndex() {
|
||||
this.provisionedThroughput = new ProvisionedThroughput(0, 0);
|
||||
}
|
||||
|
||||
public GlobalSecondaryIndex(String indexName, List<KeySchemaElement> keySchema,
|
||||
String indexArn, String projectionType) {
|
||||
@@ -22,6 +27,7 @@ public class GlobalSecondaryIndex {
|
||||
this.keySchema = keySchema;
|
||||
this.indexArn = indexArn;
|
||||
this.projectionType = projectionType != null ? projectionType : "ALL";
|
||||
this.provisionedThroughput = new ProvisionedThroughput(0, 0);
|
||||
}
|
||||
|
||||
public String getIndexName() { return indexName; }
|
||||
@@ -36,6 +42,15 @@ public class GlobalSecondaryIndex {
|
||||
public String getProjectionType() { return projectionType; }
|
||||
public void setProjectionType(String projectionType) { this.projectionType = projectionType; }
|
||||
|
||||
public ProvisionedThroughput getProvisionedThroughput() { return provisionedThroughput; }
|
||||
public void setProvisionedThroughput(ProvisionedThroughput provisionedThroughput) { this.provisionedThroughput = provisionedThroughput; }
|
||||
|
||||
public long getItemCount() { return itemCount; }
|
||||
public void setItemCount(long itemCount) { this.itemCount = itemCount; }
|
||||
|
||||
public long getIndexSizeBytes() { return indexSizeBytes; }
|
||||
public void setIndexSizeBytes(long indexSizeBytes) { this.indexSizeBytes = indexSizeBytes; }
|
||||
|
||||
public String getPartitionKeyName() {
|
||||
return keySchema.stream()
|
||||
.filter(k -> "HASH".equals(k.getKeyType()))
|
||||
|
||||
Reference in new issue
Block a user