table_info.tableName()); System.out.format("Table ARN : %s\n", table_info.tableArn()); System.out.format("Status : %s\n", table_info.tableStatus()); System.out.format("Item count : %d\n", table_info.itemCount().longValue()); System.out.format("Size (bytes): %d\n", table_info.tableSizeBytes().longValue()); table_info.provisionedThroughput(); System.out.println("Throughput"); System.out.format(" Read Capacity : %d\n", table_info.attributeDefinitions(); System.out.println("Attributes"); for (AttributeDefinition a : attributes) {
/** * 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. */ @Override public String toString() { return ToString.builder("TableDescription").add("AttributeDefinitions", attributeDefinitions()) .add("TableName", tableName()).add("KeySchema", keySchema()).add("TableStatus", tableStatusAsString()) .add("CreationDateTime", creationDateTime()).add("ProvisionedThroughput", provisionedThroughput()) .add("TableSizeBytes", tableSizeBytes()).add("ItemCount", itemCount()).add("TableArn", tableArn()) .add("TableId", tableId()).add("BillingModeSummary", billingModeSummary()) .add("LocalSecondaryIndexes", localSecondaryIndexes()).add("GlobalSecondaryIndexes", globalSecondaryIndexes()) .add("StreamSpecification", streamSpecification()).add("LatestStreamLabel", latestStreamLabel()) .add("LatestStreamArn", latestStreamArn()).add("RestoreSummary", restoreSummary()) .add("SSEDescription", sseDescription()).build(); }
/** * Checks whether the lock table exists in DynamoDB. * * @return true if the table exists, false otherwise. */ public boolean lockTableExists() { try { final DescribeTableResponse result = this.dynamoDB.describeTable(DescribeTableRequest.builder().tableName(tableName).build()); return availableStatuses.contains(result.table().tableStatus()); } catch (final ResourceNotFoundException e) { // This exception indicates the table doesn't exist. return false; } }
System.out.println(response.tableDescription().tableName()); } catch (DynamoDbException e) { System.err.println(e.getMessage());
@Override public TableDescription build() { return new TableDescription(this); }
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (!(obj instanceof TableDescription)) { return false; } TableDescription other = (TableDescription) obj; return Objects.equals(attributeDefinitions(), other.attributeDefinitions()) && Objects.equals(tableName(), other.tableName()) && Objects.equals(keySchema(), other.keySchema()) && Objects.equals(tableStatusAsString(), other.tableStatusAsString()) && Objects.equals(creationDateTime(), other.creationDateTime()) && Objects.equals(provisionedThroughput(), other.provisionedThroughput()) && Objects.equals(tableSizeBytes(), other.tableSizeBytes()) && Objects.equals(itemCount(), other.itemCount()) && Objects.equals(tableArn(), other.tableArn()) && Objects.equals(tableId(), other.tableId()) && Objects.equals(billingModeSummary(), other.billingModeSummary()) && Objects.equals(localSecondaryIndexes(), other.localSecondaryIndexes()) && Objects.equals(globalSecondaryIndexes(), other.globalSecondaryIndexes()) && Objects.equals(streamSpecification(), other.streamSpecification()) && Objects.equals(latestStreamLabel(), other.latestStreamLabel()) && Objects.equals(latestStreamArn(), other.latestStreamArn()) && Objects.equals(restoreSummary(), other.restoreSummary()) && Objects.equals(sseDescription(), other.sseDescription()); }
private TableStatus tableStatus() throws DependencyException { DescribeTableRequest request = DescribeTableRequest.builder().tableName(table).build(); final AWSExceptionManager exceptionManager = createExceptionManager(); exceptionManager.add(ResourceNotFoundException.class, t -> t); DescribeTableResponse result; try { try { result = dynamoDBClient.describeTable(request).get(); } catch (ExecutionException e) { throw exceptionManager.apply(e.getCause()); } catch (InterruptedException e) { // TODO: Check if this is the correct behavior throw new DependencyException(e); } } catch (ResourceNotFoundException e) { log.debug("Got ResourceNotFoundException for table {} in leaseTableExists, returning false.", table); return null; } catch (DynamoDbException e) { throw new DependencyException(e); } TableStatus tableStatus = result.table().tableStatus(); log.debug("Lease table exists and is in status {}", tableStatus); return tableStatus; }
@Override public int hashCode() { int hashCode = 1; hashCode = 31 * hashCode + Objects.hashCode(attributeDefinitions()); hashCode = 31 * hashCode + Objects.hashCode(tableName()); hashCode = 31 * hashCode + Objects.hashCode(keySchema()); hashCode = 31 * hashCode + Objects.hashCode(tableStatusAsString()); hashCode = 31 * hashCode + Objects.hashCode(creationDateTime()); hashCode = 31 * hashCode + Objects.hashCode(provisionedThroughput()); hashCode = 31 * hashCode + Objects.hashCode(tableSizeBytes()); hashCode = 31 * hashCode + Objects.hashCode(itemCount()); hashCode = 31 * hashCode + Objects.hashCode(tableArn()); hashCode = 31 * hashCode + Objects.hashCode(tableId()); hashCode = 31 * hashCode + Objects.hashCode(billingModeSummary()); hashCode = 31 * hashCode + Objects.hashCode(localSecondaryIndexes()); hashCode = 31 * hashCode + Objects.hashCode(globalSecondaryIndexes()); hashCode = 31 * hashCode + Objects.hashCode(streamSpecification()); hashCode = 31 * hashCode + Objects.hashCode(latestStreamLabel()); hashCode = 31 * hashCode + Objects.hashCode(latestStreamArn()); hashCode = 31 * hashCode + Objects.hashCode(restoreSummary()); hashCode = 31 * hashCode + Objects.hashCode(sseDescription()); return hashCode; }
private TableStatus tableStatus() throws DependencyException { DescribeTableRequest request = DescribeTableRequest.builder().tableName(table).build(); final AWSExceptionManager exceptionManager = createExceptionManager(); exceptionManager.add(ResourceNotFoundException.class, t -> t); DescribeTableResponse result; try { try { result = dynamoDBClient.describeTable(request).get(); } catch (ExecutionException e) { throw exceptionManager.apply(e.getCause()); } catch (InterruptedException e) { // TODO: Check if this is the correct behavior throw new DependencyException(e); } } catch (ResourceNotFoundException e) { log.debug("Got ResourceNotFoundException for table {} in leaseTableExists, returning false.", table); return null; } catch (DynamoDbException e) { throw new DependencyException(e); } TableStatus tableStatus = result.table().tableStatus(); log.debug("Lease table exists and is in status {}", tableStatus); return tableStatus; }
public <T> Optional<T> getValueForField(String fieldName, Class<T> clazz) { switch (fieldName) { case "AttributeDefinitions": return Optional.ofNullable(clazz.cast(attributeDefinitions())); case "TableName": return Optional.ofNullable(clazz.cast(tableName())); case "KeySchema": return Optional.ofNullable(clazz.cast(keySchema())); case "TableStatus": return Optional.ofNullable(clazz.cast(tableStatusAsString())); case "CreationDateTime": return Optional.ofNullable(clazz.cast(creationDateTime())); case "ProvisionedThroughput": return Optional.ofNullable(clazz.cast(provisionedThroughput())); case "TableSizeBytes": return Optional.ofNullable(clazz.cast(tableSizeBytes())); case "ItemCount": return Optional.ofNullable(clazz.cast(itemCount())); case "TableArn": return Optional.ofNullable(clazz.cast(tableArn())); case "TableId": return Optional.ofNullable(clazz.cast(tableId())); case "BillingModeSummary": return Optional.ofNullable(clazz.cast(billingModeSummary())); case "LocalSecondaryIndexes": return Optional.ofNullable(clazz.cast(localSecondaryIndexes())); case "GlobalSecondaryIndexes": return Optional.ofNullable(clazz.cast(globalSecondaryIndexes())); case "StreamSpecification": return Optional.ofNullable(clazz.cast(streamSpecification()));