示例#1
0
 /**
  * receives all sign on / sign off events so it can release locks of users which have or are
  * logged off
  */
 @Override
 public void event(final Event event) {
   final SignOnOffEvent se = (SignOnOffEvent) event;
   if (!se.isSignOn() && se.isEventOnThisNode()) {
     // it is a "logout" event - we are only interested in logout events
     // and it is from our VM => only release all locks from within one
     // VM
     final String identName = se.getIdentityName();
     // release all locks held by the identity that has just logged out.
     // (assuming one user has only one session (logged in with one
     // browser only): otherwise (as in singlevm, too)
     // since the lock is reentrant, a lock could be freed while a
     // session still is in a locked workflow (2x lock and then once
     // freed)
     try {
       clusterLockManager.releaseAllLocksFor(identName);
     } catch (final DBRuntimeException dbEx) {
       log.warn(
           "releaseAllLocksFor failed, close session and try it again for identName=" + identName);
       // TODO: 2010-04-23 Transactions [eglis]: OLAT-4318: this
       // rollback has possibly unwanted
       // side effects, as it rolls back any changes with this
       // transaction during this
       // event handling. Nicer would be to be done in the
       // outmost-possible place, e.g. dofire()
       DBFactory.getInstance().rollbackAndCloseSession();
       // try again with new db-session
       log.info("try again to release all locks for identName=" + identName);
       clusterLockManager.releaseAllLocksFor(identName);
       log.info("Done, released all locks for identName=" + identName);
     }
   }
 }
示例#2
0
 /**
  * Delete any locks hold by this principal.
  *
  * @param principal
  */
 public void releaseAllLocksForPrincipal(OLATPrincipal principal) {
   try {
     clusterLockManager.releaseAllLocksFor(principal.getName());
     log.info(
         "Done, released all locks managed by the clusterLockManager for identName="
             + principal.getName());
   } catch (Exception e) {
     log.warn("releaseAllLocksFor failed, for identName=" + principal.getName());
   }
   try {
     this.getPersistentLockManager().releaseAllLocksForPrincipal(principal);
     log.info(
         "Done, released all locks managed by the PersistentLockManager for identName="
             + principal.getName());
   } catch (Exception e) {
     log.warn("releaseAllLocksForPrincipal failed, for identName=" + principal.getName());
   }
 }