示例#1
0
 protected void handleSignalRequest(Request req) {
   Lock lock = _getLock(req.lock_name);
   lock.lock();
   try {
     ServerLock server_lock = server_locks.get(req.lock_name);
     if (server_lock != null) server_lock.handleRequest(req);
     else
       log.error(
           "Condition signal was received but lock was not created.  Couldn't notify anyone.");
   } finally {
     lock.unlock();
   }
 }
示例#2
0
 protected void handleDeleteLockRequest(String lock_name) {
   Lock lock = _getLock(lock_name);
   lock.lock();
   try {
     ServerLock server_lock = server_locks.get(lock_name);
     if (server_lock == null) return;
     synchronized (server_lock.condition) {
       if (server_lock.condition.queue.isEmpty()) server_locks.remove(lock_name);
       else server_lock.current_owner = null;
     }
   } finally {
     lock.unlock();
   }
 }
示例#3
0
 protected void handleView(View view) {
   this.view = view;
   if (log.isDebugEnabled()) log.debug("view=" + view);
   List<Address> members = view.getMembers();
   for (Map.Entry<String, ServerLock> entry : server_locks.entrySet()) {
     String lock_name = entry.getKey();
     ServerLock server_lock = entry.getValue();
     Lock lock = _getLock(lock_name);
     lock.lock();
     try {
       server_lock.handleView(members);
       if (server_lock.isEmpty()
           && server_lock.current_owner == null
           && server_lock.condition.queue.isEmpty()) server_locks.remove(lock_name);
     } finally {
       lock.unlock();
     }
   }
 }
示例#4
0
 protected void handleLockRequest(Request req) {
   Lock lock = _getLock(req.lock_name);
   lock.lock();
   try {
     ServerLock server_lock = server_locks.get(req.lock_name);
     if (server_lock == null) {
       server_lock = new ServerLock(req.lock_name);
       ServerLock tmp = server_locks.putIfAbsent(req.lock_name, server_lock);
       if (tmp != null) server_lock = tmp;
       else {
         notifyLockCreated(req.lock_name);
       }
     }
     server_lock.handleRequest(req);
     if (server_lock.isEmpty()
         && server_lock.current_owner == null
         && server_lock.condition.queue.isEmpty()) {
       server_locks.remove(req.lock_name);
     }
   } finally {
     lock.unlock();
   }
 }