@Override public void setExpectedState(ExpectedSlotStatus slotStatus) { Preconditions.checkNotNull(slotStatus, "slotStatus is null"); if (isDomainCreated()) { List<ReplaceableAttribute> attributes = newArrayList(); attributes.add(new ReplaceableAttribute("state", slotStatus.getStatus().toString(), true)); if (slotStatus.getAssignment() != null) { attributes.add(new ReplaceableAttribute("binary", slotStatus.getAssignment().getBinary(), true)); attributes.add(new ReplaceableAttribute("config", slotStatus.getAssignment().getConfig(), true)); } try { simpleDb.putAttributes(new PutAttributesRequest().withDomainName(domainName).withItemName(slotStatus.getId().toString()).withAttributes(attributes)); expectedStateStoreUp(); } catch (Exception e) { expectedStateStoreDown(e); } } }
@Override public void setExpectedState(ExpectedSlotStatus slotStatus) { Preconditions.checkNotNull(slotStatus, "slotStatus is null"); if (isDomainCreated()) { List<ReplaceableAttribute> attributes = newArrayList(); attributes.add(new ReplaceableAttribute("state", slotStatus.getStatus().toString(), true)); if (slotStatus.getAssignment() != null) { attributes.add(new ReplaceableAttribute("binary", slotStatus.getAssignment().getBinary(), true)); attributes.add(new ReplaceableAttribute("config", slotStatus.getAssignment().getConfig(), true)); } try { simpleDb.putAttributes(new PutAttributesRequest().withDomainName(domainName).withItemName(slotStatus.getId().toString()).withAttributes(attributes)); expectedStateStoreUp(); } catch (Exception e) { expectedStateStoreDown(e); } } }
private void putAndDelete(String domainName, String oldAttributeName, String newAttributeName, List<Item> items) throws AmazonClientException { AmazonSimpleDB db = factory.getSimpleDb(); for (Item item : items) { GetAttributesResult getOldResults = db.getAttributes(new GetAttributesRequest().withDomainName(domainName).withConsistentRead(true).withItemName( item.getName()).withAttributeNames(oldAttributeName)); List<Attribute> oldAtts = getOldResults.getAttributes(); if (oldAtts.size() > 0) { Attribute oldAtt = oldAtts.get(0); List<ReplaceableAttribute> atts = new ArrayList<ReplaceableAttribute>(); atts.add(new ReplaceableAttribute(newAttributeName, oldAtt.getValue(), true)); db.putAttributes(new PutAttributesRequest().withDomainName(domainName).withItemName(item.getName()).withAttributes(atts)); db.deleteAttributes(new DeleteAttributesRequest().withDomainName(domainName).withItemName(item.getName()).withAttributes(oldAtts)); } } }
if (!attsToPut.isEmpty()) { this.em.getSimpleDb().putAttributes( new PutAttributesRequest().withDomainName(domainName).withItemName(id).withAttributes(attsToPut) .withExpected(expected)); duration2 = System.currentTimeMillis() - start2;