DescribeTableRequest request = DescribeTableRequest.builder() .tableName(table_name) .build();
@Override public DescribeTableRequest build() { return new DescribeTableRequest(this); }
@Override public int hashCode() { int hashCode = 1; hashCode = 31 * hashCode + Objects.hashCode(tableName()); return hashCode; }
/** * 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; } }
/** * 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("DescribeTableRequest").add("TableName", tableName()).build(); }
throws ResourceNotFoundException, InternalServerErrorException, AwsServiceException, SdkClientException, DynamoDbException { return describeTable(DescribeTableRequest.builder().applyMutation(describeTableRequest).build());
public <T> Optional<T> getValueForField(String fieldName, Class<T> clazz) { switch (fieldName) { case "TableName": return Optional.ofNullable(clazz.cast(tableName())); default: return Optional.empty(); } }
return describeTable(DescribeTableRequest.builder().applyMutation(describeTableRequest).build());
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; }
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; }