com.threerings.presents.peer.server
Class PeerManager

java.lang.Object
  extended by com.threerings.presents.peer.server.PeerManager
All Implemented Interfaces:
Lifecycle.BaseComponent, Lifecycle.ShutdownComponent, PeerProvider, ClientManager.ClientObserver, InvocationProvider
Direct Known Subclasses:
CrowdPeerManager

public abstract class PeerManager
extends Object
implements PeerProvider, ClientManager.ClientObserver, Lifecycle.ShutdownComponent

Manages connections to the other nodes in a Presents server cluster. Each server maintains a client connection to the other servers and subscribes to the NodeObject of all peer servers and uses those objects to communicate cross-node information.


Nested Class Summary
static interface PeerManager.DroppedLockObserver
          Used by entities that wish to know when this peer has been forced into immediately releasing a lock.
static interface PeerManager.LockedOperation
          Wraps an operation that needs a shared resource lock to be acquired before it can be performed, and released after it completes.
protected  class PeerManager.LockHandler
          Handles a lock in a state of resolution.
static class PeerManager.NodeAction
          Encapsulates code that is meant to be executed one or more servers.
static interface PeerManager.NodeApplicant
           
static class PeerManager.NodeRequest
          Encapsulates code that is meant to be executed one or more servers and return a result.
protected static class PeerManager.NodeRequestsResultImpl<T>
           
static interface PeerManager.StaleCacheObserver
          Used by entities that wish to know when cached data has become stale due to a change on one of our peer servers.
static class PeerManager.Stats
          Returned by getStats().
 
Field Summary
protected  Map<String,ObserverList<PeerManager.StaleCacheObserver>> _cacheobs
          Our stale cache observers.
protected  ClientManager _clmgr
           
protected  PresentsConnectionManager _conmgr
           
protected  ObserverList<PeerManager.DroppedLockObserver> _dropobs
          Listeners for dropped locks.
protected  com.google.inject.Injector _injector
           
protected  InvocationManager _invmgr
           
protected  Invoker _invoker
           
protected  Map<NodeObject.Lock,PeerManager.LockHandler> _locks
          Locks in the process of resolution.
protected  String _nodeName
           
protected  String _nodeNamespace
           
protected  NodeObject _nodeobj
           
protected  NodeRepository _noderepo
           
protected  PresentsDObjectMgr _omgr
           
protected  Map<String,PeerNode> _peers
           
protected  Map<DObjectAddress,Tuple<Subscriber<?>,DObject>> _proxies
          Contains a mapping of proxied objects to subscriber instances.
protected  ReportManager _repmgr
           
protected  NodeRecord _self
           
protected  String _sharedSecret
           
protected  PeerManager.Stats _stats
          Used to track runtime statistics.
protected  ArrayIntSet _suboids
          The client oids of all peers subscribed to the node object.
protected static long DEFAULT_LOCK_TIMEOUT
          The default lock timeout.
protected static Function<PeerNode,NodeObject> GET_NODE_OBJECT
          Extracts the node object from the supplied peer.
 
Constructor Summary
PeerManager(Lifecycle cycle)
          Creates an uninitialized peer manager.
 
Method Summary
 void acquireLock(NodeObject.Lock lock, ResultListener<String> listener)
          Acquires a lock on a resource shared amongst this node's peers.
 void addDroppedLockObserver(PeerManager.DroppedLockObserver observer)
          Adds an observer to notify when this peer has been forced to drop a lock immediately.
 void addStaleCacheObserver(String cache, PeerManager.StaleCacheObserver observer)
          Registers a stale cache observer.
 void broadcastStaleCacheData(String cache, Streamable data)
          Called when cached data has changed on the local server and needs to inform our peers.
protected  void changedCacheData(String cache, Streamable data)
          Called when possibly cached data has changed on one of our peer servers.
protected  void clearClientInfo(PresentsSession client, ClientInfo info)
          Called when a client ends their session to clear their information from our node object.
