/** * Constructs a new PutAttributesRequest object. Callers should use the setter or fluent setter (with...) methods to * initialize any additional object members. * * @param domainName * The name of the domain in which to perform the operation. * @param itemName * The name of the item. * @param attributes * The list of attributes. * @param expected * The update condition which, if specified, determines whether the specified attributes will be updated or * not. The update condition must be satisfied in order for this request to be processed and the attributes * to be updated. */ public PutAttributesRequest(String domainName, String itemName, java.util.List<ReplaceableAttribute> attributes, UpdateCondition expected) { setDomainName(domainName); setItemName(itemName); setAttributes(attributes); setExpected(expected); }
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getDomainName() == null) ? 0 : getDomainName().hashCode()); hashCode = prime * hashCode + ((getItemName() == null) ? 0 : getItemName().hashCode()); hashCode = prime * hashCode + ((getAttributes() == null) ? 0 : getAttributes().hashCode()); hashCode = prime * hashCode + ((getExpected() == null) ? 0 : getExpected().hashCode()); return hashCode; }
/** * Constructs a new PutAttributesRequest object. Callers should use the setter or fluent setter (with...) methods to * initialize any additional object members. * * @param domainName * The name of the domain in which to perform the operation. * @param itemName * The name of the item. * @param attributes * The list of attributes. */ public PutAttributesRequest(String domainName, String itemName, java.util.List<ReplaceableAttribute> attributes) { setDomainName(domainName); setItemName(itemName); setAttributes(attributes); }
@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); } } }
/** * Register a new instance. Registration will fail if a prior entry exists * * @param instance Instance entry to be registered. * @throws AmazonServiceException If unable to write to Simple DB because of any error. */ public void registerInstance(PriamInstance instance) throws AmazonServiceException { AmazonSimpleDB simpleDBClient = getSimpleDBClient(); PutAttributesRequest putReq = new PutAttributesRequest( DOMAIN, getKey(instance), createAttributesToRegister(instance)); UpdateCondition expected = new UpdateCondition(); expected.setName(Attributes.INSTANCE_ID); expected.setExists(false); putReq.setExpected(expected); simpleDBClient.putAttributes(putReq); }
/** * Create a new instance entry in SimpleDB * * @param instance Instance entry to be created. * @throws AmazonServiceException If unable to write to Simple DB because of any error. */ public void createInstance(PriamInstance instance) throws AmazonServiceException { AmazonSimpleDB simpleDBClient = getSimpleDBClient(); PutAttributesRequest putReq = new PutAttributesRequest( DOMAIN, getKey(instance), createAttributesToRegister(instance)); simpleDBClient.putAttributes(putReq); }
/** * The list of attributes. * <p> * Returns a reference to this object so that method calls can be chained together. * * @param attributes The list of attributes. * * @return A reference to this updated object so that method calls can be chained * together. */ public PutAttributesRequest withAttributes(ReplaceableAttribute... attributes) { if (getAttributes() == null) setAttributes(new java.util.ArrayList<ReplaceableAttribute>(attributes.length)); for (ReplaceableAttribute value : attributes) { getAttributes().add(value); } return this; }
/** * The update condition which, if specified, determines whether the specified attributes will be updated or not. The * update condition must be satisfied in order for this request to be processed and the attributes to be updated. * * @param expected * The update condition which, if specified, determines whether the specified attributes will be updated or * not. The update condition must be satisfied in order for this request to be processed and the attributes * to be updated. * @return Returns a reference to this object so that method calls can be chained together. */ public PutAttributesRequest withExpected(UpdateCondition expected) { setExpected(expected); return this; }
/** * The list of attributes. * * @param attributes * The list of attributes. * @return Returns a reference to this object so that method calls can be chained together. */ public PutAttributesRequest withAttributes(java.util.Collection<ReplaceableAttribute> attributes) { setAttributes(attributes); return this; }
@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); } } }
/** * Constructs a new PutAttributesRequest object. * Callers should use the setter or fluent setter (with...) methods to * initialize any additional object members. * * @param domainName The name of the domain in which to perform the * operation. * @param itemName The name of the item. * @param attributes The list of attributes. */ public PutAttributesRequest(String domainName, String itemName, java.util.List<ReplaceableAttribute> attributes) { setDomainName(domainName); setItemName(itemName); setAttributes(attributes); }
private void putNewValue(String domainName, List<Item> items, String dtype, String newClassName) throws AmazonClientException { AmazonSimpleDB db = factory.getSimpleDb(); for (Item item : items) { List<ReplaceableAttribute> atts = new ArrayList<ReplaceableAttribute>(); atts.add(new ReplaceableAttribute(dtype, newClassName, true)); db.putAttributes(new PutAttributesRequest(domainName, item.getName(), atts)); } }
/** * The update condition which, if specified, determines whether the specified attributes will be updated or not. The * update condition must be satisfied in order for this request to be processed and the attributes to be updated. * * @param expected * The update condition which, if specified, determines whether the specified attributes will be updated or * not. The update condition must be satisfied in order for this request to be processed and the attributes * to be updated. * @return Returns a reference to this object so that method calls can be chained together. */ public PutAttributesRequest withExpected(UpdateCondition expected) { setExpected(expected); return this; }
/** * The list of attributes. * <p> * <b>NOTE:</b> This method appends the values to the existing list (if any). Use * {@link #setAttributes(java.util.Collection)} or {@link #withAttributes(java.util.Collection)} if you want to * override the existing values. * </p> * * @param attributes * The list of attributes. * @return Returns a reference to this object so that method calls can be chained together. */ public PutAttributesRequest withAttributes(ReplaceableAttribute... attributes) { if (this.attributes == null) { setAttributes(new com.amazonaws.internal.SdkInternalList<ReplaceableAttribute>(attributes.length)); } for (ReplaceableAttribute ele : attributes) { this.attributes.add(ele); } return this; }
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)); } } }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof PutAttributesRequest == false) return false; PutAttributesRequest other = (PutAttributesRequest) obj; if (other.getDomainName() == null ^ this.getDomainName() == null) return false; if (other.getDomainName() != null && other.getDomainName().equals(this.getDomainName()) == false) return false; if (other.getItemName() == null ^ this.getItemName() == null) return false; if (other.getItemName() != null && other.getItemName().equals(this.getItemName()) == false) return false; if (other.getAttributes() == null ^ this.getAttributes() == null) return false; if (other.getAttributes() != null && other.getAttributes().equals(this.getAttributes()) == false) return false; if (other.getExpected() == null ^ this.getExpected() == null) return false; if (other.getExpected() != null && other.getExpected().equals(this.getExpected()) == false) return false; return true; }
/** * Constructs a new PutAttributesRequest object. * Callers should use the setter or fluent setter (with...) methods to * initialize any additional object members. * * @param domainName The name of the domain in which to perform the * operation. * @param itemName The name of the item. * @param attributes The list of attributes. * @param expected The update condition which, if specified, determines * whether the specified attributes will be updated or not. The update * condition must be satisfied in order for this request to be processed * and the attributes to be updated. */ public PutAttributesRequest(String domainName, String itemName, java.util.List<ReplaceableAttribute> attributes, UpdateCondition expected) { setDomainName(domainName); setItemName(itemName); setAttributes(attributes); setExpected(expected); }
/** * Constructs a new PutAttributesRequest object. Callers should use the setter or fluent setter (with...) methods to * initialize any additional object members. * * @param domainName * The name of the domain in which to perform the operation. * @param itemName * The name of the item. * @param attributes * The list of attributes. */ public PutAttributesRequest(String domainName, String itemName, java.util.List<ReplaceableAttribute> attributes) { setDomainName(domainName); setItemName(itemName); setAttributes(attributes); }
/** * The list of attributes. * * @param attributes * The list of attributes. * @return Returns a reference to this object so that method calls can be chained together. */ public PutAttributesRequest withAttributes(java.util.Collection<ReplaceableAttribute> attributes) { setAttributes(attributes); return this; }
if (!attsToPut.isEmpty()) { this.em.getSimpleDb().putAttributes( new PutAttributesRequest().withDomainName(domainName).withItemName(id).withAttributes(attsToPut) .withExpected(expected)); duration2 = System.currentTimeMillis() - start2; if (logger.isLoggable(Level.FINE))