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:
@@ -22,13 +22,14 @@
|
||||
package com.threerings.bureau.client;
|
||||
|
||||
import com.samskivert.util.OneLineLogFormatter;
|
||||
import com.threerings.bureau.Log;
|
||||
import com.samskivert.util.Queue;
|
||||
import com.samskivert.util.StringUtil;
|
||||
import com.threerings.bureau.client.BureauDirector;
|
||||
import com.threerings.bureau.data.AgentObject;
|
||||
import com.samskivert.util.RunQueue;
|
||||
|
||||
import static com.threerings.bureau.Log.log;
|
||||
|
||||
/**
|
||||
* Extends bureau client minimally and provides a static main function to create a client and
|
||||
* connect to a server given by system properties.
|
||||
@@ -91,12 +92,12 @@ public class TestClient extends BureauClient
|
||||
{
|
||||
public void start ()
|
||||
{
|
||||
Log.info("Starting agent " + StringUtil.toString(_agentObj));
|
||||
log.info("Starting agent " + StringUtil.toString(_agentObj));
|
||||
}
|
||||
|
||||
public void stop ()
|
||||
{
|
||||
Log.info("Stopping agent " + StringUtil.toString(_agentObj));
|
||||
log.info("Stopping agent " + StringUtil.toString(_agentObj));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,12 +21,15 @@
|
||||
|
||||
package com.threerings.bureau.server;
|
||||
|
||||
import com.samskivert.util.OneLineLogFormatter;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.threerings.bureau.data.AgentObject;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import com.threerings.bureau.data.AgentObject;
|
||||
|
||||
import static com.threerings.bureau.Log.log;
|
||||
|
||||
/**
|
||||
* Uses a TestServer to pound on the BureauRegistry. Sends random sequences of
|
||||
* startAgent and destroyAgent. Most aspects of the randomness are configurable using system
|
||||
@@ -43,11 +46,11 @@ public class RegistryTester
|
||||
{
|
||||
String val = System.getProperty(name);
|
||||
if (val == null) {
|
||||
TestServer.log.info("Property " + name + " is " + defaultVal);
|
||||
log.info("Property " + name + " is " + defaultVal);
|
||||
return defaultVal;
|
||||
}
|
||||
int ival = Integer.parseInt(val);
|
||||
TestServer.log.info("Property " + name + " is " + ival);
|
||||
log.info("Property " + name + " is " + ival);
|
||||
return ival;
|
||||
}
|
||||
|
||||
@@ -56,9 +59,6 @@ public class RegistryTester
|
||||
*/
|
||||
public static void main (String[] args)
|
||||
{
|
||||
// make log pretty
|
||||
OneLineLogFormatter.configureDefaultHandler();
|
||||
|
||||
TestServer server = new TestServer();
|
||||
RegistryTester tester = new RegistryTester(server);
|
||||
|
||||
@@ -68,8 +68,7 @@ public class RegistryTester
|
||||
server.run();
|
||||
|
||||
} catch (Exception e) {
|
||||
TestServer.log.warning("Unable to initialize server.");
|
||||
TestServer.logStackTrace(e);
|
||||
log.warning("Unable to initialize server.", e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,7 +94,7 @@ public class RegistryTester
|
||||
// TODO: this is not called on Ctrl-C, need a way to shut down gracefully
|
||||
TestServer.registerShutdowner(new TestServer.Shutdowner() {
|
||||
public void shutdown () {
|
||||
TestServer.log.info("Shutting down tests");
|
||||
log.info("Shutting down tests");
|
||||
_stop = true;
|
||||
}
|
||||
});
|
||||
@@ -110,9 +109,9 @@ public class RegistryTester
|
||||
|
||||
Thread thread = new Thread("Registry test thread") {
|
||||
public void run () {
|
||||
TestServer.log.info(getName() + " started");
|
||||
log.info(getName() + " started");
|
||||
runTestThread();
|
||||
TestServer.log.info(getName() + " stopped");
|
||||
log.info(getName() + " stopped");
|
||||
}
|
||||
};
|
||||
thread.start();
|
||||
@@ -139,17 +138,17 @@ public class RegistryTester
|
||||
_rng1 = new Random(seed);
|
||||
_rng2 = new Random(seed);
|
||||
|
||||
TestServer.log.info("Running tests, seed is " + seed);
|
||||
log.info("Running tests, seed is " + seed);
|
||||
|
||||
// runnable that generates N requests to create or destroy agents
|
||||
Runnable createOrDestroyAgents = new Runnable() {
|
||||
public void run () {
|
||||
int ops = 1 + _rng1.nextInt(_maxOps);
|
||||
TestServer.log.info("Starting " + ops + " agent requests");
|
||||
log.info("Starting " + ops + " agent requests");
|
||||
for (int i = 0; i < ops; ++i) {
|
||||
randomlyCreateOrDestroyAgent();
|
||||
}
|
||||
TestServer.log.info("Finished " + ops + " agent requests");
|
||||
log.info("Finished " + ops + " agent requests");
|
||||
}
|
||||
};
|
||||
|
||||
@@ -188,13 +187,13 @@ public class RegistryTester
|
||||
if (size >= _maxAgents ||
|
||||
(size != 0 && _rng1.nextInt(100) >= _createChance)) {
|
||||
AgentObject toRemove = _agents.remove(_rng1.nextInt(size));
|
||||
TestServer.log.info("Removing agent " + toRemove.getOid());
|
||||
log.info("Removing agent " + toRemove.getOid());
|
||||
TestServer.breg.destroyAgent(toRemove);
|
||||
}
|
||||
else {
|
||||
AgentObject added = create(_rng1.nextInt(_numBureaus) + 1);
|
||||
_agents.add(added);
|
||||
TestServer.log.info("Added agent " + added.getOid());
|
||||
log.info("Added agent " + added.getOid());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,36 +22,24 @@
|
||||
package com.threerings.bureau.server;
|
||||
|
||||
import com.threerings.presents.server.PresentsServer;
|
||||
import com.samskivert.util.OneLineLogFormatter;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import static com.threerings.bureau.Log.log;
|
||||
|
||||
/**
|
||||
* Extends a presents server to include a bureau registry.
|
||||
*/
|
||||
public class TestServer extends PresentsServer
|
||||
{
|
||||
/** We dispatch our log messages through this logger. */
|
||||
public static Logger log = Logger.getLogger(TestServer.class.getName());
|
||||
|
||||
/**
|
||||
* The bureau registry for the server. Will be null until <code>init</code> is called.
|
||||
*/
|
||||
public static BureauRegistry breg;
|
||||
|
||||
public static void logStackTrace (Throwable t)
|
||||
{
|
||||
log.log(Level.WARNING, t.getMessage(), t);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new server and runs it.
|
||||
*/
|
||||
public static void main (String[] args)
|
||||
{
|
||||
// make log pretty
|
||||
OneLineLogFormatter.configureDefaultHandler();
|
||||
|
||||
final TestServer server = new TestServer();
|
||||
try {
|
||||
server.init();
|
||||
@@ -59,8 +47,7 @@ public class TestServer extends PresentsServer
|
||||
server.run();
|
||||
|
||||
} catch (Exception e) {
|
||||
log.warning("Unable to initialize server.");
|
||||
logStackTrace(e);
|
||||
log.warning("Unable to initialize server.", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user