use of bftsmart.reconfiguration.util.TOMConfiguration in project jdchain-core by blockchain-jd-com.
the class BftsmartPeerProxyFactory method create.
@Override
public AsynchServiceProxy create() throws Exception {
BftsmartTopology topology = BinarySerializeUtils.deserialize(bftsmartClientSettings.getTopology());
View view = topology.getView();
if (view == null) {
throw new IllegalStateException("No topology view in the bftsmart client settings!");
}
MemoryBasedViewStorage viewStorage = new MemoryBasedViewStorage(view);
TOMConfiguration tomConfiguration = BinarySerializeUtils.deserialize(bftsmartClientSettings.getTomConfig());
// every proxy client has unique id;
int processId = allocateId();
tomConfiguration.setProcessId(processId);
AsynchServiceProxy peerProxy = new AsynchServiceProxy(tomConfiguration, viewStorage, bftsmartClientSettings.getSSLSecurity());
if (LOGGER.isInfoEnabled()) {
// 打印view
int[] processes = view.getProcesses();
NodeNetwork[] addresses = new NodeNetwork[processes.length];
for (int i = 0; i < addresses.length; i++) {
addresses[i] = view.getAddress(processes[i]);
}
LOGGER.info("Creating pooled bftsmart client ... [PooledClientID={}] [ViewID={}] [ViewTopology={}] [Peers={}]", processId, view.getId(), Arrays.toString(processes), Arrays.toString(addresses));
}
return peerProxy;
}
use of bftsmart.reconfiguration.util.TOMConfiguration in project jdchain-core by blockchain-jd-com.
the class ParticipantManagerService4Bft method createPeerProxy.
private ServiceProxy createPeerProxy(Properties systemConfig, int viewId, List<NodeSettings> origConsensusNodes, SSLSecurity security) {
HostsConfig hostsConfig;
List<HostsConfig.Config> configList = new ArrayList<>();
List<NodeNetwork> nodeAddresses = new ArrayList<>();
try {
int[] origConsensusProcesses = new int[origConsensusNodes.size()];
for (int i = 0; i < origConsensusNodes.size(); i++) {
BftsmartNodeSettings node = (BftsmartNodeSettings) origConsensusNodes.get(i);
origConsensusProcesses[i] = node.getId();
configList.add(new HostsConfig.Config(node.getId(), node.getNetworkAddress().getHost(), node.getNetworkAddress().getPort(), -1, node.getNetworkAddress().isSecure(), false));
nodeAddresses.add(new NodeNetwork(node.getNetworkAddress().getHost(), node.getNetworkAddress().getPort(), -1, node.getNetworkAddress().isSecure(), false));
}
// 构建共识的代理客户端需要的主机配置和系统参数配置结构
hostsConfig = new HostsConfig(configList.toArray(new HostsConfig.Config[configList.size()]));
Properties tempSystemConfig = (Properties) systemConfig.clone();
// 构建tom 配置
TOMConfiguration tomConfig = new TOMConfiguration(-(new Random().nextInt(Integer.MAX_VALUE - 2) - 1), tempSystemConfig, hostsConfig);
View view = new View(viewId, origConsensusProcesses, tomConfig.getF(), nodeAddresses.toArray(new NodeNetwork[nodeAddresses.size()]));
LOGGER.info("ManagementController start updateView operation!, current view : {}", view.toString());
// 构建共识的代理客户端,连接目标共识节点,并递交交易进行共识过程
return new ServiceProxy(tomConfig, new MemoryBasedViewStorage(view), null, null, security);
} catch (Exception e) {
throw new CreateProxyClientException("create proxy client exception!");
}
}
use of bftsmart.reconfiguration.util.TOMConfiguration in project aware by bergerch.
the class RSAKeyPairGenerator method main.
public static void main(String[] args) throws Exception {
if (args.length < 2)
System.err.println("Use: RSAKeyPairGenerator <id> <key length> [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 RSAKeyPairGenerator().run(Integer.parseInt(args[0]), Integer.parseInt(args[1]), provider);
}
use of bftsmart.reconfiguration.util.TOMConfiguration in project bftsmart by blockchain-jd-com.
the class TestNodeServer method startNode.
public ServiceReplica startNode(String realmName) {
TOMConfiguration config = initConfig();
try {
// mock messsageHandler and cs
MessageHandler messageHandler = new MessageHandler();
MessageHandler mockMessageHandler = Mockito.spy(messageHandler);
ClientCommunicationServerSide clientCommunication = ClientCommunicationFactory.createServerSide(new ServerViewController(config, new MemoryBasedViewStorage(latestView)));
ServerCommunicationSystem cs = new ServerCommunicationSystemImpl(clientCommunication, mockMessageHandler, new ServerViewController(config, new MemoryBasedViewStorage(latestView)), realmName);
ServerCommunicationSystem mockCs = Mockito.spy(cs);
replica = new ServiceReplica(mockMessageHandler, mockCs, config, this, this, (int) -1, latestView, realmName);
} catch (Exception e) {
e.printStackTrace();
}
return replica;
}
use of bftsmart.reconfiguration.util.TOMConfiguration in project bftsmart by blockchain-jd-com.
the class MACKeyGeneratorTest 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;
}
Aggregations