From ce7cc1bc96091ac8071f6240d06133c47d39e945 Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Sun, 26 Oct 2008 20:19:32 +0000 Subject: [PATCH] Added PeerService.generateReport(). git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5467 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../presents/peer/client/PeerService.java | 5 +++ .../presents/peer/data/PeerMarshaller.java | 18 +++++++++-- .../presents/peer/server/PeerDispatcher.java | 7 +++++ .../presents/peer/server/PeerManager.java | 31 +++++++++++++------ .../presents/peer/server/PeerProvider.java | 8 +++++ 5 files changed, 58 insertions(+), 11 deletions(-) diff --git a/src/java/com/threerings/presents/peer/client/PeerService.java b/src/java/com/threerings/presents/peer/client/PeerService.java index 07fce971b..62ef397a1 100644 --- a/src/java/com/threerings/presents/peer/client/PeerService.java +++ b/src/java/com/threerings/presents/peer/client/PeerService.java @@ -40,4 +40,9 @@ public interface PeerService extends InvocationService * Requests that the specified action be invoked on this server. */ void invokeAction (Client client, byte[] serializedAction); + + /** + * Generates a server status report for this peer and returns it to the supplied listener. + */ + void generateReport (Client client, ResultListener listener); } diff --git a/src/java/com/threerings/presents/peer/data/PeerMarshaller.java b/src/java/com/threerings/presents/peer/data/PeerMarshaller.java index 181500e5b..28d81ab18 100644 --- a/src/java/com/threerings/presents/peer/data/PeerMarshaller.java +++ b/src/java/com/threerings/presents/peer/data/PeerMarshaller.java @@ -22,6 +22,7 @@ package com.threerings.presents.peer.data; import com.threerings.presents.client.Client; +import com.threerings.presents.client.InvocationService; import com.threerings.presents.data.InvocationMarshaller; import com.threerings.presents.peer.client.PeerService; @@ -35,8 +36,21 @@ import com.threerings.presents.peer.client.PeerService; public class PeerMarshaller extends InvocationMarshaller implements PeerService { + /** The method id used to dispatch {@link #generateReport} requests. */ + public static final int GENERATE_REPORT = 1; + + // from interface PeerService + public void generateReport (Client arg1, InvocationService.ResultListener arg2) + { + InvocationMarshaller.ResultMarshaller listener2 = new InvocationMarshaller.ResultMarshaller(); + listener2.listener = arg2; + sendRequest(arg1, GENERATE_REPORT, new Object[] { + listener2 + }); + } + /** The method id used to dispatch {@link #invokeAction} requests. */ - public static final int INVOKE_ACTION = 1; + public static final int INVOKE_ACTION = 2; // from interface PeerService public void invokeAction (Client arg1, byte[] arg2) @@ -47,7 +61,7 @@ public class PeerMarshaller extends InvocationMarshaller } /** The method id used to dispatch {@link #ratifyLockAction} requests. */ - public static final int RATIFY_LOCK_ACTION = 2; + public static final int RATIFY_LOCK_ACTION = 3; // from interface PeerService public void ratifyLockAction (Client arg1, NodeObject.Lock arg2, boolean arg3) diff --git a/src/java/com/threerings/presents/peer/server/PeerDispatcher.java b/src/java/com/threerings/presents/peer/server/PeerDispatcher.java index 7a081df0f..782bdd252 100644 --- a/src/java/com/threerings/presents/peer/server/PeerDispatcher.java +++ b/src/java/com/threerings/presents/peer/server/PeerDispatcher.java @@ -21,6 +21,7 @@ package com.threerings.presents.peer.server; +import com.threerings.presents.client.InvocationService; import com.threerings.presents.data.ClientObject; import com.threerings.presents.peer.data.NodeObject; import com.threerings.presents.peer.data.PeerMarshaller; @@ -53,6 +54,12 @@ public class PeerDispatcher extends InvocationDispatcher throws InvocationException { switch (methodId) { + case PeerMarshaller.GENERATE_REPORT: + ((PeerProvider)provider).generateReport( + source, (InvocationService.ResultListener)args[0] + ); + return; + case PeerMarshaller.INVOKE_ACTION: ((PeerProvider)provider).invokeAction( source, (byte[])args[0] diff --git a/src/java/com/threerings/presents/peer/server/PeerManager.java b/src/java/com/threerings/presents/peer/server/PeerManager.java index 80bf6dfeb..46619b991 100644 --- a/src/java/com/threerings/presents/peer/server/PeerManager.java +++ b/src/java/com/threerings/presents/peer/server/PeerManager.java @@ -50,9 +50,6 @@ import com.threerings.io.Streamable; import com.threerings.util.Name; -import com.threerings.presents.annotation.MainInvoker; -import com.threerings.presents.client.Client; -import com.threerings.presents.data.ClientObject; import com.threerings.presents.dobj.DObject; import com.threerings.presents.dobj.EntryAddedEvent; import com.threerings.presents.dobj.EntryRemovedEvent; @@ -60,17 +57,25 @@ import com.threerings.presents.dobj.EntryUpdatedEvent; import com.threerings.presents.dobj.ObjectAccessException; import com.threerings.presents.dobj.SetListener; import com.threerings.presents.dobj.Subscriber; + +import com.threerings.presents.annotation.MainInvoker; +import com.threerings.presents.client.Client; +import com.threerings.presents.data.ClientObject; +import com.threerings.presents.server.ClientManager; +import com.threerings.presents.server.InvocationException; +import com.threerings.presents.server.InvocationManager; +import com.threerings.presents.server.PresentsClient; +import com.threerings.presents.server.PresentsDObjectMgr; +import com.threerings.presents.server.ReportManager; +import com.threerings.presents.server.ShutdownManager; +import com.threerings.presents.server.net.ConnectionManager; + +import com.threerings.presents.peer.client.PeerService; import com.threerings.presents.peer.data.ClientInfo; import com.threerings.presents.peer.data.NodeObject; import com.threerings.presents.peer.net.PeerCreds; import com.threerings.presents.peer.server.persist.NodeRecord; import com.threerings.presents.peer.server.persist.NodeRepository; -import com.threerings.presents.server.ClientManager; -import com.threerings.presents.server.InvocationManager; -import com.threerings.presents.server.PresentsClient; -import com.threerings.presents.server.PresentsDObjectMgr; -import com.threerings.presents.server.ShutdownManager; -import com.threerings.presents.server.net.ConnectionManager; import static com.threerings.presents.Log.log; @@ -755,6 +760,13 @@ public abstract class PeerManager } } + // from interface PeerProvider + public void generateReport (ClientObject caller, PeerService.ResultListener listener) + throws InvocationException + { + listener.requestProcessed(_repmgr.generateReport()); + } + // from interface ClientManager.ClientObserver public void clientSessionDidStart (PresentsClient client) { @@ -1254,6 +1266,7 @@ public abstract class PeerManager // our service dependencies @Inject protected ConnectionManager _conmgr; @Inject protected ClientManager _clmgr; + @Inject protected ReportManager _repmgr; @Inject protected PresentsDObjectMgr _omgr; @Inject protected InvocationManager _invmgr; @Inject protected @MainInvoker Invoker _invoker; diff --git a/src/java/com/threerings/presents/peer/server/PeerProvider.java b/src/java/com/threerings/presents/peer/server/PeerProvider.java index a7744d598..df4cd0035 100644 --- a/src/java/com/threerings/presents/peer/server/PeerProvider.java +++ b/src/java/com/threerings/presents/peer/server/PeerProvider.java @@ -21,9 +21,11 @@ package com.threerings.presents.peer.server; +import com.threerings.presents.client.InvocationService; import com.threerings.presents.data.ClientObject; import com.threerings.presents.peer.client.PeerService; import com.threerings.presents.peer.data.NodeObject; +import com.threerings.presents.server.InvocationException; import com.threerings.presents.server.InvocationProvider; /** @@ -31,6 +33,12 @@ import com.threerings.presents.server.InvocationProvider; */ public interface PeerProvider extends InvocationProvider { + /** + * Handles a {@link PeerService#generateReport} request. + */ + void generateReport (ClientObject caller, InvocationService.ResultListener arg1) + throws InvocationException; + /** * Handles a {@link PeerService#invokeAction} request. */