table_info.tableArn()); System.out.format("Status : %s\n", table_info.tableStatus()); System.out.format("Item count : %d\n", table_info.itemCount().longValue());
/** * 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; } }
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; }