if (getState() != null) sb.append("State: ").append(getState()).append(","); if (getVolumeId() != null) sb.append("VolumeId: ").append(getVolumeId()).append(","); if (getIops() != null) sb.append("Iops: ").append(getIops()).append(",");
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getAttachments() == null) ? 0 : getAttachments().hashCode()); hashCode = prime * hashCode + ((getAvailabilityZone() == null) ? 0 : getAvailabilityZone().hashCode()); hashCode = prime * hashCode + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode()); hashCode = prime * hashCode + ((getEncrypted() == null) ? 0 : getEncrypted().hashCode()); hashCode = prime * hashCode + ((getKmsKeyId() == null) ? 0 : getKmsKeyId().hashCode()); hashCode = prime * hashCode + ((getSize() == null) ? 0 : getSize().hashCode()); hashCode = prime * hashCode + ((getSnapshotId() == null) ? 0 : getSnapshotId().hashCode()); hashCode = prime * hashCode + ((getState() == null) ? 0 : getState().hashCode()); hashCode = prime * hashCode + ((getVolumeId() == null) ? 0 : getVolumeId().hashCode()); hashCode = prime * hashCode + ((getIops() == null) ? 0 : getIops().hashCode()); hashCode = prime * hashCode + ((getTags() == null) ? 0 : getTags().hashCode()); hashCode = prime * hashCode + ((getVolumeType() == null) ? 0 : getVolumeType().hashCode()); return hashCode; }
if (other.getState() != null && other.getState().equals(this.getState()) == false) return false; if (other.getVolumeId() == null ^ this.getVolumeId() == null) return false; if (other.getVolumeId() != null && other.getVolumeId().equals(this.getVolumeId()) == false) return false; if (other.getIops() == null ^ this.getIops() == null)
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getVolumeId() == null) ? 0 : getVolumeId().hashCode()); hashCode = prime * hashCode + ((getSize() == null) ? 0 : getSize().hashCode()); hashCode = prime * hashCode + ((getSnapshotId() == null) ? 0 : getSnapshotId().hashCode()); hashCode = prime * hashCode + ((getAvailabilityZone() == null) ? 0 : getAvailabilityZone().hashCode()); hashCode = prime * hashCode + ((getState() == null) ? 0 : getState().hashCode()); hashCode = prime * hashCode + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode()); hashCode = prime * hashCode + ((getAttachments() == null) ? 0 : getAttachments().hashCode()); hashCode = prime * hashCode + ((getTags() == null) ? 0 : getTags().hashCode()); hashCode = prime * hashCode + ((getVolumeType() == null) ? 0 : getVolumeType().hashCode()); hashCode = prime * hashCode + ((getIops() == null) ? 0 : getIops().hashCode()); hashCode = prime * hashCode + ((isEncrypted() == null) ? 0 : isEncrypted().hashCode()); hashCode = prime * hashCode + ((getKmsKeyId() == null) ? 0 : getKmsKeyId().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 (getVolumeId() != null) sb.append("VolumeId: " + getVolumeId() + ","); if (getSize() != null) sb.append("Size: " + getSize() + ","); if (getSnapshotId() != null) sb.append("SnapshotId: " + getSnapshotId() + ","); if (getAvailabilityZone() != null) sb.append("AvailabilityZone: " + getAvailabilityZone() + ","); if (getState() != null) sb.append("State: " + getState() + ","); if (getCreateTime() != null) sb.append("CreateTime: " + getCreateTime() + ","); if (getAttachments() != null) sb.append("Attachments: " + getAttachments() + ","); if (getTags() != null) sb.append("Tags: " + getTags() + ","); if (getVolumeType() != null) sb.append("VolumeType: " + getVolumeType() + ","); if (getIops() != null) sb.append("Iops: " + getIops() + ","); if (isEncrypted() != null) sb.append("Encrypted: " + isEncrypted() + ","); if (getKmsKeyId() != null) sb.append("KmsKeyId: " + getKmsKeyId() ); sb.append("}"); return sb.toString(); }
Volume other = (Volume)obj; if (other.getVolumeId() == null ^ this.getVolumeId() == null) return false; if (other.getVolumeId() != null && other.getVolumeId().equals(this.getVolumeId()) == false) return false; if (other.getSize() == null ^ this.getSize() == null) return false; if (other.getSize() != null && other.getSize().equals(this.getSize()) == false) return false;
if (getState() != null) sb.append("State: ").append(getState()).append(","); if (getVolumeId() != null) sb.append("VolumeId: ").append(getVolumeId()).append(","); if (getIops() != null) sb.append("Iops: ").append(getIops()).append(",");
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getAttachments() == null) ? 0 : getAttachments().hashCode()); hashCode = prime * hashCode + ((getAvailabilityZone() == null) ? 0 : getAvailabilityZone().hashCode()); hashCode = prime * hashCode + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode()); hashCode = prime * hashCode + ((getEncrypted() == null) ? 0 : getEncrypted().hashCode()); hashCode = prime * hashCode + ((getKmsKeyId() == null) ? 0 : getKmsKeyId().hashCode()); hashCode = prime * hashCode + ((getSize() == null) ? 0 : getSize().hashCode()); hashCode = prime * hashCode + ((getSnapshotId() == null) ? 0 : getSnapshotId().hashCode()); hashCode = prime * hashCode + ((getState() == null) ? 0 : getState().hashCode()); hashCode = prime * hashCode + ((getVolumeId() == null) ? 0 : getVolumeId().hashCode()); hashCode = prime * hashCode + ((getIops() == null) ? 0 : getIops().hashCode()); hashCode = prime * hashCode + ((getTags() == null) ? 0 : getTags().hashCode()); hashCode = prime * hashCode + ((getVolumeType() == null) ? 0 : getVolumeType().hashCode()); return hashCode; }
/** * * @param availabilityZone - * @param size - size (in Gb) of the volume to be created. Must be larger than snapshot if used * @param snapshotId - optional if you want to create from a snapshot * @param ec2Client * @return volumeId - the id of the newly created volume */ public String createEbsVolume(String availabilityZone, int size, String snapshotId, AmazonEC2 ec2Client) { CreateVolumeRequest request = new CreateVolumeRequest() .withAvailabilityZone(availabilityZone) .withSize(size); // Only create from a snapshot if the snapshotId is not null, otherwise make new volume if (snapshotId != null && !snapshotId.equals("")) { request = request.withSnapshotId(snapshotId); } CreateVolumeResult result = ec2Client.createVolume(request); String volumeId = result.getVolume().getVolumeId(); return volumeId; }
DescribeVolumesRequest dvs = new DescribeVolumesRequest(); ArrayList<String> volumeIds = new ArrayList<String>(); volumeIds.add(createVolumeResult.getVolume().getVolumeId()); DescribeVolumesResult dvsresult = ec2.describeVolumes(dvs); running = "available".equals(dvsresult.getVolumes().get(0).getState()); .withInstanceId(instanceId) .withDevice("/dev/sda2") .withVolumeId(createVolumeResult.getVolume().getVolumeId());
if (other.getState() != null && other.getState().equals(this.getState()) == false) return false; if (other.getVolumeId() == null ^ this.getVolumeId() == null) return false; if (other.getVolumeId() != null && other.getVolumeId().equals(this.getVolumeId()) == false) return false; if (other.getIops() == null ^ this.getIops() == null)
@Override public String createVolume(CreateVolumeRequest request) { checkNotNull(request, "request"); com.amazonaws.services.ec2.model.CreateVolumeRequest cvr = new com.amazonaws.services.ec2.model.CreateVolumeRequest(); cvr.setAvailabilityZone(request.getZone()); cvr.setSize(request.getSize()); cvr.setVolumeType(request.getType()); String volumeId = client.createVolume(cvr).getVolume().getVolumeId(); return waitForVolumeState(volumeId, request.getRequiredState(), request.getTimeout()); }