|
@@ -52,7 +52,8 @@ class QuorumPeerInstance implements Instance {
|
|
|
}
|
|
|
|
|
|
InetSocketAddress clientAddr;
|
|
|
- InetSocketAddress quorumAddr;
|
|
|
+ InetSocketAddress quorumLeaderAddr;
|
|
|
+ InetSocketAddress quorumLeaderElectionAddr;
|
|
|
HashMap<Long, QuorumServer> peers;
|
|
|
File snapDir, logDir;
|
|
|
|
|
@@ -108,13 +109,20 @@ class QuorumPeerInstance implements Instance {
|
|
|
}
|
|
|
try {
|
|
|
ServerSocket ss = new ServerSocket(0, 1, InetAddress.getLocalHost());
|
|
|
- quorumAddr = (InetSocketAddress) ss.getLocalSocketAddress();
|
|
|
+ quorumLeaderAddr = (InetSocketAddress) ss.getLocalSocketAddress();
|
|
|
+ ss.close();
|
|
|
+ } catch(IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ ServerSocket ss = new ServerSocket(0, 1, InetAddress.getLocalHost());
|
|
|
+ quorumLeaderElectionAddr = (InetSocketAddress) ss.getLocalSocketAddress();
|
|
|
ss.close();
|
|
|
} catch(IOException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
String report = clientAddr.getHostName() + ':' + clientAddr.getPort() +
|
|
|
- ',' + quorumAddr.getHostName() + ':' + quorumAddr.getPort();
|
|
|
+ ',' + quorumLeaderAddr.getHostName() + ':' + quorumLeaderAddr.getPort() + ':' + quorumLeaderElectionAddr.getPort();
|
|
|
try {
|
|
|
if (LOG.isDebugEnabled()) {
|
|
|
LOG.debug("Reporting " + report);
|
|
@@ -157,8 +165,15 @@ class QuorumPeerInstance implements Instance {
|
|
|
String parts[] = quorumSpecs.split(",");
|
|
|
peers = new HashMap<Long,QuorumServer>();
|
|
|
for(int i = 0; i < parts.length; i++) {
|
|
|
- String subparts[] = parts[i].split(":");
|
|
|
- peers.put(Long.valueOf(i), new QuorumServer(i, new InetSocketAddress(subparts[0], Integer.parseInt(subparts[1]))));
|
|
|
+ // parts[i] == "host:leaderPort:leaderElectionPort;clientPort"
|
|
|
+ String subparts[] = (parts[i].split(";"))[0].split(":");
|
|
|
+ String clientPort = (parts[i].split(";"))[1];
|
|
|
+ peers.put(Long.valueOf(i),
|
|
|
+ new QuorumServer(
|
|
|
+ i,
|
|
|
+ new InetSocketAddress(subparts[0], Integer.parseInt(subparts[1])),
|
|
|
+ new InetSocketAddress(subparts[0], Integer.parseInt(subparts[2])),
|
|
|
+ new InetSocketAddress(subparts[0], Integer.parseInt(clientPort))));
|
|
|
}
|
|
|
try {
|
|
|
if (LOG.isDebugEnabled()) {
|