Package com.deftlabs.lock.mongo

Examples of com.deftlabs.lock.mongo.DistributedLock


        @Override
        public void run() {
            while (_running) {
                try {
                    for (final String lockName : _locks.keySet()) {
                        final DistributedLock lock = _locks.get(lockName);

                        final ObjectId lockId = lock.getLockId();

                        if (!lock.isLocked() || lockId == null) continue;

                        LockDao.heartbeat(_mongo, lockName, lockId, lock.getOptions(), _svcOptions);
                    }

                    Thread.sleep(HEARTBEAT_FREQUENCY);
                } catch (final InterruptedException ie) { break;
                } catch (final Throwable t) {
View Full Code Here


        @Override
        public void run() {
            while (_running) {
                try {
                    for (final String lockName : _locks.keySet()) {
                        final DistributedLock lock = _locks.get(lockName);

                        if (lock.isLocked()) continue;

                        // Check to see if this is locked.
                        if (LockDao.isLocked(_mongo, lockName, _svcOptions)) continue;

                        // The lock is not locked, wakeup any blocking threads.
                        lock.wakeupBlocked();
                    }

                    Thread.sleep(FREQUENCY);
                } catch (final InterruptedException ie) { break;
                } catch (final Throwable t) {
View Full Code Here

        try {
            _lock.lock();

            // Interrupt the locks.
            for (final String lockName : _locks.keySet()) {
                final DistributedLock lock = _locks.get(lockName);
                if (lock == null) continue;

                ((LockImpl)lock).destroy();
            }
View Full Code Here

    static class LockHeartbeat implements Runnable {
        @Override public void run() {
            while (_running) {
                try {
                    for (final String lockName : _locks.keySet()) {
                        final DistributedLock lock = _locks.get(lockName);

                        final ObjectId lockId = lock.getLockId();

                        if (!lock.isLocked() || lockId == null) continue;

                        LockDao.heartbeat(_mongo, lockName, lockId, lock.getOptions(), _svcOptions);
                    }

                    Thread.sleep(HEARTBEAT_FREQUENCY);

                } catch (final InterruptedException ie) { break;
View Full Code Here

    static class LockUnlocked implements Runnable {
        @Override public void run() {
            while (_running) {
                try {
                    for (final String lockName : _locks.keySet()) {
                        final DistributedLock lock = _locks.get(lockName);

                        if (lock.isLocked()) continue;

                        // Check to see if this is locked.
                        if (LockDao.isLocked(_mongo, lockName, _svcOptions)) continue;

                        // The lock is not locked, wakeup any blocking threads.
                        lock.wakeupBlocked();
                    }

                    Thread.sleep(FREQUENCY);
                } catch (final InterruptedException ie) { break;
                } catch (final Throwable t) { LOG.log(Level.SEVERE, t.getMessage(), t); }
View Full Code Here

        try {
            _lock.lock();

            // Interrupt the locks.
            for (final String lockName : _locks.keySet()) {
                final DistributedLock lock = _locks.get(lockName);
                if (lock == null) continue;

                ((LockImpl)lock).destroy();
            }
View Full Code Here

        @Override
        public void run() {
            while (_running) {
                try {
                    for (final String lockName : _locks.keySet()) {
                        final DistributedLock lock = _locks.get(lockName);

                        final ObjectId lockId = lock.getLockId();

                        if (!lock.isLocked() || lockId == null) continue;

                        LockDao.heartbeat(_mongo, lockName, lockId, lock.getOptions(), _svcOptions);
                    }

                    Thread.sleep(HEARTBEAT_FREQUENCY);
                } catch (final InterruptedException ie) { break;
                } catch (final Throwable t) {
View Full Code Here

        _lock.lock();
        try {
            // Interrupt the locks.
            for (final String lockName : _locks.keySet()) {
                final DistributedLock lock = _locks.get(lockName);
                if (lock == null) continue;
                ((LockImpl)lock).destroy();
            }

            _lockTimeout.shutdown();
View Full Code Here

        }

        @Override
        boolean monitor() throws InterruptedException {
            for (final String lockName : _locks.keySet()) {
                final DistributedLock lock = _locks.get(lockName);

                final ObjectId lockId = lock.getLockId();

                if (!lock.isLocked() || lockId == null) continue;

                LockDao.heartbeat(_mongo, lockName, lockId, lock.getOptions(), _svcOptions);
            }

            return _shutdown.await(_svcOptions.getHeartbeatFrequency(), TimeUnit.MILLISECONDS);
        }
View Full Code Here

        }

        @Override
        boolean monitor() throws InterruptedException {
            for (final String lockName : _locks.keySet()) {
                final DistributedLock lock = _locks.get(lockName);

                if (lock.isLocked()) continue;

                // Check to see if this is locked.
                if (LockDao.isLocked(_mongo, lockName, _svcOptions)) continue;

                // The lock is not locked, wakeup any blocking threads.
                lock.wakeupBlocked();
            }

            return _shutdown.await(_svcOptions.getLockUnlockedFrequency(), TimeUnit.MILLISECONDS);
        }
View Full Code Here

TOP

Related Classes of com.deftlabs.lock.mongo.DistributedLock

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.