Updates to support a public facing and back-channel host for each node.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4254 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -89,16 +89,21 @@ public class PeerManager
|
||||
* @param sharedSecret a shared secret used to allow the peers to
|
||||
* authenticate with one another.
|
||||
* @param hostName the DNS name of the server running this node.
|
||||
* @param publicHostName if non-null, a separate public DNS hostname by
|
||||
* which the node is to be known to normal clients (we may want inter-peer
|
||||
* communication to take place over a different network than the
|
||||
* communication between real clients and the various peer servers).
|
||||
* @param port the port on which other nodes should connect to us.
|
||||
* @param conprov used to obtain our JDBC connections.
|
||||
* @param invoker we will perform all database operations on the supplied
|
||||
* invoker thread.
|
||||
*/
|
||||
public void init (String nodeName, String sharedSecret,
|
||||
String hostName, int port)
|
||||
public void init (String nodeName, String sharedSecret, String hostName,
|
||||
String publicHostName, int port)
|
||||
{
|
||||
_nodeName = nodeName;
|
||||
_hostName = hostName;
|
||||
_publicHostName = (publicHostName == null) ? publicHostName : hostName;
|
||||
_port = port;
|
||||
_sharedSecret = sharedSecret;
|
||||
|
||||
@@ -206,7 +211,8 @@ public class PeerManager
|
||||
// register ourselves with the node table
|
||||
_invoker.postUnit(new Invoker.Unit() {
|
||||
public boolean invoke () {
|
||||
NodeRecord record = new NodeRecord(_nodeName, _hostName, _port);
|
||||
NodeRecord record = new NodeRecord(
|
||||
_nodeName, _hostName, _publicHostName, _port);
|
||||
try {
|
||||
_noderepo.updateNode(record);
|
||||
} catch (PersistenceException pe) {
|
||||
@@ -272,7 +278,7 @@ public class PeerManager
|
||||
{
|
||||
PeerNode peer = _peers.get(record.nodeName);
|
||||
if (peer == null) {
|
||||
_peers.put(record.nodeName, peer = new PeerNode(record));
|
||||
_peers.put(record.nodeName, peer = createPeerNode(record));
|
||||
}
|
||||
peer.refresh(record);
|
||||
}
|
||||
@@ -302,6 +308,15 @@ public class PeerManager
|
||||
info.username = client.getCredentials().getUsername();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@link PeerNode} to manage our connection to the specified
|
||||
* peer.
|
||||
*/
|
||||
protected PeerNode createPeerNode (NodeRecord record)
|
||||
{
|
||||
return new PeerNode(record);
|
||||
}
|
||||
|
||||
/**
|
||||
* Contains all runtime information for one of our peer nodes.
|
||||
*/
|
||||
@@ -422,7 +437,7 @@ public class PeerManager
|
||||
protected long _lastConnectStamp;
|
||||
}
|
||||
|
||||
protected String _nodeName, _hostName, _sharedSecret;
|
||||
protected String _nodeName, _hostName, _publicHostName, _sharedSecret;
|
||||
protected int _port;
|
||||
protected Invoker _invoker;
|
||||
protected NodeRepository _noderepo;
|
||||
|
||||
@@ -33,9 +33,12 @@ public class NodeRecord
|
||||
/** The unique name assigned to this node. */
|
||||
public String nodeName;
|
||||
|
||||
/** The DNS name of the server running this node. */
|
||||
/** The DNS name used to connect to this node by other peers. */
|
||||
public String hostName;
|
||||
|
||||
/** The DNS name used to connect to this node by normal clients. */
|
||||
public String publicHostName;
|
||||
|
||||
/** The port on which to connect to this node. */
|
||||
public int port;
|
||||
|
||||
@@ -48,10 +51,12 @@ public class NodeRecord
|
||||
}
|
||||
|
||||
/** Creates a record for the specified node. */
|
||||
public NodeRecord (String nodeName, String hostName, int port)
|
||||
public NodeRecord (String nodeName, String hostName, String publicHostName,
|
||||
int port)
|
||||
{
|
||||
this.nodeName = nodeName;
|
||||
this.hostName = hostName;
|
||||
this.publicHostName = publicHostName;
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
|
||||
@@ -80,10 +80,16 @@ public class NodeRepository extends JORARepository
|
||||
JDBCUtil.createTableIfMissing(conn, "NODES", new String[] {
|
||||
"NODE_NAME VARCHAR(64) NOT NULL",
|
||||
"HOST_NAME VARCHAR(64) NOT NULL",
|
||||
"PUBLIC_HOST_NAME VARCHAR(64) NOT NULL",
|
||||
"PORT INTEGER NOT NULL",
|
||||
"LAST_UPDATED TIMESTAMP NOT NULL",
|
||||
"PRIMARY KEY (NODE_NAME)",
|
||||
}, "");
|
||||
|
||||
// TEMP: add our new column
|
||||
JDBCUtil.addColumn(conn, "NODES", "PUBLIC_HOST_NAME",
|
||||
"VARCHAR(64) NOT NULL", "HOST_NAME");
|
||||
// END TEMP
|
||||
}
|
||||
|
||||
@Override // documentation inherited
|
||||
|
||||
Reference in New Issue
Block a user