Screw backwards compatibility. We're all about the future.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4786 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -24,7 +24,7 @@ package com.threerings.admin.server;
|
||||
import java.util.HashMap;
|
||||
|
||||
import com.samskivert.io.PersistenceException;
|
||||
import com.samskivert.jdbc.ConnectionProvider;
|
||||
import com.samskivert.jdbc.depot.PersistenceContext;
|
||||
import com.samskivert.util.Invoker;
|
||||
import com.samskivert.util.StringUtil;
|
||||
|
||||
@@ -34,43 +34,40 @@ import com.threerings.admin.Log;
|
||||
import com.threerings.admin.server.persist.ConfigRepository;
|
||||
|
||||
/**
|
||||
* Implements the {@link ConfigRegistry} using a JDBC database as a persistent
|
||||
* store for the configuration information. <em>Note:</em> config objects
|
||||
* should only be created during server startup because they will result in
|
||||
* synchronous requests to load up the initial configuration data from the
|
||||
* database. This ensures that systems initialized after the config registry
|
||||
* can safely make use of configuration information.
|
||||
* Implements the {@link ConfigRegistry} using a JDBC database as a persistent store for the
|
||||
* configuration information. <em>Note:</em> config objects should only be created during server
|
||||
* startup because they will result in synchronous requests to load up the initial configuration
|
||||
* data from the database. This ensures that systems initialized after the config registry can
|
||||
* safely make use of configuration information.
|
||||
*/
|
||||
public class DatabaseConfigRegistry extends ConfigRegistry
|
||||
{
|
||||
/**
|
||||
* Creates a configuration registry and prepares it for operation.
|
||||
*
|
||||
* @param conprov will provide access to our JDBC database.
|
||||
* @param invoker this will be used to perform all database activity
|
||||
* (except first time initialization) so as to avoid blocking the
|
||||
* distributed object thread.
|
||||
* @param ctx will provide access to our database.
|
||||
* @param invoker this will be used to perform all database activity (except first time
|
||||
* initialization) so as to avoid blocking the distributed object thread.
|
||||
*/
|
||||
public DatabaseConfigRegistry (ConnectionProvider conprov, Invoker invoker)
|
||||
public DatabaseConfigRegistry (PersistenceContext ctx, Invoker invoker)
|
||||
throws PersistenceException
|
||||
{
|
||||
this(conprov, invoker, "");
|
||||
this(ctx, invoker, "");
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a configuration registry and prepares it for operation.
|
||||
*
|
||||
* @param conprov will provide access to our JDBC database.
|
||||
* @param invoker this will be used to perform all database activity
|
||||
* (except first time initialization) so as to avoid blocking the
|
||||
* distributed object thread.
|
||||
* @param node if this config registry is accessed by multiple servers which
|
||||
* wish to maintain seperate configs, then specificy a node for each server
|
||||
* @param ctx will provide access to our database.
|
||||
* @param invoker this will be used to perform all database activity (except first time
|
||||
* initialization) so as to avoid blocking the distributed object thread.
|
||||
* @param node if this config registry is accessed by multiple servers which wish to maintain
|
||||
* seperate configs, then specificy a node for each server
|
||||
*/
|
||||
public DatabaseConfigRegistry (ConnectionProvider conprov, Invoker invoker, String node)
|
||||
public DatabaseConfigRegistry (PersistenceContext ctx, Invoker invoker, String node)
|
||||
throws PersistenceException
|
||||
{
|
||||
_repo = new ConfigRepository(conprov);
|
||||
_repo = new ConfigRepository(ctx);
|
||||
_invoker = invoker;
|
||||
_node = StringUtil.isBlank(node) ? "" : node;
|
||||
}
|
||||
@@ -91,17 +88,14 @@ public class DatabaseConfigRegistry extends ConfigRegistry
|
||||
|
||||
public void init ()
|
||||
{
|
||||
// load up our persistent data synchronously because we should be
|
||||
// in the middle of server startup when it's OK to do database
|
||||
// access on the main thread and we need to be completely
|
||||
// initialized when we return from this call so that subsequent
|
||||
// systems can predictably make use of the configuration
|
||||
// information that we load
|
||||
// load up our persistent data synchronously because we should be in the middle of
|
||||
// server startup when it's OK to do database access on the main thread and we need to
|
||||
// be completely initialized when we return from this call so that subsequent systems
|
||||
// can predictably make use of the configuration information that we load
|
||||
try {
|
||||
_data = _repo.loadConfig(_node, _path);
|
||||
} catch (PersistenceException pe) {
|
||||
Log.warning("Failed to load object configuration " +
|
||||
"[path=" + _path + "].");
|
||||
Log.warning("Failed to load object configuration [path=" + _path + "].");
|
||||
Log.logStackTrace(pe);
|
||||
_data = new HashMap<String,String>();
|
||||
}
|
||||
@@ -265,9 +259,8 @@ public class DatabaseConfigRegistry extends ConfigRegistry
|
||||
try {
|
||||
_repo.updateConfig(_node, _path, field, value);
|
||||
} catch (PersistenceException pe) {
|
||||
Log.warning("Failed to update object configuration " +
|
||||
"[path=" + _path + ", field=" + field +
|
||||
", value=" + value + "].");
|
||||
Log.warning("Failed to update object configuration [path=" + _path +
|
||||
", field=" + field + ", value=" + value + "].");
|
||||
Log.logStackTrace(pe);
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -25,7 +25,6 @@ import java.util.HashMap;
|
||||
import java.util.Set;
|
||||
|
||||
import com.samskivert.io.PersistenceException;
|
||||
import com.samskivert.jdbc.ConnectionProvider;
|
||||
import com.samskivert.jdbc.depot.DepotRepository;
|
||||
import com.samskivert.jdbc.depot.PersistenceContext;
|
||||
import com.samskivert.jdbc.depot.PersistentRecord;
|
||||
@@ -36,18 +35,6 @@ import com.samskivert.jdbc.depot.clause.Where;
|
||||
*/
|
||||
public class ConfigRepository extends DepotRepository
|
||||
{
|
||||
/** The identifier used when establishing a database connection. */
|
||||
public static final String CONFIG_DB_IDENT = "configdb";
|
||||
|
||||
/**
|
||||
* Constructs a new config repository with the specified connection provider.
|
||||
*/
|
||||
public ConfigRepository (ConnectionProvider conprov)
|
||||
throws PersistenceException
|
||||
{
|
||||
this(new PersistenceContext(CONFIG_DB_IDENT, conprov));
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new config repository with the specified persistence context.
|
||||
*/
|
||||
@@ -59,8 +46,7 @@ public class ConfigRepository extends DepotRepository
|
||||
/**
|
||||
* Loads up the configuration data for the specified object.
|
||||
*
|
||||
* @return a map containing field/value pairs for all stored configuration
|
||||
* data.
|
||||
* @return a map containing field/value pairs for all stored configuration data.
|
||||
*/
|
||||
public HashMap<String,String> loadConfig (String node, String object)
|
||||
throws PersistenceException
|
||||
|
||||
@@ -21,8 +21,7 @@
|
||||
|
||||
package com.threerings.crowd.peer.server;
|
||||
|
||||
import com.samskivert.io.PersistenceException;
|
||||
import com.samskivert.jdbc.ConnectionProvider;
|
||||
import com.samskivert.jdbc.depot.PersistenceContext;
|
||||
import com.samskivert.util.Invoker;
|
||||
|
||||
import com.threerings.util.Name;
|
||||
@@ -57,10 +56,9 @@ public class CrowdPeerManager extends PeerManager
|
||||
* Creates a peer manager that integrates Crowd services across a cluster
|
||||
* of servers.
|
||||
*/
|
||||
public CrowdPeerManager (ConnectionProvider conprov, Invoker invoker)
|
||||
throws PersistenceException
|
||||
public CrowdPeerManager (PersistenceContext ctx, Invoker invoker)
|
||||
{
|
||||
super(conprov, invoker);
|
||||
super(ctx, invoker);
|
||||
}
|
||||
|
||||
// documentation inherited from interface CrowdPeerProvider
|
||||
|
||||
@@ -28,7 +28,7 @@ import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import com.samskivert.io.PersistenceException;
|
||||
import com.samskivert.jdbc.ConnectionProvider;
|
||||
import com.samskivert.jdbc.depot.PersistenceContext;
|
||||
import com.samskivert.util.ArrayIntSet;
|
||||
import com.samskivert.util.ChainedResultListener;
|
||||
import com.samskivert.util.Interval;
|
||||
@@ -132,11 +132,10 @@ public class PeerManager
|
||||
* Creates a peer manager which will create a {@link NodeRepository} which will be used to
|
||||
* publish our existence and discover the other nodes.
|
||||
*/
|
||||
public PeerManager (ConnectionProvider conprov, Invoker invoker)
|
||||
throws PersistenceException
|
||||
public PeerManager (PersistenceContext ctx, Invoker invoker)
|
||||
{
|
||||
_invoker = invoker;
|
||||
_noderepo = new NodeRepository(conprov);
|
||||
_noderepo = new NodeRepository(ctx);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -26,7 +26,6 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import com.samskivert.io.PersistenceException;
|
||||
import com.samskivert.jdbc.ConnectionProvider;
|
||||
import com.samskivert.jdbc.depot.DepotRepository;
|
||||
import com.samskivert.jdbc.depot.PersistenceContext;
|
||||
import com.samskivert.jdbc.depot.PersistentRecord;
|
||||
@@ -36,21 +35,6 @@ import com.samskivert.jdbc.depot.PersistentRecord;
|
||||
*/
|
||||
public class NodeRepository extends DepotRepository
|
||||
{
|
||||
/** The database identifier used when establishing a database connection. This value being
|
||||
* <code>nodedb</code>. */
|
||||
public static final String NODE_DB_IDENT = "nodedb";
|
||||
|
||||
/**
|
||||
* Constructs a new repository with the specified connection provider.
|
||||
*
|
||||
* @param conprov the connection provider via which we will obtain our database connection.
|
||||
*/
|
||||
public NodeRepository (ConnectionProvider conprov)
|
||||
throws PersistenceException
|
||||
{
|
||||
this(new PersistenceContext(NODE_DB_IDENT, conprov));
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new repository with the specified persistence context.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user