/** * Delete them all. * @return How many were deleted */ public int flush() { final Iterator<Item> items = this.table.frame().iterator(); int total = 0; while (items.hasNext()) { items.next(); items.remove(); ++total; } return total; }
@Override @RetryOnFailure(verbose = false, delay = Tv.FIVE, unit = TimeUnit.SECONDS) public Item put(final Map<String, AttributeValue> attributes) throws IOException { return this.origin.put(attributes); }
@Override @RetryOnFailure(verbose = false, delay = Tv.FIVE, unit = TimeUnit.SECONDS) public Region region() { return new ReRegion(this.origin.region()); }
@Override @RetryOnFailure(verbose = false, delay = Tv.FIVE, unit = TimeUnit.SECONDS) public String name() { return this.origin.name(); }
@Override @RetryOnFailure(verbose = false, delay = Tv.FIVE, unit = TimeUnit.SECONDS) public void delete(final Map<String, AttributeValue> attributes) throws IOException { this.origin.delete(attributes); } }
private void add(final String name, final double diff) throws IOException { final String version = new Version().value(); final Iterator<Item> items = this.table.frame() .through( new QueryValve() before = items.next(); } else { before = this.table.put( new Attributes() .with("metric", name) ); final Item after = this.table.frame() .through( new QueryValve() final Item fin = this.table.frame() .through( new QueryValve()
@Override @RetryOnFailure(verbose = false, delay = Tv.FIVE, unit = TimeUnit.SECONDS) public Region region() { return new ReRegion(this.origin.region()); }
@Override @RetryOnFailure(verbose = false, delay = Tv.FIVE, unit = TimeUnit.SECONDS) public String name() { return this.origin.name(); }
@Override @RetryOnFailure(verbose = false, delay = Tv.FIVE, unit = TimeUnit.SECONDS) public void delete(final Map<String, AttributeValue> attributes) throws IOException { this.origin.delete(attributes); } }
Region region = new Region.Simple(credentials); Table table = region.table("my-table"); Collection<Item> items = table.frame().where("name", "Jeff"); for (Item item : items) { System.out.println(item.get("salary").getS()); }
@Override @RetryOnFailure(verbose = false, delay = Tv.FIVE, unit = TimeUnit.SECONDS) public Item put(final Map<String, AttributeValue> attributes) throws IOException { return this.origin.put(attributes); }
@Override @RetryOnFailure(verbose = false, delay = Tv.FIVE, unit = TimeUnit.SECONDS) public Frame frame() { return new ReFrame(this.origin.frame()); }
@Override @Cacheable.FlushBefore public boolean add(@NotNull final URN user, @NotNull final Domain domain) throws IOException { final ConcurrentMap<String, AttributeValue> attrs = new ConcurrentHashMap<String, AttributeValue>(0); attrs.put(DefaultDynamo.USER, new AttributeValue(user.toString())); attrs.put(DefaultDynamo.NAME, new AttributeValue(domain.name())); attrs.put(DefaultDynamo.KEY, new AttributeValue(domain.key())); attrs.put(DefaultDynamo.SECRET, new AttributeValue(domain.secret())); attrs.put(DefaultDynamo.REGION, new AttributeValue(domain.region())); attrs.put(DefaultDynamo.SYSLOG, new AttributeValue(domain.syslog())); attrs.put(DefaultDynamo.BUCKET, new AttributeValue(domain.bucket())); this.region.table(this.table).put(attrs); return true; }
@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; }
Credentials credentials = new Credentials.Simple("AWS key", "AWS secret"); Region region = new Region.Simple(credentials); Table table = region.table("foo"); Collection<Item> items = table.frame().where("id", Conditions.equalTo(123)); for (Item item : items) { System.out.println(item.get("name").getS()); }
@Override @Cacheable.FlushAfter public void refresh() throws IOException { this.region.table(DefaultUser.TOKENS).put( new Attributes() .with(DefaultUser.HASH, this.name) .with( DefaultUser.ATTR_TOKEN, Joiner.on('-').join( Iterables.limit( Splitter.fixedLength(Tv.FOUR).split( DigestUtils.md5Hex( RandomStringUtils.random(Tv.TEN) ).toUpperCase(Locale.ENGLISH) ), Tv.FOUR ) ) ) ); }
Credentials credentials = new Credentials.Simple("AWS key", "AWS secret"); Region region = new Region.Simple(credentials); Table table = region.table("foo"); Collection<Item> items = table.frame().where("id", Conditions.equalTo(123)); for (Item item : items) { System.out.println(item.get("name").getS()); }