com.threerings.presents.peer.server
Class PeerManager.LockHandler

java.lang.Object
  extended by com.threerings.presents.peer.server.PeerManager.LockHandler
Enclosing class:
PeerManager

protected class PeerManager.LockHandler
extends Object

Handles a lock in a state of resolution.


Field Summary
protected  boolean _acquire
           
protected  NodeObject.Lock _lock
           
protected  PeerNode _peer
           
protected  ArrayIntSet _remoids
           
protected  long _startStamp
           
protected  Interval _timeout
           
 ResultListenerList<String> listeners
          Listeners waiting for resolution.
 
Constructor Summary
PeerManager.LockHandler(NodeObject.Lock lock, boolean acquire, ResultListener<String> listener)
          Creates a handler to acquire or release a lock for this node.
PeerManager.LockHandler(PeerNode peer, NodeObject.Lock lock, boolean acquire)
          Creates a handle that tracks another node's acquisition or release of a lock.
 
Method Summary
protected  void activate()
          Performs the configured action.
 void cancel()
          Cancels this handler, as another one will be taking its place.
 void clientUnsubscribed(int cloid)
          Called when a client has unsubscribed from this node (which is waiting for ratification).
 String getNodeName()
          Returns the name of the node waiting to perform the action.
 boolean isAcquiring()
          Checks whether we are acquiring as opposed to releasing a lock.
protected  void maybeActivate()
          Performs the action if all remote nodes have ratified.
 void peerAddedLock(String nodeName)
          Called to notify us that a node has added the lock.
 void peerRemovedLock(String nodeName)
          Called to notify us that a node has removed the lock.
 void peerUpdatedLock(String nodeName)
          Called to notify us that a node has updated the lock.
 void ratify(ClientObject caller, boolean acquire)
          Signals that one of the remote nodes has ratified the pending action.
 String toString()
           
protected  void wasActivated(String owner)
          Called when the remote node has performed its action.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

listeners

public ResultListenerList<String> listeners
Listeners waiting for resolution.


_peer

protected PeerNode _peer

_lock

protected NodeObject.Lock _lock

_acquire

protected boolean _acquire

_remoids

protected ArrayIntSet _remoids

_timeout

protected Interval _timeout

_startStamp

protected long _startStamp
Constructor Detail

PeerManager.LockHandler

public PeerManager.LockHandler(NodeObject.Lock lock,
                               boolean acquire,
                               ResultListener<String> listener)
Creates a handler to acquire or release a lock for this node.


PeerManager.LockHandler

public PeerManager.LockHandler(PeerNode peer,
                               NodeObject.Lock lock,
                               boolean acquire)
Creates a handle that tracks another node's acquisition or release of a lock.

Method Detail

getNodeName

public String getNodeName()
Returns the name of the node waiting to perform the action.


isAcquiring

public boolean isAcquiring()
Checks whether we are acquiring as opposed to releasing a lock.


ratify

public void ratify(ClientObject caller,
                   boolean acquire)
Signals that one of the remote nodes has ratified the pending action.


clientUnsubscribed

public void clientUnsubscribed(int cloid)
Called when a client has unsubscribed from this node (which is waiting for ratification).


peerAddedLock

public void peerAddedLock(String nodeName)
Called to notify us that a node has added the lock.


peerUpdatedLock

public void peerUpdatedLock(String nodeName)
Called to notify us that a node has updated the lock.


peerRemovedLock

public void peerRemovedLock(String nodeName)
Called to notify us that a node has removed the lock.


cancel

public void cancel()
Cancels this handler, as another one will be taking its place.


toString

public String toString()
Overrides:
toString in class Object

maybeActivate

protected void maybeActivate()
Performs the action if all remote nodes have ratified.


activate

protected void activate()
Performs the configured action.


wasActivated

protected void wasActivated(String owner)
Called when the remote node has performed its action.