Browse Source

use the -DhostIp=xxx in the shell;

tags/1.1.5
zhaoguangwei 5 years ago
parent
commit
f7e789339c
1 changed files with 16 additions and 8 deletions
  1. +16
    -8
      source/consensus/consensus-bftsmart/src/main/java/com/jd/blockchain/consensus/bftsmart/service/BftsmartNodeServer.java

+ 16
- 8
source/consensus/consensus-bftsmart/src/main/java/com/jd/blockchain/consensus/bftsmart/service/BftsmartNodeServer.java View File

@@ -33,7 +33,7 @@ public class BftsmartNodeServer extends DefaultRecoverable implements NodeServer


private static Logger LOGGER = LoggerFactory.getLogger(BftsmartNodeServer.class); private static Logger LOGGER = LoggerFactory.getLogger(BftsmartNodeServer.class);


private static final String DEFAULT_BINDING_HOST = "0.0.0.0";
// private static final String DEFAULT_BINDING_HOST = "0.0.0.0";


private List<StateHandle> stateHandles = new CopyOnWriteArrayList<>(); private List<StateHandle> stateHandles = new CopyOnWriteArrayList<>();


@@ -59,7 +59,7 @@ public class BftsmartNodeServer extends DefaultRecoverable implements NodeServer


private TOMConfiguration tomConfig; private TOMConfiguration tomConfig;


private TOMConfiguration outerTomConfig;
// private TOMConfiguration outerTomConfig;


private HostsConfig hostsConfig; private HostsConfig hostsConfig;
private Properties systemConfig; private Properties systemConfig;
@@ -129,12 +129,20 @@ public class BftsmartNodeServer extends DefaultRecoverable implements NodeServer
} }


protected void initConfig(int id, Properties systemsConfig, HostsConfig hostConfig) { protected void initConfig(int id, Properties systemsConfig, HostsConfig hostConfig) {
byte[] serialHostConf = BinarySerializeUtils.serialize(hostConfig);
Properties sysConfClone = (Properties)systemsConfig.clone();
// byte[] serialHostConf = BinarySerializeUtils.serialize(hostConfig);
// Properties sysConfClone = (Properties)systemsConfig.clone();
int port = hostConfig.getPort(id); int port = hostConfig.getPort(id);
hostConfig.add(id, DEFAULT_BINDING_HOST, port);
// hostConfig.add(id, DEFAULT_BINDING_HOST, port);

//if ledger-init.sh set up the -DhostIp=xxx, then get it;
String preHostIp = System.getProperty("hostIp");
if(preHostIp != null && preHostIp.length()>0){
hostConfig.add(id, preHostIp, port);
System.out.println("###ledger-init.sh###,set up the -DhostIp="+preHostIp);
}

this.tomConfig = new TOMConfiguration(id, systemsConfig, hostConfig); this.tomConfig = new TOMConfiguration(id, systemsConfig, hostConfig);
this.outerTomConfig = new TOMConfiguration(id, sysConfClone, BinarySerializeUtils.deserialize(serialHostConf));
// this.outerTomConfig = new TOMConfiguration(id, systemsConfig, hostConfig);
} }


@Override @Override
@@ -153,7 +161,7 @@ public class BftsmartNodeServer extends DefaultRecoverable implements NodeServer
} }


public TOMConfiguration getTomConfig() { public TOMConfiguration getTomConfig() {
return outerTomConfig;
return tomConfig;
} }


public int getId() { public int getId() {
@@ -165,7 +173,7 @@ public class BftsmartNodeServer extends DefaultRecoverable implements NodeServer
throw new IllegalArgumentException("ReplicaID is negative!"); throw new IllegalArgumentException("ReplicaID is negative!");
} }
this.tomConfig.setProcessId(id); this.tomConfig.setProcessId(id);
this.outerTomConfig.setProcessId(id);
// this.outerTomConfig.setProcessId(id);
} }


public BftsmartConsensusSettings getConsensusSetting() { public BftsmartConsensusSettings getConsensusSetting() {


Loading…
Cancel
Save