List of usage examples for com.amazonaws.services.ec2.model DetachVolumeRequest setForce
public void setForce(Boolean force)
Forces detachment if the previous detachment attempt did not occur cleanly (for example, logging into an instance, unmounting the volume, and detaching normally).
From source file:com.netflix.simianarmy.client.aws.AWSClient.java
License:Apache License
@Override public void detachVolume(String instanceId, String volumeId, boolean force) { Validate.notEmpty(instanceId);//from w ww . j a v a2s. c o m LOGGER.info(String.format("Detach volumes from instance %s in region %s.", instanceId, region)); try { DetachVolumeRequest detachVolumeRequest = new DetachVolumeRequest(); detachVolumeRequest.setForce(force); detachVolumeRequest.setInstanceId(instanceId); detachVolumeRequest.setVolumeId(volumeId); ec2Client().detachVolume(detachVolumeRequest); } catch (AmazonServiceException e) { if (e.getErrorCode().equals("InvalidInstanceID.NotFound")) { throw new NotFoundException("AWS instance " + instanceId + " not found", e); } throw e; } }