Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support multi-raft #150

Merged
merged 18 commits into from
Aug 31, 2022
Merged

Conversation

TheR1sing3un
Copy link
Contributor

Multi-DLedger

Structure

overall structure

image-20220502152826885

Details

image-20220502165732144

For the above several components, do the following detailed explanation.

DLedgerProxy

We previously used DLedgerServer directly as a vehicle for receiving and processing requests in DLedger.

If we want to upgrade to a Multi-Raft architecture, we need to decouple the parts that receive and send requests from the parts that process them. we use a layer proxy to proxy the underlying Raft node, we can use multiple DLedgerServers to share a RpcService for request processing. This DLedgerProxy is a wrapper around previously implemented methods such as handle requests, and can be routed according to the configuration.

That is we ip:port can not uniquely identify a Raft node, because ip:port can also be represented as a multi-Raft structure external services, then at this time, we need a selfID to differentiate the different Raft in this Multi-Raft. All of our DLedger communications will need to be located with selfID at this time. And we added several modules in DLedgerProxy, namely ConfigManager and DLedgerManager. The two modules manage the Raft-Group configuration and the native DLedgerServer instance configuration and processing logic, respectively.

Why use ip:port+selfID to identify a raft

We used to be able to locate a Raft instance with an ip:port, but now the process we locate with ip:port is a multi-Raft, so we need to locate in process according to selfID.

ConfigManager

ConfigManager is the configuration management module for DLedger. Subsequently, using a solution such as a configuration center, online changes can be made dynamically in the Region for which the Raft-Group is responsible. At this point, ConfigManager can make the appropriate requests and responses. Because of course we can have multiple DLedgerServers share a same RegionConfig, because RegionConfig is the same for all Raft in the cluster.

Can also manage and configure the configuration of the local DLedgerServer instance, and can instantiate the DLedgerServer according to the startup parameters at startup time, you can also manage the local DLedgerServer instance by changing the local DLedgerServer instance's configuration file in real time based on the network request.

DLedgerManager

DLedgerManager is the management module for DLedgerServer, which includes the ability to route to a DLedgerServer based on configuration for network requests to DLedgerServer, and for subsequent optimizations such as the request merge mentioned above, can be unified in this module processing.


How to start with Multi-DLedger

If you need to start with Multi-DLedger, you need to start with a configuration file

Simple configurations include:

configs:
  - group: g0
    selfId: n0
    peers: n0-127.0.0.1:10000;n1-127.0.0.1:10001;n2-127.0.0.1:10002
    preferredLeaderIds: n0
  - group: g1
    selfId: a0
    peers: a0-127.0.0.1:10000;a1-127.0.0.1:10001;a2-127.0.0.1:10002
    preferredLeaderIds: a1
  - group: g2
    selfId: b0
    peers: b0-127.0.0.1:10000;b1-127.0.0.1:10001;b2-127.0.0.1:10002
    preferredLeaderIds: b2

Start in the command line:

java -jar ./DLedger.jar serverc -c ./config.yaml


Request receiving and response process

Previous request response process

Because there is only one Dledgerserver, it can directly call the handle methods of Dledgerserver.

Current request response process

Now that we have multiple DLedgerServer instances, then we need to specifically route to a DLedgerServer according to the selftID in the request. Therefore, we need to let the DledgerManager in DLedgerProxy find the specific DLedgerServer to process the request based on Selfid-> DledgerServer.

@TheR1sing3un
Copy link
Contributor Author

@yuz10 PING!Please check

1.add DLedgerProxy to be the container of DLedgerServer.
2.add
ConfigManager to manage the config about DLedgerProxy and
DLedgerServer.
3.add DLedgerManager to manage the
DLedgerServers.
4.support configuration file startup.
5.start parameters
are compatible with the old version.
6.refactor the tests.
1.fix some test and add a new test
1.fix some bugs and add some tests about leaderElector
1.add more tests about leaderElector
1.add startup args "server -c" to start with config file.
2.remove DLedgerRpcNettyServer#memstate.
3.check config before initialize DLedgerRpcNettyService.
DLedgerServer dLedgerServer = this.dLedgerManager.getDLedgerServer(request.getRemoteId());
try {
PreConditions.check(dLedgerServer != null, DLedgerResponseCode.UNKNOWN_MEMBER, "group[%s] selfId[%s] not exist in proxy", request.getGroup(), request.getRemoteId());
return this.dLedgerManager.getDLedgerServer(request.getGroup(), request.getRemoteId()).handlePush(request);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getDLedgerServer twice, the first dLedgerServer no use

1.remove DLedgerRpcNettyService#checkOnePort
2.remove printStack
1.use "groupId#selfId" to identify different DLedgerServer.
TheR1sing3un and others added 3 commits August 17, 2022 18:41
1. make ConfigManager more flexible
2. refactor structure about
multi-raft
3. more friendly for updating version
…branch

1. fix incompatible code after merge master branch
@TheR1sing3un
Copy link
Contributor Author

@yuz10 @RongtongJin Hi~ I have refactored some code about multi-raft structure! Please check! Thanks~

@yuz10
Copy link
Contributor

yuz10 commented Aug 29, 2022

@yuz10 @RongtongJin Hi~ I have refactored some code about multi-raft structure! Please check! Thanks~

Hi TheR1sing3un, please fix the merge conflicts.

@TheR1sing3un
Copy link
Contributor Author

@yuz10 @RongtongJin Hi~ I have refactored some code about multi-raft structure! Please check! Thanks~

Hi TheR1sing3un, please fix the merge conflicts.

done~

@yuz10 yuz10 merged commit ac12deb into openmessaging:master Aug 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants