@Override public AmazonDynamoDB aws() { return this.origin.aws(); } @Override
@Override public AmazonDynamoDB aws() { return this.origin.aws(); } @Override
@Override public AmazonDynamoDB aws() { try { return Dynamo.live().aws(); } catch (final IOException ex) { throw new IllegalStateException(ex); } }
@Override @RetryOnFailure(verbose = false, delay = Tv.FIVE, unit = TimeUnit.SECONDS) public AmazonDynamoDB aws() { return this.origin.aws(); }
@Override @RetryOnFailure(verbose = false, delay = Tv.FIVE, unit = TimeUnit.SECONDS) public AmazonDynamoDB aws() { return this.origin.aws(); }
/** * Adjusts throughput on the table. */ public void adjust() { this.table .region() .aws() .updateTable( this.table.name(), Throughput.suitableThroughput() ); }
/** * Adjusts throughput on the table. */ public void adjust() { this.table .region() .aws() .updateTable( this.table.name(), Throughput.suitableThroughput() ); }
/** * Drop table. * @throws InterruptedException If something fails */ public void drop() throws InterruptedException { final AmazonDynamoDB aws = this.region.aws(); final String name = this.request.getTableName(); aws.deleteTable(new DeleteTableRequest().withTableName(name)); Logger.info(this, "DynamoDB table '%s' deletion requested", name); while (this.exists()) { Logger.info(this, "DynamoDB table '%s' still exists", name); TimeUnit.SECONDS.sleep((long) Tv.TEN); } Logger.info(this, "DynamoDB table '%s' deleted", name); }
/** * Drop table. * @throws InterruptedException If something fails */ public void drop() throws InterruptedException { final AmazonDynamoDB aws = this.region.aws(); final String name = this.request.getTableName(); aws.deleteTable(new DeleteTableRequest().withTableName(name)); Logger.info(this, "DynamoDB table '%s' deletion requested", name); while (this.exists()) { Logger.info(this, "DynamoDB table '%s' still exists", name); TimeUnit.SECONDS.sleep((long) Tv.TEN); } Logger.info(this, "DynamoDB table '%s' deleted", name); }
/** * The table exists? * @return TRUE if it exists in DynamoDB * @since 0.9 */ public boolean exists() { final AmazonDynamoDB aws = this.region.aws(); final String name = this.request.getTableName(); boolean exists; try { aws.describeTable(name); exists = true; Logger.info(this, "DynamoDB table '%s' already exists", name); } catch (final ResourceNotFoundException ex) { exists = false; Logger.info( this, "DynamoDB table '%s' doesn't exist: %s", name, ex.getLocalizedMessage() ); } return exists; }
/** * The table exists? * @return TRUE if it exists in DynamoDB * @since 0.9 */ public boolean exists() { final AmazonDynamoDB aws = this.region.aws(); final String name = this.request.getTableName(); boolean exists; try { aws.describeTable(name); exists = true; Logger.info(this, "DynamoDB table '%s' already exists", name); } catch (final ResourceNotFoundException ex) { exists = false; Logger.info( this, "DynamoDB table '%s' doesn't exist: %s", name, ex.getLocalizedMessage() ); } return exists; }
@Override public String lock(final String name, final String label) throws IOException { final AmazonDynamoDB aws = this.table.region().aws(); String msg = ""; try { final PutItemRequest request = new PutItemRequest(); request.setTableName(this.table.name()); request.setItem( new Attributes() .with(DyLocks.HASH, this.owner) .with(DyLocks.RANGE, name) .with(DyLocks.ATTR_LABEL, label) ); request.setExpected( new ImmutableMap.Builder<String, ExpectedAttributeValue>().put( DyLocks.ATTR_LABEL, new ExpectedAttributeValue().withExists(false) ).build() ); aws.putItem(request); } catch (final ConditionalCheckFailedException ex) { msg = ex.getLocalizedMessage(); } catch (final AmazonClientException ex) { throw new IOException(ex); } finally { aws.shutdown(); } return msg; }
/** * Create table. * @throws InterruptedException If something fails */ public void create() throws InterruptedException { final AmazonDynamoDB aws = this.region.aws(); final String name = this.request.getTableName(); aws.createTable(this.request); Logger.info(this, "DynamoDB table '%s' creation requested...", name); final DescribeTableRequest req = new DescribeTableRequest() .withTableName(name); while (true) { final DescribeTableResult result = aws.describeTable(req); if ("ACTIVE".equals(result.getTable().getTableStatus())) { Logger.info( this, "DynamoDB table '%s' is %s", name, result.getTable().getTableStatus() ); break; } Logger.info( this, "waiting for DynamoDB table '%s': %s", name, result.getTable().getTableStatus() ); TimeUnit.SECONDS.sleep((long) Tv.TEN); } }
/** * Create table. * @throws InterruptedException If something fails */ public void create() throws InterruptedException { final AmazonDynamoDB aws = this.region.aws(); final String name = this.request.getTableName(); aws.createTable(this.request); Logger.info(this, "DynamoDB table '%s' creation requested...", name); final DescribeTableRequest req = new DescribeTableRequest() .withTableName(name); while (true) { final DescribeTableResult result = aws.describeTable(req); if ("ACTIVE".equals(result.getTable().getTableStatus())) { Logger.info( this, "DynamoDB table '%s' is %s", name, result.getTable().getTableStatus() ); break; } Logger.info( this, "waiting for DynamoDB table '%s': %s", name, result.getTable().getTableStatus() ); TimeUnit.SECONDS.sleep((long) Tv.TEN); } }