Examples of DistributedLock


Examples of com.deftlabs.lock.mongo.DistributedLock

        _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

Examples of com.deftlabs.lock.mongo.DistributedLock

        }

        @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

Examples of com.deftlabs.lock.mongo.DistributedLock

        }

        @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

Examples of com.foreach.common.concurrent.locks.distributed.DistributedLock

      ExecutorService fixedThreadPool = Executors.newFixedThreadPool( 50 );

      List<Executor> executors = new ArrayList<>( LOCKS_PER_BATCH * EXECUTORS_PER_LOCK );

      for ( int i = 0; i < LOCKS_PER_BATCH; i++ ) {
        DistributedLock lock = distributedLockRepository.getLock( "batch-lock-" + i );

        for ( int j = 0; j < EXECUTORS_PER_LOCK; j++ ) {
          executors.add( new Executor( lock, 10 ) );
        }
      }
View Full Code Here

Examples of com.foreach.common.concurrent.locks.distributed.DistributedLock

  public BootstrapLockManager( AcrossContextInfo contextInfo ) {
    this.contextInfo = contextInfo;
  }

  public void ensureLocked() {
    DistributedLock lock = loadLock();

    if ( !lock.isHeldByCurrentThread() ) {
      LOG.debug( "Acquiring Across bootstrap lock, owner id: {}", lock.getOwnerId() );

      long lockStartTime = System.currentTimeMillis();
      lock.lock();

      LOG.info( "Across bootstrap lock acquired by {} in {} ms", lock.getOwnerId(),
                System.currentTimeMillis() - lockStartTime );
    }
  }
View Full Code Here

Examples of com.twitter.common.zookeeper.DistributedLock

        return result;
    }

    public void lock(String lockPath) {
        assert mLocks.get(lockPath) == null: "mLocks.get(" + lockPath + ") == null";
        DistributedLock distributedLock = new DistributedLockImpl(mZookeeperClient, lockPath);
        mLocks.put(lockPath, distributedLock);
        distributedLock.lock();
    }
View Full Code Here

Examples of com.twitter.common.zookeeper.DistributedLock

        mLocks.put(lockPath, distributedLock);
        distributedLock.lock();
    }

    public void unlock(String lockPath) {
        DistributedLock distributedLock = mLocks.get(lockPath);
        assert distributedLock != null: "mLocks.get(" + lockPath + ") != null";
        distributedLock.unlock();
        mLocks.remove(lockPath);
    }
View Full Code Here

Examples of uk.org.microbase.util.DistributedLock

  }

  public MessageDAO(DB db, String collectionName)
  {
    super(db, collectionName);
    this.lock = new DistributedLock(LOCK_NAME);
  }
View Full Code Here

Examples of uk.org.microbase.util.DistributedLock

  private final BlockingQueue<Message> jobQueue;

  public JobQueue(String queueName)
  {
    jobQueue = Hazelcast.getQueue(queueName+QUEUE_NAME_SUFFIX);
    this.lock = new DistributedLock(LOCK_NAME);
  }
View Full Code Here

Examples of uk.org.microbase.util.DistributedLock

  public ActiveProcessDAO()
  {
    pidToProcessInfo = Hazelcast.getMultiMap(HC_MULTI_MAP_PROCESSES);

    lock = new DistributedLock(LOCK_NAME);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.