@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getAvailabilityZone() == null) ? 0 : getAvailabilityZone().hashCode()); hashCode = prime * hashCode + ((getAffinity() == null) ? 0 : getAffinity().hashCode()); hashCode = prime * hashCode + ((getGroupName() == null) ? 0 : getGroupName().hashCode()); hashCode = prime * hashCode + ((getPartitionNumber() == null) ? 0 : getPartitionNumber().hashCode()); hashCode = prime * hashCode + ((getHostId() == null) ? 0 : getHostId().hashCode()); hashCode = prime * hashCode + ((getTenancy() == null) ? 0 : getTenancy().hashCode()); hashCode = prime * hashCode + ((getSpreadDomain() == null) ? 0 : getSpreadDomain().hashCode()); return hashCode; }
/** * 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 (getAvailabilityZone() != null) sb.append("AvailabilityZone: ").append(getAvailabilityZone()).append(","); if (getAffinity() != null) sb.append("Affinity: ").append(getAffinity()).append(","); if (getGroupName() != null) sb.append("GroupName: ").append(getGroupName()).append(","); if (getPartitionNumber() != null) sb.append("PartitionNumber: ").append(getPartitionNumber()).append(","); if (getHostId() != null) sb.append("HostId: ").append(getHostId()).append(","); if (getTenancy() != null) sb.append("Tenancy: ").append(getTenancy()).append(","); if (getSpreadDomain() != null) sb.append("SpreadDomain: ").append(getSpreadDomain()); sb.append("}"); return sb.toString(); }
return false; Placement other = (Placement) obj; if (other.getAvailabilityZone() == null ^ this.getAvailabilityZone() == null) return false; if (other.getAvailabilityZone() != null && other.getAvailabilityZone().equals(this.getAvailabilityZone()) == false) return false; if (other.getAffinity() == null ^ this.getAffinity() == null)
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getAvailabilityZone() == null) ? 0 : getAvailabilityZone().hashCode()); hashCode = prime * hashCode + ((getGroupName() == null) ? 0 : getGroupName().hashCode()); hashCode = prime * hashCode + ((getTenancy() == null) ? 0 : getTenancy().hashCode()); hashCode = prime * hashCode + ((getHostId() == null) ? 0 : getHostId().hashCode()); hashCode = prime * hashCode + ((getAffinity() == null) ? 0 : getAffinity().hashCode()); return hashCode; }
/** * 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 (getAvailabilityZone() != null) sb.append("AvailabilityZone: " + getAvailabilityZone() + ","); if (getGroupName() != null) sb.append("GroupName: " + getGroupName() + ","); if (getTenancy() != null) sb.append("Tenancy: " + getTenancy() + ","); if (getHostId() != null) sb.append("HostId: " + getHostId() + ","); if (getAffinity() != null) sb.append("Affinity: " + getAffinity() ); sb.append("}"); return sb.toString(); }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof Placement == false) return false; Placement other = (Placement)obj; if (other.getAvailabilityZone() == null ^ this.getAvailabilityZone() == null) return false; if (other.getAvailabilityZone() != null && other.getAvailabilityZone().equals(this.getAvailabilityZone()) == false) return false; if (other.getGroupName() == null ^ this.getGroupName() == null) return false; if (other.getGroupName() != null && other.getGroupName().equals(this.getGroupName()) == false) return false; if (other.getTenancy() == null ^ this.getTenancy() == null) return false; if (other.getTenancy() != null && other.getTenancy().equals(this.getTenancy()) == false) return false; if (other.getHostId() == null ^ this.getHostId() == null) return false; if (other.getHostId() != null && other.getHostId().equals(this.getHostId()) == false) return false; if (other.getAffinity() == null ^ this.getAffinity() == null) return false; if (other.getAffinity() != null && other.getAffinity().equals(this.getAffinity()) == false) return false; return true; }
if (placement != null) { if (placement.getAvailabilityZone() != null) { request.addParameter("LaunchSpecification.Placement.AvailabilityZone", StringUtils.fromString(placement.getAvailabilityZone()));
if (placement != null) { if (placement.getAvailabilityZone() != null) { request.addParameter("LaunchTemplateConfigs." + launchTemplateConfigsListIndex + ".Overrides." + overridesListIndex + ".Placement.AvailabilityZone", StringUtils.fromString(placement.getAvailabilityZone()));
public static String getLocation(com.amazonaws.services.ec2.model.Instance instance, String role) { String zone = instance.getPlacement().getAvailabilityZone(); String region = zone.substring(0, zone.length() - 1); return Joiner.on('/').join("", "ec2", region, zone, instance.getInstanceId(), role); }
public static String getLocation(com.amazonaws.services.ec2.model.Instance instance, String role) { String zone = instance.getPlacement().getAvailabilityZone(); String region = zone.substring(0, zone.length() - 1); return Joiner.on('/').join("", "ec2", region, zone, instance.getInstanceId(), role); }
if (placement != null) { if (placement.getAvailabilityZone() != null) { request.addParameter("Placement.AvailabilityZone", StringUtils.fromString(placement.getAvailabilityZone()));
/** * Returns the region (for example, {@code eu-west-1}) that the * {@link Instance} was launched in by looking at the availability zone. * * @param instance * @return */ private String extractRegion(Instance instance) { if (instance.getPlacement() == null || instance.getPlacement().getAvailabilityZone() == null) { LOG.warn("failed to extract region for {}: " + "no placement/availability zone information available", instance.getInstanceId()); return "unknown"; } // availability zone is region + letter, for instance 'eu-west-1a' String availabilityZone = instance.getPlacement().getAvailabilityZone(); String region = availabilityZone.substring(0, availabilityZone.length() - 1); return region; }
protected HashMap getAwsInstanceProperties(Instance awsInstance) throws Exception { HashMap map = mapper.readValue(mapper.writeValueAsString(awsInstance), HashMap.class); if (awsInstance.getMonitoring() != null && awsInstance.getMonitoring().getState() != null) { //Have to comply with the current AWS_V1 schema map.put("monitoring", awsInstance.getMonitoring().getState().toString()); } if (awsInstance.getPlacement() != null && awsInstance.getPlacement().getAvailabilityZone() != null) { //Be backward compatible for tools Map placement = (Map) map.get("placement"); if (placement != null) { placement.put("availability_zone", awsInstance.getPlacement().getAvailabilityZone()); } } return map; } }
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getAvailabilityZone() == null) ? 0 : getAvailabilityZone().hashCode()); hashCode = prime * hashCode + ((getAffinity() == null) ? 0 : getAffinity().hashCode()); hashCode = prime * hashCode + ((getGroupName() == null) ? 0 : getGroupName().hashCode()); hashCode = prime * hashCode + ((getPartitionNumber() == null) ? 0 : getPartitionNumber().hashCode()); hashCode = prime * hashCode + ((getHostId() == null) ? 0 : getHostId().hashCode()); hashCode = prime * hashCode + ((getTenancy() == null) ? 0 : getTenancy().hashCode()); hashCode = prime * hashCode + ((getSpreadDomain() == null) ? 0 : getSpreadDomain().hashCode()); return hashCode; }
/** * 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 (getAvailabilityZone() != null) sb.append("AvailabilityZone: ").append(getAvailabilityZone()).append(","); if (getAffinity() != null) sb.append("Affinity: ").append(getAffinity()).append(","); if (getGroupName() != null) sb.append("GroupName: ").append(getGroupName()).append(","); if (getPartitionNumber() != null) sb.append("PartitionNumber: ").append(getPartitionNumber()).append(","); if (getHostId() != null) sb.append("HostId: ").append(getHostId()).append(","); if (getTenancy() != null) sb.append("Tenancy: ").append(getTenancy()).append(","); if (getSpreadDomain() != null) sb.append("SpreadDomain: ").append(getSpreadDomain()); sb.append("}"); return sb.toString(); }
return false; Placement other = (Placement) obj; if (other.getAvailabilityZone() == null ^ this.getAvailabilityZone() == null) return false; if (other.getAvailabilityZone() != null && other.getAvailabilityZone().equals(this.getAvailabilityZone()) == false) return false; if (other.getAffinity() == null ^ this.getAffinity() == null)
if (placementPlacement.getAvailabilityZone() != null) { request.addParameter("LaunchSpecification.Placement.AvailabilityZone", StringUtils.fromString(placementPlacement.getAvailabilityZone()));
@Override public EsInstance createFromEC2(Instance awsInstance) throws Exception { Preconditions.checkNotNull(awsInstance); EsInstance esInstance = new EsInstance(); esInstance.setId(awsInstance.getInstanceId()); esInstance.setState(awsInstance.getState().getName()); esInstance.setLocation(awsInstance.getPlacement().getAvailabilityZone()); //Region=location-last char. This is what CMDBV1 and people on internet do. //There should be a better way. Right now, keep as what it is esInstance.setRegion( esInstance.getLocation().substring(0, esInstance.getLocation().length() - 1)); esInstance.setAwsLaunchTime(awsInstance.getLaunchTime()); esInstance.setSubnetId(awsInstance.getSubnetId()); esInstance.setVpcId(awsInstance.getVpcId()); //Convert AWS instance to a map of property bags and save it. esInstance.getCloud() .put("aws", getAwsInstanceProperties(awsInstance)); Date utcNow = DateTime.now(DateTimeZone.UTC).toDate(); esInstance.setCreatedTime(utcNow); esInstance.setUpdatedTime(utcNow); return esInstance; } }
this.lifecycle = instance.getInstanceLifecycle(); this.hypervisor = instance.getHypervisor(); this.az = instance.getPlacement().getAvailabilityZone(); this.group = instance.getPlacement().getGroupName(); this.tenancy = instance.getPlacement().getTenancy();
if (placementPlacement.getAvailabilityZone() != null) { request.addParameter("Placement.AvailabilityZone", StringUtils.fromString(placementPlacement.getAvailabilityZone()));