diff --git a/src/java/com/threerings/presents/peer/server/PeerManager.java b/src/java/com/threerings/presents/peer/server/PeerManager.java index df40cd6be..e4b2247cb 100644 --- a/src/java/com/threerings/presents/peer/server/PeerManager.java +++ b/src/java/com/threerings/presents/peer/server/PeerManager.java @@ -43,8 +43,9 @@ import com.threerings.util.Name; import com.threerings.presents.client.Client; import com.threerings.presents.client.ClientObserver; import com.threerings.presents.data.ClientObject; -import com.threerings.presents.dobj.AttributeChangedEvent; import com.threerings.presents.dobj.AttributeChangeListener; +import com.threerings.presents.dobj.AttributeChangedEvent; +import com.threerings.presents.dobj.DObject; import com.threerings.presents.dobj.EntryAddedEvent; import com.threerings.presents.dobj.EntryRemovedEvent; import com.threerings.presents.dobj.EntryUpdatedEvent; @@ -161,7 +162,7 @@ public class PeerManager _nodeobj.setPeerService( (PeerMarshaller)PresentsServer.invmgr.registerDispatcher( new PeerDispatcher(this), false)); - + // register ourselves as a client observer PresentsServer.clmgr.addClientObserver(this); @@ -172,7 +173,7 @@ public class PeerManager refreshPeers(); } }.schedule(5000L, 60*1000L); - + // give derived classes an easy way to get in on the init action didInit(); } @@ -187,7 +188,7 @@ public class PeerManager if (_nodeobj != null) { PresentsServer.invmgr.clearDispatcher(_nodeobj.peerService); } - + // clear out our client observer registration PresentsServer.clmgr.removeClientObserver(this); @@ -206,6 +207,74 @@ public class PeerManager creds.getPassword()); } + /** + * 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.
+ */
+ public null if we are not currently connected to it.
@@ -213,9 +282,9 @@ public class PeerManager
public Client getPeerClient (String nodeName)
{
PeerNode peer = _peers.get(nodeName);
- return (peer == null) ? null : peer.getClient();
+ return (peer == null) ? null : peer.getClient();
}
-
+
/**
* 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.
@@ -238,7 +307,7 @@ public class PeerManager
}
});
}
-
+
/**
* Releases a lock. This can be cancelled using {@link #reacquireLock}, in which case the
* passed listener will receive this node's name as opposed to null, which
@@ -264,7 +333,7 @@ public class PeerManager
}
});
}
-
+
/**
* Reacquires a lock after a call to {@link #releaseLock} but before the result listener
* supplied to that method has been notified with the result of the action. The result
@@ -282,16 +351,16 @@ public class PeerManager
handler + "].");
return;
}
-
+
// perform an update to let other nodes know that we're reacquiring
_nodeobj.updateLocks(lock);
-
+
// cancel the handler and report to any listeners
_locks.remove(lock);
handler.cancel();
handler.listeners.requestCompleted(_nodeName);
}
-
+
/**
* Determines the owner of the specified lock, waiting for any resolution to complete before
* notifying the supplied listener.
@@ -304,11 +373,11 @@ public class PeerManager
handler.listeners.add(listener);
return;
}
-
+
// otherwise, return its present value
listener.requestCompleted(queryLock(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.
@@ -319,7 +388,7 @@ public class PeerManager
if (_nodeobj.locks.contains(lock)) {
return _nodeName;
}
-
+
// then in our peers
for (PeerNode peer : _peers.values()) {
if (peer.nodeobj.locks.contains(lock)) {
@@ -328,7 +397,7 @@ public class PeerManager
}
return null;
}
-
+
// documentation inherited from interface PeerProvider
public void ratifyLockAction (ClientObject caller, Lock lock, boolean acquire)
{
@@ -340,7 +409,7 @@ public class PeerManager
// allowed another to take priority
}
}
-
+
// documentation inherited from interface ClientManager.ClientObserver
public void clientSessionDidStart (PresentsClient client)
{
@@ -637,7 +706,7 @@ public class PeerManager
public void objectAvailable (NodeObject object)
{
nodeobj = object;
-
+
// listen for lock and cache updates
nodeobj.addListener(this);
}
@@ -675,7 +744,7 @@ public class PeerManager
handler.listeners.addAll(olisteners);
}
_locks.put(lock, handler);
-
+
} else if (name.equals(NodeObject.RELEASING_LOCK)) {
Lock lock = nodeobj.releasingLock;
LockHandler handler = _locks.get(lock);
@@ -685,12 +754,12 @@ public class PeerManager
log.warning("Received request to release resolving lock [node=" +
_record.nodeName + ", handler=" + handler + "].");
}
-
+
} else if (name.equals(NodeObject.CACHE_DATA)) {
changedCacheData(nodeobj.cacheData.cache, nodeobj.cacheData.data);
}
}
-
+
protected NodeRecord _record;
protected Client _client;
protected long _lastConnectStamp;
@@ -704,7 +773,7 @@ public class PeerManager
{
/** Listeners waiting for resolution. */
public ResultListenerList