protected  void clientLoggedOff(String nodeName, ClientInfo clinfo)
          Called when we hear about a client logging off of another node.
protected  void clientLoggedOn(String nodeName, ClientInfo clinfo)
          Called when we hear about a client logging on to another node.
 void clientSessionDidEnd(PresentsSession client)
          Called when a client has logged off or been forcibly logged off due to inactivity and has thus ended their session.
 void clientSessionDidStart(PresentsSession client)
          Called when a client has authenticated and been resolved and has started their session.
 void clientSubscribedToNode(int cloid)
          Called by PeerSessions when clients subscribe to the NodeObject.
 void clientUnsubscribedFromNode(int cloid)
          Called by PeerSessions when clients unsubscribe from the NodeObject.
protected  void connectedToPeer(PeerNode peer)
          Called when we have established a connection to the supplied peer.
protected  ClientInfo createClientInfo()
          Creates a ClientInfo record which will subsequently be initialized by a call to initClientInfo(com.threerings.presents.server.PresentsSession, com.threerings.presents.peer.data.ClientInfo).
protected  PeerCreds createCreds()
          Creates credentials that a PeerNode can use to authenticate with another node.
protected  PeerManager.LockHandler createLockHandler(PeerNode peer, NodeObject.Lock lock, boolean acquire)
           
protected  NodeObject createNodeObject()
          Creates the appropriate derived class of NodeObject which will be registered with the distributed object system.
protected  void didInit()
          Called after we have finished our initialization.
protected  void disconnectedFromPeer(PeerNode peer)
          Called when a ended our session with the supplied peer.
protected  void droppedLock(NodeObject.Lock lock)
          Called when we have been forced to drop a lock.
 Set<String> findApplicableNodes(PeerManager.NodeApplicant applicant)
          Returns all nodes for which applicant.isApplicable returns true.
protected  byte[] flattenAction(PeerManager.NodeAction action)
          Flattens the supplied node action into bytes.
protected  byte[] flattenRequest(PeerManager.NodeRequest request)
          Flattens the supplied node request into bytes.
 void generateReport(ClientObject caller, String type, InvocationService.ResultListener listener)
          Handles a PeerService.generateReport(java.lang.String, com.threerings.presents.client.InvocationService.ResultListener) request.
protected  PeerManager.LockHandler getLockHandler(NodeObject.Lock lock)
          Returns the lock handler for the specified lock.
protected  long getLockTimeout()
          Returns the amount of time to wait for peer ratification to complete before acquiring/releasing a lock.
 NodeObject getNodeObject()
          Returns the distributed object that represents this node to its peers.
 Iterable<NodeObject> getNodeObjects()
          Returns an iterable over our node object and that of our peers.
 Client getPeerClient(String nodeName)
          Returns the client object representing the connection to the named peer, or null if we are not currently connected to it.
 String getPeerInternalHostName(String nodeName)
          Returns the internal hostname to use when connecting to the specified peer or null if the peer is not currently connected to this server.
protected  Class<? extends PeerNode> getPeerNodeClass()
          Creates a PeerNode to manage our connection to the specified peer.
 NodeObject getPeerNodeObject(String nodeName)
          Returns the NodeObject of the named peer, or null if null if the peer is not currently connected to this server.
 int getPeerPort(String nodeName)
          Returns the port on which to connect to the specified peer or -1 if the peer is not currently connected to this server.
 String getPeerPublicHostName(String nodeName)
          Returns the public hostname to use when connecting to the specified peer or null if the peer is not currently connected to this server.
protected  String getRegion()
          Returns the region in which the local node exists.
 PeerManager.Stats getStats()
          Returns a snapshot of runtime statistics tracked by the peer manager.
protected static boolean hasPriority(String nodeName1, String nodeName2)
          Determines whether the first node named has priority over the second when resolving lock disputes.
