@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getState() == null) ? 0 : getState().hashCode()); hashCode = prime * hashCode + ((getMessages() == null) ? 0 : getMessages().hashCode()); hashCode = prime * hashCode + ((getRegionName() == null) ? 0 : getRegionName().hashCode()); hashCode = prime * hashCode + ((getZoneName() == null) ? 0 : getZoneName().hashCode()); hashCode = prime * hashCode + ((getZoneId() == null) ? 0 : getZoneId().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 (getState() != null) sb.append("State: ").append(getState()).append(","); if (getMessages() != null) sb.append("Messages: ").append(getMessages()).append(","); if (getRegionName() != null) sb.append("RegionName: ").append(getRegionName()).append(","); if (getZoneName() != null) sb.append("ZoneName: ").append(getZoneName()).append(","); if (getZoneId() != null) sb.append("ZoneId: ").append(getZoneId()); sb.append("}"); return sb.toString(); }
@Override public List<String> getDefaultRacks() { // Get the fist 3 available zones in the region AmazonEC2 client = AmazonEC2ClientBuilder.standard() .withCredentials(credential.getAwsCredentialProvider()) .withRegion(getRegion()) .build(); DescribeAvailabilityZonesResult res = client.describeAvailabilityZones(); List<String> zone = Lists.newArrayList(); for (AvailabilityZone reg : res.getAvailabilityZones()) { if (reg.getState().equals("available")) zone.add(reg.getZoneName()); if (zone.size() == 3) break; } return ImmutableList.copyOf(zone); }
public static void main(String[] args) { final AmazonEC2 ec2 = AmazonEC2ClientBuilder.defaultClient(); DescribeRegionsResult regions_response = ec2.describeRegions(); for(Region region : regions_response.getRegions()) { System.out.printf( "Found region %s " + "with endpoint %s", region.getRegionName(), region.getEndpoint()); } DescribeAvailabilityZonesResult zones_response = ec2.describeAvailabilityZones(); for(AvailabilityZone zone : zones_response.getAvailabilityZones()) { System.out.printf( "Found availability zone %s " + "with status %s " + "in region %s", zone.getZoneName(), zone.getState(), zone.getRegionName()); } } }
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getZoneName() == null) ? 0 : getZoneName().hashCode()); hashCode = prime * hashCode + ((getState() == null) ? 0 : getState().hashCode()); hashCode = prime * hashCode + ((getRegionName() == null) ? 0 : getRegionName().hashCode()); hashCode = prime * hashCode + ((getMessages() == null) ? 0 : getMessages().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 (getZoneName() != null) sb.append("ZoneName: " + getZoneName() + ","); if (getState() != null) sb.append("State: " + getState() + ","); if (getRegionName() != null) sb.append("RegionName: " + getRegionName() + ","); if (getMessages() != null) sb.append("Messages: " + getMessages() ); sb.append("}"); return sb.toString(); }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof AvailabilityZone == false) return false; AvailabilityZone other = (AvailabilityZone)obj; if (other.getZoneName() == null ^ this.getZoneName() == null) return false; if (other.getZoneName() != null && other.getZoneName().equals(this.getZoneName()) == false) return false; if (other.getState() == null ^ this.getState() == null) return false; if (other.getState() != null && other.getState().equals(this.getState()) == false) return false; if (other.getRegionName() == null ^ this.getRegionName() == null) return false; if (other.getRegionName() != null && other.getRegionName().equals(this.getRegionName()) == false) return false; if (other.getMessages() == null ^ this.getMessages() == null) return false; if (other.getMessages() != null && other.getMessages().equals(this.getMessages()) == false) return false; return true; }
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getState() == null) ? 0 : getState().hashCode()); hashCode = prime * hashCode + ((getMessages() == null) ? 0 : getMessages().hashCode()); hashCode = prime * hashCode + ((getRegionName() == null) ? 0 : getRegionName().hashCode()); hashCode = prime * hashCode + ((getZoneName() == null) ? 0 : getZoneName().hashCode()); hashCode = prime * hashCode + ((getZoneId() == null) ? 0 : getZoneId().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 (getState() != null) sb.append("State: ").append(getState()).append(","); if (getMessages() != null) sb.append("Messages: ").append(getMessages()).append(","); if (getRegionName() != null) sb.append("RegionName: ").append(getRegionName()).append(","); if (getZoneName() != null) sb.append("ZoneName: ").append(getZoneName()).append(","); if (getZoneId() != null) sb.append("ZoneId: ").append(getZoneId()); sb.append("}"); return sb.toString(); }
/** * Get the fist 3 available zones in the region */ public void setDefaultRACList(String region){ AmazonEC2 client = new AmazonEC2Client(provider.getAwsCredentialProvider()); client.setEndpoint("ec2." + region + ".amazonaws.com"); DescribeAvailabilityZonesResult res = client.describeAvailabilityZones(); List<String> zone = Lists.newArrayList(); for(AvailabilityZone reg : res.getAvailabilityZones()){ if( reg.getState().equals("available") ) zone.add(reg.getZoneName()); if( zone.size() == 3) break; } // DEFAULT_AVAILABILITY_ZONES = StringUtils.join(zone, ","); DEFAULT_AVAILABILITY_ZONES = ImmutableList.copyOf(zone); }