Switch to new samskivert logging API.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5134 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2008-05-27 19:25:38 +00:00
parent 821760366f
commit 919112cf88
80 changed files with 440 additions and 573 deletions
@@ -51,7 +51,6 @@ import com.threerings.io.ObjectOutputStream;
import com.threerings.io.UnreliableObjectInputStream;
import com.threerings.io.UnreliableObjectOutputStream;
import com.threerings.presents.Log;
import com.threerings.presents.data.AuthCodes;
import com.threerings.presents.dobj.DObjectManager;
import com.threerings.presents.net.AuthRequest;
@@ -65,6 +64,8 @@ import com.threerings.presents.net.Transport;
import com.threerings.presents.net.UpstreamMessage;
import com.threerings.presents.util.DatagramSequencer;
import static com.threerings.presents.Log.log;
/**
* The client performs all network I/O on separate threads (one for reading and one for
* writing). The communicator class encapsulates that functionality.
@@ -193,7 +194,7 @@ public class BlockingCommunicator extends Communicator
*/
protected synchronized void logonSucceeded (AuthResponseData data)
{
Log.debug("Logon succeeded: " + data);
log.debug("Logon succeeded: " + data);
// create our distributed object manager
_omgr = new ClientDObjectMgr(this, _client);
@@ -224,8 +225,7 @@ public class BlockingCommunicator extends Communicator
return;
}
Log.info("Connection failed: " + ioe);
Log.logStackTrace(ioe);
log.info("Connection failed", ioe);
// let the client know that things went south
_client.notifyObservers(Client.CLIENT_CONNECTION_FAILED, ioe);
@@ -245,7 +245,7 @@ public class BlockingCommunicator extends Communicator
return;
}
Log.debug("Connection closed.");
log.debug("Connection closed.");
// now do the whole logoff thing
logoff();
}
@@ -267,7 +267,7 @@ public class BlockingCommunicator extends Communicator
_client.cleanup(_logonError);
}
Log.debug("Reader thread exited.");
log.debug("Reader thread exited.");
}
/**
@@ -277,7 +277,7 @@ public class BlockingCommunicator extends Communicator
{
// clear out our writer reference
_writer = null;
Log.debug("Writer thread exited.");
log.debug("Writer thread exited.");
// let the client observers know that we're logged off
_client.notifyObservers(Client.CLIENT_DID_LOGOFF, null);
@@ -299,12 +299,12 @@ public class BlockingCommunicator extends Communicator
protected void closeChannel ()
{
if (_channel != null) {
Log.debug("Closing socket channel.");
log.debug("Closing socket channel.");
try {
_channel.close();
} catch (IOException ioe) {
Log.warning("Error closing failed socket: " + ioe);
log.warning("Error closing failed socket: " + ioe);
}
_channel = null;
@@ -326,7 +326,7 @@ public class BlockingCommunicator extends Communicator
closeDatagramChannel();
}
Log.debug("Datagram reader thread exited.");
log.debug("Datagram reader thread exited.");
}
/**
@@ -336,7 +336,7 @@ public class BlockingCommunicator extends Communicator
{
// clear out our writer reference
_datagramWriter = null;
Log.debug("Datagram writer thread exited.");
log.debug("Datagram writer thread exited.");
closeDatagramChannel();
}
@@ -350,17 +350,17 @@ public class BlockingCommunicator extends Communicator
try {
_selector.close();
} catch (IOException ioe) {
Log.warning("Error closing selector: " + ioe);
log.warning("Error closing selector: " + ioe);
}
_selector = null;
}
if (_datagramChannel != null) {
Log.debug("Closing datagram socket channel.");
log.debug("Closing datagram socket channel.");
try {
_datagramChannel.close();
} catch (IOException ioe) {
Log.warning("Error closing datagram socket: " + ioe);
log.warning("Error closing datagram socket: " + ioe);
}
_datagramChannel = null;
@@ -377,7 +377,7 @@ public class BlockingCommunicator extends Communicator
throws IOException
{
if (debugLogMessages()) {
Log.info("SEND " + msg);
log.info("SEND " + msg);
}
// first we write the message so that we can measure it's length
@@ -389,11 +389,11 @@ public class BlockingCommunicator extends Communicator
ByteBuffer buffer = _fout.frameAndReturnBuffer();
if (buffer.limit() > 4096) {
String txt = StringUtil.truncate(String.valueOf(msg), 80, "...");
Log.info("Whoa, writin' a big one [msg=" + txt + ", size=" + buffer.limit() + "].");
log.info("Whoa, writin' a big one [msg=" + txt + ", size=" + buffer.limit() + "].");
}
int wrote = _channel.write(buffer);
if (wrote != buffer.limit()) {
Log.warning("Aiya! Couldn't write entire message [msg=" + msg +
log.warning("Aiya! Couldn't write entire message [msg=" + msg +
", size=" + buffer.limit() + ", wrote=" + wrote + "].");
// } else {
// Log.info("Wrote " + wrote + " bytes.");
@@ -425,7 +425,7 @@ public class BlockingCommunicator extends Communicator
ByteBuffer buf = _bout.flip();
int size = buf.remaining();
if (size > Client.MAX_DATAGRAM_SIZE) {
Log.warning("Dropping oversized datagram [size=" + size +
log.warning("Dropping oversized datagram [size=" + size +
", msg=" + msg + "].");
return;
}
@@ -466,7 +466,7 @@ public class BlockingCommunicator extends Communicator
try {
DownstreamMessage msg = (DownstreamMessage)_oin.readObject();
if (debugLogMessages()) {
Log.info("RECEIVE " + msg);
log.info("RECEIVE " + msg);
}
return msg;
@@ -496,7 +496,7 @@ public class BlockingCommunicator extends Communicator
return null; // received out of order
}
if (debugLogMessages()) {
Log.info("DATAGRAM " + msg);
log.info("DATAGRAM " + msg);
}
return msg;
@@ -521,7 +521,7 @@ public class BlockingCommunicator extends Communicator
{
// the default implementation just connects to the first port and does no cycling
int port = _client.getPorts()[0];
Log.info("Connecting [host=" + host + ", port=" + port + "].");
log.info("Connecting [host=" + host + ", port=" + port + "].");
synchronized (BlockingCommunicator.this) {
_channel = SocketChannel.open(new InetSocketAddress(host, port));
}
@@ -554,8 +554,7 @@ public class BlockingCommunicator extends Communicator
logon();
} catch (Exception e) {
Log.debug("Logon failed: " + e);
// Log.logStackTrace(e);
log.debug("Logon failed: " + e);
// once we're shutdown we'll report this error
_logonError = e;
// terminate our communicator thread
@@ -596,10 +595,10 @@ public class BlockingCommunicator extends Communicator
sendMessage(req);
// now wait for the auth response
Log.debug("Waiting for auth response.");
log.debug("Waiting for auth response.");
AuthResponse rsp = (AuthResponse)receiveMessage();
AuthResponseData data = rsp.getData();
Log.debug("Got auth response: " + data);
log.debug("Got auth response: " + data);
// if the auth request failed, we want to let the communicator know by throwing a logon
// exception
@@ -627,7 +626,7 @@ public class BlockingCommunicator extends Communicator
} catch (InterruptedIOException iioe) {
// somebody set up us the bomb! we've been interrupted which means that we're being
// shut down, so we just report it and return from iterate() like a good monkey
Log.debug("Reader thread woken up in time to die.");
log.debug("Reader thread woken up in time to die.");
} catch (EOFException eofe) {
// let the communicator know that our connection was closed
@@ -642,14 +641,13 @@ public class BlockingCommunicator extends Communicator
shutdown();
} catch (Exception e) {
Log.warning("Error processing message [msg=" + msg + ", error=" + e + "].");
log.warning("Error processing message [msg=" + msg + ", error=" + e + "].");
}
}
protected void handleIterateFailure (Exception e)
{
Log.warning("Uncaught exception it reader thread.");
Log.logStackTrace(e);
log.warning("Uncaught exception it reader thread.", e);
}
protected void didShutdown ()
@@ -702,8 +700,7 @@ public class BlockingCommunicator extends Communicator
protected void handleIterateFailure (Exception e)
{
Log.warning("Uncaught exception it writer thread.");
Log.logStackTrace(e);
log.warning("Uncaught exception it writer thread.", e);
}
protected void didShutdown ()
@@ -729,7 +726,7 @@ public class BlockingCommunicator extends Communicator
try {
connect();
} catch (IOException ioe) {
Log.warning("Failed to open datagram channel [error=" + ioe + "].");
log.warning("Failed to open datagram channel [error=" + ioe + "].");
shutdown();
}
}
@@ -749,7 +746,7 @@ public class BlockingCommunicator extends Communicator
try {
_digest = MessageDigest.getInstance("MD5");
} catch (NoSuchAlgorithmException nsae) {
Log.warning("Missing MD5 algorithm.");
log.warning("Missing MD5 algorithm.");
shutdown();
return;
}
@@ -785,14 +782,14 @@ public class BlockingCommunicator extends Communicator
// check if we managed to establish a connection
if (cport > 0) {
Log.info("Datagram connection established [port=" + cport + "].");
log.info("Datagram connection established [port=" + cport + "].");
// start up the writer thread
_datagramWriter = new DatagramWriter();
_datagramWriter.start();
} else {
Log.info("Failed to establish datagram connection.");
log.info("Failed to establish datagram connection.");
shutdown();
}
}
@@ -835,20 +832,19 @@ public class BlockingCommunicator extends Communicator
} catch (AsynchronousCloseException ace) {
// somebody set up us the bomb! we've been interrupted which means that we're being
// shut down, so we just report it and return from iterate() like a good monkey
Log.debug("Datagram reader thread woken up in time to die.");
log.debug("Datagram reader thread woken up in time to die.");
} catch (IOException ioe) {
Log.warning("Error receiving datagram [error=" + ioe + "].");
log.warning("Error receiving datagram [error=" + ioe + "].");
} catch (Exception e) {
Log.warning("Error processing message [msg=" + msg + ", error=" + e + "].");
log.warning("Error processing message [msg=" + msg + ", error=" + e + "].");
}
}
protected void handleIterateFailure (Exception e)
{
Log.warning("Uncaught exception in datagram reader thread.");
Log.logStackTrace(e);
log.warning("Uncaught exception in datagram reader thread.", e);
}
protected void didShutdown ()
@@ -886,14 +882,13 @@ public class BlockingCommunicator extends Communicator
sendDatagram(msg);
} catch (IOException ioe) {
Log.warning("Error sending datagram [error=" + ioe + "].");
log.warning("Error sending datagram [error=" + ioe + "].");
}
}
protected void handleIterateFailure (Exception e)
{
Log.warning("Uncaught exception in datagram writer thread.");
Log.logStackTrace(e);
log.warning("Uncaught exception in datagram writer thread.", e);
}
protected void didShutdown ()
@@ -32,9 +32,10 @@ import com.samskivert.swing.RuntimeAdjust;
import com.samskivert.util.IntListUtil;
import com.samskivert.util.Interval;
import com.threerings.presents.Log;
import com.threerings.presents.data.AuthCodes;
import static com.threerings.presents.Log.log;
/**
* Customizes the blocking communicator with some things that we only do on users' machines (where
* there's only one client running, not potentially dozens, and where we're not sending high
@@ -78,7 +79,7 @@ public class ClientCommunicator extends BlockingCommunicator
for (int ii = 0; ii < ports.length; ii++) {
int port = ports[(ii+ppidx)%ports.length];
int nextPort = ports[(ii+ppidx+1)%ports.length];
Log.info("Connecting [host=" + host + ", port=" + port + "].");
log.info("Connecting [host=" + host + ", port=" + port + "].");
InetSocketAddress addr = new InetSocketAddress(host, port);
try {
synchronized (this) {
@@ -35,10 +35,11 @@ import com.samskivert.util.StringUtil;
import com.samskivert.util.IntMap;
import com.samskivert.util.Interval;
import com.threerings.presents.Log;
import com.threerings.presents.dobj.*;
import com.threerings.presents.net.*;
import static com.threerings.presents.Log.log;
/**
* The client distributed object manager manages a set of proxy objects which mirror the
* distributed objects maintained on the server. Requests for modifications, etc. are forwarded to
@@ -165,7 +166,7 @@ public class ClientDObjectMgr
} else if (obj instanceof UnsubscribeResponse) {
int oid = ((UnsubscribeResponse)obj).getOid();
if (_dead.remove(oid) == null) {
Log.warning("Received unsub ACK from unknown object [oid=" + oid + "].");
log.warning("Received unsub ACK from unknown object [oid=" + oid + "].");
}
} else if (obj instanceof FailureResponse) {
@@ -221,7 +222,7 @@ public class ClientDObjectMgr
DObject target = _ocache.get(remoteOid);
if (target == null) {
if (!_dead.containsKey(remoteOid)) {
Log.warning("Unable to dispatch event on non-proxied object " + event + ".");
log.warning("Unable to dispatch event on non-proxied object " + event + ".");
}
return;
}
@@ -277,8 +278,7 @@ public class ClientDObjectMgr
}
} catch (Exception e) {
Log.warning("Failure processing event [event=" + event + ", target=" + target + "].");
Log.logStackTrace(e);
log.warning("Failure processing event", "event", event, "target", target, e);
}
}
@@ -298,7 +298,7 @@ public class ClientDObjectMgr
// let the penders know that the object is available
PendingRequest<?> req = _penders.remove(obj.getOid());
if (req == null) {
Log.warning("Got object, but no one cares?! [oid=" + obj.getOid() +
log.warning("Got object, but no one cares?! [oid=" + obj.getOid() +
", obj=" + obj + "].");
return;
}
@@ -321,7 +321,7 @@ public class ClientDObjectMgr
// let the penders know that the object is not available
PendingRequest<?> req = _penders.remove(oid);
if (req == null) {
Log.warning("Failed to get object, but no one cares?! [oid=" + oid + "].");
log.warning("Failed to get object, but no one cares?! [oid=" + oid + "].");
return;
}
@@ -383,7 +383,7 @@ public class ClientDObjectMgr
dobj.removeSubscriber(target);
} else {
Log.info("Requested to remove subscriber from non-proxied object [oid=" + oid +
log.info("Requested to remove subscriber from non-proxied object [oid=" + oid +
", sub=" + target + "].");
}
}
@@ -505,9 +505,9 @@ public class ClientDObjectMgr
/** A debug hook that allows the dumping of all objects in the object table out to the log. */
protected DebugChords.Hook DUMP_OTABLE_HOOK = new DebugChords.Hook() {
public void invoke () {
Log.info("Dumping " + _ocache.size() + " objects:");
log.info("Dumping " + _ocache.size() + " objects:");
for (DObject obj : _ocache.values()) {
Log.info(obj.getClass().getName() + " " + obj);
log.info(obj.getClass().getName() + " " + obj);
}
}
};
@@ -23,10 +23,11 @@ package com.threerings.presents.client;
import java.util.Arrays;
import com.threerings.presents.Log;
import com.threerings.presents.net.PingRequest;
import com.threerings.presents.net.PongResponse;
import static com.threerings.presents.Log.log;
/**
* Used to compute the client/server time delta, attempting to account for
* the network delay experienced when the server sends its current time to
@@ -95,7 +96,7 @@ public class DeltaCalculator
// minus the server's send time (plus network delay): dT = C - S
_deltas[_iter] = recv - (server + nettime);
Log.debug("Calculated delta [delay=" + delay +
log.debug("Calculated delta [delay=" + delay +
", nettime=" + nettime + ", delta=" + _deltas[_iter] +
", rtt=" + (recv-send) + "].");
@@ -22,7 +22,8 @@
package com.threerings.presents.client;
import com.samskivert.util.StringUtil;
import com.threerings.presents.Log;
import static com.threerings.presents.Log.log;
/**
* Provides the basic functionality used to dispatch invocation
@@ -45,7 +46,7 @@ public abstract class InvocationDecoder
*/
public void dispatchNotification (int methodId, Object[] args)
{
Log.warning("Requested to dispatch unknown method " +
log.warning("Requested to dispatch unknown method " +
"[receiver=" + receiver + ", methodId=" + methodId +
", args=" + StringUtil.toString(args) + "].");
}
@@ -27,7 +27,6 @@ import java.util.Iterator;
import com.samskivert.util.HashIntMap;
import com.samskivert.util.StringUtil;
import com.threerings.presents.Log;
import com.threerings.presents.client.InvocationReceiver.Registration;
import com.threerings.presents.data.ClientObject;
@@ -47,6 +46,8 @@ import com.threerings.presents.dobj.Subscriber;
import com.threerings.presents.net.Transport;
import static com.threerings.presents.Log.log;
/**
* Handles the client side management of the invocation services.
*/
@@ -67,7 +68,7 @@ public class InvocationDirector
{
// sanity check
if (_clobj != null) {
Log.warning("Zoiks, client object around during invmgr init!");
log.warning("Zoiks, client object around during invmgr init!");
cleanup();
}
@@ -97,7 +98,7 @@ public class InvocationDirector
public void requestFailed (int oid, ObjectAccessException cause) {
// aiya! we were unable to subscribe to the client object. we're hosed!
Log.warning("Invocation director unable to subscribe to client object " +
log.warning("Invocation director unable to subscribe to client object " +
"[cloid=" + cloid + ", cause=" + cause + "]!");
_client.getClientObjectFailed(cause);
}
@@ -151,7 +152,7 @@ public class InvocationDirector
if (_clobj != null) {
Registration rreg = _clobj.receivers.get(receiverCode);
if (rreg == null) {
Log.warning("Receiver unregistered for which we have no id to code mapping " +
log.warning("Receiver unregistered for which we have no id to code mapping " +
"[code=" + receiverCode + "].");
} else {
Object decoder = _receivers.remove(rreg.receiverId);
@@ -209,7 +210,7 @@ public class InvocationDirector
int invOid, int invCode, int methodId, Object[] args, Transport transport)
{
if (_clobj == null) {
Log.warning("Dropping invocation request on shutdown director [code=" + invCode +
log.warning("Dropping invocation request on shutdown director [code=" + invCode +
", methodId=" + methodId + "].");
return;
}
@@ -273,7 +274,7 @@ public class InvocationDirector
// look up the invocation marshaller registered for that response
ListenerMarshaller listener = _listeners.remove(reqId);
if (listener == null) {
Log.warning("Received invocation response for which we have no registered listener " +
log.warning("Received invocation response for which we have no registered listener " +
"[reqId=" + reqId + ", methId=" + methodId + ", args=" +
StringUtil.toString(args) + "]. It is possible that this listener was " +
"flushed because the response did not arrive within " +
@@ -288,9 +289,8 @@ public class InvocationDirector
try {
listener.dispatchResponse(methodId, args);
} catch (Throwable t) {
Log.warning("Invocation response listener choked [listener=" + listener +
", methId=" + methodId + ", args=" + StringUtil.toString(args) + "].");
Log.logStackTrace(t);
log.warning("Invocation response listener choked [listener=" + listener +
", methId=" + methodId + ", args=" + StringUtil.toString(args) + "].", t);
}
// flush expired listeners periodically
@@ -309,7 +309,7 @@ public class InvocationDirector
// look up the decoder registered for this receiver
InvocationDecoder decoder = _receivers.get(receiverId);
if (decoder == null) {
Log.warning("Received notification for which we have no registered receiver " +
log.warning("Received notification for which we have no registered receiver " +
"[recvId=" + receiverId + ", methodId=" + methodId +
", args=" + StringUtil.toString(args) + "].");
return;
@@ -321,9 +321,8 @@ public class InvocationDirector
try {
decoder.dispatchNotification(methodId, args);
} catch (Throwable t) {
Log.warning("Invocation notification receiver choked [receiver=" + decoder.receiver +
", methId=" + methodId + ", args=" + StringUtil.toString(args) + "].");
Log.logStackTrace(t);
log.warning("Invocation notification receiver choked [receiver=" + decoder.receiver +
", methId=" + methodId + ", args=" + StringUtil.toString(args) + "].", t);
}
}
@@ -362,7 +361,7 @@ public class InvocationDirector
}
public void requestFailed (int oid, ObjectAccessException cause) {
Log.warning("Aiya! Unable to subscribe to changed client object [cloid=" + oid +
log.warning("Aiya! Unable to subscribe to changed client object [cloid=" + oid +
", cause=" + cause + "].");
}
});