protected  boolean ignoreClient(PresentsSession client)
          Returns true if we should ignore the supplied client, false if we should let our other peers know that this client is authenticated with this server.
 void init(String nodeName, String sharedSecret, String hostName, String publicHostName, int port)
          Initializes this peer manager to connect to all other nodes in the NODES table.
 void init(String nodeName, String sharedSecret, String hostName, String publicHostName, int port, String nodeNamespace)
          Initializes this peer manager and initiates the process of connecting to its peer nodes.
 void init(String nodeName, String sharedSecret, String hostName, String publicHostName, String region, int port, String nodeNamespace)
          Initializes this peer manager and initiates the process of connecting to its peer nodes.
protected  void initClientInfo(PresentsSession client, ClientInfo info)
          Initializes the supplied client info for the supplied client.
 void invokeAction(ClientObject caller, byte[] serializedAction)
          Handles a PeerService.invokeAction(byte[]) request.
 void invokeNodeAction(PeerManager.NodeAction action)
          Invokes the supplied action on this and any other server that it indicates is appropriate.
 void invokeNodeAction(PeerManager.NodeAction action, Runnable onDropped)
          Invokes the supplied action on this and any other server that it indicates is appropriate.
 void invokeNodeAction(String nodeName, PeerManager.NodeAction action)
          Invokes a node action on a specific node without executing PeerManager.NodeApplicant.isApplicable(com.threerings.presents.peer.data.NodeObject) to determine whether the action is applicable.
<T> void
invokeNodeRequest(PeerManager.NodeRequest request, NodeRequestsListener<T> listener)
          Invokes the supplied request on all servers in parallel.
protected  void invokeNodeRequest(String nodeName, byte[] requestBytes, InvocationService.ResultListener listener)
           
 void invokeNodeRequest(String nodeName, PeerManager.NodeRequest request, InvocationService.ResultListener listener)
          Invokes a node request on a specific node and returns the result through the listener.
 int invokeOnNodes(Function<Tuple<Client,NodeObject>,Boolean> func)
          Invokes the supplied function on all node objects (except the local node).
 void invokeRequest(ClientObject caller, byte[] serializedAction, InvocationService.ResultListener listener)
          Handles a PeerService.invokeRequest(byte[], com.threerings.presents.client.InvocationService.ResultListener) request.
 boolean isAuthenticPeer(PeerCreds creds)
          Returns true if the supplied peer credentials match our shared secret.
 ClientInfo locateClient(Name key)
          Locates the client with the specified name.
protected  void lockAcquired(NodeObject.Lock lock, long wait, ResultListener<String> listener)
           
protected  void lockReleased(NodeObject.Lock lock, ResultListener<String> listener)
           
<T> T
lookupNodeDatum(Function<NodeObject,T> op)
          Locates a datum from among the set of peer NodeObjects.
protected  void peerAcquiringLock(PeerNode peer, NodeObject.Lock lock)
          Called when a peer announces its intention to acquire a lock.
protected  void peerAddedLock(String nodeName, NodeObject.Lock lock)
          Called when a peer adds a lock.
protected  void peerEndedSession(PeerSession session)
          Called when a peer's session with this server ends.
protected  void peerReleasingLock(PeerNode peer, NodeObject.Lock lock)
          Called when a peer announces its intention to release a lock.
protected  void peerRemovedLock(String nodeName, NodeObject.Lock lock)
          Called when a peer removes a lock.
protected  void peerStartedSession(PeerSession session)
          Called when a peer connects to this server.
protected  void peerUpdatedLock(String nodeName, NodeObject.Lock lock)
          Called when a peer updates a lock.
 void performWithLock(NodeObject.Lock lock, PeerManager.LockedOperation operation)
          Tries to acquire the resource lock and, if successful, performs the operation and releases the lock; if unsuccessful, calls the operation's failure handler.
<T extends DObject>
void
proxyRemoteObject(DObjectAddress remote, ResultListener<Integer> listener)
           
