cloudstack-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mike Tutkowski <mike.tutkow...@solidfire.com>
Subject [QUESTION] Locking versus State Transitioning
Date Tue, 13 Jan 2015 20:34:49 GMT
Hi,

I noticed while examining the code to take a volume snapshot that
XenserverSnapshotStrategy does the following:

        SnapshotVO snapshotVO = snapshotDao
.acquireInLockTable(snapshot.getId());

        if (snapshotVO == null) {

            throw new CloudRuntimeException("Failed to get lock on
snapshot:" + snapshot.getId());

        }


        try {

            VolumeInfo volumeInfo = snapshot.getBaseVolume();

            volumeInfo.stateTransit(Volume.Event.SnapshotRequested);

            SnapshotResult result = null;

            try {

                result = snapshotSvr.takeSnapshot(snapshot);

                if (result.isFailed()) {

                    s_logger.debug("Failed to take snapshot: " +
result.getResult());

                    throw new CloudRuntimeException(result.getResult());

                }

            } finally {

                if (result != null && result.isSuccess()) {

                    volumeInfo.stateTransit(Volume.Event.OperationSucceeded
);

                } else {

                    volumeInfo.stateTransit(Volume.Event.OperationFailed);

                }

            }

Is there a reason here why the code acquires a lock on the snapshot instead
of performing a state transition (say, Allocated to Creating)?

We can see in the same code block that we use a state transition to protect
the volume.

Thanks!

-- 
*Mike Tutkowski*
*Senior CloudStack Developer, SolidFire Inc.*
e: mike.tutkowski@solidfire.com
o: 303.746.7302
Advancing the way the world uses the cloud
<http://solidfire.com/solution/overview/?video=play>*™*

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message