cloudstack-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mike Tutkowski <mike.tutkow...@solidfire.com>
Subject Re: Database locking code
Date Thu, 29 Jan 2015 14:27:23 GMT
Does this work for you?

            GlobalLock lock = GlobalLock.getInternLock(
someStringYouMadeUpThatIsUniqueForThisPurpose);

            try {

                if (!lock.lock(timeoutInSeconds)) {

                    s_logger.debug("Couldn't lock the db on the string " +
someStringYouMadeUpThatIsUniqueForThisPurpose);

                    throw new CloudRuntimeException("Couldn't acquire DB
lock");

                }

                // do your work

            }

            finally {

                lock.unlock();

                lock.releaseRef();

            }

On Thu, Jan 29, 2015 at 3:32 AM, Jeff Hair <jeff@greenqloud.com> wrote:

> I have some code I've added to CloudStack that I am currently
> synchronizing on in the traditional manner (synchronized block,
> ExecutorService, etc). I'm currently running a single instance of
> CloudStack so I don't have to deal with clustering.
>
> I've read the Data Access Layer documentation and am wondering if the
> database locks are the actual appropriate solution rather than what
> I'm doing.
>
> Basically my issue is that I need to lock access to an IP address
> reserved to the account and perform some long operations on it. I also
> need to guarantee that no other IPs on the account are manipulated
> while performing this task. Synchronization accomplishes this because
> I can force the IP operations through an ExecutorService, but I'm
> really looking for a better solution that will also work with
> clustered management servers.
>
> Thanks,
>
> Jeff
>



-- 
*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