<T extends DObject>
void
proxyRemoteObject(String nodeName, int remoteOid, ResultListener<Integer> listener)
          Initiates a proxy on an object that is managed by the specified peer.
 String queryLock(NodeObject.Lock lock)
          Finds the owner of the specified lock (if any) among this node and its peers.
 void queryLock(NodeObject.Lock lock, ResultListener<String> listener)
          Determines the owner of the specified lock, waiting for any resolution to complete before notifying the supplied listener.
 void ratifyLockAction(ClientObject caller, NodeObject.Lock lock, boolean acquire)
          Handles a PeerService.ratifyLockAction(com.threerings.presents.peer.data.NodeObject.Lock, boolean) request.
 void reacquireLock(NodeObject.Lock lock)
          Reacquires a lock after a call to releaseLock(com.threerings.presents.peer.data.NodeObject.Lock, com.samskivert.util.ResultListener) but before the result listener supplied to that method has been notified with the result of the action.
protected  void refreshPeer(NodeRecord record)
          Ensures that we have a connection to the specified node if it has checked in since we last failed to connect.
protected  void refreshPeers()
          Reloads the list of peer nodes from our table and refreshes each with a call to refreshPeer(com.threerings.presents.peer.server.persist.NodeRecord).
 void releaseLock(NodeObject.Lock lock, ResultListener<String> listener)
          Releases a lock.
 void removeDroppedLockObserver(PeerManager.DroppedLockObserver observer)
          Removes a dropped lock observer from the list.
 void removeStaleCacheObserver(String cache, PeerManager.StaleCacheObserver observer)
          Removes a stale cache observer registration.
 void shutdown()
           
 void unproxyRemoteObject(DObjectAddress addr)
          Unsubscribes from and clears a proxied object.
 void unproxyRemoteObject(String nodeName, int remoteOid)
          Unsubscribes from and clears a proxied object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

GET_NODE_OBJECT

protected static final Function<PeerNode,NodeObject> GET_NODE_OBJECT
Extracts the node object from the supplied peer.


_nodeName

protected String _nodeName

_sharedSecret

protected String _sharedSecret

_self

protected NodeRecord _self

_nodeobj

protected NodeObject _nodeobj

_nodeNamespace

protected String _nodeNamespace

_peers

protected Map<String,PeerNode> _peers

_suboids

protected ArrayIntSet _suboids
The client oids of all peers subscribed to the node object.


_proxies

protected Map<DObjectAddress,Tuple<Subscriber<?>,DObject>> _proxies
Contains a mapping of proxied objects to subscriber instances.


_cacheobs

protected Map<String,ObserverList<PeerManager.StaleCacheObserver>> _cacheobs
Our stale cache observers.


_dropobs

protected ObserverList<PeerManager.DroppedLockObserver> _dropobs
Listeners for dropped locks.


_locks

protected Map<NodeObject.Lock,PeerManager.LockHandler> _locks
Locks in the process of resolution.


_stats

protected PeerManager.Stats _stats
Used to track runtime statistics.


_invoker

@Inject
protected Invoker _invoker

_clmgr

@Inject
protected ClientManager _clmgr

_conmgr

@Inject
protected PresentsConnectionManager _conmgr

_injector

@Inject
protected com.google.inject.Injector _injector

_invmgr

@Inject
protected InvocationManager _invmgr

_noderepo

@Inject
protected NodeRepository _noderepo

_omgr

@Inject
protected PresentsDObjectMgr _omgr

_repmgr

@Inject
protected ReportManager _repmgr

DEFAULT_LOCK_TIMEOUT

protected static final long DEFAULT_LOCK_TIMEOUT
The default lock timeout.

See Also:
Constant Field Values
Constructor Detail

PeerManager

@Inject
public PeerManager(Lifecycle cycle)
Creates an uninitialized peer manager.

Method Detail

getNodeObject

public NodeObject getNodeObject()
Returns the distributed object that represents this node to its peers.


getNodeObjects

public Iterable<NodeObject> getNodeObjects()
Returns an iterable over our node object and that of our peers.


init

public void init(String nodeName,
                 String sharedSecret,
                 String hostName,
                 String publicHostName,
                 int port)
