Search in sources :

Example 1 with TOMConfiguration

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);
}
Also used : TOMConfiguration(bftsmart.reconfiguration.util.TOMConfiguration)

Example 2 with TOMConfiguration

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);
}
Also used : ViewStorage(bftsmart.reconfiguration.views.ViewStorage) MemoryBasedViewStorage(bftsmart.reconfiguration.views.MemoryBasedViewStorage) Random(java.util.Random) AsynchServiceProxy(bftsmart.tom.AsynchServiceProxy) View(bftsmart.reconfiguration.views.View) MemoryBasedViewStorage(bftsmart.reconfiguration.views.MemoryBasedViewStorage) TOMConfiguration(bftsmart.reconfiguration.util.TOMConfiguration)

Example 3 with TOMConfiguration

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;
}
Also used : HostsConfig(bftsmart.reconfiguration.util.HostsConfig) Properties(java.util.Properties) TOMConfiguration(bftsmart.reconfiguration.util.TOMConfiguration)

Example 4 with TOMConfiguration

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;
}
Also used : HostsConfig(bftsmart.reconfiguration.util.HostsConfig) Properties(java.util.Properties) TOMConfiguration(bftsmart.reconfiguration.util.TOMConfiguration)

Example 5 with TOMConfiguration

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);
}
Also used : HostsConfig(bftsmart.reconfiguration.util.HostsConfig) Properties(java.util.Properties) View(bftsmart.reconfiguration.views.View) TOMConfiguration(bftsmart.reconfiguration.util.TOMConfiguration) NodeNetwork(bftsmart.reconfiguration.views.NodeNetwork)

Aggregations

TOMConfiguration (bftsmart.reconfiguration.util.TOMConfiguration)10 HostsConfig (bftsmart.reconfiguration.util.HostsConfig)5 Properties (java.util.Properties)5 MemoryBasedViewStorage (bftsmart.reconfiguration.views.MemoryBasedViewStorage)4 View (bftsmart.reconfiguration.views.View)4 NodeNetwork (bftsmart.reconfiguration.views.NodeNetwork)3 AsynchServiceProxy (bftsmart.tom.AsynchServiceProxy)2 Random (java.util.Random)2 MessageHandler (bftsmart.communication.MessageHandler)1 ServerCommunicationSystem (bftsmart.communication.ServerCommunicationSystem)1 ServerCommunicationSystemImpl (bftsmart.communication.ServerCommunicationSystemImpl)1 ClientCommunicationServerSide (bftsmart.communication.client.ClientCommunicationServerSide)1 ServerViewController (bftsmart.reconfiguration.ServerViewController)1 ViewStorage (bftsmart.reconfiguration.views.ViewStorage)1 ServiceProxy (bftsmart.tom.ServiceProxy)1 ServiceReplica (bftsmart.tom.ServiceReplica)1 BftsmartNodeSettings (com.jd.blockchain.consensus.bftsmart.BftsmartNodeSettings)1 BftsmartTopology (com.jd.blockchain.consensus.bftsmart.BftsmartTopology)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1