Package org.olat.core.util.coordinate

Examples of org.olat.core.util.coordinate.LockEntry


        LockResultImpl lres;
        LockImpl li = cm.findLock(asset);
        if (li == null) { // fine, we can lock it
          li = cm.createLockImpl(asset, requestor);
          cm.saveLock(li);
          LockEntry le = new LockEntry(li.getAsset(), li.getCreationDate().getTime(), li.getOwner());
          lres = new LockResultImpl(true, le);
        } else {
          // already locked by a user.
          // if that user is us, we can reacquire it
          LockEntry le = new LockEntry(li.getAsset(), li.getCreationDate().getTime(), li.getOwner());
          if (requestor.getName().equals(li.getOwner().getName())) {
            // that's us -> success (asset, owner is the same, and we leave creationdate to when the lock was originally acquired, not when it was reacquired.
            lres = new LockResultImpl(true, le);       
          } else {
            lres = new LockResultImpl(false, le);
View Full Code Here


    // if the lock has not been acquired, then nothing is to be released -
    // return silently to make cleaning up easier
    if (!lockResult.isSuccess()) {
      return;
    }
    LockEntry le = ((LockResultImpl) lockResult).getLockEntry();
   
    String asset = le.getKey();
    Identity releaseRequestor = le.getOwner();
   
    final ClusterLockManager cm = ClusterLockManager.getInstance();
   
    // cluster:: change to useage with syncer, but we don't have the olatresourceable yet
    PessimisticLockManager.getInstance().findOrPersistPLock(asset);
View Full Code Here

  public List<LockEntry> adminOnlyGetLockEntries() {
    ClusterLockManager cm = ClusterLockManager.getInstance();
    List<LockImpl> li = cm.getAllLocks();
    List<LockEntry> res = new ArrayList<LockEntry>(li.size());
    for (LockImpl impl : li) {
      res.add(new LockEntry(impl.getAsset(), impl.getCreationDate().getTime(), impl.getOwner()));
    }
    return res;
  }
View Full Code Here

      // FIXME:fj:c find a better way to retrieve information about the
      // lock-holder
      lockOwner = ManagerFactory.getManager().loadIdentityByKey(lockOwnerKey);
    }
   
    LockEntry le = new LockEntry(derivedLockString, aqTime, lockOwner);
    lres = new LockResultImpl(success, le);
    return lres;
   
  }
View Full Code Here

    // if the lock has not been acquired, then nothing is to be released -
    // return silently to make cleaning up easier
    if (!lockResult.isSuccess()) {
      return;
    }
    LockEntry le = ((LockResultImpl) lockResult).getLockEntry();
    releaseLock(le);
  }
View Full Code Here

   */
  private LockResult acquireLock(String key, Identity identity) {
    LockResult lockResult;
    boolean logDebug = log.isDebug();
    synchronized (locks) { //o_clusterOK by:fj, by definition we are in singleVM mode
      LockEntry oldLockEntry = locks.get(key);
      if (oldLockEntry == null || identity.getName().equals(oldLockEntry.getOwner().getName())) {
        // no one has the lock aquired yet - or user reacquired its own
        // lock (e.g. in case of browser crash or such)
        LockEntry lockEntry = new LockEntry(key, System.currentTimeMillis(), identity);
        locks.put(key, lockEntry);
        lockResult = new LockResultImpl(true, lockEntry);
        if (logDebug) {
          String msg;
          if (oldLockEntry == null) {
View Full Code Here

      // release all locks hold by the identity that has just logged out.
      synchronized (locks) { //o_clusterOK by:fj, by definition we are in singleVM mode
        for (Iterator<Entry<String, LockEntry>> iter = locks.entrySet().iterator(); iter.hasNext();) {
          Map.Entry<String, LockEntry> entry = iter.next();
          String key = entry.getKey();
          LockEntry le = entry.getValue();
          Identity owner = le.getOwner();
          if (owner.getName().equals(name)) {
            iter.remove();
            log.audit("identity '" + name + "' signed off and thus released lock on " + key);
          }
        }
View Full Code Here

    DBFactory.getInstance().closeSession();

    // test the admin
    List<LockEntry> entries = cl.adminOnlyGetLockEntries();
    assertEquals(1, entries.size());
    LockEntry le = entries.get(0);
    // must be original owner
    assertEquals(le.getOwner().getName(), ident.getName());

    // release lock
    cl.releaseLock(res3);
    DBFactory.getInstance().closeSession();
    // test the admin
View Full Code Here

TOP

Related Classes of org.olat.core.util.coordinate.LockEntry

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.