提交 390acee5 编写于 作者: J João Sousa

Changed parameter system.communication.nettybindaddress to just...

Changed parameter system.communication.nettybindaddress to just system.communication.bindaddress. The replica will now use that value both for netty and the replica sockets.
Fixed an issue related to the loopback address. If hosts.config specify such address, parameter system.comunication.bindaddress is overridden
上级 40cf6236
无法预览此类型文件
...@@ -27,9 +27,10 @@ system.communication.useSenderThread = true ...@@ -27,9 +27,10 @@ system.communication.useSenderThread = true
#and benchmarks, but must not be used in production systems. #and benchmarks, but must not be used in production systems.
system.communication.defaultkeys = true system.communication.defaultkeys = true
#IP address this replica should use when binding Netty's server bootstrap. If this parameter does not have a valid ip address, #IP address this replica should bind to. If this parameter does not have a valid ip address,
#the replica will fetch the host address on its own #the replica will fetch the host address on its own. If config/hosts.config specifies the
system.communication.nettybindaddress = auto #loopback address for the host machine, this parameter is overriden by that
system.communication.bindaddress = auto
############################################ ############################################
### Replication Algorithm Configurations ### ### Replication Algorithm Configurations ###
......
...@@ -110,13 +110,19 @@ public class NettyClientServerCommunicationSystemServerSide extends SimpleChanne ...@@ -110,13 +110,19 @@ public class NettyClientServerCommunicationSystemServerSide extends SimpleChanne
}) .childOption(ChannelOption.SO_KEEPALIVE, true).childOption(ChannelOption.TCP_NODELAY, true); }) .childOption(ChannelOption.SO_KEEPALIVE, true).childOption(ChannelOption.TCP_NODELAY, true);
String myAddress; String myAddress;
if (controller.getStaticConf().getNettyBindAddress().equals("")) { String confAddress =
controller.getStaticConf().getRemoteAddress(controller.getStaticConf().getProcessId()).getAddress().getHostAddress();
if (InetAddress.getLoopbackAddress().getHostAddress().equals(confAddress)) {
myAddress = InetAddress.getLocalHost().getHostAddress(); myAddress = InetAddress.getLoopbackAddress().getHostAddress();
String confAddress = }
controller.getStaticConf().getRemoteAddress(controller.getStaticConf().getProcessId()).getAddress().getHostAddress();
else if (controller.getStaticConf().getBindAddress().equals("")) {
myAddress = InetAddress.getLocalHost().getHostAddress();
//If Netty binds to the loopback address, clients will not be able to connect to replicas. //If Netty binds to the loopback address, clients will not be able to connect to replicas.
//To solve that issue, we bind to the address supplied in config/hosts.config instead. //To solve that issue, we bind to the address supplied in config/hosts.config instead.
if (InetAddress.getLoopbackAddress().getHostAddress().equals(myAddress) && !myAddress.equals(confAddress)) { if (InetAddress.getLoopbackAddress().getHostAddress().equals(myAddress) && !myAddress.equals(confAddress)) {
...@@ -127,11 +133,12 @@ public class NettyClientServerCommunicationSystemServerSide extends SimpleChanne ...@@ -127,11 +133,12 @@ public class NettyClientServerCommunicationSystemServerSide extends SimpleChanne
} else { } else {
myAddress = controller.getStaticConf().getNettyBindAddress(); myAddress = controller.getStaticConf().getBindAddress();
} }
int myPort = controller.getStaticConf().getPort(controller.getStaticConf().getProcessId());
ChannelFuture f = b.bind(new InetSocketAddress(myAddress, ChannelFuture f = b.bind(new InetSocketAddress(myAddress, myPort)).sync();
controller.getStaticConf().getPort(controller.getStaticConf().getProcessId()))).sync();
System.out.println("-- ID = " + controller.getStaticConf().getProcessId()); System.out.println("-- ID = " + controller.getStaticConf().getProcessId());
System.out.println("-- N = " + controller.getCurrentViewN()); System.out.println("-- N = " + controller.getCurrentViewN());
...@@ -141,7 +148,7 @@ public class NettyClientServerCommunicationSystemServerSide extends SimpleChanne ...@@ -141,7 +148,7 @@ public class NettyClientServerCommunicationSystemServerSide extends SimpleChanne
System.out.println("-- maxBatch = " + controller.getStaticConf().getMaxBatchSize()); System.out.println("-- maxBatch = " + controller.getStaticConf().getMaxBatchSize());
if (controller.getStaticConf().getUseMACs() == 1) System.out.println("-- Using MACs"); if (controller.getStaticConf().getUseMACs() == 1) System.out.println("-- Using MACs");
if(controller.getStaticConf().getUseSignatures() == 1) System.out.println("-- Using Signatures"); if(controller.getStaticConf().getUseSignatures() == 1) System.out.println("-- Using Signatures");
System.out.println("-- Netty binded to host " + myAddress); System.out.println("-- Binded replica to " + myAddress);
//******* EDUARDO END **************// //******* EDUARDO END **************//
mainChannel = f.channel(); mainChannel = f.channel();
......
...@@ -36,6 +36,7 @@ import java.util.logging.Logger; ...@@ -36,6 +36,7 @@ import java.util.logging.Logger;
import bftsmart.communication.SystemMessage; import bftsmart.communication.SystemMessage;
import bftsmart.reconfiguration.ServerViewController; import bftsmart.reconfiguration.ServerViewController;
import bftsmart.tom.ServiceReplica; import bftsmart.tom.ServiceReplica;
import java.net.InetAddress;
import javax.crypto.SecretKey; import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory; import javax.crypto.SecretKeyFactory;
...@@ -80,8 +81,39 @@ public class ServersCommunicationLayer extends Thread { ...@@ -80,8 +81,39 @@ public class ServersCommunicationLayer extends Thread {
} }
} }
serverSocket = new ServerSocket(controller.getStaticConf().getServerToServerPort( String myAddress;
controller.getStaticConf().getProcessId())); String confAddress =
controller.getStaticConf().getRemoteAddress(controller.getStaticConf().getProcessId()).getAddress().getHostAddress();
if (InetAddress.getLoopbackAddress().getHostAddress().equals(confAddress)) {
myAddress = InetAddress.getLoopbackAddress().getHostAddress();
}
else if (controller.getStaticConf().getBindAddress().equals("")) {
myAddress = InetAddress.getLocalHost().getHostAddress();
//If the replica binds to the loopback address, clients will not be able to connect to replicas.
//To solve that issue, we bind to the address supplied in config/hosts.config instead.
if (InetAddress.getLoopbackAddress().getHostAddress().equals(myAddress) && !myAddress.equals(confAddress)) {
myAddress = confAddress;
}
} else {
myAddress = controller.getStaticConf().getBindAddress();
}
int myPort = controller.getStaticConf().getServerToServerPort(controller.getStaticConf().getProcessId());
serverSocket = new ServerSocket(myPort, 50, InetAddress.getByName(myAddress));
/*serverSocket = new ServerSocket(controller.getStaticConf().getServerToServerPort(
controller.getStaticConf().getProcessId()));*/
SecretKeyFactory fac = SecretKeyFactory.getInstance("PBEWithMD5AndDES"); SecretKeyFactory fac = SecretKeyFactory.getInstance("PBEWithMD5AndDES");
PBEKeySpec spec = new PBEKeySpec(PASSWORD.toCharArray()); PBEKeySpec spec = new PBEKeySpec(PASSWORD.toCharArray());
......
...@@ -59,7 +59,7 @@ public class TOMConfiguration extends Configuration { ...@@ -59,7 +59,7 @@ public class TOMConfiguration extends Configuration {
private int numRepliers; private int numRepliers;
private int numNettyWorkers; private int numNettyWorkers;
private boolean sameBatchSize; private boolean sameBatchSize;
private String nettyBindAddress; private String bindAddress;
/** Creates a new instance of TOMConfiguration */ /** Creates a new instance of TOMConfiguration */
public TOMConfiguration(int processId) { public TOMConfiguration(int processId) {
...@@ -334,14 +334,14 @@ public class TOMConfiguration extends Configuration { ...@@ -334,14 +334,14 @@ public class TOMConfiguration extends Configuration {
numNettyWorkers = Integer.parseInt(s); numNettyWorkers = Integer.parseInt(s);
} }
s = (String) configs.remove("system.communication.nettybindaddress"); s = (String) configs.remove("system.communication.bindaddress");
Pattern pattern = Pattern.compile("^(([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.){3}([01]?\\d\\d?|2[0-4]\\d|25[0-5])$"); Pattern pattern = Pattern.compile("^(([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.){3}([01]?\\d\\d?|2[0-4]\\d|25[0-5])$");
if (s == null || !pattern.matcher(s).matches()) { if (s == null || !pattern.matcher(s).matches()) {
nettyBindAddress = ""; bindAddress = "";
} else { } else {
nettyBindAddress = s; bindAddress = s;
} }
s = (String) configs.remove("system.samebatchsize"); s = (String) configs.remove("system.samebatchsize");
...@@ -550,7 +550,7 @@ public class TOMConfiguration extends Configuration { ...@@ -550,7 +550,7 @@ public class TOMConfiguration extends Configuration {
return sameBatchSize; return sameBatchSize;
} }
public String getNettyBindAddress() { public String getBindAddress() {
return nettyBindAddress; return bindAddress;
} }
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册