if (getTableName() != null) sb.append("TableName: ").append(getTableName()).append(","); if (getKeySchema() != null) sb.append("KeySchema: ").append(getKeySchema()).append(","); if (getTableStatus() != null) sb.append("TableStatus: ").append(getTableStatus()).append(",");
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getAttributeDefinitions() == null) ? 0 : getAttributeDefinitions().hashCode()); hashCode = prime * hashCode + ((getTableName() == null) ? 0 : getTableName().hashCode()); hashCode = prime * hashCode + ((getKeySchema() == null) ? 0 : getKeySchema().hashCode()); hashCode = prime * hashCode + ((getTableStatus() == null) ? 0 : getTableStatus().hashCode()); hashCode = prime * hashCode + ((getCreationDateTime() == null) ? 0 : getCreationDateTime().hashCode()); hashCode = prime * hashCode + ((getProvisionedThroughput() == null) ? 0 : getProvisionedThroughput().hashCode()); hashCode = prime * hashCode + ((getTableSizeBytes() == null) ? 0 : getTableSizeBytes().hashCode()); hashCode = prime * hashCode + ((getItemCount() == null) ? 0 : getItemCount().hashCode()); hashCode = prime * hashCode + ((getTableArn() == null) ? 0 : getTableArn().hashCode()); hashCode = prime * hashCode + ((getTableId() == null) ? 0 : getTableId().hashCode()); hashCode = prime * hashCode + ((getBillingModeSummary() == null) ? 0 : getBillingModeSummary().hashCode()); hashCode = prime * hashCode + ((getLocalSecondaryIndexes() == null) ? 0 : getLocalSecondaryIndexes().hashCode()); hashCode = prime * hashCode + ((getGlobalSecondaryIndexes() == null) ? 0 : getGlobalSecondaryIndexes().hashCode()); hashCode = prime * hashCode + ((getStreamSpecification() == null) ? 0 : getStreamSpecification().hashCode()); hashCode = prime * hashCode + ((getLatestStreamLabel() == null) ? 0 : getLatestStreamLabel().hashCode()); hashCode = prime * hashCode + ((getLatestStreamArn() == null) ? 0 : getLatestStreamArn().hashCode()); hashCode = prime * hashCode + ((getRestoreSummary() == null) ? 0 : getRestoreSummary().hashCode()); hashCode = prime * hashCode + ((getSSEDescription() == null) ? 0 : getSSEDescription().hashCode()); return hashCode; }
private void runTest(AmazonDynamoDB client) { CreateTableRequest request = new CreateTableRequest() .withAttributeDefinitions(new AttributeDefinition( "Name", ScalarAttributeType.S)) .withKeySchema(new KeySchemaElement("Name", KeyType.HASH)) .withProvisionedThroughput(new ProvisionedThroughput( new Long(10), new Long(10))) .withTableName("foo"); client.createTable(request); final TableDescription tableDescription = client.describeTable("foo").getTable(); assertNotNull("the description is not null", tableDescription); assertEquals("the table has the right name", "foo", tableDescription.getTableName()); assertEquals("the name has the right primary key", "Name", tableDescription.getKeySchema().get(0).getAttributeName()); } }
if (other.getTableName() != null && other.getTableName().equals(this.getTableName()) == false) return false; if (other.getKeySchema() == null ^ this.getKeySchema() == null) return false; if (other.getKeySchema() != null && other.getKeySchema().equals(this.getKeySchema()) == false) return false; if (other.getTableStatus() == null ^ this.getTableStatus() == null)
/** * Marshall the given parameter object. */ public void marshall(TableDescription tableDescription, ProtocolMarshaller protocolMarshaller) { if (tableDescription == null) { throw new SdkClientException("Invalid argument passed to marshall(...)"); } try { protocolMarshaller.marshall(tableDescription.getAttributeDefinitions(), ATTRIBUTEDEFINITIONS_BINDING); protocolMarshaller.marshall(tableDescription.getTableName(), TABLENAME_BINDING); protocolMarshaller.marshall(tableDescription.getKeySchema(), KEYSCHEMA_BINDING); protocolMarshaller.marshall(tableDescription.getTableStatus(), TABLESTATUS_BINDING); protocolMarshaller.marshall(tableDescription.getCreationDateTime(), CREATIONDATETIME_BINDING); protocolMarshaller.marshall(tableDescription.getProvisionedThroughput(), PROVISIONEDTHROUGHPUT_BINDING); protocolMarshaller.marshall(tableDescription.getTableSizeBytes(), TABLESIZEBYTES_BINDING); protocolMarshaller.marshall(tableDescription.getItemCount(), ITEMCOUNT_BINDING); protocolMarshaller.marshall(tableDescription.getTableArn(), TABLEARN_BINDING); protocolMarshaller.marshall(tableDescription.getTableId(), TABLEID_BINDING); protocolMarshaller.marshall(tableDescription.getBillingModeSummary(), BILLINGMODESUMMARY_BINDING); protocolMarshaller.marshall(tableDescription.getLocalSecondaryIndexes(), LOCALSECONDARYINDEXES_BINDING); protocolMarshaller.marshall(tableDescription.getGlobalSecondaryIndexes(), GLOBALSECONDARYINDEXES_BINDING); protocolMarshaller.marshall(tableDescription.getStreamSpecification(), STREAMSPECIFICATION_BINDING); protocolMarshaller.marshall(tableDescription.getLatestStreamLabel(), LATESTSTREAMLABEL_BINDING); protocolMarshaller.marshall(tableDescription.getLatestStreamArn(), LATESTSTREAMARN_BINDING); protocolMarshaller.marshall(tableDescription.getRestoreSummary(), RESTORESUMMARY_BINDING); protocolMarshaller.marshall(tableDescription.getSSEDescription(), SSEDESCRIPTION_BINDING); } catch (Exception e) { throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e); } }
if (getKeySchema() == null) { this.keySchema = new java.util.ArrayList<KeySchemaElement>(keySchema.length);
@PostConstruct public void setup() { try { DescribeTableResult table = dynamoDBClient.describeTable(tableConfig.getTableName()); if (!table.getTable().getKeySchema().equals(PROJECT_KEYSCHEMA)) { throw new IllegalStateException("Dynamodb table for query metadata store has invalid key schema"); } if (!ImmutableSet.copyOf(table.getTable().getAttributeDefinitions()).equals(ATTRIBUTES)) { throw new IllegalStateException("Dynamodb table for query metadata store has invalid attribute schema"); } } catch (ResourceNotFoundException e) { createTable(); } }
@PostConstruct public void setup() { try { DescribeTableResult table = dynamoDBClient.describeTable(tableConfig.getTableName()); if (!table.getTable().getKeySchema().equals(PROJECT_KEYSCHEMA)) { throw new IllegalStateException("Dynamodb table for query metadata store has invalid key schema"); } if (!ImmutableSet.copyOf(table.getTable().getAttributeDefinitions()).equals(ATTRIBUTES)) { throw new IllegalStateException("Dynamodb table for query metadata store has invalid attribute schema"); } } catch (ResourceNotFoundException e) { createTable(); } }
@PostConstruct public void setup() { try { DescribeTableResult table = dynamoDBClient.describeTable(tableConfig.getTableName()); if (!table.getTable().getKeySchema().equals(PROJECT_KEYSCHEMA)) { throw new IllegalStateException("Dynamodb table for config manager has invalid key schema"); } if (!ImmutableSet.copyOf(table.getTable().getAttributeDefinitions()).equals(ATTRIBUTES)) { throw new IllegalStateException("Dynamodb table for config manager has invalid attribute schema."); } } catch (ResourceNotFoundException e) { createTable(); } }
if (getTableName() != null) sb.append("TableName: " + getTableName() + ","); if (getKeySchema() != null) sb.append("KeySchema: " + getKeySchema() + ","); if (getTableStatus() != null) sb.append("TableStatus: " + getTableStatus() + ",");
@PostConstruct public void setup() { try { DescribeTableResult result = dynamoDBClient.describeTable(tableConfig.getTableName()); if (!result.getTable().getKeySchema().equals(PROJECT_KEYSCHEMA) || !ImmutableSet.copyOf(result.getTable().getAttributeDefinitions()).equals(ATTRIBUTES)) { throw new IllegalStateException("Invalid schema for user storage dynamodb table. " + "Please remove existing table or change dynamodb table."); } } catch (ResourceNotFoundException e) { dynamoDBClient.createTable(new CreateTableRequest().withTableName(tableConfig.getTableName()) .withKeySchema(PROJECT_KEYSCHEMA) .withAttributeDefinitions(ATTRIBUTES) .withProvisionedThroughput(new ProvisionedThroughput() .withReadCapacityUnits(3L) .withWriteCapacityUnits(3L))); } }
+ ((getAttributeDefinitions() == null) ? 0 : getAttributeDefinitions().hashCode()); hashCode = prime * hashCode + ((getTableName() == null) ? 0 : getTableName().hashCode()); hashCode = prime * hashCode + ((getKeySchema() == null) ? 0 : getKeySchema().hashCode()); hashCode = prime * hashCode + ((getTableStatus() == null) ? 0 : getTableStatus().hashCode());
for (final KeySchemaElement element : this.tableDescription.getKeySchema()) { final String keyName = element.getAttributeName(); for (final AttributeDefinition ad : this.tableDescription.getAttributeDefinitions()) {
&& other.getTableName().equals(this.getTableName()) == false) return false; if (other.getKeySchema() == null ^ this.getKeySchema() == null) return false; if (other.getKeySchema() != null && other.getKeySchema().equals(this.getKeySchema()) == false) return false; if (other.getTableStatus() == null ^ this.getTableStatus() == null)
protected List<KeySchemaElement> getTableSchema(String tableName) throws ResourceNotFoundException { List<KeySchemaElement> schema = tableSchemaCache.get(tableName); if(schema == null) { DescribeTableResult result = client.describeTable(new DescribeTableRequest().withTableName(tableName)); schema = Collections.unmodifiableList(result.getTable().getKeySchema()); tableSchemaCache.put(tableName, schema); } return schema; }
/** * Generate a list of attribute names found in the Aggregator's dynamo * table. Assumes that all Items in the Aggregator table are of the same * structure. * * @param dynamoClient Dynamo DB Client to use for connection to Dynamo DB. * @param dynamoTable The Dynamo Table for the Aggregator * @return A list of attribute names from the Dynamo table * @throws Exception */ protected List<String> getDictionaryEntry() throws Exception { // get a list of all columns in the table, with keys first List<String> columns = new ArrayList<>(); List<KeySchemaElement> keys = dynamoClient.describeTable(this.tableName).getTable().getKeySchema(); for (KeySchemaElement key : keys) { columns.add(key.getAttributeName()); } ScanResult scan = dynamoClient.scan(new ScanRequest().withTableName(this.tableName).withSelect( Select.ALL_ATTRIBUTES).withLimit(1)); List<Map<String, AttributeValue>> scannedItems = scan.getItems(); for (Map<String, AttributeValue> map : scannedItems) { for (String s : map.keySet()) { if (!columns.contains(s)) columns.add(s); } } return columns; }
jsonWriter.value(tableName); if (tableDescription.getKeySchema() != null) { java.util.List<KeySchemaElement> keySchema = tableDescription.getKeySchema(); jsonWriter.name("KeySchema"); jsonWriter.beginArray();
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getAttributeDefinitions() == null) ? 0 : getAttributeDefinitions().hashCode()); hashCode = prime * hashCode + ((getTableName() == null) ? 0 : getTableName().hashCode()); hashCode = prime * hashCode + ((getKeySchema() == null) ? 0 : getKeySchema().hashCode()); hashCode = prime * hashCode + ((getTableStatus() == null) ? 0 : getTableStatus().hashCode()); hashCode = prime * hashCode + ((getCreationDateTime() == null) ? 0 : getCreationDateTime().hashCode()); hashCode = prime * hashCode + ((getProvisionedThroughput() == null) ? 0 : getProvisionedThroughput().hashCode()); hashCode = prime * hashCode + ((getTableSizeBytes() == null) ? 0 : getTableSizeBytes().hashCode()); hashCode = prime * hashCode + ((getItemCount() == null) ? 0 : getItemCount().hashCode()); hashCode = prime * hashCode + ((getTableArn() == null) ? 0 : getTableArn().hashCode()); hashCode = prime * hashCode + ((getTableId() == null) ? 0 : getTableId().hashCode()); hashCode = prime * hashCode + ((getBillingModeSummary() == null) ? 0 : getBillingModeSummary().hashCode()); hashCode = prime * hashCode + ((getLocalSecondaryIndexes() == null) ? 0 : getLocalSecondaryIndexes().hashCode()); hashCode = prime * hashCode + ((getGlobalSecondaryIndexes() == null) ? 0 : getGlobalSecondaryIndexes().hashCode()); hashCode = prime * hashCode + ((getStreamSpecification() == null) ? 0 : getStreamSpecification().hashCode()); hashCode = prime * hashCode + ((getLatestStreamLabel() == null) ? 0 : getLatestStreamLabel().hashCode()); hashCode = prime * hashCode + ((getLatestStreamArn() == null) ? 0 : getLatestStreamArn().hashCode()); hashCode = prime * hashCode + ((getRestoreSummary() == null) ? 0 : getRestoreSummary().hashCode()); hashCode = prime * hashCode + ((getSSEDescription() == null) ? 0 : getSSEDescription().hashCode()); return hashCode; }
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)); } } }
/** * Marshall the given parameter object. */ public void marshall(TableDescription tableDescription, ProtocolMarshaller protocolMarshaller) { if (tableDescription == null) { throw new SdkClientException("Invalid argument passed to marshall(...)"); } try { protocolMarshaller.marshall(tableDescription.getAttributeDefinitions(), ATTRIBUTEDEFINITIONS_BINDING); protocolMarshaller.marshall(tableDescription.getTableName(), TABLENAME_BINDING); protocolMarshaller.marshall(tableDescription.getKeySchema(), KEYSCHEMA_BINDING); protocolMarshaller.marshall(tableDescription.getTableStatus(), TABLESTATUS_BINDING); protocolMarshaller.marshall(tableDescription.getCreationDateTime(), CREATIONDATETIME_BINDING); protocolMarshaller.marshall(tableDescription.getProvisionedThroughput(), PROVISIONEDTHROUGHPUT_BINDING); protocolMarshaller.marshall(tableDescription.getTableSizeBytes(), TABLESIZEBYTES_BINDING); protocolMarshaller.marshall(tableDescription.getItemCount(), ITEMCOUNT_BINDING); protocolMarshaller.marshall(tableDescription.getTableArn(), TABLEARN_BINDING); protocolMarshaller.marshall(tableDescription.getTableId(), TABLEID_BINDING); protocolMarshaller.marshall(tableDescription.getBillingModeSummary(), BILLINGMODESUMMARY_BINDING); protocolMarshaller.marshall(tableDescription.getLocalSecondaryIndexes(), LOCALSECONDARYINDEXES_BINDING); protocolMarshaller.marshall(tableDescription.getGlobalSecondaryIndexes(), GLOBALSECONDARYINDEXES_BINDING); protocolMarshaller.marshall(tableDescription.getStreamSpecification(), STREAMSPECIFICATION_BINDING); protocolMarshaller.marshall(tableDescription.getLatestStreamLabel(), LATESTSTREAMLABEL_BINDING); protocolMarshaller.marshall(tableDescription.getLatestStreamArn(), LATESTSTREAMARN_BINDING); protocolMarshaller.marshall(tableDescription.getRestoreSummary(), RESTORESUMMARY_BINDING); protocolMarshaller.marshall(tableDescription.getSSEDescription(), SSEDESCRIPTION_BINDING); } catch (Exception e) { throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e); } }