@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getName() == null) ? 0 : getName().hashCode()); hashCode = prime * hashCode + ((getAlternateNameEncoding() == null) ? 0 : getAlternateNameEncoding().hashCode()); hashCode = prime * hashCode + ((getValue() == null) ? 0 : getValue().hashCode()); hashCode = prime * hashCode + ((getAlternateValueEncoding() == null) ? 0 : getAlternateValueEncoding().hashCode()); return hashCode; }
public Attribute unmarshall(StaxUnmarshallerContext context) throws Exception { Attribute attribute = new Attribute(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; attribute.setName(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; attribute.setAlternateNameEncoding(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; attribute.setValue(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; attribute.setAlternateValueEncoding(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue;
private void addProperty(Item item) { Iterator<Attribute> attrs = item.getAttributes().iterator(); String prop = ""; String value = ""; String dc = ""; while (attrs.hasNext()) { Attribute att = attrs.next(); if (att.getName().equals(Attributes.PROPERTY)) prop = att.getValue(); else if (att.getName().equals(Attributes.PROPERTY_VALUE)) value = att.getValue(); else if (att.getName().equals(Attributes.REGION)) dc = att.getValue(); } // Ignore, if not this region if (StringUtils.isNotBlank(dc) && !dc.equals(getRegion())) return; // Override only if region is specified if (data.containsKey(prop) && StringUtils.isBlank(dc)) return; data.put(prop, value); }
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)); } } }
protected List<Attribute> createAttributesToDeRegister(PriamInstance instance) { List<Attribute> attrs = new ArrayList<>(); attrs.add(new Attribute(Attributes.INSTANCE_ID, instance.getInstanceId())); attrs.add(new Attribute(Attributes.TOKEN, instance.getToken())); attrs.add(new Attribute(Attributes.APP_ID, instance.getApp())); attrs.add(new Attribute(Attributes.ID, Integer.toString(instance.getId()))); attrs.add(new Attribute(Attributes.AVAILABILITY_ZONE, instance.getRac())); attrs.add(new Attribute(Attributes.ELASTIC_IP, instance.getHostIP())); attrs.add(new Attribute(Attributes.HOSTNAME, instance.getHostName())); attrs.add(new Attribute(Attributes.LOCATION, instance.getDC())); attrs.add(new Attribute(Attributes.UPDATE_TS, Long.toString(instance.getUpdatetime()))); return attrs; }
/** * <p> * </p> * * @param alternateNameEncoding * @return Returns a reference to this object so that method calls can be chained together. */ public Attribute withAlternateNameEncoding(String alternateNameEncoding) { setAlternateNameEncoding(alternateNameEncoding); return this; }
/** * Convert a simpledb item to PriamInstance * * @param item * @return */ public PriamInstance transform(Item item) { PriamInstance ins = new PriamInstance(); for (Attribute att : item.getAttributes()) { if (att.getName().equals(Attributes.INSTANCE_ID)) ins.setInstanceId(att.getValue()); else if (att.getName().equals(Attributes.TOKEN)) ins.setToken(att.getValue()); else if (att.getName().equals(Attributes.APP_ID)) ins.setApp(att.getValue()); else if (att.getName().equals(Attributes.ID)) ins.setId(Integer.parseInt(att.getValue())); else if (att.getName().equals(Attributes.AVAILABILITY_ZONE)) ins.setRac(att.getValue()); else if (att.getName().equals(Attributes.ELASTIC_IP)) ins.setHostIP(att.getValue()); else if (att.getName().equals(Attributes.HOSTNAME)) ins.setHost(att.getValue()); else if (att.getName().equals(Attributes.LOCATION)) ins.setDC(att.getValue()); else if (att.getName().equals(Attributes.UPDATE_TS)) ins.setUpdatetime(Long.parseLong(att.getValue())); } return ins; }
@Override public void deleteExpectedState(UUID slotId) { Preconditions.checkNotNull(slotId, "id is null"); if (isDomainCreated()) { List<Attribute> attributes = newArrayList(); attributes.add(new Attribute("state", null)); attributes.add(new Attribute("binary", null)); attributes.add(new Attribute("config", null)); try { simpleDb.deleteAttributes(new DeleteAttributesRequest().withDomainName(domainName).withItemName(slotId.toString()).withAttributes(attributes)); expectedStateStoreUp(); } catch (Exception e) { expectedStateStoreDown(e); } } }
/** * <p> * </p> * * @param alternateNameEncoding * @return Returns a reference to this object so that method calls can be chained together. */ public Attribute withAlternateNameEncoding(String alternateNameEncoding) { setAlternateNameEncoding(alternateNameEncoding); return this; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof Attribute == false) return false; Attribute other = (Attribute) obj; if (other.getName() == null ^ this.getName() == null) return false; if (other.getName() != null && other.getName().equals(this.getName()) == false) return false; if (other.getAlternateNameEncoding() == null ^ this.getAlternateNameEncoding() == null) return false; if (other.getAlternateNameEncoding() != null && other.getAlternateNameEncoding().equals(this.getAlternateNameEncoding()) == false) return false; if (other.getValue() == null ^ this.getValue() == null) return false; if (other.getValue() != null && other.getValue().equals(this.getValue()) == false) return false; if (other.getAlternateValueEncoding() == null ^ this.getAlternateValueEncoding() == null) return false; if (other.getAlternateValueEncoding() != null && other.getAlternateValueEncoding().equals(this.getAlternateValueEncoding()) == false) return false; return true; }
public Attribute unmarshall(StaxUnmarshallerContext context) throws Exception { Attribute attribute = new Attribute(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; attribute.setName(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; attribute.setAlternateNameEncoding(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; attribute.setValue(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; attribute.setAlternateValueEncoding(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue;
@Override public void deleteExpectedState(UUID slotId) { Preconditions.checkNotNull(slotId, "id is null"); if (isDomainCreated()) { List<Attribute> attributes = newArrayList(); attributes.add(new Attribute("state", null)); attributes.add(new Attribute("binary", null)); attributes.add(new Attribute("config", null)); try { simpleDb.deleteAttributes(new DeleteAttributesRequest().withDomainName(domainName).withItemName(slotId.toString()).withAttributes(attributes)); expectedStateStoreUp(); } catch (Exception e) { expectedStateStoreDown(e); } } }
/** * Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be * redacted from this string using a placeholder value. * * @return A string representation of this object. * * @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getName() != null) sb.append("Name: ").append(getName()).append(","); if (getAlternateNameEncoding() != null) sb.append("AlternateNameEncoding: ").append(getAlternateNameEncoding()).append(","); if (getValue() != null) sb.append("Value: ").append(getValue()).append(","); if (getAlternateValueEncoding() != null) sb.append("AlternateValueEncoding: ").append(getAlternateValueEncoding()); sb.append("}"); return sb.toString(); }
private static String getValueToSet(List<Attribute> atts, String propertyName, String columnName) { if(columnName != null) propertyName = columnName; for (Attribute att : atts) { String attName = att.getName(); if (attName.equals(propertyName)) { String val = att.getValue(); return val; } } return null; }
public Attribute unmarshall(StaxUnmarshallerContext context) throws Exception { Attribute attribute = new Attribute(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; attribute.setName(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; attribute.setAlternateNameEncoding(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; attribute.setValue(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; attribute.setAlternateValueEncoding(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue;
if (attributesListValue.getName() != null) { request.addParameter("Item." + itemsListIndex + ".Attribute." + attributesListIndex + ".Name", StringUtils.fromString(attributesListValue.getName())); if (attributesListValue.getAlternateNameEncoding() != null) { request.addParameter("Item." + itemsListIndex + ".Attribute." + attributesListIndex + ".AlternateNameEncoding", StringUtils.fromString(attributesListValue.getAlternateNameEncoding())); if (attributesListValue.getValue() != null) { request.addParameter("Item." + itemsListIndex + ".Attribute." + attributesListIndex + ".Value", StringUtils.fromString(attributesListValue.getValue())); if (attributesListValue.getAlternateValueEncoding() != null) { request.addParameter("Item." + itemsListIndex + ".Attribute." + attributesListIndex + ".AlternateValueEncoding", StringUtils.fromString(attributesListValue.getAlternateValueEncoding()));
if (attributesListValue.getName() != null) { request.addParameter("Attribute." + attributesListIndex + ".Name", StringUtils.fromString(attributesListValue.getName())); if (attributesListValue.getAlternateNameEncoding() != null) { request.addParameter("Attribute." + attributesListIndex + ".AlternateNameEncoding", StringUtils.fromString(attributesListValue.getAlternateNameEncoding())); if (attributesListValue.getValue() != null) { request.addParameter("Attribute." + attributesListIndex + ".Value", StringUtils.fromString(attributesListValue.getValue())); if (attributesListValue.getAlternateValueEncoding() != null) { request.addParameter("Attribute." + attributesListIndex + ".AlternateValueEncoding", StringUtils.fromString(attributesListValue.getAlternateValueEncoding()));