protected LockInfoResponse createLockInfoResponse() { LockInfoResponse rsp=new LockInfoResponse(); List<Tuple<String,Owner>> locks=client_lock_table.getLockInfo(); // successfully acquired locks for(Tuple<String,Owner> t: locks) rsp.add(t); List<Request> pending_reqs=client_lock_table.getPendingRequests(local_addr); // pending lock/unlock requests if(pending_reqs != null && !pending_reqs.isEmpty()) rsp.pending_requests=pending_reqs; return rsp; }
@ManagedOperation(description="Dumps all locks") public String printLocks() { StringBuilder sb=new StringBuilder(); Collection<ServerLock> values=server_locks.values(); if(values != null && !values.isEmpty()) { sb.append("server locks: "); for(ServerLock sl : server_locks.values()) sb.append(sl).append("\n"); } String client_locks=client_lock_table.printLocks(); if(client_locks != null && !client_locks.isEmpty()) sb.append("my locks: ").append(client_lock_table.printLocks()); return sb.toString(); }
protected synchronized void _unlockOK() { acquired=denied=false; notifyAll(); if(client_lock_table.removeClientLock(name,owner)) notifyLockDeleted(name); owner=null; }
public void handleView(View view) { super.handleView(view); Address old_coord=coord; if(view.size() > 0) { coord=view.getCoord(); is_coord=coord.equals(local_addr); log.debug("[%s] coord=%s, is_coord=%b", local_addr, coord, is_coord); } if(is_coord && num_backups > 0) { List<Address> new_backups=Util.pickNext(view.getMembers(), local_addr, num_backups); List<Address> copy_locks_list=null; synchronized(backups) { if(!backups.equals(new_backups)) { copy_locks_list=new ArrayList<>(new_backups); copy_locks_list.removeAll(backups); backups.clear(); backups.addAll(new_backups); } } if(copy_locks_list != null && !copy_locks_list.isEmpty()) copyLocksTo(copy_locks_list); } // For all non-acquired client locks, send the GRANT_LOCK request to the new coordinator (if changed) if(old_coord != null && !old_coord.equals(coord)) client_lock_table.resendPendingLockRequests(); }
@ManagedAttribute(description="Number of client locks") public int getNumClientLocks() {return client_lock_table.numLocks();}
protected synchronized void _unlock(boolean force) { if(!acquired && !denied && !force) return; this.timeout=0; this.is_trylock=false; if(!denied) { if(!force) client_lock_table.addToPendingReleaseRequests(this); sendReleaseLockRequest(name, lock_id, owner); // lock will be released on RELEASE_LOCK_OK response if(force && client_lock_table.removeClientLock(name,owner)) notifyLockDeleted(name); } else _unlockOK(); }
protected ClientLock getLock(String name) { return client_lock_table.getLock(name,getOwner(),true); }
@ManagedOperation(description="Dumps all locks") public String printLocks() { StringBuilder sb=new StringBuilder(); Collection<ServerLock> values=server_locks.values(); if(values != null && !values.isEmpty()) { sb.append("server locks: "); for(ServerLock sl : server_locks.values()) sb.append(sl).append("\n"); } String client_locks=client_lock_table.printLocks(); if(client_locks != null && !client_locks.isEmpty()) sb.append("my locks: ").append(client_lock_table.printLocks()); return sb.toString(); }
protected ClientLock getLock(String name, boolean create_if_absent) { return client_lock_table.getLock(name,getOwner(),create_if_absent); }
@ManagedOperation(description="Forcefully removes the client lock") public void unlockForce(String lock_name) { client_lock_table.unlockForce(lock_name); }
@ManagedOperation(description="Unlocks all currently held locks") public void unlockAll() { client_lock_table.unlockAll(); }
protected void handleLockReleasedResponse(String lock_name, int lock_id, Owner owner) { ClientLock lock=client_lock_table.getLock(lock_name,owner,false); if(lock != null) lock.handleLockReleasedResponse(lock_id); }
protected void handleLockGrantedResponse(String lock_name, int lock_id, Owner owner) { ClientLock lock=client_lock_table.getLock(lock_name,owner,false); if(lock != null) lock.handleLockGrantedResponse(lock_id); }
protected synchronized void _unlockOK() { acquired=denied=false; notifyAll(); if(client_lock_table.removeClientLock(name,owner)) notifyLockDeleted(name); owner=null; }
protected void handleLockDeniedResponse(String lock_name, int lock_id, Owner owner) { ClientLock lock=client_lock_table.getLock(lock_name,owner,false); if(lock != null) lock.lockDenied(lock_id); }
protected LockInfoResponse createLockInfoResponse() { LockInfoResponse rsp=new LockInfoResponse(); List<Tuple<String,Owner>> locks=client_lock_table.getLockInfo(); // successfully acquired locks for(Tuple<String,Owner> t: locks) rsp.add(t); List<Request> pending_reqs=client_lock_table.getPendingRequests(local_addr); // pending lock/unlock requests if(pending_reqs != null && !pending_reqs.isEmpty()) rsp.pending_requests=pending_reqs; return rsp; }
protected void handleSignalResponse(String lock_name, Owner owner) { ClientLock lock=client_lock_table.getLock(lock_name,owner,false); if(lock != null) { lock.condition.signaled(); } else { log.error(Util.getMessage("ConditionResponseWasClientLockWasNotPresentIgnoredSignal")); } }
public void handleView(View view) { super.handleView(view); Address old_coord=coord; if(view.size() > 0) { coord=view.getCoord(); is_coord=coord.equals(local_addr); log.debug("[%s] coord=%s, is_coord=%b", local_addr, coord, is_coord); } if(is_coord && num_backups > 0) { List<Address> new_backups=Util.pickNext(view.getMembers(), local_addr, num_backups); List<Address> copy_locks_list=null; synchronized(backups) { if(!backups.equals(new_backups)) { copy_locks_list=new ArrayList<>(new_backups); copy_locks_list.removeAll(backups); backups.clear(); backups.addAll(new_backups); } } if(copy_locks_list != null && !copy_locks_list.isEmpty()) copyLocksTo(copy_locks_list); } // For all non-acquired client locks, send the GRANT_LOCK request to the new coordinator (if changed) if(old_coord != null && !old_coord.equals(coord)) client_lock_table.resendPendingLockRequests(); }
@ManagedAttribute(description="Number of client locks") public int getNumClientLocks() {return client_lock_table.numLocks();}
protected synchronized void _unlock(boolean force) { if(!acquired && !denied && !force) return; this.timeout=0; this.is_trylock=false; if(!denied) { if(!force) client_lock_table.addToPendingReleaseRequests(this); sendReleaseLockRequest(name, lock_id, owner); // lock will be released on RELEASE_LOCK_OK response if(force && client_lock_table.removeClientLock(name,owner)) notifyLockDeleted(name); } else _unlockOK(); }