Search in sources :

Example 6 with RaftNodeSettings

use of com.jd.blockchain.consensus.raft.settings.RaftNodeSettings in project jdchain-core by blockchain-jd-com.

the class ParticipantManagerService4Raft method shuffleInvoke.

private RpcResponse shuffleInvoke(ParticipantContext context, List<NodeSettings> origConsensusNodes, Object request) {
    Collections.shuffle(origConsensusNodes);
    for (NodeSettings nodeSettings : origConsensusNodes) {
        RaftNodeSettings raftNodeSettings = (RaftNodeSettings) nodeSettings;
        Endpoint remoteEndpoint = new Endpoint(raftNodeSettings.getNetworkAddress().getHost(), raftNodeSettings.getNetworkAddress().getPort());
        CliClientServiceImpl cliClientService = createRpcClient(context);
        if (cliClientService.connect(remoteEndpoint)) {
            return invoke(context, remoteEndpoint, request);
        }
    }
    return RpcResponse.fail(-1, "not found connected nodes");
}
Also used : NodeSettings(com.jd.blockchain.consensus.NodeSettings) RaftNodeSettings(com.jd.blockchain.consensus.raft.settings.RaftNodeSettings) RaftNodeSettings(com.jd.blockchain.consensus.raft.settings.RaftNodeSettings) Endpoint(com.alipay.sofa.jraft.util.Endpoint) CliClientServiceImpl(com.alipay.sofa.jraft.rpc.impl.cli.CliClientServiceImpl)

Example 7 with RaftNodeSettings

use of com.jd.blockchain.consensus.raft.settings.RaftNodeSettings in project jdchain-core by blockchain-jd-com.

the class RaftConsensusClientFactory method buildClientSettings.

@Override
public ClientSettings buildClientSettings(ClientIncomingSettings incomingSettings, SSLSecurity sslSecurity) {
    if (!(incomingSettings instanceof RaftClientIncomingSettings)) {
        throw new IllegalStateException("incoming settings should be raft-client-incoming-settings type");
    }
    ClientSettings clientSettings = new RaftClientConfig((RaftClientIncomingSettings) incomingSettings);
    if (sslSecurity == null) {
        return clientSettings;
    }
    // TLS适配
    // 仅作为网关连接共识节点时所配置的TLS信息, 作为客户端进行配置, 仅使用truststore信息
    // 判断TLS是否启用规则: client为网关使用,仅作为客户端连接共识节点。 因此根据共识服务是否启用TLS来进行判断
    RaftNodeSettings node = (RaftNodeSettings) incomingSettings.getViewSettings().getNodes()[0];
    if (node.getNetworkAddress().isSecure()) {
        GmSSLProvider.enableGMSupport(sslSecurity.getProtocol());
        setSystemProperty("bolt.client.ssl.enable", "true");
        setSystemProperty("bolt.client.ssl.keystore", sslSecurity.getTrustStore());
        setSystemProperty("bolt.client.ssl.keystore.password", sslSecurity.getTrustStorePassword());
        setSystemProperty("bolt.client.ssl.keystore.type", sslSecurity.getTrustStoreType() == null ? "JKS" : sslSecurity.getTrustStoreType());
        setSystemProperty("bolt.ssl.protocol", sslSecurity.getProtocol());
        setSystemProperty("bolt.server.ssl.enable", "true");
        setSystemProperty("bolt.server.ssl.keystore", sslSecurity.getKeyStore());
        setSystemProperty("bolt.server.ssl.keyalias", sslSecurity.getKeyAlias());
        setSystemProperty("bolt.server.ssl.keystore.password", sslSecurity.getKeyStorePassword());
        setSystemProperty("bolt.server.ssl.keystore.type", sslSecurity.getKeyStoreType());
        if (sslSecurity.getEnabledProtocols() != null && sslSecurity.getEnabledProtocols().length > 0) {
            setSystemProperty("bolt.ssl.enabled-protocols", String.join(",", sslSecurity.getEnabledProtocols()));
        }
        if (sslSecurity.getCiphers() != null && sslSecurity.getCiphers().length > 0) {
            setSystemProperty("bolt.ssl.ciphers", String.join(",", sslSecurity.getCiphers()));
        }
    }
    return buildClientSettings(incomingSettings);
}
Also used : RaftClientConfig(com.jd.blockchain.consensus.raft.config.RaftClientConfig) RaftNodeSettings(com.jd.blockchain.consensus.raft.settings.RaftNodeSettings) RaftClientIncomingSettings(com.jd.blockchain.consensus.raft.settings.RaftClientIncomingSettings) RaftClientSettings(com.jd.blockchain.consensus.raft.settings.RaftClientSettings) ClientSettings(com.jd.blockchain.consensus.client.ClientSettings)

Aggregations

RaftNodeSettings (com.jd.blockchain.consensus.raft.settings.RaftNodeSettings)7 NodeSettings (com.jd.blockchain.consensus.NodeSettings)4 RaftConsensusSettings (com.jd.blockchain.consensus.raft.settings.RaftConsensusSettings)2 CliClientServiceImpl (com.alipay.sofa.jraft.rpc.impl.cli.CliClientServiceImpl)1 Endpoint (com.alipay.sofa.jraft.util.Endpoint)1 Replica (com.jd.blockchain.consensus.Replica)1 BftsmartConsensusConfig (com.jd.blockchain.consensus.bftsmart.BftsmartConsensusConfig)1 BftsmartConsensusViewSettings (com.jd.blockchain.consensus.bftsmart.BftsmartConsensusViewSettings)1 BftsmartNodeConfig (com.jd.blockchain.consensus.bftsmart.BftsmartNodeConfig)1 BftsmartNodeSettings (com.jd.blockchain.consensus.bftsmart.BftsmartNodeSettings)1 ClientSettings (com.jd.blockchain.consensus.client.ClientSettings)1 MsgQueueBlockConfig (com.jd.blockchain.consensus.mq.config.MsgQueueBlockConfig)1 MsgQueueConsensusConfig (com.jd.blockchain.consensus.mq.config.MsgQueueConsensusConfig)1 MsgQueueNetworkConfig (com.jd.blockchain.consensus.mq.config.MsgQueueNetworkConfig)1 MsgQueueNodeConfig (com.jd.blockchain.consensus.mq.config.MsgQueueNodeConfig)1 MsgQueueBlockSettings (com.jd.blockchain.consensus.mq.settings.MsgQueueBlockSettings)1 MsgQueueConsensusSettings (com.jd.blockchain.consensus.mq.settings.MsgQueueConsensusSettings)1 MsgQueueNetworkSettings (com.jd.blockchain.consensus.mq.settings.MsgQueueNetworkSettings)1 MsgQueueNodeSettings (com.jd.blockchain.consensus.mq.settings.MsgQueueNodeSettings)1 RaftClientConfig (com.jd.blockchain.consensus.raft.config.RaftClientConfig)1