Initializes this peer manager to connect to all other nodes in the NODES table. See init(String, String, String, String, int, String) for the behavior of the method and the meaning of its parameters.


init

public void init(String nodeName,
                 String sharedSecret,
                 String hostName,
                 String publicHostName,
                 int port,
                 String nodeNamespace)
Initializes this peer manager and initiates the process of connecting to its peer nodes. This will also reconfigure the ConnectionManager and ClientManager with peer related bits, so this should not be called until after the main server has set up its client factory and authenticator.

Parameters:
nodeName - this node's unique name.
sharedSecret - a shared secret used to allow the peers to authenticate with one another.
hostName - the DNS name of the server running this node.
publicHostName - if non-null, a separate public DNS hostname by which the node is to be known to normal clients (we may want inter-peer communication to take place over a different network than the communication between real clients and the various peer servers).
port - the port on which other nodes should connect to us.
nodeNamespace - The namespace for nodes to peer with. This node will connect to other nodes with the same prefix from the NODES table.

init

public void init(String nodeName,
                 String sharedSecret,
                 String hostName,
                 String publicHostName,
                 String region,
                 int port,
                 String nodeNamespace)
Initializes this peer manager and initiates the process of connecting to its peer nodes. This will also reconfigure the ConnectionManager and ClientManager with peer related bits, so this should not be called until after the main server has set up its client factory and authenticator.

Parameters:
nodeName - this node's unique name.
sharedSecret - a shared secret used to allow the peers to authenticate with one another.
hostName - the DNS name of the server running this node.
publicHostName - if non-null, a separate public DNS hostname by which the node is to be known to normal clients (we may want inter-peer communication to take place over a different network than the communication between real clients and the various peer servers).
region - the region in which the node lives, which may be null. Nodes in different regions must connect to each other through the public host name.
port - the port on which other nodes should connect to us.
nodeNamespace - The namespace for nodes to peer with. This node will connect to other nodes with the same prefix from the NODES table.

isAuthenticPeer

public boolean isAuthenticPeer(PeerCreds creds)
Returns true if the supplied peer credentials match our shared secret.


locateClient

public ClientInfo locateClient(Name key)
Locates the client with the specified name. Returns null if the client is not logged onto any peer.


lookupNodeDatum

public <T> T lookupNodeDatum(Function<NodeObject,T> op)
Locates a datum from among the set of peer NodeObjects. Objects are searched in arbitrary order and the first non-null value returned by the supplied lookup operation is returned to the caller. Null if all lookup operations returned null.


invokeOnNodes

public int invokeOnNodes(Function<Tuple<Client,NodeObject>,Boolean> func)
Invokes the supplied function on all node objects (except the local node). A caller that needs to call an invocation service method on a remote node should use this mechanism to locate the appropriate node (or nodes) and call the desired method.

Returns:
the number of times the invoked function returned true.

invokeNodeAction

public void invokeNodeAction(PeerManager.NodeAction action)
Invokes the supplied action on this and any other server that it indicates is appropriate. The action will be executed on the distributed object thread, but this method does not need to be called from the distributed object thread.


invokeNodeAction

public void invokeNodeAction(PeerManager.NodeAction action,
                             Runnable onDropped)
Invokes the supplied action on this and any other server that it indicates is appropriate. The action will be executed on the distributed object thread, but this method does not need to be called from the distributed object thread.

Parameters:
onDropped - a runnable to be executed if the action was not invoked on the local server or any peer node due to failing to match any of the nodes. The runnable will be executed on the dobj event thread.

invokeNodeAction

public void invokeNodeAction(String nodeName,
                             PeerManager.NodeAction action)
Invokes a node action on a specific node without executing PeerManager.NodeApplicant.isApplicable(com.threerings.presents.peer.data.NodeObject) to determine whether the action is applicable.


invokeNodeRequest

public <T> void invokeNodeRequest(PeerManager.NodeRequest request,
                                  NodeRequestsListener<T> listener)
Invokes the supplied request on all servers in parallel. The request will execute on the distributed object thread, but this method does not need to be called from there. If any one node reports failure, this function reports failure. If all nodes report success, this function will report success.


