@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getResourceId() == null) ? 0 : getResourceId().hashCode()); hashCode = prime * hashCode + ((getResourceType() == null) ? 0 : getResourceType().hashCode()); hashCode = prime * hashCode + ((getKey() == null) ? 0 : getKey().hashCode()); hashCode = prime * hashCode + ((getValue() == null) ? 0 : getValue().hashCode()); hashCode = prime * hashCode + ((getPropagateAtLaunch() == null) ? 0 : getPropagateAtLaunch().hashCode()); return hashCode; }
/** * <p> * The tag value. * </p> * * @param value * The tag value. * @return Returns a reference to this object so that method calls can be chained together. */ public TagDescription withValue(String value) { setValue(value); return this; }
/** * <p> * The tag key. * </p> * * @param key * The tag key. * @return Returns a reference to this object so that method calls can be chained together. */ public TagDescription withKey(String key) { setKey(key); return this; }
if (tagDescription.getKey().equalsIgnoreCase(CLUSTER_ID_ASG_TAG)) { clusterId = Optional.of(tagDescription.getValue()); if (tagDescription.getKey().equalsIgnoreCase(ASG_TYPE_ASG_TAG)) { if (tagDescription.getValue().equalsIgnoreCase(ASG_TYPE_MASTER)) { masterAsg = Optional.of(autoScalingGroups.get(0)); workersAsg = Optional.of(autoScalingGroups.get(1));
public TagDescription unmarshall(StaxUnmarshallerContext context) throws Exception { TagDescription tagDescription = new TagDescription(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; tagDescription.setResourceId(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; tagDescription.setResourceType(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; tagDescription.setKey(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; tagDescription.setValue(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; tagDescription.setPropagateAtLaunch(BooleanStaxUnmarshaller.getInstance().unmarshall(context)); continue;
/*** * Get list of {@link AutoScalingGroup}s for a given tag * * @param tag Tag to filter the auto scaling groups * @return List of {@link AutoScalingGroup}s qualifying the filter tag */ public List<AutoScalingGroup> getAutoScalingGroupsWithTag(Tag tag) { final AmazonAutoScaling autoScaling = getAmazonAutoScalingClient(); final DescribeAutoScalingGroupsRequest describeAutoScalingGroupsRequest = new DescribeAutoScalingGroupsRequest(); final List<AutoScalingGroup> allAutoScalingGroups = autoScaling .describeAutoScalingGroups(describeAutoScalingGroupsRequest) .getAutoScalingGroups(); final List<AutoScalingGroup> filteredAutoScalingGroups = Lists.newArrayList(); for (AutoScalingGroup autoScalingGroup : allAutoScalingGroups) { for (TagDescription tagDescription : autoScalingGroup.getTags()) { if (tagDescription.getKey().equalsIgnoreCase(tag.getKey()) && tagDescription.getValue().equalsIgnoreCase(tag.getValue())) { filteredAutoScalingGroups.add(autoScalingGroup); } } } return filteredAutoScalingGroups; }
public TagDescription unmarshall(StaxUnmarshallerContext context) throws Exception { TagDescription tagDescription = new TagDescription(); tagDescription.setResourceId(StringStaxUnmarshaller.getInstance().unmarshall( context)); continue; tagDescription.setResourceType(StringStaxUnmarshaller.getInstance().unmarshall( context)); continue; tagDescription.setKey(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; tagDescription.setValue(StringStaxUnmarshaller.getInstance() .unmarshall(context)); continue; tagDescription.setPropagateAtLaunch(BooleanStaxUnmarshaller.getInstance() .unmarshall(context)); continue;
return false; TagDescription other = (TagDescription) obj; if (other.getResourceId() == null ^ this.getResourceId() == null) return false; if (other.getResourceId() != null && other.getResourceId().equals(this.getResourceId()) == false) return false; if (other.getResourceType() == null ^ this.getResourceType() == null) return false; if (other.getResourceType() != null && other.getResourceType().equals(this.getResourceType()) == false) return false; if (other.getKey() == null ^ this.getKey() == null) return false; if (other.getKey() != null && other.getKey().equals(this.getKey()) == 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.getPropagateAtLaunch() == null ^ this.getPropagateAtLaunch() == null) return false; if (other.getPropagateAtLaunch() != null && other.getPropagateAtLaunch().equals(this.getPropagateAtLaunch()) == false) return false; return true;
String instanceId = EC2MetadataUtils.getInstanceId(); String asgName = null; List<TagDescription> tagDescriptions = new AmazonEC2Client().describeTags( new DescribeTagsRequest().withFilters( new Filter().withName("resource-id").withValues(instanceId) ) ).getTags(); for (TagDescription tagDescription : tagDescriptions) { if ("aws:autoscaling:groupName".equals(tagDescription.getKey())) { asgName = tagDescription.getValue(); break; } }
@Test(dependsOnMethods = "testCreateHelixCluster") public void testSetupAndSubmitApplication() throws Exception { // Setup new cluster this.clusterId = this.gobblinAwsClusterLauncher.setupGobblinCluster(); this.clusterIdTag.setValue(this.clusterId); }
/** * 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 (getResourceId() != null) sb.append("ResourceId: ").append(getResourceId()).append(","); if (getResourceType() != null) sb.append("ResourceType: ").append(getResourceType()).append(","); if (getKey() != null) sb.append("Key: ").append(getKey()).append(","); if (getValue() != null) sb.append("Value: ").append(getValue()).append(","); if (getPropagateAtLaunch() != null) sb.append("PropagateAtLaunch: ").append(getPropagateAtLaunch()); sb.append("}"); return sb.toString(); }
if (tagDescription.getKey().equalsIgnoreCase(CLUSTER_ID_ASG_TAG)) { clusterId = Optional.of(tagDescription.getValue()); if (tagDescription.getKey().equalsIgnoreCase(ASG_TYPE_ASG_TAG)) { if (tagDescription.getValue().equalsIgnoreCase(ASG_TYPE_MASTER)) { masterAsg = Optional.of(autoScalingGroups.get(0)); workersAsg = Optional.of(autoScalingGroups.get(1));
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getResourceId() == null) ? 0 : getResourceId().hashCode()); hashCode = prime * hashCode + ((getResourceType() == null) ? 0 : getResourceType().hashCode()); hashCode = prime * hashCode + ((getKey() == null) ? 0 : getKey().hashCode()); hashCode = prime * hashCode + ((getValue() == null) ? 0 : getValue().hashCode()); hashCode = prime * hashCode + ((getPropagateAtLaunch() == null) ? 0 : getPropagateAtLaunch().hashCode()); return hashCode; }
if (tagDescription.getKey().equalsIgnoreCase(CLUSTER_ID_ASG_TAG)) { clusterId = Optional.of(tagDescription.getValue()); if (tagDescription.getKey().equalsIgnoreCase(ASG_TYPE_ASG_TAG)) { if (tagDescription.getValue().equalsIgnoreCase(ASG_TYPE_MASTER)) { masterAsg = Optional.of(autoScalingGroups.get(0)); workersAsg = Optional.of(autoScalingGroups.get(1));
TagDescription other = (TagDescription) obj; if (other.getResourceId() == null ^ this.getResourceId() == null) return false; if (other.getResourceId() != null && other.getResourceId().equals(this.getResourceId()) == false) return false; if (other.getResourceType() == null ^ this.getResourceType() == null) return false; if (other.getResourceType() != null && other.getResourceType().equals(this.getResourceType()) == false) return false; if (other.getKey() == null ^ this.getKey() == null) return false; if (other.getKey() != null && other.getKey().equals(this.getKey()) == 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.getPropagateAtLaunch() == null ^ this.getPropagateAtLaunch() == null) return false; if (other.getPropagateAtLaunch() != null && other.getPropagateAtLaunch().equals(this.getPropagateAtLaunch()) == false) return false; return true;
public Map<String, String> getDeployTags() { Map<String, String> tags = new HashMap<>(3); Optional<AutoScalingInstanceDetails> details = describeInstance(); details.ifPresent(autoScalingInstanceDetails -> { autoScalingInstanceDetails.getAutoScalingGroupName(); List<Filter> filters = Collections.singletonList( new Filter().withName("auto-scaling-group").withValues(autoScalingInstanceDetails.getAutoScalingGroupName()) ); DescribeTagsResult result = asyncClient.describeTags(new DescribeTagsRequest().withFilters(filters)); result.getTags().forEach(t -> tags.put(t.getKey(), t.getValue())); }); return tags; }
/** * Returns a string representation of this object; useful for testing and * debugging. * * @return A string representation of this object. * @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getResourceId() != null) sb.append("ResourceId: " + getResourceId() + ","); if (getResourceType() != null) sb.append("ResourceType: " + getResourceType() + ","); if (getKey() != null) sb.append("Key: " + getKey() + ","); if (getValue() != null) sb.append("Value: " + getValue() + ","); if (getPropagateAtLaunch() != null) sb.append("PropagateAtLaunch: " + getPropagateAtLaunch()); sb.append("}"); return sb.toString(); }
/*** * Get list of {@link AutoScalingGroup}s for a given tag * * @param tag Tag to filter the auto scaling groups * @return List of {@link AutoScalingGroup}s qualifying the filter tag */ public List<AutoScalingGroup> getAutoScalingGroupsWithTag(Tag tag) { final AmazonAutoScaling autoScaling = getAmazonAutoScalingClient(); final DescribeAutoScalingGroupsRequest describeAutoScalingGroupsRequest = new DescribeAutoScalingGroupsRequest(); final List<AutoScalingGroup> allAutoScalingGroups = autoScaling .describeAutoScalingGroups(describeAutoScalingGroupsRequest) .getAutoScalingGroups(); final List<AutoScalingGroup> filteredAutoScalingGroups = Lists.newArrayList(); for (AutoScalingGroup autoScalingGroup : allAutoScalingGroups) { for (TagDescription tagDescription : autoScalingGroup.getTags()) { if (tagDescription.getKey().equalsIgnoreCase(tag.getKey()) && tagDescription.getValue().equalsIgnoreCase(tag.getValue())) { filteredAutoScalingGroups.add(autoScalingGroup); } } } return filteredAutoScalingGroups; }
public void marshall(TagDescription _tagDescription, Request<?> request, String _prefix) { String prefix; if (_tagDescription.getResourceId() != null) { prefix = _prefix + "ResourceId"; String resourceId = _tagDescription.getResourceId(); request.addParameter(prefix, StringUtils.fromString(resourceId)); } if (_tagDescription.getResourceType() != null) { prefix = _prefix + "ResourceType"; String resourceType = _tagDescription.getResourceType(); request.addParameter(prefix, StringUtils.fromString(resourceType)); } if (_tagDescription.getKey() != null) { prefix = _prefix + "Key"; String key = _tagDescription.getKey(); request.addParameter(prefix, StringUtils.fromString(key)); } if (_tagDescription.getValue() != null) { prefix = _prefix + "Value"; String value = _tagDescription.getValue(); request.addParameter(prefix, StringUtils.fromString(value)); } if (_tagDescription.getPropagateAtLaunch() != null) { prefix = _prefix + "PropagateAtLaunch"; Boolean propagateAtLaunch = _tagDescription.getPropagateAtLaunch(); request.addParameter(prefix, StringUtils.fromBoolean(propagateAtLaunch)); } }
/*** * Get list of {@link AutoScalingGroup}s for a given tag * * @param tag Tag to filter the auto scaling groups * @return List of {@link AutoScalingGroup}s qualifying the filter tag */ public List<AutoScalingGroup> getAutoScalingGroupsWithTag(Tag tag) { final AmazonAutoScaling autoScaling = getAmazonAutoScalingClient(); final DescribeAutoScalingGroupsRequest describeAutoScalingGroupsRequest = new DescribeAutoScalingGroupsRequest(); final List<AutoScalingGroup> allAutoScalingGroups = autoScaling .describeAutoScalingGroups(describeAutoScalingGroupsRequest) .getAutoScalingGroups(); final List<AutoScalingGroup> filteredAutoScalingGroups = Lists.newArrayList(); for (AutoScalingGroup autoScalingGroup : allAutoScalingGroups) { for (TagDescription tagDescription : autoScalingGroup.getTags()) { if (tagDescription.getKey().equalsIgnoreCase(tag.getKey()) && tagDescription.getValue().equalsIgnoreCase(tag.getValue())) { filteredAutoScalingGroups.add(autoScalingGroup); } } } return filteredAutoScalingGroups; }