@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof DescribeTableResult == false) return false; DescribeTableResult other = (DescribeTableResult) obj; if (other.getTable() == null ^ this.getTable() == null) return false; if (other.getTable() != null && other.getTable().equals(this.getTable()) == false) return false; return true; }
/** * Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be * redacted from this string using a placeholder value. * * @return A string representation of this object. * * @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getTable() != null) sb.append("Table: ").append(getTable()); sb.append("}"); return sb.toString(); }
/** * Returns information about the table, including the current status of the * table, when it was created, the primary key schema, and any indexes on * the table. * @return The describe table results. * @see com.amazonaws.services.dynamodbv2.AmazonDynamoDB#describeTable */ public TableDescription describeTable() { return db.describeTable( mapper.getTableName(model.targetType(), config) ).getTable(); }
/** * Retrieves the table description from DynamoDB. Involves network calls. * Meant to be called as infrequently as possible to avoid throttling * exception from the server side. * * @return a non-null table description * * @throws ResourceNotFoundException if the table doesn't exist */ public TableDescription describe() { DescribeTableResult result = client.describeTable( InternalUtils.applyUserAgent(new DescribeTableRequest(tableName))); return tableDescription = result.getTable(); }
while (System.currentTimeMillis() < endTime) { try { table = dynamo.describeTable(new DescribeTableRequest(tableName)).getTable(); if (desiredStatus == null || table.getTableStatus().equals(desiredStatus.toString())) { return table;
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()); } }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof DescribeTableResult == false) return false; DescribeTableResult other = (DescribeTableResult) obj; if (other.getTable() == null ^ this.getTable() == null) return false; if (other.getTable() != null && other.getTable().equals(this.getTable()) == false) return false; return true; } }
/** * Returns a string representation of this object; useful for testing and * debugging. * * @return A string representation of this object. * @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getTable() != null) sb.append("Table: " + getTable()); sb.append("}"); return sb.toString(); }
@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(); } }
/** * Checks if a specified table exists and is in <code>ACTIVE</code> state. * * @param dynamo The AWS DynamoDB client to use to make requests. * @param tableName The name of the table being searched for. * @return True if a table already exists with the specified name, otherwise * false. */ public static boolean doesTableExist(AmazonDynamoDB dynamo, String tableName) { try { TableDescription table = dynamo.describeTable(new DescribeTableRequest(tableName)) .getTable(); return TableStatus.ACTIVE.toString().equals(table.getTableStatus()); } catch (ResourceNotFoundException rnfe) { // This means the table doesn't exist in the account yet return false; } }
@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))); } }
try { TableDescription table = dynamo.describeTable(new DescribeTableRequest(tableName)) .getTable(); if (table != null && table.getTableStatus().equals(TableStatus.ACTIVE.toString())) return;
.describeTable(request); this.tableDescription = result.getTable();
@Override public boolean metadataExists(final MetadataType type) throws IOException { try { return TableStatus.ACTIVE.name().equals( client.describeTable(getMetadataTableName(type)).getTable().getTableStatus()); } catch (final AmazonDynamoDBException e) { LOGGER.info("Unable to check existence of table", e); } return false; }
/** * Returns information about the table, including the current status of the * table, when it was created, the primary key schema, and any indexes on * the table. * @return The describe table results. * @see com.amazonaws.services.dynamodbv2.AmazonDynamoDB#describeTable */ public TableDescription describeTable() { return db.describeTable( mapper.getTableName(model.targetType(), config) ).getTable(); }