findApplicableNodes

public Set<String> findApplicableNodes(PeerManager.NodeApplicant applicant)
Returns all nodes for which applicant.isApplicable returns true.


invokeNodeRequest

public void invokeNodeRequest(String nodeName,
                              PeerManager.NodeRequest request,
                              InvocationService.ResultListener listener)
Invokes a node request on a specific node and returns the result through the listener.


proxyRemoteObject

public <T extends DObject> void proxyRemoteObject(String nodeName,
                                                  int remoteOid,
                                                  ResultListener<Integer> listener)
Initiates a proxy on an object that is managed by the specified peer. The object will be proxied into this server's distributed object space and its local oid reported back to the supplied result listener.

Note that proxy requests do not stack like subscription requests. Only one entity must issue a request to proxy an object and that entity must be responsible for releasing the proxy when it knows that there are no longer any local subscribers to the object.


proxyRemoteObject

public <T extends DObject> void proxyRemoteObject(DObjectAddress remote,
                                                  ResultListener<Integer> listener)

unproxyRemoteObject

public void unproxyRemoteObject(String nodeName,
                                int remoteOid)
Unsubscribes from and clears a proxied object. The caller must be sure that there are no remaining subscribers to the object on this local server.


unproxyRemoteObject

public void unproxyRemoteObject(DObjectAddress addr)
Unsubscribes from and clears a proxied object. The caller must be sure that there are no remaining subscribers to the object on this local server.


getPeerNodeObject

public NodeObject getPeerNodeObject(String nodeName)
Returns the NodeObject of the named peer, or null if null if the peer is not currently connected to this server.


getPeerClient

public Client getPeerClient(String nodeName)
Returns the client object representing the connection to the named peer, or null if we are not currently connected to it.


getPeerPublicHostName

public String getPeerPublicHostName(String nodeName)
Returns the public hostname to use when connecting to the specified peer or null if the peer is not currently connected to this server.


getPeerInternalHostName

public String getPeerInternalHostName(String nodeName)
Returns the internal hostname to use when connecting to the specified peer or null if the peer is not currently connected to this server. Peers connect to one another via their internal hostname. Do not publish this data to clients out on the Internets.


getPeerPort

public int getPeerPort(String nodeName)
Returns the port on which to connect to the specified peer or -1 if the peer is not currently connected to this server.


acquireLock

public void acquireLock(NodeObject.Lock lock,
                        ResultListener<String> listener)
Acquires a lock on a resource shared amongst this node's peers. If the lock is successfully acquired, the supplied listener will receive this node's name. If another node acquires the lock first, then the listener will receive the name of that node.


releaseLock

public void releaseLock(NodeObject.Lock lock,
                        ResultListener<String> listener)
Releases a lock. This can be cancelled using reacquireLock(com.threerings.presents.peer.data.NodeObject.Lock), in which case the passed listener will receive this node's name as opposed to null, which signifies that the lock has been successfully released.


reacquireLock

public void reacquireLock(NodeObject.Lock lock)
Reacquires a lock after a call to releaseLock(com.threerings.presents.peer.data.NodeObject.Lock, com.samskivert.util.ResultListener) but before the result listener supplied to that method has been notified with the result of the action. The result listener will receive the name of this node to indicate that the lock is still held. If a node requests to release a lock, then receives a lock-related request from another peer, it can use this method to cancel the release reliably, since the lock-related request will have been sent before the peer's ratification of the release.


queryLock

public void queryLock(NodeObject.Lock lock,
                      ResultListener<String> listener)
Determines the owner of the specified lock, waiting for any resolution to complete before notifying the supplied listener.


queryLock

public String queryLock(NodeObject.Lock lock)
Finds the owner of the specified lock (if any) among this node and its peers. This answer is not definitive, as the lock may be in the process of resolving.


performWithLock

public void performWithLock(NodeObject.Lock lock,
                            PeerManager.LockedOperation operation)
