com.amazonaws.services.dynamodbv2.model.GlobalSecondaryIndexDescription Java Examples
The following examples show how to use
com.amazonaws.services.dynamodbv2.model.GlobalSecondaryIndexDescription.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DynamoDbDelegate.java From dynamodb-janusgraph-storage-backend with Apache License 2.0 | 6 votes |
private static boolean areGsisSameConfiguration(final List<GlobalSecondaryIndexDescription> g1, final List<GlobalSecondaryIndexDescription> g2) { if (g1 == null) { return g2 == null; } if (g1.size() != g2.size()) { return false; } // make copy of the lists because we don't want to mutate the lists final ArrayList<GlobalSecondaryIndexDescription> g1clone = new ArrayList<>(g1.size()); g1clone.addAll(g1); final ArrayList<GlobalSecondaryIndexDescription> g2clone = new ArrayList<>(g2.size()); g1clone.addAll(g2); for (final GlobalSecondaryIndexDescription gi1 : g1) { for (final GlobalSecondaryIndexDescription gi2 : g2) { if (areGsisSameConfiguration(gi1, gi2)) { g1clone.remove(gi1); g2clone.remove(gi2); break; } } } return g1clone.isEmpty() || g2clone.isEmpty(); }
Example #2
Source File: DynamoDbDelegate.java From dynamodb-janusgraph-storage-backend with Apache License 2.0 | 6 votes |
private static boolean areGsisSameConfiguration(final GlobalSecondaryIndexDescription g1, final GlobalSecondaryIndexDescription g2) { if (g1 == null ^ g2 == null) { return false; } if (g1 == g2) { return true; } final EqualsBuilder builder = new EqualsBuilder(); builder.append(g1.getIndexName(), g2.getIndexName()); builder.append(g1.getKeySchema(), g2.getKeySchema()); builder.append(g1.getProjection().getProjectionType(), g2.getProjection().getProjectionType()); builder.append(g1.getProvisionedThroughput().getReadCapacityUnits(), g2.getProvisionedThroughput().getReadCapacityUnits()); builder.append(g1.getProvisionedThroughput().getWriteCapacityUnits(), g2.getProvisionedThroughput().getWriteCapacityUnits()); final Set<String> projectionNonKeyAttributesG1 = new HashSet<>(Optional.ofNullable(g1.getProjection().getNonKeyAttributes()).orElse(Collections.emptyList())); final Set<String> projectionNonKeyAttributesG2 = new HashSet<>(Optional.ofNullable(g2.getProjection().getNonKeyAttributes()).orElse(Collections.emptyList())); builder.append(projectionNonKeyAttributesG1, projectionNonKeyAttributesG2); return builder.build(); }
Example #3
Source File: DynamoTable.java From billow with Apache License 2.0 | 6 votes |
public DynamoTable(Table table) { table.describe(); tableName = table.getTableName(); attributeDefinitions = table.getDescription().getAttributeDefinitions().toString(); tableStatus = table.getDescription().getTableStatus(); keySchema = table.getDescription().getKeySchema().toString(); creationDateTime = new DateTime(table.getDescription().getCreationDateTime()); numberOfDecreasesToday = table.getDescription().getProvisionedThroughput().getNumberOfDecreasesToday(); readCapacityUnits = table.getDescription().getProvisionedThroughput().getReadCapacityUnits(); writeCapacityUnits = table.getDescription().getProvisionedThroughput().getWriteCapacityUnits(); tableSizeBytes = table.getDescription().getTableSizeBytes(); itemCount = table.getDescription().getItemCount(); tableArn = table.getDescription().getTableArn(); provisionedThroughput = table.getDescription().getProvisionedThroughput().toString(); globalSecondaryIndexes = new ArrayList<>(); if (table.getDescription().getGlobalSecondaryIndexes() != null) { for (GlobalSecondaryIndexDescription gsiDesc : table .getDescription() .getGlobalSecondaryIndexes()) { globalSecondaryIndexes.add(new DynamoGSI(gsiDesc)); } } }
Example #4
Source File: DynamoTable.java From billow with Apache License 2.0 | 5 votes |
public DynamoGSI(GlobalSecondaryIndexDescription desc) { gsiName = desc.getIndexName(); readCapacityUnits = desc.getProvisionedThroughput().getReadCapacityUnits(); writeCapacityUnits = desc.getProvisionedThroughput().getWriteCapacityUnits(); itemCount = desc.getItemCount(); indexSizeBytes = desc.getIndexSizeBytes(); indexStatus = desc.getIndexStatus(); backfilling = desc.getBackfilling(); indexArn = desc.getIndexArn(); }
Example #5
Source File: DynamoDbDelegate.java From dynamodb-janusgraph-storage-backend with Apache License 2.0 | 4 votes |
public void waitForTableCreation(final String tableName, final boolean verifyIndexesList, final List<LocalSecondaryIndexDescription> expectedLsiList, final List<GlobalSecondaryIndexDescription> expectedGsiList) throws BackendException { boolean successFlag = false; int retryCount = 0; while (!successFlag && retryCount < maxRetries) { try { boolean areAllGsisActive = true; final TableDescription td = describeTable(tableName); if (verifyIndexesList) { final Set<LocalSecondaryIndexDescription> expectedLSIs = new HashSet<LocalSecondaryIndexDescription>(); if (expectedLsiList != null) { expectedLSIs.addAll(expectedLsiList); } final Set<LocalSecondaryIndexDescription> actualLSIs = new HashSet<LocalSecondaryIndexDescription>(); if (td.getLocalSecondaryIndexes() != null) { actualLSIs.addAll(td.getLocalSecondaryIndexes()); } // the lsi list should be there even if the table is in creating state if (!(expectedLsiList == null && td.getLocalSecondaryIndexes() == null || expectedLSIs.equals(actualLSIs))) { throw new PermanentBackendException("LSI list is not as expected during table creation. expectedLsiList=" + expectedLsiList.toString() + "; table description=" + td.toString()); } // ignore the status of all GSIs since they will mess up .equals() if (td.getGlobalSecondaryIndexes() != null) { for (final GlobalSecondaryIndexDescription gDesc : td.getGlobalSecondaryIndexes()) { if (!isTableAcceptingWrites(gDesc.getIndexStatus())) { areAllGsisActive = false; break; } } } // the gsi list should be there even if the table is in creating state if (!areGsisSameConfiguration(expectedGsiList, td.getGlobalSecondaryIndexes())) { throw new PermanentBackendException("GSI list is not as expected during table creation. expectedGsiList=" + expectedGsiList.toString() + "; table description=" + td.toString()); } } successFlag = isTableAcceptingWrites(td.getTableStatus()) && areAllGsisActive; } catch (BackendNotFoundException ignore) { successFlag = false; } if (!successFlag) { interruptibleSleep(CONTROL_PLANE_RETRY_DELAY_MS); } retryCount++; } if (!successFlag) { throw new PermanentBackendException("Table creation not completed for table " + tableName + " after retrying " + this.maxRetries + " times for a duration of " + CONTROL_PLANE_RETRY_DELAY_MS * this.maxRetries + " ms"); } }