Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ExecutionException;

Expand Down Expand Up @@ -306,6 +308,8 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
private long _maxVolumeSizeInGb;
private final StateMachine2<Volume.State, Volume.Event, Volume> _volStateMachine;

private static final Set<Volume.State> STATES_VOLUME_CANNOT_BE_DESTROYED = new HashSet<>(Arrays.asList(Volume.State.Destroy, Volume.State.Expunging, Volume.State.Expunged, Volume.State.Allocated));

protected VolumeApiServiceImpl() {
_volStateMachine = Volume.State.getStateMachine();
_gson = GsonHelper.getGsonLogger();
Expand Down Expand Up @@ -1451,13 +1455,14 @@ protected VolumeVO retrieveAndValidateVolume(long volumeId, Account caller) {
* <ul>
* <li> {@value Volume.State#Destroy};
* <li> {@value Volume.State#Expunging};
* <li> {@value Volume.State#Expunged}.
* <li> {@value Volume.State#Expunged};
* <li> {@value Volume.State#Allocated}.
* </ul>
*
* The volume is destroyed via {@link VolumeService#destroyVolume(long)} method.
*/
protected void destroyVolumeIfPossible(VolumeVO volume) {
if (volume.getState() != Volume.State.Destroy && volume.getState() != Volume.State.Expunging && volume.getState() != Volume.State.Expunged && volume.getState() != Volume.State.Allocated && volume.getState() != Volume.State.Uploaded) {
if (!STATES_VOLUME_CANNOT_BE_DESTROYED.contains(volume.getState())) {
volService.destroyVolume(volume.getId());
}
}
Expand Down