Skip to content

Commit

Permalink
update raft nodes management
Browse files Browse the repository at this point in the history
  • Loading branch information
imuge committed Mar 16, 2022
1 parent f4f7125 commit 6966921
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

public class RaftNodeServer implements NodeServer {

private static final String RAFT_PATH_KEY = "raft.path";
public static final String RAFT_PATH_KEY = "raft.path";

static {
System.getProperties().setProperty("bolt.netty.buffer.low.watermark", String.valueOf(128 * 1024 * 1024));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@

public interface IParticipantManagerService {

String RAFT_CONSENSUS_NODE_STORAGE = "RAFT_CONSENSUS_NODE_STORAGE";

default boolean supportManagerParticipant() {
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.alipay.sofa.jraft.rpc.RpcClient;
import com.alipay.sofa.jraft.rpc.impl.cli.CliClientServiceImpl;
import com.alipay.sofa.jraft.util.Endpoint;
import com.google.common.base.Strings;
import com.jd.binaryproto.BinaryProtocol;
import com.jd.blockchain.consensus.NodeSettings;
import com.jd.blockchain.consensus.raft.rpc.*;
Expand Down Expand Up @@ -36,7 +35,6 @@ public class ParticipantManagerService4Raft implements IParticipantManagerServic
private static final Logger LOGGER = LoggerFactory.getLogger(ParticipantManagerService4Raft.class);

private static final int RAFT_CONSENSUS_MIN_NODES = 1;
private static final String RAFT_PATH_KEY = "raft_path";
private static final int MAX_RETRY_TIMES = 3;
private static final String RPC_QUEST_TIMEOUT_MS = "rpc_quest_timeout_ms";
private static final String RPC_CLIENT = "rpc_client";
Expand All @@ -49,25 +47,16 @@ public int minConsensusNodes() {

@Override
public Properties getCustomProperties(ParticipantContext context) {
Properties properties = new Properties();
properties.setProperty(RAFT_PATH_KEY, String.valueOf(context.getProperty(IParticipantManagerService.RAFT_CONSENSUS_NODE_STORAGE)));
return properties;
return new Properties();
}

@Override
public Property[] createActiveProperties(NetworkAddress address, PubKey activePubKey, int activeID, Properties customProperties) {

String raftPath = customProperties.getProperty(RAFT_PATH_KEY);
if (Strings.isNullOrEmpty(raftPath) || "null".equals(raftPath)) {
throw new IllegalStateException("raft path is missing, --consensus-storage required");
}

List<Property> properties = new ArrayList<>();

properties.add(new Property(keyOfNode("system.server.%d.network.host", activeID), address.getHost()));
properties.add(new Property(keyOfNode("system.server.%d.network.port", activeID), String.valueOf(address.getPort())));
properties.add(new Property(keyOfNode("system.server.%d.network.secure", activeID), String.valueOf(address.isSecure())));
properties.add(new Property(keyOfNode("system.server.%d.raft.path", activeID), raftPath));
properties.add(new Property(keyOfNode("system.server.%d.pubkey", activeID), activePubKey.toBase58()));
properties.add(new Property("participant.op", "active"));
properties.add(new Property("active.participant.id", String.valueOf(activeID)));
Expand Down Expand Up @@ -263,7 +252,7 @@ private CliClientServiceImpl createRpcClient(ParticipantContext context) {

SSLSecurity sslSecurity = context.sslSecurity();
//启用TLS
if(sslSecurity != null && sslSecurity.getKeyStore() != null){
if (sslSecurity != null && sslSecurity.getKeyStore() != null) {
setSystemProperty("bolt.client.ssl.enable", "true");
setSystemProperty("bolt.client.ssl.keystore", sslSecurity.getTrustStore());
setSystemProperty("bolt.client.ssl.keystore.password", sslSecurity.getTrustStorePassword());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,6 @@ public WebResponse syncBlock(@RequestParam("ledgerHash") String ledgerHash,
public WebResponse activateParticipant(@RequestParam("ledgerHash") String base58LedgerHash,
@RequestParam("consensusHost") String consensusHost,
@RequestParam("consensusPort") int consensusPort,
@RequestParam(name = "consensusStorage", required = false) String consensusStorage,
@RequestParam(name = "consensusSecure", required = false, defaultValue = "false") boolean consensusSecure,
@RequestParam("remoteManageHost") String remoteManageHost,
@RequestParam("remoteManagePort") int remoteManagePort,
Expand Down Expand Up @@ -661,7 +660,6 @@ public WebResponse activateParticipant(@RequestParam("ledgerHash") String base58
currentProvider,
participantService,
bindingConfigs.get(ledgerHash).getSslSecurity());
context.setProperty(IParticipantManagerService.RAFT_CONSENSUS_NODE_STORAGE, consensusStorage);
context.setProperty(ParticipantContext.HASH_ALG_PROP, ledgerCryptoSettings.get(ledgerHash).getHashAlgorithm());
context.setProperty(ParticipantContext.ENDPOINT_SIGNER_PROP, new AsymmetricKeypair(ledgerKeypairs.get(ledgerHash).getPubKey(),
ledgerKeypairs.get(ledgerHash).getPrivKey()));
Expand Down Expand Up @@ -710,7 +708,6 @@ public WebResponse activateParticipant(@RequestParam("ledgerHash") String base58
public WebResponse updateParticipant(@RequestParam("ledgerHash") String base58LedgerHash,
@RequestParam("consensusHost") String consensusHost,
@RequestParam("consensusPort") int consensusPort,
@RequestParam(name = "consensusStorage", required = false) String consensusStorage,
@RequestParam(name = "consensusSecure", required = false, defaultValue = "false") boolean consensusSecure,
@RequestParam(name = "shutdown", required = false, defaultValue = "false") boolean shutdown) {
try {
Expand All @@ -735,7 +732,6 @@ public WebResponse updateParticipant(@RequestParam("ledgerHash") String base58Le
currentProvider,
participantService,
bindingConfigs.get(ledgerHash).getSslSecurity());
context.setProperty(IParticipantManagerService.RAFT_CONSENSUS_NODE_STORAGE, consensusStorage);
context.setProperty(ParticipantContext.HASH_ALG_PROP, ledgerCryptoSettings.get(ledgerHash).getHashAlgorithm());
context.setProperty(ParticipantContext.ENDPOINT_SIGNER_PROP, new AsymmetricKeypair(ledgerKeypairs.get(ledgerHash).getPubKey(),
ledgerKeypairs.get(ledgerHash).getPrivKey()));
Expand Down

0 comments on commit 6966921

Please sign in to comment.