Skip to content
Snippets Groups Projects
Commit e2ede869 authored by Rob Adams's avatar Rob Adams
Browse files

When using fallback config, listen only on localhost

parent 3cf1e473
No related branches found
No related tags found
No related merge requests found
......@@ -25,6 +25,7 @@ public class ClusterConfig {
private AuthScheme authScheme;
private String keyStorePath;
private String keyStorePassword;
private String listenAddress;
public ClusterConfig() {
super();
......@@ -38,8 +39,7 @@ public class ClusterConfig {
*/
public ClusterConfig(List<Node> nodes, short thisNodeId)
throws SyncException {
init(nodes, thisNodeId);
this.authScheme = AuthScheme.NO_AUTH;
init(nodes, thisNodeId, AuthScheme.NO_AUTH, null, null);
}
/**
......@@ -49,7 +49,7 @@ public class ClusterConfig {
* @param authScheme the {@link AuthScheme}
* @param keyStorePath the path to a java key store containing
* credentials necessary for implementing the {@link AuthScheme}
* @param keyStorePassword the password fro the key store.
* @param keyStorePassword the password for the key store.
* @throws SyncException
*/
public ClusterConfig(List<Node> nodes, short thisNodeId,
......@@ -57,12 +57,28 @@ public class ClusterConfig {
String keyStorePath,
String keyStorePassword)
throws SyncException {
init(nodes, thisNodeId);
this.authScheme = authScheme;
if (this.authScheme == null)
this.authScheme = AuthScheme.NO_AUTH;
this.keyStorePath = keyStorePath;
this.keyStorePassword = keyStorePassword;
init(nodes, thisNodeId, authScheme, keyStorePath, keyStorePassword);
}
/**
* Initialize a cluster config using a list of nodes
* @param nodes the nodes to use
* @param thisNodeId the node ID for the current node
* @param listenAddress String representing the address to listen on
* @param authScheme the {@link AuthScheme}
* @param keyStorePath the path to a java key store containing
* credentials necessary for implementing the {@link AuthScheme}
* @param keyStorePassword the password for the key store.
* @throws SyncException
*/
public ClusterConfig(List<Node> nodes, short thisNodeId,
String listenAddress,
AuthScheme authScheme,
String keyStorePath,
String keyStorePassword)
throws SyncException {
init(nodes, thisNodeId, authScheme, keyStorePath, keyStorePassword);
this.listenAddress = listenAddress;
}
/**
......@@ -107,6 +123,15 @@ public class ClusterConfig {
return allNodes.get(nodeId);
}
/**
* Get a string representing the host/address on which the local
* node should listen
* @return the listen address
*/
public String getListenAddress() {
return listenAddress;
}
/**
* Get the authentication scheme to use for authenticating RPC connections
* @return the {@link AuthScheme} object
......@@ -157,7 +182,10 @@ public class ClusterConfig {
localDomain.add(node);
}
private void init(List<Node> nodes, short thisNodeId)
private void init(List<Node> nodes, short thisNodeId,
AuthScheme authScheme,
String keyStorePath,
String keyStorePassword)
throws SyncException {
for (Node n : nodes) {
addNode(n);
......@@ -167,6 +195,11 @@ public class ClusterConfig {
throw new SyncException("Cannot set thisNode " +
"node: No node with ID " + thisNodeId);
}
this.authScheme = authScheme;
if (this.authScheme == null)
this.authScheme = AuthScheme.NO_AUTH;
this.keyStorePath = keyStorePath;
this.keyStorePassword = keyStorePassword;
}
@Override
......
......@@ -47,6 +47,7 @@ public class FallbackCCProvider implements IClusterConfigProvider {
Short.MAX_VALUE,
Short.MAX_VALUE)),
Short.MAX_VALUE,
"localhost",
authScheme,
keyStorePath,
keyStorePassword);
......
......@@ -454,7 +454,14 @@ public class RPCService {
serverBootstrap = bootstrap;
int port = syncManager.getClusterConfig().getNode().getPort();
InetSocketAddress sa = new InetSocketAddress(port);
InetSocketAddress sa;
String listenAddress =
syncManager.getClusterConfig().getListenAddress();
if (listenAddress != null)
sa = new InetSocketAddress(listenAddress, port);
else
sa = new InetSocketAddress(port);
cg.add(bootstrap.bind(sa));
logger.info("Listening for internal floodlight RPC on {}", sa);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment