Package org.apache.curator.framework.recipes.locks

Examples of org.apache.curator.framework.recipes.locks.InterProcessSemaphoreMutex


    public OptionalLockProjection acquireLock(CuratorProjection projection, final String path, int maxWaitMs) throws RpcException
    {
        try
        {
            CuratorEntry entry = CuratorEntry.mustGetEntry(connectionManager, projection);
            final InterProcessSemaphoreMutex lock = new InterProcessSemaphoreMutex(entry.getClient(), path);
            if ( !lock.acquire(maxWaitMs, TimeUnit.MILLISECONDS) )
            {
                return new OptionalLockProjection();
            }

            Closer closer = new Closer()
            {
                @Override
                public void close()
                {
                    if ( lock.isAcquiredInThisProcess() )
                    {
                        try
                        {
                            lock.release();
                        }
                        catch ( Exception e )
                        {
                            log.error("Could not release left-over lock for path: " + path, e);
                        }
View Full Code Here

TOP

Related Classes of org.apache.curator.framework.recipes.locks.InterProcessSemaphoreMutex

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.