use of bftsmart.reconfiguration.util.TOMConfiguration in project aware by bergerch.
the class ECDSAKeyPairGenerator method main.
public static void main(String[] args) throws Exception {
if (args.length < 2)
System.err.println("Use: ECDSAKeyPairGenerator <id> <domain parameter> [config dir]");
String confHome = "";
if (args.length > 2)
confHome = args[2];
TOMConfiguration conf = new TOMConfiguration(Integer.parseInt(args[0]), confHome, null);
String provider = conf.getSignatureAlgorithmProvider();
new ECDSAKeyPairGenerator().run(Integer.parseInt(args[0]), args[1], provider);
}
use of bftsmart.reconfiguration.util.TOMConfiguration in project bftsmart by blockchain-jd-com.
the class ConsensusTest_ method createClient.
/**
* 准备共识客户端
*/
public void createClient(int nodeNum) {
TOMConfiguration config = loadClientConfig(nodeNum);
latestView = new View(0, config.getInitialView(), config.getF(), addresses.toArray(new NodeNetwork[addresses.size()]));
ViewStorage viewStorage = new MemoryBasedViewStorage(latestView);
clientProxy = new AsynchServiceProxy(config, viewStorage);
Random random = new Random();
bytes = new byte[4];
random.nextBytes(bytes);
}
use of bftsmart.reconfiguration.util.TOMConfiguration in project bftsmart by blockchain-jd-com.
the class SystemMessageCodecTest method generateConfig.
private static ReplicaConfiguration generateConfig(int id, int[] viewProcessIds) {
HostsConfig hosts = new HostsConfig();
hosts.add(0, "localhost", 10010, 10012);
hosts.add(1, "localhost", 10020, 10022);
hosts.add(2, "localhost", 10030, 10032);
hosts.add(3, "localhost", 10040, 10042);
TOMConfiguration conf = new TOMConfiguration(0, new Properties(), hosts);
return conf;
}
use of bftsmart.reconfiguration.util.TOMConfiguration in project bftsmart by blockchain-jd-com.
the class CommunicationtTestMocker method mockDefaultConfiguration.
public static ReplicaConfiguration mockDefaultConfiguration(int currentId, int[] processIds, int[] ports) {
HostsConfig hosts = new HostsConfig();
for (int i = 0; i < processIds.length; i++) {
int port = ports == null ? 0 : ports[i];
hosts.add(processIds[i], "localhost", port, 0);
}
TOMConfiguration conf = new TOMConfiguration(currentId, new Properties(), hosts);
conf = Mockito.spy(conf);
when(conf.getProcessId()).thenReturn(currentId);
when(conf.getInQueueSize()).thenReturn(100000);
when(conf.getOutQueueSize()).thenReturn(100000);
return conf;
// ReplicaConfiguration conf = mockConfiguration(currentId, processIds);
//
// when(conf.getServerToServerPort(anyInt())).thenAnswer(new Answer<Integer>() {
// @Override
// public Integer answer(InvocationOnMock invocation) throws Throwable {
// int id = invocation.getArgument(0);
// for (int i = 0; i < processIds.length; i++) {
// if (processIds[i] == id) {
// return ports[i];
// }
// }
// throw new IllegalArgumentException(
// "The id[" + id + "] is out of range[" + Arrays.toString(processIds) + "]!");
// }
// });
// return conf;
}
use of bftsmart.reconfiguration.util.TOMConfiguration in project jdchain-core by blockchain-jd-com.
the class BftsmartNodeServer method initConfig.
protected void initConfig(int id, Properties systemsConfig, HostsConfig hostConfig) {
HostsConfig outerHostConfig = BinarySerializeUtils.deserialize(BinarySerializeUtils.serialize(hostConfig));
Properties sysConfClone = (Properties) systemsConfig.clone();
int port = hostConfig.getPort(id);
boolean isSecure = hostConfig.isSecure(id);
// hostConfig.add(id, DEFAULT_BINDING_HOST, port);
// if peer-startup.sh set up the -DhostIp=xxx, then get it;
String preHostPort = System.getProperty("hostPort");
if (!StringUtils.isEmpty(preHostPort)) {
port = NumberUtils.parseNumber(preHostPort, Integer.class);
LOGGER.info("###peer-startup.sh###,set up the -DhostPort=" + port);
}
int monitorPort = RuntimeConstant.getMonitorPort();
boolean monitorSecure = RuntimeConstant.isMonitorSecure();
String preHostIp = System.getProperty("hostIp");
if (!StringUtils.isEmpty(preHostIp)) {
hostConfig.add(id, preHostIp, port, monitorPort, isSecure, monitorSecure);
LOGGER.info("###peer-startup.sh###,set up the -DhostIp=" + preHostIp);
LOGGER.info("###peer-startup.sh###,isSecure=" + isSecure);
}
// 调整视图中的本节点端口号
consensusAddresses.get(id).setMonitorPort(monitorPort);
consensusAddresses.get(id).setMonitorSecure(monitorSecure);
this.tomConfig = new TOMConfiguration(id, systemsConfig, hostConfig, outerHostConfig);
Collection<NodeNetwork> nodeNetworks = consensusAddresses.values();
NodeNetwork[] nodeNetworksArray = new NodeNetwork[nodeNetworks.size()];
// 保证处理器ID与共识端口一致性
int[] init_view = new int[consensusAddresses.size()];
int i = 0;
for (int proid : consensusAddresses.keySet()) {
init_view[i++] = proid;
}
this.latestView = new View(setting.getViewId(), init_view, tomConfig.getF(), nodeNetworks.toArray(nodeNetworksArray));
LOGGER.info("[initConfig] latestview = {}", this.latestView);
this.outerTomConfig = new TOMConfiguration(id, sysConfClone, outerHostConfig);
}
Aggregations