Tries to acquire the resource lock and, if successful, performs the operation and releases the lock; if unsuccessful, calls the operation's failure handler. Please note: the lock will be released immediately after the operation.


addDroppedLockObserver

public void addDroppedLockObserver(PeerManager.DroppedLockObserver observer)
Adds an observer to notify when this peer has been forced to drop a lock immediately.


removeDroppedLockObserver

public void removeDroppedLockObserver(PeerManager.DroppedLockObserver observer)
Removes a dropped lock observer from the list.


clientSubscribedToNode

public void clientSubscribedToNode(int cloid)
Called by PeerSessions when clients subscribe to the NodeObject.


clientUnsubscribedFromNode

public void clientUnsubscribedFromNode(int cloid)
Called by PeerSessions when clients unsubscribe from the NodeObject.


addStaleCacheObserver

public void addStaleCacheObserver(String cache,
                                  PeerManager.StaleCacheObserver observer)
Registers a stale cache observer.


removeStaleCacheObserver

public void removeStaleCacheObserver(String cache,
                                     PeerManager.StaleCacheObserver observer)
Removes a stale cache observer registration.


broadcastStaleCacheData

public void broadcastStaleCacheData(String cache,
                                    Streamable data)
Called when cached data has changed on the local server and needs to inform our peers.


getStats

public PeerManager.Stats getStats()
Returns a snapshot of runtime statistics tracked by the peer manager.


shutdown

public void shutdown()
Specified by:
shutdown in interface Lifecycle.ShutdownComponent

ratifyLockAction

public void ratifyLockAction(ClientObject caller,
                             NodeObject.Lock lock,
                             boolean acquire)
Description copied from interface: PeerProvider
Handles a PeerService.ratifyLockAction(com.threerings.presents.peer.data.NodeObject.Lock, boolean) request.

Specified by:
ratifyLockAction in interface PeerProvider

invokeAction

public void invokeAction(ClientObject caller,
                         byte[] serializedAction)
Description copied from interface: PeerProvider
Handles a PeerService.invokeAction(byte[]) request.

Specified by:
invokeAction in interface PeerProvider

invokeRequest

public void invokeRequest(ClientObject caller,
                          byte[] serializedAction,
                          InvocationService.ResultListener listener)
Description copied from interface: PeerProvider
Handles a PeerService.invokeRequest(byte[], com.threerings.presents.client.InvocationService.ResultListener) request.

Specified by:
invokeRequest in interface PeerProvider

generateReport

public void generateReport(ClientObject caller,
                           String type,
                           InvocationService.ResultListener listener)
                    throws InvocationException
Description copied from interface: PeerProvider
Handles a PeerService.generateReport(java.lang.String, com.threerings.presents.client.InvocationService.ResultListener) request.

Specified by:
generateReport in interface PeerProvider
Throws:
InvocationException

clientSessionDidStart

public void clientSessionDidStart(PresentsSession client)
Description copied from interface: ClientManager.ClientObserver
Called when a client has authenticated and been resolved and has started their session.

Specified by:
clientSessionDidStart in interface ClientManager.ClientObserver

clientSessionDidEnd

public void clientSessionDidEnd(PresentsSession client)
Description copied from interface: ClientManager.ClientObserver
Called when a client has logged off or been forcibly logged off due to inactivity and has thus ended their session.

Specified by:
clientSessionDidEnd in interface ClientManager.ClientObserver

didInit

protected void didInit()
Called after we have finished our initialization.


refreshPeers

protected void refreshPeers()
Reloads the list of peer nodes from our table and refreshes each with a call to refreshPeer(com.threerings.presents.peer.server.persist.NodeRecord).


refreshPeer

protected void refreshPeer(NodeRecord record)
Ensures that we have a connection to the specified node if it has checked in since we last failed to connect.


ignoreClient

protected boolean ignoreClient(PresentsSession client)
Returns true if we should ignore the supplied client, false if we should let our other peers know that this client is authenticated with this server. Note: this is called at the beginning and end of the client session, so this method should return the same value both times.


createNodeObject

protected NodeObject createNodeObject()
Creates the appropriate derived class of NodeObject which will be registered with the distributed object system.


createClientInfo

protected ClientInfo createClientInfo()
Creates a ClientInfo record which will subsequently be initialized by a call to initClientInfo(com.threerings.presents.server.PresentsSession, com.threerings.presents.peer.data.ClientInfo).


getLockHandler

protected PeerManager.LockHandler getLockHandler(NodeObject.Lock lock)
Returns the lock handler for the specified lock.


createLockHandler

protected PeerManager.LockHandler createLockHandler(PeerNode peer,
                                                    NodeObject.Lock lock,
                                                    boolean acquire)

changedCacheData

protected void changedCacheData(String cache,
                                Streamable data)
Called when possibly cached data has changed on one of our peer servers.


droppedLock

protected void droppedLock(NodeObject.Lock lock)
Called when we have been forced to drop a lock.


initClientInfo

protected void initClientInfo(PresentsSession client,
                              ClientInfo info)
Initializes the supplied client info for the supplied client.


clearClientInfo

protected void clearClientInfo(PresentsSession client,
                               ClientInfo info)
Called when a client ends their session to clear their information from our node object.


getPeerNodeClass

protected Class<? extends PeerNode> getPeerNodeClass()
Creates a PeerNode to manage our connection to the specified peer.


createCreds

protected PeerCreds createCreds()
Creates credentials that a PeerNode can use to authenticate with another node.


getRegion

protected String getRegion()
Returns the region in which the local node exists.


clientLoggedOn

protected void clientLoggedOn(String nodeName,
                              ClientInfo clinfo)
Called when we hear about a client logging on to another node.


clientLoggedOff

protected void clientLoggedOff(String nodeName,
                               ClientInfo clinfo)
Called when we hear about a client logging off of another node.


peerStartedSession

protected void peerStartedSession(PeerSession session)
Called when a peer connects to this server.


peerEndedSession

protected void peerEndedSession(PeerSession session)
Called when a peer's session with this server ends.


connectedToPeer

protected void connectedToPeer(PeerNode peer)
Called when we have established a connection to the supplied peer.


disconnectedFromPeer

protected void disconnectedFromPeer(PeerNode peer)
Called when a ended our session with the supplied peer.


peerAcquiringLock

protected void peerAcquiringLock(PeerNode peer,
                                 NodeObject.Lock lock)
Called when a peer announces its intention to acquire a lock.


peerReleasingLock

protected void peerReleasingLock(PeerNode peer,
                                 NodeObject.Lock lock)
Called when a peer announces its intention to release a lock.


peerAddedLock

protected void peerAddedLock(String nodeName,
                             NodeObject.Lock lock)
Called when a peer adds a lock.


peerUpdatedLock

protected void peerUpdatedLock(String nodeName,
                               NodeObject.Lock lock)
Called when a peer updates a lock.


peerRemovedLock

protected void peerRemovedLock(String nodeName,
                               NodeObject.Lock lock)
Called when a peer removes a lock.


flattenAction

protected byte[] flattenAction(PeerManager.NodeAction action)
Flattens the supplied node action into bytes.


flattenRequest

protected byte[] flattenRequest(PeerManager.NodeRequest request)
Flattens the supplied node request into bytes.


invokeNodeRequest

protected void invokeNodeRequest(String nodeName,
                                 byte[] requestBytes,
                                 InvocationService.ResultListener listener)

lockAcquired

protected void lockAcquired(NodeObject.Lock lock,
                            long wait,
                            ResultListener<String> listener)

lockReleased

protected void lockReleased(NodeObject.Lock lock,
                            ResultListener<String> listener)

getLockTimeout

protected long getLockTimeout()
Returns the amount of time to wait for peer ratification to complete before acquiring/releasing a lock.


hasPriority

protected static boolean hasPriority(String nodeName1,
                                     String nodeName2)
Determines whether the first node named has priority over the second when resolving lock disputes.